mutation.go 1.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257
  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/workexperience"
  43. "wechat-api/ent/wpchatroom"
  44. "wechat-api/ent/wpchatroommember"
  45. "wechat-api/ent/wx"
  46. "wechat-api/ent/wxcard"
  47. "wechat-api/ent/wxcarduser"
  48. "wechat-api/ent/wxcardvisit"
  49. "entgo.io/ent"
  50. "entgo.io/ent/dialect/sql"
  51. )
  52. const (
  53. // Operation types.
  54. OpCreate = ent.OpCreate
  55. OpDelete = ent.OpDelete
  56. OpDeleteOne = ent.OpDeleteOne
  57. OpUpdate = ent.OpUpdate
  58. OpUpdateOne = ent.OpUpdateOne
  59. // Node types.
  60. TypeAgent = "Agent"
  61. TypeAgentBase = "AgentBase"
  62. TypeAliyunAvatar = "AliyunAvatar"
  63. TypeAllocAgent = "AllocAgent"
  64. TypeBatchMsg = "BatchMsg"
  65. TypeCategory = "Category"
  66. TypeChatRecords = "ChatRecords"
  67. TypeChatSession = "ChatSession"
  68. TypeContact = "Contact"
  69. TypeCreditBalance = "CreditBalance"
  70. TypeCreditUsage = "CreditUsage"
  71. TypeEmployee = "Employee"
  72. TypeEmployeeConfig = "EmployeeConfig"
  73. TypeLabel = "Label"
  74. TypeLabelRelationship = "LabelRelationship"
  75. TypeLabelTagging = "LabelTagging"
  76. TypeMessage = "Message"
  77. TypeMessageRecords = "MessageRecords"
  78. TypeMsg = "Msg"
  79. TypePayRecharge = "PayRecharge"
  80. TypeServer = "Server"
  81. TypeSopNode = "SopNode"
  82. TypeSopStage = "SopStage"
  83. TypeSopTask = "SopTask"
  84. TypeToken = "Token"
  85. TypeTutorial = "Tutorial"
  86. TypeUsageDetail = "UsageDetail"
  87. TypeUsageStatisticDay = "UsageStatisticDay"
  88. TypeUsageStatisticHour = "UsageStatisticHour"
  89. TypeUsageStatisticMonth = "UsageStatisticMonth"
  90. TypeUsageTotal = "UsageTotal"
  91. TypeWorkExperience = "WorkExperience"
  92. TypeWpChatroom = "WpChatroom"
  93. TypeWpChatroomMember = "WpChatroomMember"
  94. TypeWx = "Wx"
  95. TypeWxCard = "WxCard"
  96. TypeWxCardUser = "WxCardUser"
  97. TypeWxCardVisit = "WxCardVisit"
  98. )
  99. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  100. type AgentMutation struct {
  101. config
  102. op Op
  103. typ string
  104. id *uint64
  105. created_at *time.Time
  106. updated_at *time.Time
  107. deleted_at *time.Time
  108. name *string
  109. role *string
  110. status *int
  111. addstatus *int
  112. background *string
  113. examples *string
  114. organization_id *uint64
  115. addorganization_id *int64
  116. dataset_id *string
  117. collection_id *string
  118. clearedFields map[string]struct{}
  119. wx_agent map[uint64]struct{}
  120. removedwx_agent map[uint64]struct{}
  121. clearedwx_agent bool
  122. token_agent map[uint64]struct{}
  123. removedtoken_agent map[uint64]struct{}
  124. clearedtoken_agent bool
  125. done bool
  126. oldValue func(context.Context) (*Agent, error)
  127. predicates []predicate.Agent
  128. }
  129. var _ ent.Mutation = (*AgentMutation)(nil)
  130. // agentOption allows management of the mutation configuration using functional options.
  131. type agentOption func(*AgentMutation)
  132. // newAgentMutation creates new mutation for the Agent entity.
  133. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  134. m := &AgentMutation{
  135. config: c,
  136. op: op,
  137. typ: TypeAgent,
  138. clearedFields: make(map[string]struct{}),
  139. }
  140. for _, opt := range opts {
  141. opt(m)
  142. }
  143. return m
  144. }
  145. // withAgentID sets the ID field of the mutation.
  146. func withAgentID(id uint64) agentOption {
  147. return func(m *AgentMutation) {
  148. var (
  149. err error
  150. once sync.Once
  151. value *Agent
  152. )
  153. m.oldValue = func(ctx context.Context) (*Agent, error) {
  154. once.Do(func() {
  155. if m.done {
  156. err = errors.New("querying old values post mutation is not allowed")
  157. } else {
  158. value, err = m.Client().Agent.Get(ctx, id)
  159. }
  160. })
  161. return value, err
  162. }
  163. m.id = &id
  164. }
  165. }
  166. // withAgent sets the old Agent of the mutation.
  167. func withAgent(node *Agent) agentOption {
  168. return func(m *AgentMutation) {
  169. m.oldValue = func(context.Context) (*Agent, error) {
  170. return node, nil
  171. }
  172. m.id = &node.ID
  173. }
  174. }
  175. // Client returns a new `ent.Client` from the mutation. If the mutation was
  176. // executed in a transaction (ent.Tx), a transactional client is returned.
  177. func (m AgentMutation) Client() *Client {
  178. client := &Client{config: m.config}
  179. client.init()
  180. return client
  181. }
  182. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  183. // it returns an error otherwise.
  184. func (m AgentMutation) Tx() (*Tx, error) {
  185. if _, ok := m.driver.(*txDriver); !ok {
  186. return nil, errors.New("ent: mutation is not running in a transaction")
  187. }
  188. tx := &Tx{config: m.config}
  189. tx.init()
  190. return tx, nil
  191. }
  192. // SetID sets the value of the id field. Note that this
  193. // operation is only accepted on creation of Agent entities.
  194. func (m *AgentMutation) SetID(id uint64) {
  195. m.id = &id
  196. }
  197. // ID returns the ID value in the mutation. Note that the ID is only available
  198. // if it was provided to the builder or after it was returned from the database.
  199. func (m *AgentMutation) ID() (id uint64, exists bool) {
  200. if m.id == nil {
  201. return
  202. }
  203. return *m.id, true
  204. }
  205. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  206. // That means, if the mutation is applied within a transaction with an isolation level such
  207. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  208. // or updated by the mutation.
  209. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  210. switch {
  211. case m.op.Is(OpUpdateOne | OpDeleteOne):
  212. id, exists := m.ID()
  213. if exists {
  214. return []uint64{id}, nil
  215. }
  216. fallthrough
  217. case m.op.Is(OpUpdate | OpDelete):
  218. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  219. default:
  220. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  221. }
  222. }
  223. // SetCreatedAt sets the "created_at" field.
  224. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  225. m.created_at = &t
  226. }
  227. // CreatedAt returns the value of the "created_at" field in the mutation.
  228. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  229. v := m.created_at
  230. if v == nil {
  231. return
  232. }
  233. return *v, true
  234. }
  235. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  236. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  238. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  239. if !m.op.Is(OpUpdateOne) {
  240. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  241. }
  242. if m.id == nil || m.oldValue == nil {
  243. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  244. }
  245. oldValue, err := m.oldValue(ctx)
  246. if err != nil {
  247. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  248. }
  249. return oldValue.CreatedAt, nil
  250. }
  251. // ResetCreatedAt resets all changes to the "created_at" field.
  252. func (m *AgentMutation) ResetCreatedAt() {
  253. m.created_at = nil
  254. }
  255. // SetUpdatedAt sets the "updated_at" field.
  256. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  257. m.updated_at = &t
  258. }
  259. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  260. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  261. v := m.updated_at
  262. if v == nil {
  263. return
  264. }
  265. return *v, true
  266. }
  267. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  268. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  270. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  271. if !m.op.Is(OpUpdateOne) {
  272. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  273. }
  274. if m.id == nil || m.oldValue == nil {
  275. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  276. }
  277. oldValue, err := m.oldValue(ctx)
  278. if err != nil {
  279. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  280. }
  281. return oldValue.UpdatedAt, nil
  282. }
  283. // ResetUpdatedAt resets all changes to the "updated_at" field.
  284. func (m *AgentMutation) ResetUpdatedAt() {
  285. m.updated_at = nil
  286. }
  287. // SetDeletedAt sets the "deleted_at" field.
  288. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  289. m.deleted_at = &t
  290. }
  291. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  292. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  293. v := m.deleted_at
  294. if v == nil {
  295. return
  296. }
  297. return *v, true
  298. }
  299. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  300. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  302. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  303. if !m.op.Is(OpUpdateOne) {
  304. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  305. }
  306. if m.id == nil || m.oldValue == nil {
  307. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  308. }
  309. oldValue, err := m.oldValue(ctx)
  310. if err != nil {
  311. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  312. }
  313. return oldValue.DeletedAt, nil
  314. }
  315. // ClearDeletedAt clears the value of the "deleted_at" field.
  316. func (m *AgentMutation) ClearDeletedAt() {
  317. m.deleted_at = nil
  318. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  319. }
  320. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  321. func (m *AgentMutation) DeletedAtCleared() bool {
  322. _, ok := m.clearedFields[agent.FieldDeletedAt]
  323. return ok
  324. }
  325. // ResetDeletedAt resets all changes to the "deleted_at" field.
  326. func (m *AgentMutation) ResetDeletedAt() {
  327. m.deleted_at = nil
  328. delete(m.clearedFields, agent.FieldDeletedAt)
  329. }
  330. // SetName sets the "name" field.
  331. func (m *AgentMutation) SetName(s string) {
  332. m.name = &s
  333. }
  334. // Name returns the value of the "name" field in the mutation.
  335. func (m *AgentMutation) Name() (r string, exists bool) {
  336. v := m.name
  337. if v == nil {
  338. return
  339. }
  340. return *v, true
  341. }
  342. // OldName returns the old "name" field's value of the Agent entity.
  343. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  345. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  346. if !m.op.Is(OpUpdateOne) {
  347. return v, errors.New("OldName is only allowed on UpdateOne operations")
  348. }
  349. if m.id == nil || m.oldValue == nil {
  350. return v, errors.New("OldName requires an ID field in the mutation")
  351. }
  352. oldValue, err := m.oldValue(ctx)
  353. if err != nil {
  354. return v, fmt.Errorf("querying old value for OldName: %w", err)
  355. }
  356. return oldValue.Name, nil
  357. }
  358. // ResetName resets all changes to the "name" field.
  359. func (m *AgentMutation) ResetName() {
  360. m.name = nil
  361. }
  362. // SetRole sets the "role" field.
  363. func (m *AgentMutation) SetRole(s string) {
  364. m.role = &s
  365. }
  366. // Role returns the value of the "role" field in the mutation.
  367. func (m *AgentMutation) Role() (r string, exists bool) {
  368. v := m.role
  369. if v == nil {
  370. return
  371. }
  372. return *v, true
  373. }
  374. // OldRole returns the old "role" field's value of the Agent entity.
  375. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  377. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  378. if !m.op.Is(OpUpdateOne) {
  379. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  380. }
  381. if m.id == nil || m.oldValue == nil {
  382. return v, errors.New("OldRole requires an ID field in the mutation")
  383. }
  384. oldValue, err := m.oldValue(ctx)
  385. if err != nil {
  386. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  387. }
  388. return oldValue.Role, nil
  389. }
  390. // ResetRole resets all changes to the "role" field.
  391. func (m *AgentMutation) ResetRole() {
  392. m.role = nil
  393. }
  394. // SetStatus sets the "status" field.
  395. func (m *AgentMutation) SetStatus(i int) {
  396. m.status = &i
  397. m.addstatus = nil
  398. }
  399. // Status returns the value of the "status" field in the mutation.
  400. func (m *AgentMutation) Status() (r int, exists bool) {
  401. v := m.status
  402. if v == nil {
  403. return
  404. }
  405. return *v, true
  406. }
  407. // OldStatus returns the old "status" field's value of the Agent entity.
  408. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  410. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  411. if !m.op.Is(OpUpdateOne) {
  412. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  413. }
  414. if m.id == nil || m.oldValue == nil {
  415. return v, errors.New("OldStatus requires an ID field in the mutation")
  416. }
  417. oldValue, err := m.oldValue(ctx)
  418. if err != nil {
  419. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  420. }
  421. return oldValue.Status, nil
  422. }
  423. // AddStatus adds i to the "status" field.
  424. func (m *AgentMutation) AddStatus(i int) {
  425. if m.addstatus != nil {
  426. *m.addstatus += i
  427. } else {
  428. m.addstatus = &i
  429. }
  430. }
  431. // AddedStatus returns the value that was added to the "status" field in this mutation.
  432. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  433. v := m.addstatus
  434. if v == nil {
  435. return
  436. }
  437. return *v, true
  438. }
  439. // ClearStatus clears the value of the "status" field.
  440. func (m *AgentMutation) ClearStatus() {
  441. m.status = nil
  442. m.addstatus = nil
  443. m.clearedFields[agent.FieldStatus] = struct{}{}
  444. }
  445. // StatusCleared returns if the "status" field was cleared in this mutation.
  446. func (m *AgentMutation) StatusCleared() bool {
  447. _, ok := m.clearedFields[agent.FieldStatus]
  448. return ok
  449. }
  450. // ResetStatus resets all changes to the "status" field.
  451. func (m *AgentMutation) ResetStatus() {
  452. m.status = nil
  453. m.addstatus = nil
  454. delete(m.clearedFields, agent.FieldStatus)
  455. }
  456. // SetBackground sets the "background" field.
  457. func (m *AgentMutation) SetBackground(s string) {
  458. m.background = &s
  459. }
  460. // Background returns the value of the "background" field in the mutation.
  461. func (m *AgentMutation) Background() (r string, exists bool) {
  462. v := m.background
  463. if v == nil {
  464. return
  465. }
  466. return *v, true
  467. }
  468. // OldBackground returns the old "background" field's value of the Agent entity.
  469. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  470. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  471. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  472. if !m.op.Is(OpUpdateOne) {
  473. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  474. }
  475. if m.id == nil || m.oldValue == nil {
  476. return v, errors.New("OldBackground requires an ID field in the mutation")
  477. }
  478. oldValue, err := m.oldValue(ctx)
  479. if err != nil {
  480. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  481. }
  482. return oldValue.Background, nil
  483. }
  484. // ClearBackground clears the value of the "background" field.
  485. func (m *AgentMutation) ClearBackground() {
  486. m.background = nil
  487. m.clearedFields[agent.FieldBackground] = struct{}{}
  488. }
  489. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  490. func (m *AgentMutation) BackgroundCleared() bool {
  491. _, ok := m.clearedFields[agent.FieldBackground]
  492. return ok
  493. }
  494. // ResetBackground resets all changes to the "background" field.
  495. func (m *AgentMutation) ResetBackground() {
  496. m.background = nil
  497. delete(m.clearedFields, agent.FieldBackground)
  498. }
  499. // SetExamples sets the "examples" field.
  500. func (m *AgentMutation) SetExamples(s string) {
  501. m.examples = &s
  502. }
  503. // Examples returns the value of the "examples" field in the mutation.
  504. func (m *AgentMutation) Examples() (r string, exists bool) {
  505. v := m.examples
  506. if v == nil {
  507. return
  508. }
  509. return *v, true
  510. }
  511. // OldExamples returns the old "examples" field's value of the Agent entity.
  512. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  514. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  515. if !m.op.Is(OpUpdateOne) {
  516. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  517. }
  518. if m.id == nil || m.oldValue == nil {
  519. return v, errors.New("OldExamples requires an ID field in the mutation")
  520. }
  521. oldValue, err := m.oldValue(ctx)
  522. if err != nil {
  523. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  524. }
  525. return oldValue.Examples, nil
  526. }
  527. // ClearExamples clears the value of the "examples" field.
  528. func (m *AgentMutation) ClearExamples() {
  529. m.examples = nil
  530. m.clearedFields[agent.FieldExamples] = struct{}{}
  531. }
  532. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  533. func (m *AgentMutation) ExamplesCleared() bool {
  534. _, ok := m.clearedFields[agent.FieldExamples]
  535. return ok
  536. }
  537. // ResetExamples resets all changes to the "examples" field.
  538. func (m *AgentMutation) ResetExamples() {
  539. m.examples = nil
  540. delete(m.clearedFields, agent.FieldExamples)
  541. }
  542. // SetOrganizationID sets the "organization_id" field.
  543. func (m *AgentMutation) SetOrganizationID(u uint64) {
  544. m.organization_id = &u
  545. m.addorganization_id = nil
  546. }
  547. // OrganizationID returns the value of the "organization_id" field in the mutation.
  548. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  549. v := m.organization_id
  550. if v == nil {
  551. return
  552. }
  553. return *v, true
  554. }
  555. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  556. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  558. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  559. if !m.op.Is(OpUpdateOne) {
  560. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  561. }
  562. if m.id == nil || m.oldValue == nil {
  563. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  564. }
  565. oldValue, err := m.oldValue(ctx)
  566. if err != nil {
  567. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  568. }
  569. return oldValue.OrganizationID, nil
  570. }
  571. // AddOrganizationID adds u to the "organization_id" field.
  572. func (m *AgentMutation) AddOrganizationID(u int64) {
  573. if m.addorganization_id != nil {
  574. *m.addorganization_id += u
  575. } else {
  576. m.addorganization_id = &u
  577. }
  578. }
  579. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  580. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  581. v := m.addorganization_id
  582. if v == nil {
  583. return
  584. }
  585. return *v, true
  586. }
  587. // ResetOrganizationID resets all changes to the "organization_id" field.
  588. func (m *AgentMutation) ResetOrganizationID() {
  589. m.organization_id = nil
  590. m.addorganization_id = nil
  591. }
  592. // SetDatasetID sets the "dataset_id" field.
  593. func (m *AgentMutation) SetDatasetID(s string) {
  594. m.dataset_id = &s
  595. }
  596. // DatasetID returns the value of the "dataset_id" field in the mutation.
  597. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  598. v := m.dataset_id
  599. if v == nil {
  600. return
  601. }
  602. return *v, true
  603. }
  604. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  605. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  607. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  608. if !m.op.Is(OpUpdateOne) {
  609. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  610. }
  611. if m.id == nil || m.oldValue == nil {
  612. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  613. }
  614. oldValue, err := m.oldValue(ctx)
  615. if err != nil {
  616. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  617. }
  618. return oldValue.DatasetID, nil
  619. }
  620. // ResetDatasetID resets all changes to the "dataset_id" field.
  621. func (m *AgentMutation) ResetDatasetID() {
  622. m.dataset_id = nil
  623. }
  624. // SetCollectionID sets the "collection_id" field.
  625. func (m *AgentMutation) SetCollectionID(s string) {
  626. m.collection_id = &s
  627. }
  628. // CollectionID returns the value of the "collection_id" field in the mutation.
  629. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  630. v := m.collection_id
  631. if v == nil {
  632. return
  633. }
  634. return *v, true
  635. }
  636. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  637. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  639. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  640. if !m.op.Is(OpUpdateOne) {
  641. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  642. }
  643. if m.id == nil || m.oldValue == nil {
  644. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  645. }
  646. oldValue, err := m.oldValue(ctx)
  647. if err != nil {
  648. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  649. }
  650. return oldValue.CollectionID, nil
  651. }
  652. // ResetCollectionID resets all changes to the "collection_id" field.
  653. func (m *AgentMutation) ResetCollectionID() {
  654. m.collection_id = nil
  655. }
  656. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  657. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  658. if m.wx_agent == nil {
  659. m.wx_agent = make(map[uint64]struct{})
  660. }
  661. for i := range ids {
  662. m.wx_agent[ids[i]] = struct{}{}
  663. }
  664. }
  665. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  666. func (m *AgentMutation) ClearWxAgent() {
  667. m.clearedwx_agent = true
  668. }
  669. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  670. func (m *AgentMutation) WxAgentCleared() bool {
  671. return m.clearedwx_agent
  672. }
  673. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  674. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  675. if m.removedwx_agent == nil {
  676. m.removedwx_agent = make(map[uint64]struct{})
  677. }
  678. for i := range ids {
  679. delete(m.wx_agent, ids[i])
  680. m.removedwx_agent[ids[i]] = struct{}{}
  681. }
  682. }
  683. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  684. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  685. for id := range m.removedwx_agent {
  686. ids = append(ids, id)
  687. }
  688. return
  689. }
  690. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  691. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  692. for id := range m.wx_agent {
  693. ids = append(ids, id)
  694. }
  695. return
  696. }
  697. // ResetWxAgent resets all changes to the "wx_agent" edge.
  698. func (m *AgentMutation) ResetWxAgent() {
  699. m.wx_agent = nil
  700. m.clearedwx_agent = false
  701. m.removedwx_agent = nil
  702. }
  703. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  704. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  705. if m.token_agent == nil {
  706. m.token_agent = make(map[uint64]struct{})
  707. }
  708. for i := range ids {
  709. m.token_agent[ids[i]] = struct{}{}
  710. }
  711. }
  712. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  713. func (m *AgentMutation) ClearTokenAgent() {
  714. m.clearedtoken_agent = true
  715. }
  716. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  717. func (m *AgentMutation) TokenAgentCleared() bool {
  718. return m.clearedtoken_agent
  719. }
  720. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  721. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  722. if m.removedtoken_agent == nil {
  723. m.removedtoken_agent = make(map[uint64]struct{})
  724. }
  725. for i := range ids {
  726. delete(m.token_agent, ids[i])
  727. m.removedtoken_agent[ids[i]] = struct{}{}
  728. }
  729. }
  730. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  731. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  732. for id := range m.removedtoken_agent {
  733. ids = append(ids, id)
  734. }
  735. return
  736. }
  737. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  738. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  739. for id := range m.token_agent {
  740. ids = append(ids, id)
  741. }
  742. return
  743. }
  744. // ResetTokenAgent resets all changes to the "token_agent" edge.
  745. func (m *AgentMutation) ResetTokenAgent() {
  746. m.token_agent = nil
  747. m.clearedtoken_agent = false
  748. m.removedtoken_agent = nil
  749. }
  750. // Where appends a list predicates to the AgentMutation builder.
  751. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  752. m.predicates = append(m.predicates, ps...)
  753. }
  754. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  755. // users can use type-assertion to append predicates that do not depend on any generated package.
  756. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  757. p := make([]predicate.Agent, len(ps))
  758. for i := range ps {
  759. p[i] = ps[i]
  760. }
  761. m.Where(p...)
  762. }
  763. // Op returns the operation name.
  764. func (m *AgentMutation) Op() Op {
  765. return m.op
  766. }
  767. // SetOp allows setting the mutation operation.
  768. func (m *AgentMutation) SetOp(op Op) {
  769. m.op = op
  770. }
  771. // Type returns the node type of this mutation (Agent).
  772. func (m *AgentMutation) Type() string {
  773. return m.typ
  774. }
  775. // Fields returns all fields that were changed during this mutation. Note that in
  776. // order to get all numeric fields that were incremented/decremented, call
  777. // AddedFields().
  778. func (m *AgentMutation) Fields() []string {
  779. fields := make([]string, 0, 11)
  780. if m.created_at != nil {
  781. fields = append(fields, agent.FieldCreatedAt)
  782. }
  783. if m.updated_at != nil {
  784. fields = append(fields, agent.FieldUpdatedAt)
  785. }
  786. if m.deleted_at != nil {
  787. fields = append(fields, agent.FieldDeletedAt)
  788. }
  789. if m.name != nil {
  790. fields = append(fields, agent.FieldName)
  791. }
  792. if m.role != nil {
  793. fields = append(fields, agent.FieldRole)
  794. }
  795. if m.status != nil {
  796. fields = append(fields, agent.FieldStatus)
  797. }
  798. if m.background != nil {
  799. fields = append(fields, agent.FieldBackground)
  800. }
  801. if m.examples != nil {
  802. fields = append(fields, agent.FieldExamples)
  803. }
  804. if m.organization_id != nil {
  805. fields = append(fields, agent.FieldOrganizationID)
  806. }
  807. if m.dataset_id != nil {
  808. fields = append(fields, agent.FieldDatasetID)
  809. }
  810. if m.collection_id != nil {
  811. fields = append(fields, agent.FieldCollectionID)
  812. }
  813. return fields
  814. }
  815. // Field returns the value of a field with the given name. The second boolean
  816. // return value indicates that this field was not set, or was not defined in the
  817. // schema.
  818. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  819. switch name {
  820. case agent.FieldCreatedAt:
  821. return m.CreatedAt()
  822. case agent.FieldUpdatedAt:
  823. return m.UpdatedAt()
  824. case agent.FieldDeletedAt:
  825. return m.DeletedAt()
  826. case agent.FieldName:
  827. return m.Name()
  828. case agent.FieldRole:
  829. return m.Role()
  830. case agent.FieldStatus:
  831. return m.Status()
  832. case agent.FieldBackground:
  833. return m.Background()
  834. case agent.FieldExamples:
  835. return m.Examples()
  836. case agent.FieldOrganizationID:
  837. return m.OrganizationID()
  838. case agent.FieldDatasetID:
  839. return m.DatasetID()
  840. case agent.FieldCollectionID:
  841. return m.CollectionID()
  842. }
  843. return nil, false
  844. }
  845. // OldField returns the old value of the field from the database. An error is
  846. // returned if the mutation operation is not UpdateOne, or the query to the
  847. // database failed.
  848. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  849. switch name {
  850. case agent.FieldCreatedAt:
  851. return m.OldCreatedAt(ctx)
  852. case agent.FieldUpdatedAt:
  853. return m.OldUpdatedAt(ctx)
  854. case agent.FieldDeletedAt:
  855. return m.OldDeletedAt(ctx)
  856. case agent.FieldName:
  857. return m.OldName(ctx)
  858. case agent.FieldRole:
  859. return m.OldRole(ctx)
  860. case agent.FieldStatus:
  861. return m.OldStatus(ctx)
  862. case agent.FieldBackground:
  863. return m.OldBackground(ctx)
  864. case agent.FieldExamples:
  865. return m.OldExamples(ctx)
  866. case agent.FieldOrganizationID:
  867. return m.OldOrganizationID(ctx)
  868. case agent.FieldDatasetID:
  869. return m.OldDatasetID(ctx)
  870. case agent.FieldCollectionID:
  871. return m.OldCollectionID(ctx)
  872. }
  873. return nil, fmt.Errorf("unknown Agent field %s", name)
  874. }
  875. // SetField sets the value of a field with the given name. It returns an error if
  876. // the field is not defined in the schema, or if the type mismatched the field
  877. // type.
  878. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  879. switch name {
  880. case agent.FieldCreatedAt:
  881. v, ok := value.(time.Time)
  882. if !ok {
  883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  884. }
  885. m.SetCreatedAt(v)
  886. return nil
  887. case agent.FieldUpdatedAt:
  888. v, ok := value.(time.Time)
  889. if !ok {
  890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  891. }
  892. m.SetUpdatedAt(v)
  893. return nil
  894. case agent.FieldDeletedAt:
  895. v, ok := value.(time.Time)
  896. if !ok {
  897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  898. }
  899. m.SetDeletedAt(v)
  900. return nil
  901. case agent.FieldName:
  902. v, ok := value.(string)
  903. if !ok {
  904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  905. }
  906. m.SetName(v)
  907. return nil
  908. case agent.FieldRole:
  909. v, ok := value.(string)
  910. if !ok {
  911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  912. }
  913. m.SetRole(v)
  914. return nil
  915. case agent.FieldStatus:
  916. v, ok := value.(int)
  917. if !ok {
  918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  919. }
  920. m.SetStatus(v)
  921. return nil
  922. case agent.FieldBackground:
  923. v, ok := value.(string)
  924. if !ok {
  925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  926. }
  927. m.SetBackground(v)
  928. return nil
  929. case agent.FieldExamples:
  930. v, ok := value.(string)
  931. if !ok {
  932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  933. }
  934. m.SetExamples(v)
  935. return nil
  936. case agent.FieldOrganizationID:
  937. v, ok := value.(uint64)
  938. if !ok {
  939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  940. }
  941. m.SetOrganizationID(v)
  942. return nil
  943. case agent.FieldDatasetID:
  944. v, ok := value.(string)
  945. if !ok {
  946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  947. }
  948. m.SetDatasetID(v)
  949. return nil
  950. case agent.FieldCollectionID:
  951. v, ok := value.(string)
  952. if !ok {
  953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  954. }
  955. m.SetCollectionID(v)
  956. return nil
  957. }
  958. return fmt.Errorf("unknown Agent field %s", name)
  959. }
  960. // AddedFields returns all numeric fields that were incremented/decremented during
  961. // this mutation.
  962. func (m *AgentMutation) AddedFields() []string {
  963. var fields []string
  964. if m.addstatus != nil {
  965. fields = append(fields, agent.FieldStatus)
  966. }
  967. if m.addorganization_id != nil {
  968. fields = append(fields, agent.FieldOrganizationID)
  969. }
  970. return fields
  971. }
  972. // AddedField returns the numeric value that was incremented/decremented on a field
  973. // with the given name. The second boolean return value indicates that this field
  974. // was not set, or was not defined in the schema.
  975. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  976. switch name {
  977. case agent.FieldStatus:
  978. return m.AddedStatus()
  979. case agent.FieldOrganizationID:
  980. return m.AddedOrganizationID()
  981. }
  982. return nil, false
  983. }
  984. // AddField adds the value to the field with the given name. It returns an error if
  985. // the field is not defined in the schema, or if the type mismatched the field
  986. // type.
  987. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  988. switch name {
  989. case agent.FieldStatus:
  990. v, ok := value.(int)
  991. if !ok {
  992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  993. }
  994. m.AddStatus(v)
  995. return nil
  996. case agent.FieldOrganizationID:
  997. v, ok := value.(int64)
  998. if !ok {
  999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1000. }
  1001. m.AddOrganizationID(v)
  1002. return nil
  1003. }
  1004. return fmt.Errorf("unknown Agent numeric field %s", name)
  1005. }
  1006. // ClearedFields returns all nullable fields that were cleared during this
  1007. // mutation.
  1008. func (m *AgentMutation) ClearedFields() []string {
  1009. var fields []string
  1010. if m.FieldCleared(agent.FieldDeletedAt) {
  1011. fields = append(fields, agent.FieldDeletedAt)
  1012. }
  1013. if m.FieldCleared(agent.FieldStatus) {
  1014. fields = append(fields, agent.FieldStatus)
  1015. }
  1016. if m.FieldCleared(agent.FieldBackground) {
  1017. fields = append(fields, agent.FieldBackground)
  1018. }
  1019. if m.FieldCleared(agent.FieldExamples) {
  1020. fields = append(fields, agent.FieldExamples)
  1021. }
  1022. return fields
  1023. }
  1024. // FieldCleared returns a boolean indicating if a field with the given name was
  1025. // cleared in this mutation.
  1026. func (m *AgentMutation) FieldCleared(name string) bool {
  1027. _, ok := m.clearedFields[name]
  1028. return ok
  1029. }
  1030. // ClearField clears the value of the field with the given name. It returns an
  1031. // error if the field is not defined in the schema.
  1032. func (m *AgentMutation) ClearField(name string) error {
  1033. switch name {
  1034. case agent.FieldDeletedAt:
  1035. m.ClearDeletedAt()
  1036. return nil
  1037. case agent.FieldStatus:
  1038. m.ClearStatus()
  1039. return nil
  1040. case agent.FieldBackground:
  1041. m.ClearBackground()
  1042. return nil
  1043. case agent.FieldExamples:
  1044. m.ClearExamples()
  1045. return nil
  1046. }
  1047. return fmt.Errorf("unknown Agent nullable field %s", name)
  1048. }
  1049. // ResetField resets all changes in the mutation for the field with the given name.
  1050. // It returns an error if the field is not defined in the schema.
  1051. func (m *AgentMutation) ResetField(name string) error {
  1052. switch name {
  1053. case agent.FieldCreatedAt:
  1054. m.ResetCreatedAt()
  1055. return nil
  1056. case agent.FieldUpdatedAt:
  1057. m.ResetUpdatedAt()
  1058. return nil
  1059. case agent.FieldDeletedAt:
  1060. m.ResetDeletedAt()
  1061. return nil
  1062. case agent.FieldName:
  1063. m.ResetName()
  1064. return nil
  1065. case agent.FieldRole:
  1066. m.ResetRole()
  1067. return nil
  1068. case agent.FieldStatus:
  1069. m.ResetStatus()
  1070. return nil
  1071. case agent.FieldBackground:
  1072. m.ResetBackground()
  1073. return nil
  1074. case agent.FieldExamples:
  1075. m.ResetExamples()
  1076. return nil
  1077. case agent.FieldOrganizationID:
  1078. m.ResetOrganizationID()
  1079. return nil
  1080. case agent.FieldDatasetID:
  1081. m.ResetDatasetID()
  1082. return nil
  1083. case agent.FieldCollectionID:
  1084. m.ResetCollectionID()
  1085. return nil
  1086. }
  1087. return fmt.Errorf("unknown Agent field %s", name)
  1088. }
  1089. // AddedEdges returns all edge names that were set/added in this mutation.
  1090. func (m *AgentMutation) AddedEdges() []string {
  1091. edges := make([]string, 0, 2)
  1092. if m.wx_agent != nil {
  1093. edges = append(edges, agent.EdgeWxAgent)
  1094. }
  1095. if m.token_agent != nil {
  1096. edges = append(edges, agent.EdgeTokenAgent)
  1097. }
  1098. return edges
  1099. }
  1100. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1101. // name in this mutation.
  1102. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1103. switch name {
  1104. case agent.EdgeWxAgent:
  1105. ids := make([]ent.Value, 0, len(m.wx_agent))
  1106. for id := range m.wx_agent {
  1107. ids = append(ids, id)
  1108. }
  1109. return ids
  1110. case agent.EdgeTokenAgent:
  1111. ids := make([]ent.Value, 0, len(m.token_agent))
  1112. for id := range m.token_agent {
  1113. ids = append(ids, id)
  1114. }
  1115. return ids
  1116. }
  1117. return nil
  1118. }
  1119. // RemovedEdges returns all edge names that were removed in this mutation.
  1120. func (m *AgentMutation) RemovedEdges() []string {
  1121. edges := make([]string, 0, 2)
  1122. if m.removedwx_agent != nil {
  1123. edges = append(edges, agent.EdgeWxAgent)
  1124. }
  1125. if m.removedtoken_agent != nil {
  1126. edges = append(edges, agent.EdgeTokenAgent)
  1127. }
  1128. return edges
  1129. }
  1130. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1131. // the given name in this mutation.
  1132. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1133. switch name {
  1134. case agent.EdgeWxAgent:
  1135. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1136. for id := range m.removedwx_agent {
  1137. ids = append(ids, id)
  1138. }
  1139. return ids
  1140. case agent.EdgeTokenAgent:
  1141. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1142. for id := range m.removedtoken_agent {
  1143. ids = append(ids, id)
  1144. }
  1145. return ids
  1146. }
  1147. return nil
  1148. }
  1149. // ClearedEdges returns all edge names that were cleared in this mutation.
  1150. func (m *AgentMutation) ClearedEdges() []string {
  1151. edges := make([]string, 0, 2)
  1152. if m.clearedwx_agent {
  1153. edges = append(edges, agent.EdgeWxAgent)
  1154. }
  1155. if m.clearedtoken_agent {
  1156. edges = append(edges, agent.EdgeTokenAgent)
  1157. }
  1158. return edges
  1159. }
  1160. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1161. // was cleared in this mutation.
  1162. func (m *AgentMutation) EdgeCleared(name string) bool {
  1163. switch name {
  1164. case agent.EdgeWxAgent:
  1165. return m.clearedwx_agent
  1166. case agent.EdgeTokenAgent:
  1167. return m.clearedtoken_agent
  1168. }
  1169. return false
  1170. }
  1171. // ClearEdge clears the value of the edge with the given name. It returns an error
  1172. // if that edge is not defined in the schema.
  1173. func (m *AgentMutation) ClearEdge(name string) error {
  1174. switch name {
  1175. }
  1176. return fmt.Errorf("unknown Agent unique edge %s", name)
  1177. }
  1178. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1179. // It returns an error if the edge is not defined in the schema.
  1180. func (m *AgentMutation) ResetEdge(name string) error {
  1181. switch name {
  1182. case agent.EdgeWxAgent:
  1183. m.ResetWxAgent()
  1184. return nil
  1185. case agent.EdgeTokenAgent:
  1186. m.ResetTokenAgent()
  1187. return nil
  1188. }
  1189. return fmt.Errorf("unknown Agent edge %s", name)
  1190. }
  1191. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1192. type AgentBaseMutation struct {
  1193. config
  1194. op Op
  1195. typ string
  1196. id *string
  1197. q *string
  1198. a *string
  1199. chunk_index *uint64
  1200. addchunk_index *int64
  1201. indexes *[]string
  1202. appendindexes []string
  1203. dataset_id *string
  1204. collection_id *string
  1205. source_name *string
  1206. can_write *[]bool
  1207. appendcan_write []bool
  1208. is_owner *[]bool
  1209. appendis_owner []bool
  1210. clearedFields map[string]struct{}
  1211. wx_agent map[uint64]struct{}
  1212. removedwx_agent map[uint64]struct{}
  1213. clearedwx_agent bool
  1214. done bool
  1215. oldValue func(context.Context) (*AgentBase, error)
  1216. predicates []predicate.AgentBase
  1217. }
  1218. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1219. // agentbaseOption allows management of the mutation configuration using functional options.
  1220. type agentbaseOption func(*AgentBaseMutation)
  1221. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1222. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1223. m := &AgentBaseMutation{
  1224. config: c,
  1225. op: op,
  1226. typ: TypeAgentBase,
  1227. clearedFields: make(map[string]struct{}),
  1228. }
  1229. for _, opt := range opts {
  1230. opt(m)
  1231. }
  1232. return m
  1233. }
  1234. // withAgentBaseID sets the ID field of the mutation.
  1235. func withAgentBaseID(id string) agentbaseOption {
  1236. return func(m *AgentBaseMutation) {
  1237. var (
  1238. err error
  1239. once sync.Once
  1240. value *AgentBase
  1241. )
  1242. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1243. once.Do(func() {
  1244. if m.done {
  1245. err = errors.New("querying old values post mutation is not allowed")
  1246. } else {
  1247. value, err = m.Client().AgentBase.Get(ctx, id)
  1248. }
  1249. })
  1250. return value, err
  1251. }
  1252. m.id = &id
  1253. }
  1254. }
  1255. // withAgentBase sets the old AgentBase of the mutation.
  1256. func withAgentBase(node *AgentBase) agentbaseOption {
  1257. return func(m *AgentBaseMutation) {
  1258. m.oldValue = func(context.Context) (*AgentBase, error) {
  1259. return node, nil
  1260. }
  1261. m.id = &node.ID
  1262. }
  1263. }
  1264. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1265. // executed in a transaction (ent.Tx), a transactional client is returned.
  1266. func (m AgentBaseMutation) Client() *Client {
  1267. client := &Client{config: m.config}
  1268. client.init()
  1269. return client
  1270. }
  1271. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1272. // it returns an error otherwise.
  1273. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1274. if _, ok := m.driver.(*txDriver); !ok {
  1275. return nil, errors.New("ent: mutation is not running in a transaction")
  1276. }
  1277. tx := &Tx{config: m.config}
  1278. tx.init()
  1279. return tx, nil
  1280. }
  1281. // SetID sets the value of the id field. Note that this
  1282. // operation is only accepted on creation of AgentBase entities.
  1283. func (m *AgentBaseMutation) SetID(id string) {
  1284. m.id = &id
  1285. }
  1286. // ID returns the ID value in the mutation. Note that the ID is only available
  1287. // if it was provided to the builder or after it was returned from the database.
  1288. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1289. if m.id == nil {
  1290. return
  1291. }
  1292. return *m.id, true
  1293. }
  1294. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1295. // That means, if the mutation is applied within a transaction with an isolation level such
  1296. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1297. // or updated by the mutation.
  1298. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1299. switch {
  1300. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1301. id, exists := m.ID()
  1302. if exists {
  1303. return []string{id}, nil
  1304. }
  1305. fallthrough
  1306. case m.op.Is(OpUpdate | OpDelete):
  1307. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1308. default:
  1309. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1310. }
  1311. }
  1312. // SetQ sets the "q" field.
  1313. func (m *AgentBaseMutation) SetQ(s string) {
  1314. m.q = &s
  1315. }
  1316. // Q returns the value of the "q" field in the mutation.
  1317. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1318. v := m.q
  1319. if v == nil {
  1320. return
  1321. }
  1322. return *v, true
  1323. }
  1324. // OldQ returns the old "q" field's value of the AgentBase entity.
  1325. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1327. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1328. if !m.op.Is(OpUpdateOne) {
  1329. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1330. }
  1331. if m.id == nil || m.oldValue == nil {
  1332. return v, errors.New("OldQ requires an ID field in the mutation")
  1333. }
  1334. oldValue, err := m.oldValue(ctx)
  1335. if err != nil {
  1336. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1337. }
  1338. return oldValue.Q, nil
  1339. }
  1340. // ClearQ clears the value of the "q" field.
  1341. func (m *AgentBaseMutation) ClearQ() {
  1342. m.q = nil
  1343. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1344. }
  1345. // QCleared returns if the "q" field was cleared in this mutation.
  1346. func (m *AgentBaseMutation) QCleared() bool {
  1347. _, ok := m.clearedFields[agentbase.FieldQ]
  1348. return ok
  1349. }
  1350. // ResetQ resets all changes to the "q" field.
  1351. func (m *AgentBaseMutation) ResetQ() {
  1352. m.q = nil
  1353. delete(m.clearedFields, agentbase.FieldQ)
  1354. }
  1355. // SetA sets the "a" field.
  1356. func (m *AgentBaseMutation) SetA(s string) {
  1357. m.a = &s
  1358. }
  1359. // A returns the value of the "a" field in the mutation.
  1360. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1361. v := m.a
  1362. if v == nil {
  1363. return
  1364. }
  1365. return *v, true
  1366. }
  1367. // OldA returns the old "a" field's value of the AgentBase entity.
  1368. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1370. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1371. if !m.op.Is(OpUpdateOne) {
  1372. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1373. }
  1374. if m.id == nil || m.oldValue == nil {
  1375. return v, errors.New("OldA requires an ID field in the mutation")
  1376. }
  1377. oldValue, err := m.oldValue(ctx)
  1378. if err != nil {
  1379. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1380. }
  1381. return oldValue.A, nil
  1382. }
  1383. // ClearA clears the value of the "a" field.
  1384. func (m *AgentBaseMutation) ClearA() {
  1385. m.a = nil
  1386. m.clearedFields[agentbase.FieldA] = struct{}{}
  1387. }
  1388. // ACleared returns if the "a" field was cleared in this mutation.
  1389. func (m *AgentBaseMutation) ACleared() bool {
  1390. _, ok := m.clearedFields[agentbase.FieldA]
  1391. return ok
  1392. }
  1393. // ResetA resets all changes to the "a" field.
  1394. func (m *AgentBaseMutation) ResetA() {
  1395. m.a = nil
  1396. delete(m.clearedFields, agentbase.FieldA)
  1397. }
  1398. // SetChunkIndex sets the "chunk_index" field.
  1399. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1400. m.chunk_index = &u
  1401. m.addchunk_index = nil
  1402. }
  1403. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1404. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1405. v := m.chunk_index
  1406. if v == nil {
  1407. return
  1408. }
  1409. return *v, true
  1410. }
  1411. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1412. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1414. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1415. if !m.op.Is(OpUpdateOne) {
  1416. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1417. }
  1418. if m.id == nil || m.oldValue == nil {
  1419. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1420. }
  1421. oldValue, err := m.oldValue(ctx)
  1422. if err != nil {
  1423. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1424. }
  1425. return oldValue.ChunkIndex, nil
  1426. }
  1427. // AddChunkIndex adds u to the "chunk_index" field.
  1428. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1429. if m.addchunk_index != nil {
  1430. *m.addchunk_index += u
  1431. } else {
  1432. m.addchunk_index = &u
  1433. }
  1434. }
  1435. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1436. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1437. v := m.addchunk_index
  1438. if v == nil {
  1439. return
  1440. }
  1441. return *v, true
  1442. }
  1443. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1444. func (m *AgentBaseMutation) ResetChunkIndex() {
  1445. m.chunk_index = nil
  1446. m.addchunk_index = nil
  1447. }
  1448. // SetIndexes sets the "indexes" field.
  1449. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1450. m.indexes = &s
  1451. m.appendindexes = nil
  1452. }
  1453. // Indexes returns the value of the "indexes" field in the mutation.
  1454. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1455. v := m.indexes
  1456. if v == nil {
  1457. return
  1458. }
  1459. return *v, true
  1460. }
  1461. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1462. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1464. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1465. if !m.op.Is(OpUpdateOne) {
  1466. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1467. }
  1468. if m.id == nil || m.oldValue == nil {
  1469. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1470. }
  1471. oldValue, err := m.oldValue(ctx)
  1472. if err != nil {
  1473. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1474. }
  1475. return oldValue.Indexes, nil
  1476. }
  1477. // AppendIndexes adds s to the "indexes" field.
  1478. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1479. m.appendindexes = append(m.appendindexes, s...)
  1480. }
  1481. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1482. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1483. if len(m.appendindexes) == 0 {
  1484. return nil, false
  1485. }
  1486. return m.appendindexes, true
  1487. }
  1488. // ClearIndexes clears the value of the "indexes" field.
  1489. func (m *AgentBaseMutation) ClearIndexes() {
  1490. m.indexes = nil
  1491. m.appendindexes = nil
  1492. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1493. }
  1494. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1495. func (m *AgentBaseMutation) IndexesCleared() bool {
  1496. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1497. return ok
  1498. }
  1499. // ResetIndexes resets all changes to the "indexes" field.
  1500. func (m *AgentBaseMutation) ResetIndexes() {
  1501. m.indexes = nil
  1502. m.appendindexes = nil
  1503. delete(m.clearedFields, agentbase.FieldIndexes)
  1504. }
  1505. // SetDatasetID sets the "dataset_id" field.
  1506. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1507. m.dataset_id = &s
  1508. }
  1509. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1510. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1511. v := m.dataset_id
  1512. if v == nil {
  1513. return
  1514. }
  1515. return *v, true
  1516. }
  1517. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1518. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1520. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1521. if !m.op.Is(OpUpdateOne) {
  1522. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1523. }
  1524. if m.id == nil || m.oldValue == nil {
  1525. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1526. }
  1527. oldValue, err := m.oldValue(ctx)
  1528. if err != nil {
  1529. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1530. }
  1531. return oldValue.DatasetID, nil
  1532. }
  1533. // ClearDatasetID clears the value of the "dataset_id" field.
  1534. func (m *AgentBaseMutation) ClearDatasetID() {
  1535. m.dataset_id = nil
  1536. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1537. }
  1538. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1539. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1540. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1541. return ok
  1542. }
  1543. // ResetDatasetID resets all changes to the "dataset_id" field.
  1544. func (m *AgentBaseMutation) ResetDatasetID() {
  1545. m.dataset_id = nil
  1546. delete(m.clearedFields, agentbase.FieldDatasetID)
  1547. }
  1548. // SetCollectionID sets the "collection_id" field.
  1549. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1550. m.collection_id = &s
  1551. }
  1552. // CollectionID returns the value of the "collection_id" field in the mutation.
  1553. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1554. v := m.collection_id
  1555. if v == nil {
  1556. return
  1557. }
  1558. return *v, true
  1559. }
  1560. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1561. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1563. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1564. if !m.op.Is(OpUpdateOne) {
  1565. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1566. }
  1567. if m.id == nil || m.oldValue == nil {
  1568. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1569. }
  1570. oldValue, err := m.oldValue(ctx)
  1571. if err != nil {
  1572. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1573. }
  1574. return oldValue.CollectionID, nil
  1575. }
  1576. // ClearCollectionID clears the value of the "collection_id" field.
  1577. func (m *AgentBaseMutation) ClearCollectionID() {
  1578. m.collection_id = nil
  1579. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1580. }
  1581. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1582. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1583. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1584. return ok
  1585. }
  1586. // ResetCollectionID resets all changes to the "collection_id" field.
  1587. func (m *AgentBaseMutation) ResetCollectionID() {
  1588. m.collection_id = nil
  1589. delete(m.clearedFields, agentbase.FieldCollectionID)
  1590. }
  1591. // SetSourceName sets the "source_name" field.
  1592. func (m *AgentBaseMutation) SetSourceName(s string) {
  1593. m.source_name = &s
  1594. }
  1595. // SourceName returns the value of the "source_name" field in the mutation.
  1596. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1597. v := m.source_name
  1598. if v == nil {
  1599. return
  1600. }
  1601. return *v, true
  1602. }
  1603. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1604. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1606. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1607. if !m.op.Is(OpUpdateOne) {
  1608. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1609. }
  1610. if m.id == nil || m.oldValue == nil {
  1611. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1612. }
  1613. oldValue, err := m.oldValue(ctx)
  1614. if err != nil {
  1615. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1616. }
  1617. return oldValue.SourceName, nil
  1618. }
  1619. // ClearSourceName clears the value of the "source_name" field.
  1620. func (m *AgentBaseMutation) ClearSourceName() {
  1621. m.source_name = nil
  1622. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1623. }
  1624. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1625. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1626. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1627. return ok
  1628. }
  1629. // ResetSourceName resets all changes to the "source_name" field.
  1630. func (m *AgentBaseMutation) ResetSourceName() {
  1631. m.source_name = nil
  1632. delete(m.clearedFields, agentbase.FieldSourceName)
  1633. }
  1634. // SetCanWrite sets the "can_write" field.
  1635. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1636. m.can_write = &b
  1637. m.appendcan_write = nil
  1638. }
  1639. // CanWrite returns the value of the "can_write" field in the mutation.
  1640. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1641. v := m.can_write
  1642. if v == nil {
  1643. return
  1644. }
  1645. return *v, true
  1646. }
  1647. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1648. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1650. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1651. if !m.op.Is(OpUpdateOne) {
  1652. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1653. }
  1654. if m.id == nil || m.oldValue == nil {
  1655. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1656. }
  1657. oldValue, err := m.oldValue(ctx)
  1658. if err != nil {
  1659. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1660. }
  1661. return oldValue.CanWrite, nil
  1662. }
  1663. // AppendCanWrite adds b to the "can_write" field.
  1664. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1665. m.appendcan_write = append(m.appendcan_write, b...)
  1666. }
  1667. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1668. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1669. if len(m.appendcan_write) == 0 {
  1670. return nil, false
  1671. }
  1672. return m.appendcan_write, true
  1673. }
  1674. // ClearCanWrite clears the value of the "can_write" field.
  1675. func (m *AgentBaseMutation) ClearCanWrite() {
  1676. m.can_write = nil
  1677. m.appendcan_write = nil
  1678. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1679. }
  1680. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1681. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1682. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1683. return ok
  1684. }
  1685. // ResetCanWrite resets all changes to the "can_write" field.
  1686. func (m *AgentBaseMutation) ResetCanWrite() {
  1687. m.can_write = nil
  1688. m.appendcan_write = nil
  1689. delete(m.clearedFields, agentbase.FieldCanWrite)
  1690. }
  1691. // SetIsOwner sets the "is_owner" field.
  1692. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1693. m.is_owner = &b
  1694. m.appendis_owner = nil
  1695. }
  1696. // IsOwner returns the value of the "is_owner" field in the mutation.
  1697. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1698. v := m.is_owner
  1699. if v == nil {
  1700. return
  1701. }
  1702. return *v, true
  1703. }
  1704. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1705. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1706. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1707. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1708. if !m.op.Is(OpUpdateOne) {
  1709. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1710. }
  1711. if m.id == nil || m.oldValue == nil {
  1712. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1713. }
  1714. oldValue, err := m.oldValue(ctx)
  1715. if err != nil {
  1716. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1717. }
  1718. return oldValue.IsOwner, nil
  1719. }
  1720. // AppendIsOwner adds b to the "is_owner" field.
  1721. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1722. m.appendis_owner = append(m.appendis_owner, b...)
  1723. }
  1724. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1725. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1726. if len(m.appendis_owner) == 0 {
  1727. return nil, false
  1728. }
  1729. return m.appendis_owner, true
  1730. }
  1731. // ClearIsOwner clears the value of the "is_owner" field.
  1732. func (m *AgentBaseMutation) ClearIsOwner() {
  1733. m.is_owner = nil
  1734. m.appendis_owner = nil
  1735. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1736. }
  1737. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1738. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1739. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1740. return ok
  1741. }
  1742. // ResetIsOwner resets all changes to the "is_owner" field.
  1743. func (m *AgentBaseMutation) ResetIsOwner() {
  1744. m.is_owner = nil
  1745. m.appendis_owner = nil
  1746. delete(m.clearedFields, agentbase.FieldIsOwner)
  1747. }
  1748. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1749. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1750. if m.wx_agent == nil {
  1751. m.wx_agent = make(map[uint64]struct{})
  1752. }
  1753. for i := range ids {
  1754. m.wx_agent[ids[i]] = struct{}{}
  1755. }
  1756. }
  1757. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1758. func (m *AgentBaseMutation) ClearWxAgent() {
  1759. m.clearedwx_agent = true
  1760. }
  1761. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1762. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1763. return m.clearedwx_agent
  1764. }
  1765. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1766. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1767. if m.removedwx_agent == nil {
  1768. m.removedwx_agent = make(map[uint64]struct{})
  1769. }
  1770. for i := range ids {
  1771. delete(m.wx_agent, ids[i])
  1772. m.removedwx_agent[ids[i]] = struct{}{}
  1773. }
  1774. }
  1775. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1776. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1777. for id := range m.removedwx_agent {
  1778. ids = append(ids, id)
  1779. }
  1780. return
  1781. }
  1782. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1783. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1784. for id := range m.wx_agent {
  1785. ids = append(ids, id)
  1786. }
  1787. return
  1788. }
  1789. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1790. func (m *AgentBaseMutation) ResetWxAgent() {
  1791. m.wx_agent = nil
  1792. m.clearedwx_agent = false
  1793. m.removedwx_agent = nil
  1794. }
  1795. // Where appends a list predicates to the AgentBaseMutation builder.
  1796. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1797. m.predicates = append(m.predicates, ps...)
  1798. }
  1799. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1800. // users can use type-assertion to append predicates that do not depend on any generated package.
  1801. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1802. p := make([]predicate.AgentBase, len(ps))
  1803. for i := range ps {
  1804. p[i] = ps[i]
  1805. }
  1806. m.Where(p...)
  1807. }
  1808. // Op returns the operation name.
  1809. func (m *AgentBaseMutation) Op() Op {
  1810. return m.op
  1811. }
  1812. // SetOp allows setting the mutation operation.
  1813. func (m *AgentBaseMutation) SetOp(op Op) {
  1814. m.op = op
  1815. }
  1816. // Type returns the node type of this mutation (AgentBase).
  1817. func (m *AgentBaseMutation) Type() string {
  1818. return m.typ
  1819. }
  1820. // Fields returns all fields that were changed during this mutation. Note that in
  1821. // order to get all numeric fields that were incremented/decremented, call
  1822. // AddedFields().
  1823. func (m *AgentBaseMutation) Fields() []string {
  1824. fields := make([]string, 0, 9)
  1825. if m.q != nil {
  1826. fields = append(fields, agentbase.FieldQ)
  1827. }
  1828. if m.a != nil {
  1829. fields = append(fields, agentbase.FieldA)
  1830. }
  1831. if m.chunk_index != nil {
  1832. fields = append(fields, agentbase.FieldChunkIndex)
  1833. }
  1834. if m.indexes != nil {
  1835. fields = append(fields, agentbase.FieldIndexes)
  1836. }
  1837. if m.dataset_id != nil {
  1838. fields = append(fields, agentbase.FieldDatasetID)
  1839. }
  1840. if m.collection_id != nil {
  1841. fields = append(fields, agentbase.FieldCollectionID)
  1842. }
  1843. if m.source_name != nil {
  1844. fields = append(fields, agentbase.FieldSourceName)
  1845. }
  1846. if m.can_write != nil {
  1847. fields = append(fields, agentbase.FieldCanWrite)
  1848. }
  1849. if m.is_owner != nil {
  1850. fields = append(fields, agentbase.FieldIsOwner)
  1851. }
  1852. return fields
  1853. }
  1854. // Field returns the value of a field with the given name. The second boolean
  1855. // return value indicates that this field was not set, or was not defined in the
  1856. // schema.
  1857. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1858. switch name {
  1859. case agentbase.FieldQ:
  1860. return m.Q()
  1861. case agentbase.FieldA:
  1862. return m.A()
  1863. case agentbase.FieldChunkIndex:
  1864. return m.ChunkIndex()
  1865. case agentbase.FieldIndexes:
  1866. return m.Indexes()
  1867. case agentbase.FieldDatasetID:
  1868. return m.DatasetID()
  1869. case agentbase.FieldCollectionID:
  1870. return m.CollectionID()
  1871. case agentbase.FieldSourceName:
  1872. return m.SourceName()
  1873. case agentbase.FieldCanWrite:
  1874. return m.CanWrite()
  1875. case agentbase.FieldIsOwner:
  1876. return m.IsOwner()
  1877. }
  1878. return nil, false
  1879. }
  1880. // OldField returns the old value of the field from the database. An error is
  1881. // returned if the mutation operation is not UpdateOne, or the query to the
  1882. // database failed.
  1883. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1884. switch name {
  1885. case agentbase.FieldQ:
  1886. return m.OldQ(ctx)
  1887. case agentbase.FieldA:
  1888. return m.OldA(ctx)
  1889. case agentbase.FieldChunkIndex:
  1890. return m.OldChunkIndex(ctx)
  1891. case agentbase.FieldIndexes:
  1892. return m.OldIndexes(ctx)
  1893. case agentbase.FieldDatasetID:
  1894. return m.OldDatasetID(ctx)
  1895. case agentbase.FieldCollectionID:
  1896. return m.OldCollectionID(ctx)
  1897. case agentbase.FieldSourceName:
  1898. return m.OldSourceName(ctx)
  1899. case agentbase.FieldCanWrite:
  1900. return m.OldCanWrite(ctx)
  1901. case agentbase.FieldIsOwner:
  1902. return m.OldIsOwner(ctx)
  1903. }
  1904. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1905. }
  1906. // SetField sets the value of a field with the given name. It returns an error if
  1907. // the field is not defined in the schema, or if the type mismatched the field
  1908. // type.
  1909. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1910. switch name {
  1911. case agentbase.FieldQ:
  1912. v, ok := value.(string)
  1913. if !ok {
  1914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1915. }
  1916. m.SetQ(v)
  1917. return nil
  1918. case agentbase.FieldA:
  1919. v, ok := value.(string)
  1920. if !ok {
  1921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1922. }
  1923. m.SetA(v)
  1924. return nil
  1925. case agentbase.FieldChunkIndex:
  1926. v, ok := value.(uint64)
  1927. if !ok {
  1928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1929. }
  1930. m.SetChunkIndex(v)
  1931. return nil
  1932. case agentbase.FieldIndexes:
  1933. v, ok := value.([]string)
  1934. if !ok {
  1935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1936. }
  1937. m.SetIndexes(v)
  1938. return nil
  1939. case agentbase.FieldDatasetID:
  1940. v, ok := value.(string)
  1941. if !ok {
  1942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1943. }
  1944. m.SetDatasetID(v)
  1945. return nil
  1946. case agentbase.FieldCollectionID:
  1947. v, ok := value.(string)
  1948. if !ok {
  1949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1950. }
  1951. m.SetCollectionID(v)
  1952. return nil
  1953. case agentbase.FieldSourceName:
  1954. v, ok := value.(string)
  1955. if !ok {
  1956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1957. }
  1958. m.SetSourceName(v)
  1959. return nil
  1960. case agentbase.FieldCanWrite:
  1961. v, ok := value.([]bool)
  1962. if !ok {
  1963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1964. }
  1965. m.SetCanWrite(v)
  1966. return nil
  1967. case agentbase.FieldIsOwner:
  1968. v, ok := value.([]bool)
  1969. if !ok {
  1970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1971. }
  1972. m.SetIsOwner(v)
  1973. return nil
  1974. }
  1975. return fmt.Errorf("unknown AgentBase field %s", name)
  1976. }
  1977. // AddedFields returns all numeric fields that were incremented/decremented during
  1978. // this mutation.
  1979. func (m *AgentBaseMutation) AddedFields() []string {
  1980. var fields []string
  1981. if m.addchunk_index != nil {
  1982. fields = append(fields, agentbase.FieldChunkIndex)
  1983. }
  1984. return fields
  1985. }
  1986. // AddedField returns the numeric value that was incremented/decremented on a field
  1987. // with the given name. The second boolean return value indicates that this field
  1988. // was not set, or was not defined in the schema.
  1989. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  1990. switch name {
  1991. case agentbase.FieldChunkIndex:
  1992. return m.AddedChunkIndex()
  1993. }
  1994. return nil, false
  1995. }
  1996. // AddField adds the value to the field with the given name. It returns an error if
  1997. // the field is not defined in the schema, or if the type mismatched the field
  1998. // type.
  1999. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2000. switch name {
  2001. case agentbase.FieldChunkIndex:
  2002. v, ok := value.(int64)
  2003. if !ok {
  2004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2005. }
  2006. m.AddChunkIndex(v)
  2007. return nil
  2008. }
  2009. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2010. }
  2011. // ClearedFields returns all nullable fields that were cleared during this
  2012. // mutation.
  2013. func (m *AgentBaseMutation) ClearedFields() []string {
  2014. var fields []string
  2015. if m.FieldCleared(agentbase.FieldQ) {
  2016. fields = append(fields, agentbase.FieldQ)
  2017. }
  2018. if m.FieldCleared(agentbase.FieldA) {
  2019. fields = append(fields, agentbase.FieldA)
  2020. }
  2021. if m.FieldCleared(agentbase.FieldIndexes) {
  2022. fields = append(fields, agentbase.FieldIndexes)
  2023. }
  2024. if m.FieldCleared(agentbase.FieldDatasetID) {
  2025. fields = append(fields, agentbase.FieldDatasetID)
  2026. }
  2027. if m.FieldCleared(agentbase.FieldCollectionID) {
  2028. fields = append(fields, agentbase.FieldCollectionID)
  2029. }
  2030. if m.FieldCleared(agentbase.FieldSourceName) {
  2031. fields = append(fields, agentbase.FieldSourceName)
  2032. }
  2033. if m.FieldCleared(agentbase.FieldCanWrite) {
  2034. fields = append(fields, agentbase.FieldCanWrite)
  2035. }
  2036. if m.FieldCleared(agentbase.FieldIsOwner) {
  2037. fields = append(fields, agentbase.FieldIsOwner)
  2038. }
  2039. return fields
  2040. }
  2041. // FieldCleared returns a boolean indicating if a field with the given name was
  2042. // cleared in this mutation.
  2043. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2044. _, ok := m.clearedFields[name]
  2045. return ok
  2046. }
  2047. // ClearField clears the value of the field with the given name. It returns an
  2048. // error if the field is not defined in the schema.
  2049. func (m *AgentBaseMutation) ClearField(name string) error {
  2050. switch name {
  2051. case agentbase.FieldQ:
  2052. m.ClearQ()
  2053. return nil
  2054. case agentbase.FieldA:
  2055. m.ClearA()
  2056. return nil
  2057. case agentbase.FieldIndexes:
  2058. m.ClearIndexes()
  2059. return nil
  2060. case agentbase.FieldDatasetID:
  2061. m.ClearDatasetID()
  2062. return nil
  2063. case agentbase.FieldCollectionID:
  2064. m.ClearCollectionID()
  2065. return nil
  2066. case agentbase.FieldSourceName:
  2067. m.ClearSourceName()
  2068. return nil
  2069. case agentbase.FieldCanWrite:
  2070. m.ClearCanWrite()
  2071. return nil
  2072. case agentbase.FieldIsOwner:
  2073. m.ClearIsOwner()
  2074. return nil
  2075. }
  2076. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2077. }
  2078. // ResetField resets all changes in the mutation for the field with the given name.
  2079. // It returns an error if the field is not defined in the schema.
  2080. func (m *AgentBaseMutation) ResetField(name string) error {
  2081. switch name {
  2082. case agentbase.FieldQ:
  2083. m.ResetQ()
  2084. return nil
  2085. case agentbase.FieldA:
  2086. m.ResetA()
  2087. return nil
  2088. case agentbase.FieldChunkIndex:
  2089. m.ResetChunkIndex()
  2090. return nil
  2091. case agentbase.FieldIndexes:
  2092. m.ResetIndexes()
  2093. return nil
  2094. case agentbase.FieldDatasetID:
  2095. m.ResetDatasetID()
  2096. return nil
  2097. case agentbase.FieldCollectionID:
  2098. m.ResetCollectionID()
  2099. return nil
  2100. case agentbase.FieldSourceName:
  2101. m.ResetSourceName()
  2102. return nil
  2103. case agentbase.FieldCanWrite:
  2104. m.ResetCanWrite()
  2105. return nil
  2106. case agentbase.FieldIsOwner:
  2107. m.ResetIsOwner()
  2108. return nil
  2109. }
  2110. return fmt.Errorf("unknown AgentBase field %s", name)
  2111. }
  2112. // AddedEdges returns all edge names that were set/added in this mutation.
  2113. func (m *AgentBaseMutation) AddedEdges() []string {
  2114. edges := make([]string, 0, 1)
  2115. if m.wx_agent != nil {
  2116. edges = append(edges, agentbase.EdgeWxAgent)
  2117. }
  2118. return edges
  2119. }
  2120. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2121. // name in this mutation.
  2122. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2123. switch name {
  2124. case agentbase.EdgeWxAgent:
  2125. ids := make([]ent.Value, 0, len(m.wx_agent))
  2126. for id := range m.wx_agent {
  2127. ids = append(ids, id)
  2128. }
  2129. return ids
  2130. }
  2131. return nil
  2132. }
  2133. // RemovedEdges returns all edge names that were removed in this mutation.
  2134. func (m *AgentBaseMutation) RemovedEdges() []string {
  2135. edges := make([]string, 0, 1)
  2136. if m.removedwx_agent != nil {
  2137. edges = append(edges, agentbase.EdgeWxAgent)
  2138. }
  2139. return edges
  2140. }
  2141. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2142. // the given name in this mutation.
  2143. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2144. switch name {
  2145. case agentbase.EdgeWxAgent:
  2146. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2147. for id := range m.removedwx_agent {
  2148. ids = append(ids, id)
  2149. }
  2150. return ids
  2151. }
  2152. return nil
  2153. }
  2154. // ClearedEdges returns all edge names that were cleared in this mutation.
  2155. func (m *AgentBaseMutation) ClearedEdges() []string {
  2156. edges := make([]string, 0, 1)
  2157. if m.clearedwx_agent {
  2158. edges = append(edges, agentbase.EdgeWxAgent)
  2159. }
  2160. return edges
  2161. }
  2162. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2163. // was cleared in this mutation.
  2164. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2165. switch name {
  2166. case agentbase.EdgeWxAgent:
  2167. return m.clearedwx_agent
  2168. }
  2169. return false
  2170. }
  2171. // ClearEdge clears the value of the edge with the given name. It returns an error
  2172. // if that edge is not defined in the schema.
  2173. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2174. switch name {
  2175. }
  2176. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2177. }
  2178. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2179. // It returns an error if the edge is not defined in the schema.
  2180. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2181. switch name {
  2182. case agentbase.EdgeWxAgent:
  2183. m.ResetWxAgent()
  2184. return nil
  2185. }
  2186. return fmt.Errorf("unknown AgentBase edge %s", name)
  2187. }
  2188. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2189. type AliyunAvatarMutation struct {
  2190. config
  2191. op Op
  2192. typ string
  2193. id *uint64
  2194. created_at *time.Time
  2195. updated_at *time.Time
  2196. deleted_at *time.Time
  2197. user_id *uint64
  2198. adduser_id *int64
  2199. biz_id *string
  2200. access_key_id *string
  2201. access_key_secret *string
  2202. app_id *string
  2203. tenant_id *uint64
  2204. addtenant_id *int64
  2205. response *string
  2206. token *string
  2207. session_id *string
  2208. clearedFields map[string]struct{}
  2209. done bool
  2210. oldValue func(context.Context) (*AliyunAvatar, error)
  2211. predicates []predicate.AliyunAvatar
  2212. }
  2213. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2214. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2215. type aliyunavatarOption func(*AliyunAvatarMutation)
  2216. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2217. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2218. m := &AliyunAvatarMutation{
  2219. config: c,
  2220. op: op,
  2221. typ: TypeAliyunAvatar,
  2222. clearedFields: make(map[string]struct{}),
  2223. }
  2224. for _, opt := range opts {
  2225. opt(m)
  2226. }
  2227. return m
  2228. }
  2229. // withAliyunAvatarID sets the ID field of the mutation.
  2230. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2231. return func(m *AliyunAvatarMutation) {
  2232. var (
  2233. err error
  2234. once sync.Once
  2235. value *AliyunAvatar
  2236. )
  2237. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2238. once.Do(func() {
  2239. if m.done {
  2240. err = errors.New("querying old values post mutation is not allowed")
  2241. } else {
  2242. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2243. }
  2244. })
  2245. return value, err
  2246. }
  2247. m.id = &id
  2248. }
  2249. }
  2250. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2251. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2252. return func(m *AliyunAvatarMutation) {
  2253. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2254. return node, nil
  2255. }
  2256. m.id = &node.ID
  2257. }
  2258. }
  2259. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2260. // executed in a transaction (ent.Tx), a transactional client is returned.
  2261. func (m AliyunAvatarMutation) Client() *Client {
  2262. client := &Client{config: m.config}
  2263. client.init()
  2264. return client
  2265. }
  2266. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2267. // it returns an error otherwise.
  2268. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2269. if _, ok := m.driver.(*txDriver); !ok {
  2270. return nil, errors.New("ent: mutation is not running in a transaction")
  2271. }
  2272. tx := &Tx{config: m.config}
  2273. tx.init()
  2274. return tx, nil
  2275. }
  2276. // SetID sets the value of the id field. Note that this
  2277. // operation is only accepted on creation of AliyunAvatar entities.
  2278. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2279. m.id = &id
  2280. }
  2281. // ID returns the ID value in the mutation. Note that the ID is only available
  2282. // if it was provided to the builder or after it was returned from the database.
  2283. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2284. if m.id == nil {
  2285. return
  2286. }
  2287. return *m.id, true
  2288. }
  2289. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2290. // That means, if the mutation is applied within a transaction with an isolation level such
  2291. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2292. // or updated by the mutation.
  2293. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2294. switch {
  2295. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2296. id, exists := m.ID()
  2297. if exists {
  2298. return []uint64{id}, nil
  2299. }
  2300. fallthrough
  2301. case m.op.Is(OpUpdate | OpDelete):
  2302. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2303. default:
  2304. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2305. }
  2306. }
  2307. // SetCreatedAt sets the "created_at" field.
  2308. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2309. m.created_at = &t
  2310. }
  2311. // CreatedAt returns the value of the "created_at" field in the mutation.
  2312. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2313. v := m.created_at
  2314. if v == nil {
  2315. return
  2316. }
  2317. return *v, true
  2318. }
  2319. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2320. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2322. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2323. if !m.op.Is(OpUpdateOne) {
  2324. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2325. }
  2326. if m.id == nil || m.oldValue == nil {
  2327. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2328. }
  2329. oldValue, err := m.oldValue(ctx)
  2330. if err != nil {
  2331. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2332. }
  2333. return oldValue.CreatedAt, nil
  2334. }
  2335. // ResetCreatedAt resets all changes to the "created_at" field.
  2336. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2337. m.created_at = nil
  2338. }
  2339. // SetUpdatedAt sets the "updated_at" field.
  2340. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2341. m.updated_at = &t
  2342. }
  2343. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2344. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2345. v := m.updated_at
  2346. if v == nil {
  2347. return
  2348. }
  2349. return *v, true
  2350. }
  2351. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2352. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2354. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2355. if !m.op.Is(OpUpdateOne) {
  2356. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2357. }
  2358. if m.id == nil || m.oldValue == nil {
  2359. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2360. }
  2361. oldValue, err := m.oldValue(ctx)
  2362. if err != nil {
  2363. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2364. }
  2365. return oldValue.UpdatedAt, nil
  2366. }
  2367. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2368. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2369. m.updated_at = nil
  2370. }
  2371. // SetDeletedAt sets the "deleted_at" field.
  2372. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2373. m.deleted_at = &t
  2374. }
  2375. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2376. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2377. v := m.deleted_at
  2378. if v == nil {
  2379. return
  2380. }
  2381. return *v, true
  2382. }
  2383. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2384. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2386. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2387. if !m.op.Is(OpUpdateOne) {
  2388. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2389. }
  2390. if m.id == nil || m.oldValue == nil {
  2391. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2392. }
  2393. oldValue, err := m.oldValue(ctx)
  2394. if err != nil {
  2395. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2396. }
  2397. return oldValue.DeletedAt, nil
  2398. }
  2399. // ClearDeletedAt clears the value of the "deleted_at" field.
  2400. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2401. m.deleted_at = nil
  2402. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2403. }
  2404. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2405. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2406. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2407. return ok
  2408. }
  2409. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2410. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2411. m.deleted_at = nil
  2412. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2413. }
  2414. // SetUserID sets the "user_id" field.
  2415. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2416. m.user_id = &u
  2417. m.adduser_id = nil
  2418. }
  2419. // UserID returns the value of the "user_id" field in the mutation.
  2420. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2421. v := m.user_id
  2422. if v == nil {
  2423. return
  2424. }
  2425. return *v, true
  2426. }
  2427. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2428. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2430. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2431. if !m.op.Is(OpUpdateOne) {
  2432. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2433. }
  2434. if m.id == nil || m.oldValue == nil {
  2435. return v, errors.New("OldUserID requires an ID field in the mutation")
  2436. }
  2437. oldValue, err := m.oldValue(ctx)
  2438. if err != nil {
  2439. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2440. }
  2441. return oldValue.UserID, nil
  2442. }
  2443. // AddUserID adds u to the "user_id" field.
  2444. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2445. if m.adduser_id != nil {
  2446. *m.adduser_id += u
  2447. } else {
  2448. m.adduser_id = &u
  2449. }
  2450. }
  2451. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2452. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2453. v := m.adduser_id
  2454. if v == nil {
  2455. return
  2456. }
  2457. return *v, true
  2458. }
  2459. // ResetUserID resets all changes to the "user_id" field.
  2460. func (m *AliyunAvatarMutation) ResetUserID() {
  2461. m.user_id = nil
  2462. m.adduser_id = nil
  2463. }
  2464. // SetBizID sets the "biz_id" field.
  2465. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2466. m.biz_id = &s
  2467. }
  2468. // BizID returns the value of the "biz_id" field in the mutation.
  2469. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2470. v := m.biz_id
  2471. if v == nil {
  2472. return
  2473. }
  2474. return *v, true
  2475. }
  2476. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2477. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2479. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2480. if !m.op.Is(OpUpdateOne) {
  2481. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2482. }
  2483. if m.id == nil || m.oldValue == nil {
  2484. return v, errors.New("OldBizID requires an ID field in the mutation")
  2485. }
  2486. oldValue, err := m.oldValue(ctx)
  2487. if err != nil {
  2488. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2489. }
  2490. return oldValue.BizID, nil
  2491. }
  2492. // ResetBizID resets all changes to the "biz_id" field.
  2493. func (m *AliyunAvatarMutation) ResetBizID() {
  2494. m.biz_id = nil
  2495. }
  2496. // SetAccessKeyID sets the "access_key_id" field.
  2497. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2498. m.access_key_id = &s
  2499. }
  2500. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2501. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2502. v := m.access_key_id
  2503. if v == nil {
  2504. return
  2505. }
  2506. return *v, true
  2507. }
  2508. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2509. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2510. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2511. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2512. if !m.op.Is(OpUpdateOne) {
  2513. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2514. }
  2515. if m.id == nil || m.oldValue == nil {
  2516. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2517. }
  2518. oldValue, err := m.oldValue(ctx)
  2519. if err != nil {
  2520. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2521. }
  2522. return oldValue.AccessKeyID, nil
  2523. }
  2524. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2525. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2526. m.access_key_id = nil
  2527. }
  2528. // SetAccessKeySecret sets the "access_key_secret" field.
  2529. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2530. m.access_key_secret = &s
  2531. }
  2532. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2533. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2534. v := m.access_key_secret
  2535. if v == nil {
  2536. return
  2537. }
  2538. return *v, true
  2539. }
  2540. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2541. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2543. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2544. if !m.op.Is(OpUpdateOne) {
  2545. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2546. }
  2547. if m.id == nil || m.oldValue == nil {
  2548. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2549. }
  2550. oldValue, err := m.oldValue(ctx)
  2551. if err != nil {
  2552. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2553. }
  2554. return oldValue.AccessKeySecret, nil
  2555. }
  2556. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2557. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2558. m.access_key_secret = nil
  2559. }
  2560. // SetAppID sets the "app_id" field.
  2561. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2562. m.app_id = &s
  2563. }
  2564. // AppID returns the value of the "app_id" field in the mutation.
  2565. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2566. v := m.app_id
  2567. if v == nil {
  2568. return
  2569. }
  2570. return *v, true
  2571. }
  2572. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2573. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2574. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2575. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2576. if !m.op.Is(OpUpdateOne) {
  2577. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2578. }
  2579. if m.id == nil || m.oldValue == nil {
  2580. return v, errors.New("OldAppID requires an ID field in the mutation")
  2581. }
  2582. oldValue, err := m.oldValue(ctx)
  2583. if err != nil {
  2584. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2585. }
  2586. return oldValue.AppID, nil
  2587. }
  2588. // ClearAppID clears the value of the "app_id" field.
  2589. func (m *AliyunAvatarMutation) ClearAppID() {
  2590. m.app_id = nil
  2591. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2592. }
  2593. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2594. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2595. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2596. return ok
  2597. }
  2598. // ResetAppID resets all changes to the "app_id" field.
  2599. func (m *AliyunAvatarMutation) ResetAppID() {
  2600. m.app_id = nil
  2601. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2602. }
  2603. // SetTenantID sets the "tenant_id" field.
  2604. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2605. m.tenant_id = &u
  2606. m.addtenant_id = nil
  2607. }
  2608. // TenantID returns the value of the "tenant_id" field in the mutation.
  2609. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2610. v := m.tenant_id
  2611. if v == nil {
  2612. return
  2613. }
  2614. return *v, true
  2615. }
  2616. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2617. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2619. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2620. if !m.op.Is(OpUpdateOne) {
  2621. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2622. }
  2623. if m.id == nil || m.oldValue == nil {
  2624. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2625. }
  2626. oldValue, err := m.oldValue(ctx)
  2627. if err != nil {
  2628. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2629. }
  2630. return oldValue.TenantID, nil
  2631. }
  2632. // AddTenantID adds u to the "tenant_id" field.
  2633. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2634. if m.addtenant_id != nil {
  2635. *m.addtenant_id += u
  2636. } else {
  2637. m.addtenant_id = &u
  2638. }
  2639. }
  2640. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2641. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2642. v := m.addtenant_id
  2643. if v == nil {
  2644. return
  2645. }
  2646. return *v, true
  2647. }
  2648. // ResetTenantID resets all changes to the "tenant_id" field.
  2649. func (m *AliyunAvatarMutation) ResetTenantID() {
  2650. m.tenant_id = nil
  2651. m.addtenant_id = nil
  2652. }
  2653. // SetResponse sets the "response" field.
  2654. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2655. m.response = &s
  2656. }
  2657. // Response returns the value of the "response" field in the mutation.
  2658. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2659. v := m.response
  2660. if v == nil {
  2661. return
  2662. }
  2663. return *v, true
  2664. }
  2665. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2666. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2668. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2669. if !m.op.Is(OpUpdateOne) {
  2670. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2671. }
  2672. if m.id == nil || m.oldValue == nil {
  2673. return v, errors.New("OldResponse requires an ID field in the mutation")
  2674. }
  2675. oldValue, err := m.oldValue(ctx)
  2676. if err != nil {
  2677. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2678. }
  2679. return oldValue.Response, nil
  2680. }
  2681. // ResetResponse resets all changes to the "response" field.
  2682. func (m *AliyunAvatarMutation) ResetResponse() {
  2683. m.response = nil
  2684. }
  2685. // SetToken sets the "token" field.
  2686. func (m *AliyunAvatarMutation) SetToken(s string) {
  2687. m.token = &s
  2688. }
  2689. // Token returns the value of the "token" field in the mutation.
  2690. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2691. v := m.token
  2692. if v == nil {
  2693. return
  2694. }
  2695. return *v, true
  2696. }
  2697. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2698. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2700. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2701. if !m.op.Is(OpUpdateOne) {
  2702. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2703. }
  2704. if m.id == nil || m.oldValue == nil {
  2705. return v, errors.New("OldToken requires an ID field in the mutation")
  2706. }
  2707. oldValue, err := m.oldValue(ctx)
  2708. if err != nil {
  2709. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2710. }
  2711. return oldValue.Token, nil
  2712. }
  2713. // ResetToken resets all changes to the "token" field.
  2714. func (m *AliyunAvatarMutation) ResetToken() {
  2715. m.token = nil
  2716. }
  2717. // SetSessionID sets the "session_id" field.
  2718. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2719. m.session_id = &s
  2720. }
  2721. // SessionID returns the value of the "session_id" field in the mutation.
  2722. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2723. v := m.session_id
  2724. if v == nil {
  2725. return
  2726. }
  2727. return *v, true
  2728. }
  2729. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2730. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2732. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2733. if !m.op.Is(OpUpdateOne) {
  2734. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2735. }
  2736. if m.id == nil || m.oldValue == nil {
  2737. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2738. }
  2739. oldValue, err := m.oldValue(ctx)
  2740. if err != nil {
  2741. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2742. }
  2743. return oldValue.SessionID, nil
  2744. }
  2745. // ResetSessionID resets all changes to the "session_id" field.
  2746. func (m *AliyunAvatarMutation) ResetSessionID() {
  2747. m.session_id = nil
  2748. }
  2749. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2750. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2751. m.predicates = append(m.predicates, ps...)
  2752. }
  2753. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2754. // users can use type-assertion to append predicates that do not depend on any generated package.
  2755. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2756. p := make([]predicate.AliyunAvatar, len(ps))
  2757. for i := range ps {
  2758. p[i] = ps[i]
  2759. }
  2760. m.Where(p...)
  2761. }
  2762. // Op returns the operation name.
  2763. func (m *AliyunAvatarMutation) Op() Op {
  2764. return m.op
  2765. }
  2766. // SetOp allows setting the mutation operation.
  2767. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2768. m.op = op
  2769. }
  2770. // Type returns the node type of this mutation (AliyunAvatar).
  2771. func (m *AliyunAvatarMutation) Type() string {
  2772. return m.typ
  2773. }
  2774. // Fields returns all fields that were changed during this mutation. Note that in
  2775. // order to get all numeric fields that were incremented/decremented, call
  2776. // AddedFields().
  2777. func (m *AliyunAvatarMutation) Fields() []string {
  2778. fields := make([]string, 0, 12)
  2779. if m.created_at != nil {
  2780. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2781. }
  2782. if m.updated_at != nil {
  2783. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2784. }
  2785. if m.deleted_at != nil {
  2786. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2787. }
  2788. if m.user_id != nil {
  2789. fields = append(fields, aliyunavatar.FieldUserID)
  2790. }
  2791. if m.biz_id != nil {
  2792. fields = append(fields, aliyunavatar.FieldBizID)
  2793. }
  2794. if m.access_key_id != nil {
  2795. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2796. }
  2797. if m.access_key_secret != nil {
  2798. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2799. }
  2800. if m.app_id != nil {
  2801. fields = append(fields, aliyunavatar.FieldAppID)
  2802. }
  2803. if m.tenant_id != nil {
  2804. fields = append(fields, aliyunavatar.FieldTenantID)
  2805. }
  2806. if m.response != nil {
  2807. fields = append(fields, aliyunavatar.FieldResponse)
  2808. }
  2809. if m.token != nil {
  2810. fields = append(fields, aliyunavatar.FieldToken)
  2811. }
  2812. if m.session_id != nil {
  2813. fields = append(fields, aliyunavatar.FieldSessionID)
  2814. }
  2815. return fields
  2816. }
  2817. // Field returns the value of a field with the given name. The second boolean
  2818. // return value indicates that this field was not set, or was not defined in the
  2819. // schema.
  2820. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2821. switch name {
  2822. case aliyunavatar.FieldCreatedAt:
  2823. return m.CreatedAt()
  2824. case aliyunavatar.FieldUpdatedAt:
  2825. return m.UpdatedAt()
  2826. case aliyunavatar.FieldDeletedAt:
  2827. return m.DeletedAt()
  2828. case aliyunavatar.FieldUserID:
  2829. return m.UserID()
  2830. case aliyunavatar.FieldBizID:
  2831. return m.BizID()
  2832. case aliyunavatar.FieldAccessKeyID:
  2833. return m.AccessKeyID()
  2834. case aliyunavatar.FieldAccessKeySecret:
  2835. return m.AccessKeySecret()
  2836. case aliyunavatar.FieldAppID:
  2837. return m.AppID()
  2838. case aliyunavatar.FieldTenantID:
  2839. return m.TenantID()
  2840. case aliyunavatar.FieldResponse:
  2841. return m.Response()
  2842. case aliyunavatar.FieldToken:
  2843. return m.Token()
  2844. case aliyunavatar.FieldSessionID:
  2845. return m.SessionID()
  2846. }
  2847. return nil, false
  2848. }
  2849. // OldField returns the old value of the field from the database. An error is
  2850. // returned if the mutation operation is not UpdateOne, or the query to the
  2851. // database failed.
  2852. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2853. switch name {
  2854. case aliyunavatar.FieldCreatedAt:
  2855. return m.OldCreatedAt(ctx)
  2856. case aliyunavatar.FieldUpdatedAt:
  2857. return m.OldUpdatedAt(ctx)
  2858. case aliyunavatar.FieldDeletedAt:
  2859. return m.OldDeletedAt(ctx)
  2860. case aliyunavatar.FieldUserID:
  2861. return m.OldUserID(ctx)
  2862. case aliyunavatar.FieldBizID:
  2863. return m.OldBizID(ctx)
  2864. case aliyunavatar.FieldAccessKeyID:
  2865. return m.OldAccessKeyID(ctx)
  2866. case aliyunavatar.FieldAccessKeySecret:
  2867. return m.OldAccessKeySecret(ctx)
  2868. case aliyunavatar.FieldAppID:
  2869. return m.OldAppID(ctx)
  2870. case aliyunavatar.FieldTenantID:
  2871. return m.OldTenantID(ctx)
  2872. case aliyunavatar.FieldResponse:
  2873. return m.OldResponse(ctx)
  2874. case aliyunavatar.FieldToken:
  2875. return m.OldToken(ctx)
  2876. case aliyunavatar.FieldSessionID:
  2877. return m.OldSessionID(ctx)
  2878. }
  2879. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2880. }
  2881. // SetField sets the value of a field with the given name. It returns an error if
  2882. // the field is not defined in the schema, or if the type mismatched the field
  2883. // type.
  2884. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2885. switch name {
  2886. case aliyunavatar.FieldCreatedAt:
  2887. v, ok := value.(time.Time)
  2888. if !ok {
  2889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2890. }
  2891. m.SetCreatedAt(v)
  2892. return nil
  2893. case aliyunavatar.FieldUpdatedAt:
  2894. v, ok := value.(time.Time)
  2895. if !ok {
  2896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2897. }
  2898. m.SetUpdatedAt(v)
  2899. return nil
  2900. case aliyunavatar.FieldDeletedAt:
  2901. v, ok := value.(time.Time)
  2902. if !ok {
  2903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2904. }
  2905. m.SetDeletedAt(v)
  2906. return nil
  2907. case aliyunavatar.FieldUserID:
  2908. v, ok := value.(uint64)
  2909. if !ok {
  2910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2911. }
  2912. m.SetUserID(v)
  2913. return nil
  2914. case aliyunavatar.FieldBizID:
  2915. v, ok := value.(string)
  2916. if !ok {
  2917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2918. }
  2919. m.SetBizID(v)
  2920. return nil
  2921. case aliyunavatar.FieldAccessKeyID:
  2922. v, ok := value.(string)
  2923. if !ok {
  2924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2925. }
  2926. m.SetAccessKeyID(v)
  2927. return nil
  2928. case aliyunavatar.FieldAccessKeySecret:
  2929. v, ok := value.(string)
  2930. if !ok {
  2931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2932. }
  2933. m.SetAccessKeySecret(v)
  2934. return nil
  2935. case aliyunavatar.FieldAppID:
  2936. v, ok := value.(string)
  2937. if !ok {
  2938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2939. }
  2940. m.SetAppID(v)
  2941. return nil
  2942. case aliyunavatar.FieldTenantID:
  2943. v, ok := value.(uint64)
  2944. if !ok {
  2945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2946. }
  2947. m.SetTenantID(v)
  2948. return nil
  2949. case aliyunavatar.FieldResponse:
  2950. v, ok := value.(string)
  2951. if !ok {
  2952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2953. }
  2954. m.SetResponse(v)
  2955. return nil
  2956. case aliyunavatar.FieldToken:
  2957. v, ok := value.(string)
  2958. if !ok {
  2959. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2960. }
  2961. m.SetToken(v)
  2962. return nil
  2963. case aliyunavatar.FieldSessionID:
  2964. v, ok := value.(string)
  2965. if !ok {
  2966. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2967. }
  2968. m.SetSessionID(v)
  2969. return nil
  2970. }
  2971. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  2972. }
  2973. // AddedFields returns all numeric fields that were incremented/decremented during
  2974. // this mutation.
  2975. func (m *AliyunAvatarMutation) AddedFields() []string {
  2976. var fields []string
  2977. if m.adduser_id != nil {
  2978. fields = append(fields, aliyunavatar.FieldUserID)
  2979. }
  2980. if m.addtenant_id != nil {
  2981. fields = append(fields, aliyunavatar.FieldTenantID)
  2982. }
  2983. return fields
  2984. }
  2985. // AddedField returns the numeric value that was incremented/decremented on a field
  2986. // with the given name. The second boolean return value indicates that this field
  2987. // was not set, or was not defined in the schema.
  2988. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  2989. switch name {
  2990. case aliyunavatar.FieldUserID:
  2991. return m.AddedUserID()
  2992. case aliyunavatar.FieldTenantID:
  2993. return m.AddedTenantID()
  2994. }
  2995. return nil, false
  2996. }
  2997. // AddField adds the value to the field with the given name. It returns an error if
  2998. // the field is not defined in the schema, or if the type mismatched the field
  2999. // type.
  3000. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3001. switch name {
  3002. case aliyunavatar.FieldUserID:
  3003. v, ok := value.(int64)
  3004. if !ok {
  3005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3006. }
  3007. m.AddUserID(v)
  3008. return nil
  3009. case aliyunavatar.FieldTenantID:
  3010. v, ok := value.(int64)
  3011. if !ok {
  3012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3013. }
  3014. m.AddTenantID(v)
  3015. return nil
  3016. }
  3017. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3018. }
  3019. // ClearedFields returns all nullable fields that were cleared during this
  3020. // mutation.
  3021. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3022. var fields []string
  3023. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3024. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3025. }
  3026. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3027. fields = append(fields, aliyunavatar.FieldAppID)
  3028. }
  3029. return fields
  3030. }
  3031. // FieldCleared returns a boolean indicating if a field with the given name was
  3032. // cleared in this mutation.
  3033. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3034. _, ok := m.clearedFields[name]
  3035. return ok
  3036. }
  3037. // ClearField clears the value of the field with the given name. It returns an
  3038. // error if the field is not defined in the schema.
  3039. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3040. switch name {
  3041. case aliyunavatar.FieldDeletedAt:
  3042. m.ClearDeletedAt()
  3043. return nil
  3044. case aliyunavatar.FieldAppID:
  3045. m.ClearAppID()
  3046. return nil
  3047. }
  3048. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3049. }
  3050. // ResetField resets all changes in the mutation for the field with the given name.
  3051. // It returns an error if the field is not defined in the schema.
  3052. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3053. switch name {
  3054. case aliyunavatar.FieldCreatedAt:
  3055. m.ResetCreatedAt()
  3056. return nil
  3057. case aliyunavatar.FieldUpdatedAt:
  3058. m.ResetUpdatedAt()
  3059. return nil
  3060. case aliyunavatar.FieldDeletedAt:
  3061. m.ResetDeletedAt()
  3062. return nil
  3063. case aliyunavatar.FieldUserID:
  3064. m.ResetUserID()
  3065. return nil
  3066. case aliyunavatar.FieldBizID:
  3067. m.ResetBizID()
  3068. return nil
  3069. case aliyunavatar.FieldAccessKeyID:
  3070. m.ResetAccessKeyID()
  3071. return nil
  3072. case aliyunavatar.FieldAccessKeySecret:
  3073. m.ResetAccessKeySecret()
  3074. return nil
  3075. case aliyunavatar.FieldAppID:
  3076. m.ResetAppID()
  3077. return nil
  3078. case aliyunavatar.FieldTenantID:
  3079. m.ResetTenantID()
  3080. return nil
  3081. case aliyunavatar.FieldResponse:
  3082. m.ResetResponse()
  3083. return nil
  3084. case aliyunavatar.FieldToken:
  3085. m.ResetToken()
  3086. return nil
  3087. case aliyunavatar.FieldSessionID:
  3088. m.ResetSessionID()
  3089. return nil
  3090. }
  3091. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3092. }
  3093. // AddedEdges returns all edge names that were set/added in this mutation.
  3094. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3095. edges := make([]string, 0, 0)
  3096. return edges
  3097. }
  3098. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3099. // name in this mutation.
  3100. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3101. return nil
  3102. }
  3103. // RemovedEdges returns all edge names that were removed in this mutation.
  3104. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3105. edges := make([]string, 0, 0)
  3106. return edges
  3107. }
  3108. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3109. // the given name in this mutation.
  3110. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3111. return nil
  3112. }
  3113. // ClearedEdges returns all edge names that were cleared in this mutation.
  3114. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3115. edges := make([]string, 0, 0)
  3116. return edges
  3117. }
  3118. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3119. // was cleared in this mutation.
  3120. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3121. return false
  3122. }
  3123. // ClearEdge clears the value of the edge with the given name. It returns an error
  3124. // if that edge is not defined in the schema.
  3125. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3126. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3127. }
  3128. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3129. // It returns an error if the edge is not defined in the schema.
  3130. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3131. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3132. }
  3133. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3134. type AllocAgentMutation struct {
  3135. config
  3136. op Op
  3137. typ string
  3138. id *uint64
  3139. created_at *time.Time
  3140. updated_at *time.Time
  3141. deleted_at *time.Time
  3142. user_id *string
  3143. organization_id *uint64
  3144. addorganization_id *int64
  3145. agents *[]uint64
  3146. appendagents []uint64
  3147. status *int
  3148. addstatus *int
  3149. clearedFields map[string]struct{}
  3150. done bool
  3151. oldValue func(context.Context) (*AllocAgent, error)
  3152. predicates []predicate.AllocAgent
  3153. }
  3154. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3155. // allocagentOption allows management of the mutation configuration using functional options.
  3156. type allocagentOption func(*AllocAgentMutation)
  3157. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3158. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3159. m := &AllocAgentMutation{
  3160. config: c,
  3161. op: op,
  3162. typ: TypeAllocAgent,
  3163. clearedFields: make(map[string]struct{}),
  3164. }
  3165. for _, opt := range opts {
  3166. opt(m)
  3167. }
  3168. return m
  3169. }
  3170. // withAllocAgentID sets the ID field of the mutation.
  3171. func withAllocAgentID(id uint64) allocagentOption {
  3172. return func(m *AllocAgentMutation) {
  3173. var (
  3174. err error
  3175. once sync.Once
  3176. value *AllocAgent
  3177. )
  3178. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3179. once.Do(func() {
  3180. if m.done {
  3181. err = errors.New("querying old values post mutation is not allowed")
  3182. } else {
  3183. value, err = m.Client().AllocAgent.Get(ctx, id)
  3184. }
  3185. })
  3186. return value, err
  3187. }
  3188. m.id = &id
  3189. }
  3190. }
  3191. // withAllocAgent sets the old AllocAgent of the mutation.
  3192. func withAllocAgent(node *AllocAgent) allocagentOption {
  3193. return func(m *AllocAgentMutation) {
  3194. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3195. return node, nil
  3196. }
  3197. m.id = &node.ID
  3198. }
  3199. }
  3200. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3201. // executed in a transaction (ent.Tx), a transactional client is returned.
  3202. func (m AllocAgentMutation) Client() *Client {
  3203. client := &Client{config: m.config}
  3204. client.init()
  3205. return client
  3206. }
  3207. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3208. // it returns an error otherwise.
  3209. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3210. if _, ok := m.driver.(*txDriver); !ok {
  3211. return nil, errors.New("ent: mutation is not running in a transaction")
  3212. }
  3213. tx := &Tx{config: m.config}
  3214. tx.init()
  3215. return tx, nil
  3216. }
  3217. // SetID sets the value of the id field. Note that this
  3218. // operation is only accepted on creation of AllocAgent entities.
  3219. func (m *AllocAgentMutation) SetID(id uint64) {
  3220. m.id = &id
  3221. }
  3222. // ID returns the ID value in the mutation. Note that the ID is only available
  3223. // if it was provided to the builder or after it was returned from the database.
  3224. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3225. if m.id == nil {
  3226. return
  3227. }
  3228. return *m.id, true
  3229. }
  3230. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3231. // That means, if the mutation is applied within a transaction with an isolation level such
  3232. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3233. // or updated by the mutation.
  3234. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3235. switch {
  3236. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3237. id, exists := m.ID()
  3238. if exists {
  3239. return []uint64{id}, nil
  3240. }
  3241. fallthrough
  3242. case m.op.Is(OpUpdate | OpDelete):
  3243. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3244. default:
  3245. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3246. }
  3247. }
  3248. // SetCreatedAt sets the "created_at" field.
  3249. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3250. m.created_at = &t
  3251. }
  3252. // CreatedAt returns the value of the "created_at" field in the mutation.
  3253. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3254. v := m.created_at
  3255. if v == nil {
  3256. return
  3257. }
  3258. return *v, true
  3259. }
  3260. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3261. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3263. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3264. if !m.op.Is(OpUpdateOne) {
  3265. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3266. }
  3267. if m.id == nil || m.oldValue == nil {
  3268. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3269. }
  3270. oldValue, err := m.oldValue(ctx)
  3271. if err != nil {
  3272. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3273. }
  3274. return oldValue.CreatedAt, nil
  3275. }
  3276. // ResetCreatedAt resets all changes to the "created_at" field.
  3277. func (m *AllocAgentMutation) ResetCreatedAt() {
  3278. m.created_at = nil
  3279. }
  3280. // SetUpdatedAt sets the "updated_at" field.
  3281. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3282. m.updated_at = &t
  3283. }
  3284. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3285. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3286. v := m.updated_at
  3287. if v == nil {
  3288. return
  3289. }
  3290. return *v, true
  3291. }
  3292. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3293. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3295. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3296. if !m.op.Is(OpUpdateOne) {
  3297. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3298. }
  3299. if m.id == nil || m.oldValue == nil {
  3300. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3301. }
  3302. oldValue, err := m.oldValue(ctx)
  3303. if err != nil {
  3304. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3305. }
  3306. return oldValue.UpdatedAt, nil
  3307. }
  3308. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3309. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3310. m.updated_at = nil
  3311. }
  3312. // SetDeletedAt sets the "deleted_at" field.
  3313. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3314. m.deleted_at = &t
  3315. }
  3316. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3317. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3318. v := m.deleted_at
  3319. if v == nil {
  3320. return
  3321. }
  3322. return *v, true
  3323. }
  3324. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3325. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3327. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3328. if !m.op.Is(OpUpdateOne) {
  3329. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3330. }
  3331. if m.id == nil || m.oldValue == nil {
  3332. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3333. }
  3334. oldValue, err := m.oldValue(ctx)
  3335. if err != nil {
  3336. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3337. }
  3338. return oldValue.DeletedAt, nil
  3339. }
  3340. // ClearDeletedAt clears the value of the "deleted_at" field.
  3341. func (m *AllocAgentMutation) ClearDeletedAt() {
  3342. m.deleted_at = nil
  3343. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3344. }
  3345. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3346. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3347. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3348. return ok
  3349. }
  3350. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3351. func (m *AllocAgentMutation) ResetDeletedAt() {
  3352. m.deleted_at = nil
  3353. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3354. }
  3355. // SetUserID sets the "user_id" field.
  3356. func (m *AllocAgentMutation) SetUserID(s string) {
  3357. m.user_id = &s
  3358. }
  3359. // UserID returns the value of the "user_id" field in the mutation.
  3360. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3361. v := m.user_id
  3362. if v == nil {
  3363. return
  3364. }
  3365. return *v, true
  3366. }
  3367. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3368. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3370. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3371. if !m.op.Is(OpUpdateOne) {
  3372. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3373. }
  3374. if m.id == nil || m.oldValue == nil {
  3375. return v, errors.New("OldUserID requires an ID field in the mutation")
  3376. }
  3377. oldValue, err := m.oldValue(ctx)
  3378. if err != nil {
  3379. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3380. }
  3381. return oldValue.UserID, nil
  3382. }
  3383. // ClearUserID clears the value of the "user_id" field.
  3384. func (m *AllocAgentMutation) ClearUserID() {
  3385. m.user_id = nil
  3386. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3387. }
  3388. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3389. func (m *AllocAgentMutation) UserIDCleared() bool {
  3390. _, ok := m.clearedFields[allocagent.FieldUserID]
  3391. return ok
  3392. }
  3393. // ResetUserID resets all changes to the "user_id" field.
  3394. func (m *AllocAgentMutation) ResetUserID() {
  3395. m.user_id = nil
  3396. delete(m.clearedFields, allocagent.FieldUserID)
  3397. }
  3398. // SetOrganizationID sets the "organization_id" field.
  3399. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3400. m.organization_id = &u
  3401. m.addorganization_id = nil
  3402. }
  3403. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3404. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3405. v := m.organization_id
  3406. if v == nil {
  3407. return
  3408. }
  3409. return *v, true
  3410. }
  3411. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3412. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3414. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3415. if !m.op.Is(OpUpdateOne) {
  3416. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3417. }
  3418. if m.id == nil || m.oldValue == nil {
  3419. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3420. }
  3421. oldValue, err := m.oldValue(ctx)
  3422. if err != nil {
  3423. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3424. }
  3425. return oldValue.OrganizationID, nil
  3426. }
  3427. // AddOrganizationID adds u to the "organization_id" field.
  3428. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3429. if m.addorganization_id != nil {
  3430. *m.addorganization_id += u
  3431. } else {
  3432. m.addorganization_id = &u
  3433. }
  3434. }
  3435. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3436. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3437. v := m.addorganization_id
  3438. if v == nil {
  3439. return
  3440. }
  3441. return *v, true
  3442. }
  3443. // ClearOrganizationID clears the value of the "organization_id" field.
  3444. func (m *AllocAgentMutation) ClearOrganizationID() {
  3445. m.organization_id = nil
  3446. m.addorganization_id = nil
  3447. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3448. }
  3449. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3450. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3451. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3452. return ok
  3453. }
  3454. // ResetOrganizationID resets all changes to the "organization_id" field.
  3455. func (m *AllocAgentMutation) ResetOrganizationID() {
  3456. m.organization_id = nil
  3457. m.addorganization_id = nil
  3458. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3459. }
  3460. // SetAgents sets the "agents" field.
  3461. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3462. m.agents = &u
  3463. m.appendagents = nil
  3464. }
  3465. // Agents returns the value of the "agents" field in the mutation.
  3466. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3467. v := m.agents
  3468. if v == nil {
  3469. return
  3470. }
  3471. return *v, true
  3472. }
  3473. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3474. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3476. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3477. if !m.op.Is(OpUpdateOne) {
  3478. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3479. }
  3480. if m.id == nil || m.oldValue == nil {
  3481. return v, errors.New("OldAgents requires an ID field in the mutation")
  3482. }
  3483. oldValue, err := m.oldValue(ctx)
  3484. if err != nil {
  3485. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3486. }
  3487. return oldValue.Agents, nil
  3488. }
  3489. // AppendAgents adds u to the "agents" field.
  3490. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3491. m.appendagents = append(m.appendagents, u...)
  3492. }
  3493. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3494. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3495. if len(m.appendagents) == 0 {
  3496. return nil, false
  3497. }
  3498. return m.appendagents, true
  3499. }
  3500. // ResetAgents resets all changes to the "agents" field.
  3501. func (m *AllocAgentMutation) ResetAgents() {
  3502. m.agents = nil
  3503. m.appendagents = nil
  3504. }
  3505. // SetStatus sets the "status" field.
  3506. func (m *AllocAgentMutation) SetStatus(i int) {
  3507. m.status = &i
  3508. m.addstatus = nil
  3509. }
  3510. // Status returns the value of the "status" field in the mutation.
  3511. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3512. v := m.status
  3513. if v == nil {
  3514. return
  3515. }
  3516. return *v, true
  3517. }
  3518. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3519. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3521. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3522. if !m.op.Is(OpUpdateOne) {
  3523. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3524. }
  3525. if m.id == nil || m.oldValue == nil {
  3526. return v, errors.New("OldStatus requires an ID field in the mutation")
  3527. }
  3528. oldValue, err := m.oldValue(ctx)
  3529. if err != nil {
  3530. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3531. }
  3532. return oldValue.Status, nil
  3533. }
  3534. // AddStatus adds i to the "status" field.
  3535. func (m *AllocAgentMutation) AddStatus(i int) {
  3536. if m.addstatus != nil {
  3537. *m.addstatus += i
  3538. } else {
  3539. m.addstatus = &i
  3540. }
  3541. }
  3542. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3543. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3544. v := m.addstatus
  3545. if v == nil {
  3546. return
  3547. }
  3548. return *v, true
  3549. }
  3550. // ClearStatus clears the value of the "status" field.
  3551. func (m *AllocAgentMutation) ClearStatus() {
  3552. m.status = nil
  3553. m.addstatus = nil
  3554. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3555. }
  3556. // StatusCleared returns if the "status" field was cleared in this mutation.
  3557. func (m *AllocAgentMutation) StatusCleared() bool {
  3558. _, ok := m.clearedFields[allocagent.FieldStatus]
  3559. return ok
  3560. }
  3561. // ResetStatus resets all changes to the "status" field.
  3562. func (m *AllocAgentMutation) ResetStatus() {
  3563. m.status = nil
  3564. m.addstatus = nil
  3565. delete(m.clearedFields, allocagent.FieldStatus)
  3566. }
  3567. // Where appends a list predicates to the AllocAgentMutation builder.
  3568. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3569. m.predicates = append(m.predicates, ps...)
  3570. }
  3571. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3572. // users can use type-assertion to append predicates that do not depend on any generated package.
  3573. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3574. p := make([]predicate.AllocAgent, len(ps))
  3575. for i := range ps {
  3576. p[i] = ps[i]
  3577. }
  3578. m.Where(p...)
  3579. }
  3580. // Op returns the operation name.
  3581. func (m *AllocAgentMutation) Op() Op {
  3582. return m.op
  3583. }
  3584. // SetOp allows setting the mutation operation.
  3585. func (m *AllocAgentMutation) SetOp(op Op) {
  3586. m.op = op
  3587. }
  3588. // Type returns the node type of this mutation (AllocAgent).
  3589. func (m *AllocAgentMutation) Type() string {
  3590. return m.typ
  3591. }
  3592. // Fields returns all fields that were changed during this mutation. Note that in
  3593. // order to get all numeric fields that were incremented/decremented, call
  3594. // AddedFields().
  3595. func (m *AllocAgentMutation) Fields() []string {
  3596. fields := make([]string, 0, 7)
  3597. if m.created_at != nil {
  3598. fields = append(fields, allocagent.FieldCreatedAt)
  3599. }
  3600. if m.updated_at != nil {
  3601. fields = append(fields, allocagent.FieldUpdatedAt)
  3602. }
  3603. if m.deleted_at != nil {
  3604. fields = append(fields, allocagent.FieldDeletedAt)
  3605. }
  3606. if m.user_id != nil {
  3607. fields = append(fields, allocagent.FieldUserID)
  3608. }
  3609. if m.organization_id != nil {
  3610. fields = append(fields, allocagent.FieldOrganizationID)
  3611. }
  3612. if m.agents != nil {
  3613. fields = append(fields, allocagent.FieldAgents)
  3614. }
  3615. if m.status != nil {
  3616. fields = append(fields, allocagent.FieldStatus)
  3617. }
  3618. return fields
  3619. }
  3620. // Field returns the value of a field with the given name. The second boolean
  3621. // return value indicates that this field was not set, or was not defined in the
  3622. // schema.
  3623. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3624. switch name {
  3625. case allocagent.FieldCreatedAt:
  3626. return m.CreatedAt()
  3627. case allocagent.FieldUpdatedAt:
  3628. return m.UpdatedAt()
  3629. case allocagent.FieldDeletedAt:
  3630. return m.DeletedAt()
  3631. case allocagent.FieldUserID:
  3632. return m.UserID()
  3633. case allocagent.FieldOrganizationID:
  3634. return m.OrganizationID()
  3635. case allocagent.FieldAgents:
  3636. return m.Agents()
  3637. case allocagent.FieldStatus:
  3638. return m.Status()
  3639. }
  3640. return nil, false
  3641. }
  3642. // OldField returns the old value of the field from the database. An error is
  3643. // returned if the mutation operation is not UpdateOne, or the query to the
  3644. // database failed.
  3645. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3646. switch name {
  3647. case allocagent.FieldCreatedAt:
  3648. return m.OldCreatedAt(ctx)
  3649. case allocagent.FieldUpdatedAt:
  3650. return m.OldUpdatedAt(ctx)
  3651. case allocagent.FieldDeletedAt:
  3652. return m.OldDeletedAt(ctx)
  3653. case allocagent.FieldUserID:
  3654. return m.OldUserID(ctx)
  3655. case allocagent.FieldOrganizationID:
  3656. return m.OldOrganizationID(ctx)
  3657. case allocagent.FieldAgents:
  3658. return m.OldAgents(ctx)
  3659. case allocagent.FieldStatus:
  3660. return m.OldStatus(ctx)
  3661. }
  3662. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3663. }
  3664. // SetField sets the value of a field with the given name. It returns an error if
  3665. // the field is not defined in the schema, or if the type mismatched the field
  3666. // type.
  3667. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3668. switch name {
  3669. case allocagent.FieldCreatedAt:
  3670. v, ok := value.(time.Time)
  3671. if !ok {
  3672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3673. }
  3674. m.SetCreatedAt(v)
  3675. return nil
  3676. case allocagent.FieldUpdatedAt:
  3677. v, ok := value.(time.Time)
  3678. if !ok {
  3679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3680. }
  3681. m.SetUpdatedAt(v)
  3682. return nil
  3683. case allocagent.FieldDeletedAt:
  3684. v, ok := value.(time.Time)
  3685. if !ok {
  3686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3687. }
  3688. m.SetDeletedAt(v)
  3689. return nil
  3690. case allocagent.FieldUserID:
  3691. v, ok := value.(string)
  3692. if !ok {
  3693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3694. }
  3695. m.SetUserID(v)
  3696. return nil
  3697. case allocagent.FieldOrganizationID:
  3698. v, ok := value.(uint64)
  3699. if !ok {
  3700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3701. }
  3702. m.SetOrganizationID(v)
  3703. return nil
  3704. case allocagent.FieldAgents:
  3705. v, ok := value.([]uint64)
  3706. if !ok {
  3707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3708. }
  3709. m.SetAgents(v)
  3710. return nil
  3711. case allocagent.FieldStatus:
  3712. v, ok := value.(int)
  3713. if !ok {
  3714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3715. }
  3716. m.SetStatus(v)
  3717. return nil
  3718. }
  3719. return fmt.Errorf("unknown AllocAgent field %s", name)
  3720. }
  3721. // AddedFields returns all numeric fields that were incremented/decremented during
  3722. // this mutation.
  3723. func (m *AllocAgentMutation) AddedFields() []string {
  3724. var fields []string
  3725. if m.addorganization_id != nil {
  3726. fields = append(fields, allocagent.FieldOrganizationID)
  3727. }
  3728. if m.addstatus != nil {
  3729. fields = append(fields, allocagent.FieldStatus)
  3730. }
  3731. return fields
  3732. }
  3733. // AddedField returns the numeric value that was incremented/decremented on a field
  3734. // with the given name. The second boolean return value indicates that this field
  3735. // was not set, or was not defined in the schema.
  3736. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3737. switch name {
  3738. case allocagent.FieldOrganizationID:
  3739. return m.AddedOrganizationID()
  3740. case allocagent.FieldStatus:
  3741. return m.AddedStatus()
  3742. }
  3743. return nil, false
  3744. }
  3745. // AddField adds the value to the field with the given name. It returns an error if
  3746. // the field is not defined in the schema, or if the type mismatched the field
  3747. // type.
  3748. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3749. switch name {
  3750. case allocagent.FieldOrganizationID:
  3751. v, ok := value.(int64)
  3752. if !ok {
  3753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3754. }
  3755. m.AddOrganizationID(v)
  3756. return nil
  3757. case allocagent.FieldStatus:
  3758. v, ok := value.(int)
  3759. if !ok {
  3760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3761. }
  3762. m.AddStatus(v)
  3763. return nil
  3764. }
  3765. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  3766. }
  3767. // ClearedFields returns all nullable fields that were cleared during this
  3768. // mutation.
  3769. func (m *AllocAgentMutation) ClearedFields() []string {
  3770. var fields []string
  3771. if m.FieldCleared(allocagent.FieldDeletedAt) {
  3772. fields = append(fields, allocagent.FieldDeletedAt)
  3773. }
  3774. if m.FieldCleared(allocagent.FieldUserID) {
  3775. fields = append(fields, allocagent.FieldUserID)
  3776. }
  3777. if m.FieldCleared(allocagent.FieldOrganizationID) {
  3778. fields = append(fields, allocagent.FieldOrganizationID)
  3779. }
  3780. if m.FieldCleared(allocagent.FieldStatus) {
  3781. fields = append(fields, allocagent.FieldStatus)
  3782. }
  3783. return fields
  3784. }
  3785. // FieldCleared returns a boolean indicating if a field with the given name was
  3786. // cleared in this mutation.
  3787. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  3788. _, ok := m.clearedFields[name]
  3789. return ok
  3790. }
  3791. // ClearField clears the value of the field with the given name. It returns an
  3792. // error if the field is not defined in the schema.
  3793. func (m *AllocAgentMutation) ClearField(name string) error {
  3794. switch name {
  3795. case allocagent.FieldDeletedAt:
  3796. m.ClearDeletedAt()
  3797. return nil
  3798. case allocagent.FieldUserID:
  3799. m.ClearUserID()
  3800. return nil
  3801. case allocagent.FieldOrganizationID:
  3802. m.ClearOrganizationID()
  3803. return nil
  3804. case allocagent.FieldStatus:
  3805. m.ClearStatus()
  3806. return nil
  3807. }
  3808. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  3809. }
  3810. // ResetField resets all changes in the mutation for the field with the given name.
  3811. // It returns an error if the field is not defined in the schema.
  3812. func (m *AllocAgentMutation) ResetField(name string) error {
  3813. switch name {
  3814. case allocagent.FieldCreatedAt:
  3815. m.ResetCreatedAt()
  3816. return nil
  3817. case allocagent.FieldUpdatedAt:
  3818. m.ResetUpdatedAt()
  3819. return nil
  3820. case allocagent.FieldDeletedAt:
  3821. m.ResetDeletedAt()
  3822. return nil
  3823. case allocagent.FieldUserID:
  3824. m.ResetUserID()
  3825. return nil
  3826. case allocagent.FieldOrganizationID:
  3827. m.ResetOrganizationID()
  3828. return nil
  3829. case allocagent.FieldAgents:
  3830. m.ResetAgents()
  3831. return nil
  3832. case allocagent.FieldStatus:
  3833. m.ResetStatus()
  3834. return nil
  3835. }
  3836. return fmt.Errorf("unknown AllocAgent field %s", name)
  3837. }
  3838. // AddedEdges returns all edge names that were set/added in this mutation.
  3839. func (m *AllocAgentMutation) AddedEdges() []string {
  3840. edges := make([]string, 0, 0)
  3841. return edges
  3842. }
  3843. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3844. // name in this mutation.
  3845. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  3846. return nil
  3847. }
  3848. // RemovedEdges returns all edge names that were removed in this mutation.
  3849. func (m *AllocAgentMutation) RemovedEdges() []string {
  3850. edges := make([]string, 0, 0)
  3851. return edges
  3852. }
  3853. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3854. // the given name in this mutation.
  3855. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  3856. return nil
  3857. }
  3858. // ClearedEdges returns all edge names that were cleared in this mutation.
  3859. func (m *AllocAgentMutation) ClearedEdges() []string {
  3860. edges := make([]string, 0, 0)
  3861. return edges
  3862. }
  3863. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3864. // was cleared in this mutation.
  3865. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  3866. return false
  3867. }
  3868. // ClearEdge clears the value of the edge with the given name. It returns an error
  3869. // if that edge is not defined in the schema.
  3870. func (m *AllocAgentMutation) ClearEdge(name string) error {
  3871. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  3872. }
  3873. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3874. // It returns an error if the edge is not defined in the schema.
  3875. func (m *AllocAgentMutation) ResetEdge(name string) error {
  3876. return fmt.Errorf("unknown AllocAgent edge %s", name)
  3877. }
  3878. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3879. type BatchMsgMutation struct {
  3880. config
  3881. op Op
  3882. typ string
  3883. id *uint64
  3884. created_at *time.Time
  3885. updated_at *time.Time
  3886. deleted_at *time.Time
  3887. status *uint8
  3888. addstatus *int8
  3889. batch_no *string
  3890. task_name *string
  3891. fromwxid *string
  3892. msg *string
  3893. tag *string
  3894. tagids *string
  3895. total *int32
  3896. addtotal *int32
  3897. success *int32
  3898. addsuccess *int32
  3899. fail *int32
  3900. addfail *int32
  3901. start_time *time.Time
  3902. stop_time *time.Time
  3903. send_time *time.Time
  3904. _type *int32
  3905. add_type *int32
  3906. organization_id *uint64
  3907. addorganization_id *int64
  3908. clearedFields map[string]struct{}
  3909. done bool
  3910. oldValue func(context.Context) (*BatchMsg, error)
  3911. predicates []predicate.BatchMsg
  3912. }
  3913. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  3914. // batchmsgOption allows management of the mutation configuration using functional options.
  3915. type batchmsgOption func(*BatchMsgMutation)
  3916. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  3917. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  3918. m := &BatchMsgMutation{
  3919. config: c,
  3920. op: op,
  3921. typ: TypeBatchMsg,
  3922. clearedFields: make(map[string]struct{}),
  3923. }
  3924. for _, opt := range opts {
  3925. opt(m)
  3926. }
  3927. return m
  3928. }
  3929. // withBatchMsgID sets the ID field of the mutation.
  3930. func withBatchMsgID(id uint64) batchmsgOption {
  3931. return func(m *BatchMsgMutation) {
  3932. var (
  3933. err error
  3934. once sync.Once
  3935. value *BatchMsg
  3936. )
  3937. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  3938. once.Do(func() {
  3939. if m.done {
  3940. err = errors.New("querying old values post mutation is not allowed")
  3941. } else {
  3942. value, err = m.Client().BatchMsg.Get(ctx, id)
  3943. }
  3944. })
  3945. return value, err
  3946. }
  3947. m.id = &id
  3948. }
  3949. }
  3950. // withBatchMsg sets the old BatchMsg of the mutation.
  3951. func withBatchMsg(node *BatchMsg) batchmsgOption {
  3952. return func(m *BatchMsgMutation) {
  3953. m.oldValue = func(context.Context) (*BatchMsg, error) {
  3954. return node, nil
  3955. }
  3956. m.id = &node.ID
  3957. }
  3958. }
  3959. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3960. // executed in a transaction (ent.Tx), a transactional client is returned.
  3961. func (m BatchMsgMutation) Client() *Client {
  3962. client := &Client{config: m.config}
  3963. client.init()
  3964. return client
  3965. }
  3966. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3967. // it returns an error otherwise.
  3968. func (m BatchMsgMutation) Tx() (*Tx, error) {
  3969. if _, ok := m.driver.(*txDriver); !ok {
  3970. return nil, errors.New("ent: mutation is not running in a transaction")
  3971. }
  3972. tx := &Tx{config: m.config}
  3973. tx.init()
  3974. return tx, nil
  3975. }
  3976. // SetID sets the value of the id field. Note that this
  3977. // operation is only accepted on creation of BatchMsg entities.
  3978. func (m *BatchMsgMutation) SetID(id uint64) {
  3979. m.id = &id
  3980. }
  3981. // ID returns the ID value in the mutation. Note that the ID is only available
  3982. // if it was provided to the builder or after it was returned from the database.
  3983. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  3984. if m.id == nil {
  3985. return
  3986. }
  3987. return *m.id, true
  3988. }
  3989. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3990. // That means, if the mutation is applied within a transaction with an isolation level such
  3991. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3992. // or updated by the mutation.
  3993. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  3994. switch {
  3995. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3996. id, exists := m.ID()
  3997. if exists {
  3998. return []uint64{id}, nil
  3999. }
  4000. fallthrough
  4001. case m.op.Is(OpUpdate | OpDelete):
  4002. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  4003. default:
  4004. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4005. }
  4006. }
  4007. // SetCreatedAt sets the "created_at" field.
  4008. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  4009. m.created_at = &t
  4010. }
  4011. // CreatedAt returns the value of the "created_at" field in the mutation.
  4012. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  4013. v := m.created_at
  4014. if v == nil {
  4015. return
  4016. }
  4017. return *v, true
  4018. }
  4019. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  4020. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4021. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4022. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4023. if !m.op.Is(OpUpdateOne) {
  4024. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4025. }
  4026. if m.id == nil || m.oldValue == nil {
  4027. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4028. }
  4029. oldValue, err := m.oldValue(ctx)
  4030. if err != nil {
  4031. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4032. }
  4033. return oldValue.CreatedAt, nil
  4034. }
  4035. // ResetCreatedAt resets all changes to the "created_at" field.
  4036. func (m *BatchMsgMutation) ResetCreatedAt() {
  4037. m.created_at = nil
  4038. }
  4039. // SetUpdatedAt sets the "updated_at" field.
  4040. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  4041. m.updated_at = &t
  4042. }
  4043. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4044. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  4045. v := m.updated_at
  4046. if v == nil {
  4047. return
  4048. }
  4049. return *v, true
  4050. }
  4051. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  4052. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4054. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4055. if !m.op.Is(OpUpdateOne) {
  4056. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4057. }
  4058. if m.id == nil || m.oldValue == nil {
  4059. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4060. }
  4061. oldValue, err := m.oldValue(ctx)
  4062. if err != nil {
  4063. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4064. }
  4065. return oldValue.UpdatedAt, nil
  4066. }
  4067. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4068. func (m *BatchMsgMutation) ResetUpdatedAt() {
  4069. m.updated_at = nil
  4070. }
  4071. // SetDeletedAt sets the "deleted_at" field.
  4072. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  4073. m.deleted_at = &t
  4074. }
  4075. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4076. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  4077. v := m.deleted_at
  4078. if v == nil {
  4079. return
  4080. }
  4081. return *v, true
  4082. }
  4083. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  4084. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4086. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4087. if !m.op.Is(OpUpdateOne) {
  4088. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4089. }
  4090. if m.id == nil || m.oldValue == nil {
  4091. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4092. }
  4093. oldValue, err := m.oldValue(ctx)
  4094. if err != nil {
  4095. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4096. }
  4097. return oldValue.DeletedAt, nil
  4098. }
  4099. // ClearDeletedAt clears the value of the "deleted_at" field.
  4100. func (m *BatchMsgMutation) ClearDeletedAt() {
  4101. m.deleted_at = nil
  4102. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  4103. }
  4104. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4105. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  4106. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  4107. return ok
  4108. }
  4109. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4110. func (m *BatchMsgMutation) ResetDeletedAt() {
  4111. m.deleted_at = nil
  4112. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  4113. }
  4114. // SetStatus sets the "status" field.
  4115. func (m *BatchMsgMutation) SetStatus(u uint8) {
  4116. m.status = &u
  4117. m.addstatus = nil
  4118. }
  4119. // Status returns the value of the "status" field in the mutation.
  4120. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  4121. v := m.status
  4122. if v == nil {
  4123. return
  4124. }
  4125. return *v, true
  4126. }
  4127. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  4128. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4130. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4131. if !m.op.Is(OpUpdateOne) {
  4132. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4133. }
  4134. if m.id == nil || m.oldValue == nil {
  4135. return v, errors.New("OldStatus requires an ID field in the mutation")
  4136. }
  4137. oldValue, err := m.oldValue(ctx)
  4138. if err != nil {
  4139. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4140. }
  4141. return oldValue.Status, nil
  4142. }
  4143. // AddStatus adds u to the "status" field.
  4144. func (m *BatchMsgMutation) AddStatus(u int8) {
  4145. if m.addstatus != nil {
  4146. *m.addstatus += u
  4147. } else {
  4148. m.addstatus = &u
  4149. }
  4150. }
  4151. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4152. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  4153. v := m.addstatus
  4154. if v == nil {
  4155. return
  4156. }
  4157. return *v, true
  4158. }
  4159. // ClearStatus clears the value of the "status" field.
  4160. func (m *BatchMsgMutation) ClearStatus() {
  4161. m.status = nil
  4162. m.addstatus = nil
  4163. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  4164. }
  4165. // StatusCleared returns if the "status" field was cleared in this mutation.
  4166. func (m *BatchMsgMutation) StatusCleared() bool {
  4167. _, ok := m.clearedFields[batchmsg.FieldStatus]
  4168. return ok
  4169. }
  4170. // ResetStatus resets all changes to the "status" field.
  4171. func (m *BatchMsgMutation) ResetStatus() {
  4172. m.status = nil
  4173. m.addstatus = nil
  4174. delete(m.clearedFields, batchmsg.FieldStatus)
  4175. }
  4176. // SetBatchNo sets the "batch_no" field.
  4177. func (m *BatchMsgMutation) SetBatchNo(s string) {
  4178. m.batch_no = &s
  4179. }
  4180. // BatchNo returns the value of the "batch_no" field in the mutation.
  4181. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  4182. v := m.batch_no
  4183. if v == nil {
  4184. return
  4185. }
  4186. return *v, true
  4187. }
  4188. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  4189. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4191. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  4192. if !m.op.Is(OpUpdateOne) {
  4193. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  4194. }
  4195. if m.id == nil || m.oldValue == nil {
  4196. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  4197. }
  4198. oldValue, err := m.oldValue(ctx)
  4199. if err != nil {
  4200. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  4201. }
  4202. return oldValue.BatchNo, nil
  4203. }
  4204. // ClearBatchNo clears the value of the "batch_no" field.
  4205. func (m *BatchMsgMutation) ClearBatchNo() {
  4206. m.batch_no = nil
  4207. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  4208. }
  4209. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  4210. func (m *BatchMsgMutation) BatchNoCleared() bool {
  4211. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  4212. return ok
  4213. }
  4214. // ResetBatchNo resets all changes to the "batch_no" field.
  4215. func (m *BatchMsgMutation) ResetBatchNo() {
  4216. m.batch_no = nil
  4217. delete(m.clearedFields, batchmsg.FieldBatchNo)
  4218. }
  4219. // SetTaskName sets the "task_name" field.
  4220. func (m *BatchMsgMutation) SetTaskName(s string) {
  4221. m.task_name = &s
  4222. }
  4223. // TaskName returns the value of the "task_name" field in the mutation.
  4224. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  4225. v := m.task_name
  4226. if v == nil {
  4227. return
  4228. }
  4229. return *v, true
  4230. }
  4231. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  4232. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4234. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  4235. if !m.op.Is(OpUpdateOne) {
  4236. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  4237. }
  4238. if m.id == nil || m.oldValue == nil {
  4239. return v, errors.New("OldTaskName requires an ID field in the mutation")
  4240. }
  4241. oldValue, err := m.oldValue(ctx)
  4242. if err != nil {
  4243. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  4244. }
  4245. return oldValue.TaskName, nil
  4246. }
  4247. // ClearTaskName clears the value of the "task_name" field.
  4248. func (m *BatchMsgMutation) ClearTaskName() {
  4249. m.task_name = nil
  4250. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  4251. }
  4252. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  4253. func (m *BatchMsgMutation) TaskNameCleared() bool {
  4254. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  4255. return ok
  4256. }
  4257. // ResetTaskName resets all changes to the "task_name" field.
  4258. func (m *BatchMsgMutation) ResetTaskName() {
  4259. m.task_name = nil
  4260. delete(m.clearedFields, batchmsg.FieldTaskName)
  4261. }
  4262. // SetFromwxid sets the "fromwxid" field.
  4263. func (m *BatchMsgMutation) SetFromwxid(s string) {
  4264. m.fromwxid = &s
  4265. }
  4266. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  4267. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  4268. v := m.fromwxid
  4269. if v == nil {
  4270. return
  4271. }
  4272. return *v, true
  4273. }
  4274. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  4275. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4276. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4277. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  4278. if !m.op.Is(OpUpdateOne) {
  4279. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  4280. }
  4281. if m.id == nil || m.oldValue == nil {
  4282. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  4283. }
  4284. oldValue, err := m.oldValue(ctx)
  4285. if err != nil {
  4286. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  4287. }
  4288. return oldValue.Fromwxid, nil
  4289. }
  4290. // ClearFromwxid clears the value of the "fromwxid" field.
  4291. func (m *BatchMsgMutation) ClearFromwxid() {
  4292. m.fromwxid = nil
  4293. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  4294. }
  4295. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  4296. func (m *BatchMsgMutation) FromwxidCleared() bool {
  4297. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  4298. return ok
  4299. }
  4300. // ResetFromwxid resets all changes to the "fromwxid" field.
  4301. func (m *BatchMsgMutation) ResetFromwxid() {
  4302. m.fromwxid = nil
  4303. delete(m.clearedFields, batchmsg.FieldFromwxid)
  4304. }
  4305. // SetMsg sets the "msg" field.
  4306. func (m *BatchMsgMutation) SetMsg(s string) {
  4307. m.msg = &s
  4308. }
  4309. // Msg returns the value of the "msg" field in the mutation.
  4310. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  4311. v := m.msg
  4312. if v == nil {
  4313. return
  4314. }
  4315. return *v, true
  4316. }
  4317. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  4318. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4320. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  4321. if !m.op.Is(OpUpdateOne) {
  4322. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  4323. }
  4324. if m.id == nil || m.oldValue == nil {
  4325. return v, errors.New("OldMsg requires an ID field in the mutation")
  4326. }
  4327. oldValue, err := m.oldValue(ctx)
  4328. if err != nil {
  4329. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  4330. }
  4331. return oldValue.Msg, nil
  4332. }
  4333. // ClearMsg clears the value of the "msg" field.
  4334. func (m *BatchMsgMutation) ClearMsg() {
  4335. m.msg = nil
  4336. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  4337. }
  4338. // MsgCleared returns if the "msg" field was cleared in this mutation.
  4339. func (m *BatchMsgMutation) MsgCleared() bool {
  4340. _, ok := m.clearedFields[batchmsg.FieldMsg]
  4341. return ok
  4342. }
  4343. // ResetMsg resets all changes to the "msg" field.
  4344. func (m *BatchMsgMutation) ResetMsg() {
  4345. m.msg = nil
  4346. delete(m.clearedFields, batchmsg.FieldMsg)
  4347. }
  4348. // SetTag sets the "tag" field.
  4349. func (m *BatchMsgMutation) SetTag(s string) {
  4350. m.tag = &s
  4351. }
  4352. // Tag returns the value of the "tag" field in the mutation.
  4353. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  4354. v := m.tag
  4355. if v == nil {
  4356. return
  4357. }
  4358. return *v, true
  4359. }
  4360. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  4361. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4363. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  4364. if !m.op.Is(OpUpdateOne) {
  4365. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  4366. }
  4367. if m.id == nil || m.oldValue == nil {
  4368. return v, errors.New("OldTag requires an ID field in the mutation")
  4369. }
  4370. oldValue, err := m.oldValue(ctx)
  4371. if err != nil {
  4372. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  4373. }
  4374. return oldValue.Tag, nil
  4375. }
  4376. // ClearTag clears the value of the "tag" field.
  4377. func (m *BatchMsgMutation) ClearTag() {
  4378. m.tag = nil
  4379. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  4380. }
  4381. // TagCleared returns if the "tag" field was cleared in this mutation.
  4382. func (m *BatchMsgMutation) TagCleared() bool {
  4383. _, ok := m.clearedFields[batchmsg.FieldTag]
  4384. return ok
  4385. }
  4386. // ResetTag resets all changes to the "tag" field.
  4387. func (m *BatchMsgMutation) ResetTag() {
  4388. m.tag = nil
  4389. delete(m.clearedFields, batchmsg.FieldTag)
  4390. }
  4391. // SetTagids sets the "tagids" field.
  4392. func (m *BatchMsgMutation) SetTagids(s string) {
  4393. m.tagids = &s
  4394. }
  4395. // Tagids returns the value of the "tagids" field in the mutation.
  4396. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  4397. v := m.tagids
  4398. if v == nil {
  4399. return
  4400. }
  4401. return *v, true
  4402. }
  4403. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  4404. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4406. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  4407. if !m.op.Is(OpUpdateOne) {
  4408. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  4409. }
  4410. if m.id == nil || m.oldValue == nil {
  4411. return v, errors.New("OldTagids requires an ID field in the mutation")
  4412. }
  4413. oldValue, err := m.oldValue(ctx)
  4414. if err != nil {
  4415. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  4416. }
  4417. return oldValue.Tagids, nil
  4418. }
  4419. // ClearTagids clears the value of the "tagids" field.
  4420. func (m *BatchMsgMutation) ClearTagids() {
  4421. m.tagids = nil
  4422. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  4423. }
  4424. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  4425. func (m *BatchMsgMutation) TagidsCleared() bool {
  4426. _, ok := m.clearedFields[batchmsg.FieldTagids]
  4427. return ok
  4428. }
  4429. // ResetTagids resets all changes to the "tagids" field.
  4430. func (m *BatchMsgMutation) ResetTagids() {
  4431. m.tagids = nil
  4432. delete(m.clearedFields, batchmsg.FieldTagids)
  4433. }
  4434. // SetTotal sets the "total" field.
  4435. func (m *BatchMsgMutation) SetTotal(i int32) {
  4436. m.total = &i
  4437. m.addtotal = nil
  4438. }
  4439. // Total returns the value of the "total" field in the mutation.
  4440. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  4441. v := m.total
  4442. if v == nil {
  4443. return
  4444. }
  4445. return *v, true
  4446. }
  4447. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  4448. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4450. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  4451. if !m.op.Is(OpUpdateOne) {
  4452. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  4453. }
  4454. if m.id == nil || m.oldValue == nil {
  4455. return v, errors.New("OldTotal requires an ID field in the mutation")
  4456. }
  4457. oldValue, err := m.oldValue(ctx)
  4458. if err != nil {
  4459. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  4460. }
  4461. return oldValue.Total, nil
  4462. }
  4463. // AddTotal adds i to the "total" field.
  4464. func (m *BatchMsgMutation) AddTotal(i int32) {
  4465. if m.addtotal != nil {
  4466. *m.addtotal += i
  4467. } else {
  4468. m.addtotal = &i
  4469. }
  4470. }
  4471. // AddedTotal returns the value that was added to the "total" field in this mutation.
  4472. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  4473. v := m.addtotal
  4474. if v == nil {
  4475. return
  4476. }
  4477. return *v, true
  4478. }
  4479. // ClearTotal clears the value of the "total" field.
  4480. func (m *BatchMsgMutation) ClearTotal() {
  4481. m.total = nil
  4482. m.addtotal = nil
  4483. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  4484. }
  4485. // TotalCleared returns if the "total" field was cleared in this mutation.
  4486. func (m *BatchMsgMutation) TotalCleared() bool {
  4487. _, ok := m.clearedFields[batchmsg.FieldTotal]
  4488. return ok
  4489. }
  4490. // ResetTotal resets all changes to the "total" field.
  4491. func (m *BatchMsgMutation) ResetTotal() {
  4492. m.total = nil
  4493. m.addtotal = nil
  4494. delete(m.clearedFields, batchmsg.FieldTotal)
  4495. }
  4496. // SetSuccess sets the "success" field.
  4497. func (m *BatchMsgMutation) SetSuccess(i int32) {
  4498. m.success = &i
  4499. m.addsuccess = nil
  4500. }
  4501. // Success returns the value of the "success" field in the mutation.
  4502. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  4503. v := m.success
  4504. if v == nil {
  4505. return
  4506. }
  4507. return *v, true
  4508. }
  4509. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  4510. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4512. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  4513. if !m.op.Is(OpUpdateOne) {
  4514. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  4515. }
  4516. if m.id == nil || m.oldValue == nil {
  4517. return v, errors.New("OldSuccess requires an ID field in the mutation")
  4518. }
  4519. oldValue, err := m.oldValue(ctx)
  4520. if err != nil {
  4521. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  4522. }
  4523. return oldValue.Success, nil
  4524. }
  4525. // AddSuccess adds i to the "success" field.
  4526. func (m *BatchMsgMutation) AddSuccess(i int32) {
  4527. if m.addsuccess != nil {
  4528. *m.addsuccess += i
  4529. } else {
  4530. m.addsuccess = &i
  4531. }
  4532. }
  4533. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  4534. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  4535. v := m.addsuccess
  4536. if v == nil {
  4537. return
  4538. }
  4539. return *v, true
  4540. }
  4541. // ClearSuccess clears the value of the "success" field.
  4542. func (m *BatchMsgMutation) ClearSuccess() {
  4543. m.success = nil
  4544. m.addsuccess = nil
  4545. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  4546. }
  4547. // SuccessCleared returns if the "success" field was cleared in this mutation.
  4548. func (m *BatchMsgMutation) SuccessCleared() bool {
  4549. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  4550. return ok
  4551. }
  4552. // ResetSuccess resets all changes to the "success" field.
  4553. func (m *BatchMsgMutation) ResetSuccess() {
  4554. m.success = nil
  4555. m.addsuccess = nil
  4556. delete(m.clearedFields, batchmsg.FieldSuccess)
  4557. }
  4558. // SetFail sets the "fail" field.
  4559. func (m *BatchMsgMutation) SetFail(i int32) {
  4560. m.fail = &i
  4561. m.addfail = nil
  4562. }
  4563. // Fail returns the value of the "fail" field in the mutation.
  4564. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  4565. v := m.fail
  4566. if v == nil {
  4567. return
  4568. }
  4569. return *v, true
  4570. }
  4571. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  4572. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4574. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  4575. if !m.op.Is(OpUpdateOne) {
  4576. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  4577. }
  4578. if m.id == nil || m.oldValue == nil {
  4579. return v, errors.New("OldFail requires an ID field in the mutation")
  4580. }
  4581. oldValue, err := m.oldValue(ctx)
  4582. if err != nil {
  4583. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  4584. }
  4585. return oldValue.Fail, nil
  4586. }
  4587. // AddFail adds i to the "fail" field.
  4588. func (m *BatchMsgMutation) AddFail(i int32) {
  4589. if m.addfail != nil {
  4590. *m.addfail += i
  4591. } else {
  4592. m.addfail = &i
  4593. }
  4594. }
  4595. // AddedFail returns the value that was added to the "fail" field in this mutation.
  4596. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  4597. v := m.addfail
  4598. if v == nil {
  4599. return
  4600. }
  4601. return *v, true
  4602. }
  4603. // ClearFail clears the value of the "fail" field.
  4604. func (m *BatchMsgMutation) ClearFail() {
  4605. m.fail = nil
  4606. m.addfail = nil
  4607. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  4608. }
  4609. // FailCleared returns if the "fail" field was cleared in this mutation.
  4610. func (m *BatchMsgMutation) FailCleared() bool {
  4611. _, ok := m.clearedFields[batchmsg.FieldFail]
  4612. return ok
  4613. }
  4614. // ResetFail resets all changes to the "fail" field.
  4615. func (m *BatchMsgMutation) ResetFail() {
  4616. m.fail = nil
  4617. m.addfail = nil
  4618. delete(m.clearedFields, batchmsg.FieldFail)
  4619. }
  4620. // SetStartTime sets the "start_time" field.
  4621. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  4622. m.start_time = &t
  4623. }
  4624. // StartTime returns the value of the "start_time" field in the mutation.
  4625. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  4626. v := m.start_time
  4627. if v == nil {
  4628. return
  4629. }
  4630. return *v, true
  4631. }
  4632. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  4633. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4635. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  4636. if !m.op.Is(OpUpdateOne) {
  4637. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  4638. }
  4639. if m.id == nil || m.oldValue == nil {
  4640. return v, errors.New("OldStartTime requires an ID field in the mutation")
  4641. }
  4642. oldValue, err := m.oldValue(ctx)
  4643. if err != nil {
  4644. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  4645. }
  4646. return oldValue.StartTime, nil
  4647. }
  4648. // ClearStartTime clears the value of the "start_time" field.
  4649. func (m *BatchMsgMutation) ClearStartTime() {
  4650. m.start_time = nil
  4651. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  4652. }
  4653. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  4654. func (m *BatchMsgMutation) StartTimeCleared() bool {
  4655. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  4656. return ok
  4657. }
  4658. // ResetStartTime resets all changes to the "start_time" field.
  4659. func (m *BatchMsgMutation) ResetStartTime() {
  4660. m.start_time = nil
  4661. delete(m.clearedFields, batchmsg.FieldStartTime)
  4662. }
  4663. // SetStopTime sets the "stop_time" field.
  4664. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  4665. m.stop_time = &t
  4666. }
  4667. // StopTime returns the value of the "stop_time" field in the mutation.
  4668. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  4669. v := m.stop_time
  4670. if v == nil {
  4671. return
  4672. }
  4673. return *v, true
  4674. }
  4675. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  4676. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4678. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  4679. if !m.op.Is(OpUpdateOne) {
  4680. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  4681. }
  4682. if m.id == nil || m.oldValue == nil {
  4683. return v, errors.New("OldStopTime requires an ID field in the mutation")
  4684. }
  4685. oldValue, err := m.oldValue(ctx)
  4686. if err != nil {
  4687. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  4688. }
  4689. return oldValue.StopTime, nil
  4690. }
  4691. // ClearStopTime clears the value of the "stop_time" field.
  4692. func (m *BatchMsgMutation) ClearStopTime() {
  4693. m.stop_time = nil
  4694. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  4695. }
  4696. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  4697. func (m *BatchMsgMutation) StopTimeCleared() bool {
  4698. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  4699. return ok
  4700. }
  4701. // ResetStopTime resets all changes to the "stop_time" field.
  4702. func (m *BatchMsgMutation) ResetStopTime() {
  4703. m.stop_time = nil
  4704. delete(m.clearedFields, batchmsg.FieldStopTime)
  4705. }
  4706. // SetSendTime sets the "send_time" field.
  4707. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  4708. m.send_time = &t
  4709. }
  4710. // SendTime returns the value of the "send_time" field in the mutation.
  4711. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  4712. v := m.send_time
  4713. if v == nil {
  4714. return
  4715. }
  4716. return *v, true
  4717. }
  4718. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  4719. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4721. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  4722. if !m.op.Is(OpUpdateOne) {
  4723. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  4724. }
  4725. if m.id == nil || m.oldValue == nil {
  4726. return v, errors.New("OldSendTime requires an ID field in the mutation")
  4727. }
  4728. oldValue, err := m.oldValue(ctx)
  4729. if err != nil {
  4730. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  4731. }
  4732. return oldValue.SendTime, nil
  4733. }
  4734. // ClearSendTime clears the value of the "send_time" field.
  4735. func (m *BatchMsgMutation) ClearSendTime() {
  4736. m.send_time = nil
  4737. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  4738. }
  4739. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  4740. func (m *BatchMsgMutation) SendTimeCleared() bool {
  4741. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  4742. return ok
  4743. }
  4744. // ResetSendTime resets all changes to the "send_time" field.
  4745. func (m *BatchMsgMutation) ResetSendTime() {
  4746. m.send_time = nil
  4747. delete(m.clearedFields, batchmsg.FieldSendTime)
  4748. }
  4749. // SetType sets the "type" field.
  4750. func (m *BatchMsgMutation) SetType(i int32) {
  4751. m._type = &i
  4752. m.add_type = nil
  4753. }
  4754. // GetType returns the value of the "type" field in the mutation.
  4755. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  4756. v := m._type
  4757. if v == nil {
  4758. return
  4759. }
  4760. return *v, true
  4761. }
  4762. // OldType returns the old "type" field's value of the BatchMsg entity.
  4763. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4764. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4765. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  4766. if !m.op.Is(OpUpdateOne) {
  4767. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4768. }
  4769. if m.id == nil || m.oldValue == nil {
  4770. return v, errors.New("OldType requires an ID field in the mutation")
  4771. }
  4772. oldValue, err := m.oldValue(ctx)
  4773. if err != nil {
  4774. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4775. }
  4776. return oldValue.Type, nil
  4777. }
  4778. // AddType adds i to the "type" field.
  4779. func (m *BatchMsgMutation) AddType(i int32) {
  4780. if m.add_type != nil {
  4781. *m.add_type += i
  4782. } else {
  4783. m.add_type = &i
  4784. }
  4785. }
  4786. // AddedType returns the value that was added to the "type" field in this mutation.
  4787. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4788. v := m.add_type
  4789. if v == nil {
  4790. return
  4791. }
  4792. return *v, true
  4793. }
  4794. // ClearType clears the value of the "type" field.
  4795. func (m *BatchMsgMutation) ClearType() {
  4796. m._type = nil
  4797. m.add_type = nil
  4798. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4799. }
  4800. // TypeCleared returns if the "type" field was cleared in this mutation.
  4801. func (m *BatchMsgMutation) TypeCleared() bool {
  4802. _, ok := m.clearedFields[batchmsg.FieldType]
  4803. return ok
  4804. }
  4805. // ResetType resets all changes to the "type" field.
  4806. func (m *BatchMsgMutation) ResetType() {
  4807. m._type = nil
  4808. m.add_type = nil
  4809. delete(m.clearedFields, batchmsg.FieldType)
  4810. }
  4811. // SetOrganizationID sets the "organization_id" field.
  4812. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4813. m.organization_id = &u
  4814. m.addorganization_id = nil
  4815. }
  4816. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4817. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4818. v := m.organization_id
  4819. if v == nil {
  4820. return
  4821. }
  4822. return *v, true
  4823. }
  4824. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4825. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4827. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4828. if !m.op.Is(OpUpdateOne) {
  4829. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4830. }
  4831. if m.id == nil || m.oldValue == nil {
  4832. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4833. }
  4834. oldValue, err := m.oldValue(ctx)
  4835. if err != nil {
  4836. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4837. }
  4838. return oldValue.OrganizationID, nil
  4839. }
  4840. // AddOrganizationID adds u to the "organization_id" field.
  4841. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4842. if m.addorganization_id != nil {
  4843. *m.addorganization_id += u
  4844. } else {
  4845. m.addorganization_id = &u
  4846. }
  4847. }
  4848. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4849. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4850. v := m.addorganization_id
  4851. if v == nil {
  4852. return
  4853. }
  4854. return *v, true
  4855. }
  4856. // ResetOrganizationID resets all changes to the "organization_id" field.
  4857. func (m *BatchMsgMutation) ResetOrganizationID() {
  4858. m.organization_id = nil
  4859. m.addorganization_id = nil
  4860. }
  4861. // Where appends a list predicates to the BatchMsgMutation builder.
  4862. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  4863. m.predicates = append(m.predicates, ps...)
  4864. }
  4865. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  4866. // users can use type-assertion to append predicates that do not depend on any generated package.
  4867. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  4868. p := make([]predicate.BatchMsg, len(ps))
  4869. for i := range ps {
  4870. p[i] = ps[i]
  4871. }
  4872. m.Where(p...)
  4873. }
  4874. // Op returns the operation name.
  4875. func (m *BatchMsgMutation) Op() Op {
  4876. return m.op
  4877. }
  4878. // SetOp allows setting the mutation operation.
  4879. func (m *BatchMsgMutation) SetOp(op Op) {
  4880. m.op = op
  4881. }
  4882. // Type returns the node type of this mutation (BatchMsg).
  4883. func (m *BatchMsgMutation) Type() string {
  4884. return m.typ
  4885. }
  4886. // Fields returns all fields that were changed during this mutation. Note that in
  4887. // order to get all numeric fields that were incremented/decremented, call
  4888. // AddedFields().
  4889. func (m *BatchMsgMutation) Fields() []string {
  4890. fields := make([]string, 0, 18)
  4891. if m.created_at != nil {
  4892. fields = append(fields, batchmsg.FieldCreatedAt)
  4893. }
  4894. if m.updated_at != nil {
  4895. fields = append(fields, batchmsg.FieldUpdatedAt)
  4896. }
  4897. if m.deleted_at != nil {
  4898. fields = append(fields, batchmsg.FieldDeletedAt)
  4899. }
  4900. if m.status != nil {
  4901. fields = append(fields, batchmsg.FieldStatus)
  4902. }
  4903. if m.batch_no != nil {
  4904. fields = append(fields, batchmsg.FieldBatchNo)
  4905. }
  4906. if m.task_name != nil {
  4907. fields = append(fields, batchmsg.FieldTaskName)
  4908. }
  4909. if m.fromwxid != nil {
  4910. fields = append(fields, batchmsg.FieldFromwxid)
  4911. }
  4912. if m.msg != nil {
  4913. fields = append(fields, batchmsg.FieldMsg)
  4914. }
  4915. if m.tag != nil {
  4916. fields = append(fields, batchmsg.FieldTag)
  4917. }
  4918. if m.tagids != nil {
  4919. fields = append(fields, batchmsg.FieldTagids)
  4920. }
  4921. if m.total != nil {
  4922. fields = append(fields, batchmsg.FieldTotal)
  4923. }
  4924. if m.success != nil {
  4925. fields = append(fields, batchmsg.FieldSuccess)
  4926. }
  4927. if m.fail != nil {
  4928. fields = append(fields, batchmsg.FieldFail)
  4929. }
  4930. if m.start_time != nil {
  4931. fields = append(fields, batchmsg.FieldStartTime)
  4932. }
  4933. if m.stop_time != nil {
  4934. fields = append(fields, batchmsg.FieldStopTime)
  4935. }
  4936. if m.send_time != nil {
  4937. fields = append(fields, batchmsg.FieldSendTime)
  4938. }
  4939. if m._type != nil {
  4940. fields = append(fields, batchmsg.FieldType)
  4941. }
  4942. if m.organization_id != nil {
  4943. fields = append(fields, batchmsg.FieldOrganizationID)
  4944. }
  4945. return fields
  4946. }
  4947. // Field returns the value of a field with the given name. The second boolean
  4948. // return value indicates that this field was not set, or was not defined in the
  4949. // schema.
  4950. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  4951. switch name {
  4952. case batchmsg.FieldCreatedAt:
  4953. return m.CreatedAt()
  4954. case batchmsg.FieldUpdatedAt:
  4955. return m.UpdatedAt()
  4956. case batchmsg.FieldDeletedAt:
  4957. return m.DeletedAt()
  4958. case batchmsg.FieldStatus:
  4959. return m.Status()
  4960. case batchmsg.FieldBatchNo:
  4961. return m.BatchNo()
  4962. case batchmsg.FieldTaskName:
  4963. return m.TaskName()
  4964. case batchmsg.FieldFromwxid:
  4965. return m.Fromwxid()
  4966. case batchmsg.FieldMsg:
  4967. return m.Msg()
  4968. case batchmsg.FieldTag:
  4969. return m.Tag()
  4970. case batchmsg.FieldTagids:
  4971. return m.Tagids()
  4972. case batchmsg.FieldTotal:
  4973. return m.Total()
  4974. case batchmsg.FieldSuccess:
  4975. return m.Success()
  4976. case batchmsg.FieldFail:
  4977. return m.Fail()
  4978. case batchmsg.FieldStartTime:
  4979. return m.StartTime()
  4980. case batchmsg.FieldStopTime:
  4981. return m.StopTime()
  4982. case batchmsg.FieldSendTime:
  4983. return m.SendTime()
  4984. case batchmsg.FieldType:
  4985. return m.GetType()
  4986. case batchmsg.FieldOrganizationID:
  4987. return m.OrganizationID()
  4988. }
  4989. return nil, false
  4990. }
  4991. // OldField returns the old value of the field from the database. An error is
  4992. // returned if the mutation operation is not UpdateOne, or the query to the
  4993. // database failed.
  4994. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4995. switch name {
  4996. case batchmsg.FieldCreatedAt:
  4997. return m.OldCreatedAt(ctx)
  4998. case batchmsg.FieldUpdatedAt:
  4999. return m.OldUpdatedAt(ctx)
  5000. case batchmsg.FieldDeletedAt:
  5001. return m.OldDeletedAt(ctx)
  5002. case batchmsg.FieldStatus:
  5003. return m.OldStatus(ctx)
  5004. case batchmsg.FieldBatchNo:
  5005. return m.OldBatchNo(ctx)
  5006. case batchmsg.FieldTaskName:
  5007. return m.OldTaskName(ctx)
  5008. case batchmsg.FieldFromwxid:
  5009. return m.OldFromwxid(ctx)
  5010. case batchmsg.FieldMsg:
  5011. return m.OldMsg(ctx)
  5012. case batchmsg.FieldTag:
  5013. return m.OldTag(ctx)
  5014. case batchmsg.FieldTagids:
  5015. return m.OldTagids(ctx)
  5016. case batchmsg.FieldTotal:
  5017. return m.OldTotal(ctx)
  5018. case batchmsg.FieldSuccess:
  5019. return m.OldSuccess(ctx)
  5020. case batchmsg.FieldFail:
  5021. return m.OldFail(ctx)
  5022. case batchmsg.FieldStartTime:
  5023. return m.OldStartTime(ctx)
  5024. case batchmsg.FieldStopTime:
  5025. return m.OldStopTime(ctx)
  5026. case batchmsg.FieldSendTime:
  5027. return m.OldSendTime(ctx)
  5028. case batchmsg.FieldType:
  5029. return m.OldType(ctx)
  5030. case batchmsg.FieldOrganizationID:
  5031. return m.OldOrganizationID(ctx)
  5032. }
  5033. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  5034. }
  5035. // SetField sets the value of a field with the given name. It returns an error if
  5036. // the field is not defined in the schema, or if the type mismatched the field
  5037. // type.
  5038. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  5039. switch name {
  5040. case batchmsg.FieldCreatedAt:
  5041. v, ok := value.(time.Time)
  5042. if !ok {
  5043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5044. }
  5045. m.SetCreatedAt(v)
  5046. return nil
  5047. case batchmsg.FieldUpdatedAt:
  5048. v, ok := value.(time.Time)
  5049. if !ok {
  5050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5051. }
  5052. m.SetUpdatedAt(v)
  5053. return nil
  5054. case batchmsg.FieldDeletedAt:
  5055. v, ok := value.(time.Time)
  5056. if !ok {
  5057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5058. }
  5059. m.SetDeletedAt(v)
  5060. return nil
  5061. case batchmsg.FieldStatus:
  5062. v, ok := value.(uint8)
  5063. if !ok {
  5064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5065. }
  5066. m.SetStatus(v)
  5067. return nil
  5068. case batchmsg.FieldBatchNo:
  5069. v, ok := value.(string)
  5070. if !ok {
  5071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5072. }
  5073. m.SetBatchNo(v)
  5074. return nil
  5075. case batchmsg.FieldTaskName:
  5076. v, ok := value.(string)
  5077. if !ok {
  5078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5079. }
  5080. m.SetTaskName(v)
  5081. return nil
  5082. case batchmsg.FieldFromwxid:
  5083. v, ok := value.(string)
  5084. if !ok {
  5085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5086. }
  5087. m.SetFromwxid(v)
  5088. return nil
  5089. case batchmsg.FieldMsg:
  5090. v, ok := value.(string)
  5091. if !ok {
  5092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5093. }
  5094. m.SetMsg(v)
  5095. return nil
  5096. case batchmsg.FieldTag:
  5097. v, ok := value.(string)
  5098. if !ok {
  5099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5100. }
  5101. m.SetTag(v)
  5102. return nil
  5103. case batchmsg.FieldTagids:
  5104. v, ok := value.(string)
  5105. if !ok {
  5106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5107. }
  5108. m.SetTagids(v)
  5109. return nil
  5110. case batchmsg.FieldTotal:
  5111. v, ok := value.(int32)
  5112. if !ok {
  5113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5114. }
  5115. m.SetTotal(v)
  5116. return nil
  5117. case batchmsg.FieldSuccess:
  5118. v, ok := value.(int32)
  5119. if !ok {
  5120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5121. }
  5122. m.SetSuccess(v)
  5123. return nil
  5124. case batchmsg.FieldFail:
  5125. v, ok := value.(int32)
  5126. if !ok {
  5127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5128. }
  5129. m.SetFail(v)
  5130. return nil
  5131. case batchmsg.FieldStartTime:
  5132. v, ok := value.(time.Time)
  5133. if !ok {
  5134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5135. }
  5136. m.SetStartTime(v)
  5137. return nil
  5138. case batchmsg.FieldStopTime:
  5139. v, ok := value.(time.Time)
  5140. if !ok {
  5141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5142. }
  5143. m.SetStopTime(v)
  5144. return nil
  5145. case batchmsg.FieldSendTime:
  5146. v, ok := value.(time.Time)
  5147. if !ok {
  5148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5149. }
  5150. m.SetSendTime(v)
  5151. return nil
  5152. case batchmsg.FieldType:
  5153. v, ok := value.(int32)
  5154. if !ok {
  5155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5156. }
  5157. m.SetType(v)
  5158. return nil
  5159. case batchmsg.FieldOrganizationID:
  5160. v, ok := value.(uint64)
  5161. if !ok {
  5162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5163. }
  5164. m.SetOrganizationID(v)
  5165. return nil
  5166. }
  5167. return fmt.Errorf("unknown BatchMsg field %s", name)
  5168. }
  5169. // AddedFields returns all numeric fields that were incremented/decremented during
  5170. // this mutation.
  5171. func (m *BatchMsgMutation) AddedFields() []string {
  5172. var fields []string
  5173. if m.addstatus != nil {
  5174. fields = append(fields, batchmsg.FieldStatus)
  5175. }
  5176. if m.addtotal != nil {
  5177. fields = append(fields, batchmsg.FieldTotal)
  5178. }
  5179. if m.addsuccess != nil {
  5180. fields = append(fields, batchmsg.FieldSuccess)
  5181. }
  5182. if m.addfail != nil {
  5183. fields = append(fields, batchmsg.FieldFail)
  5184. }
  5185. if m.add_type != nil {
  5186. fields = append(fields, batchmsg.FieldType)
  5187. }
  5188. if m.addorganization_id != nil {
  5189. fields = append(fields, batchmsg.FieldOrganizationID)
  5190. }
  5191. return fields
  5192. }
  5193. // AddedField returns the numeric value that was incremented/decremented on a field
  5194. // with the given name. The second boolean return value indicates that this field
  5195. // was not set, or was not defined in the schema.
  5196. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  5197. switch name {
  5198. case batchmsg.FieldStatus:
  5199. return m.AddedStatus()
  5200. case batchmsg.FieldTotal:
  5201. return m.AddedTotal()
  5202. case batchmsg.FieldSuccess:
  5203. return m.AddedSuccess()
  5204. case batchmsg.FieldFail:
  5205. return m.AddedFail()
  5206. case batchmsg.FieldType:
  5207. return m.AddedType()
  5208. case batchmsg.FieldOrganizationID:
  5209. return m.AddedOrganizationID()
  5210. }
  5211. return nil, false
  5212. }
  5213. // AddField adds the value to the field with the given name. It returns an error if
  5214. // the field is not defined in the schema, or if the type mismatched the field
  5215. // type.
  5216. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  5217. switch name {
  5218. case batchmsg.FieldStatus:
  5219. v, ok := value.(int8)
  5220. if !ok {
  5221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5222. }
  5223. m.AddStatus(v)
  5224. return nil
  5225. case batchmsg.FieldTotal:
  5226. v, ok := value.(int32)
  5227. if !ok {
  5228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5229. }
  5230. m.AddTotal(v)
  5231. return nil
  5232. case batchmsg.FieldSuccess:
  5233. v, ok := value.(int32)
  5234. if !ok {
  5235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5236. }
  5237. m.AddSuccess(v)
  5238. return nil
  5239. case batchmsg.FieldFail:
  5240. v, ok := value.(int32)
  5241. if !ok {
  5242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5243. }
  5244. m.AddFail(v)
  5245. return nil
  5246. case batchmsg.FieldType:
  5247. v, ok := value.(int32)
  5248. if !ok {
  5249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5250. }
  5251. m.AddType(v)
  5252. return nil
  5253. case batchmsg.FieldOrganizationID:
  5254. v, ok := value.(int64)
  5255. if !ok {
  5256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5257. }
  5258. m.AddOrganizationID(v)
  5259. return nil
  5260. }
  5261. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  5262. }
  5263. // ClearedFields returns all nullable fields that were cleared during this
  5264. // mutation.
  5265. func (m *BatchMsgMutation) ClearedFields() []string {
  5266. var fields []string
  5267. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  5268. fields = append(fields, batchmsg.FieldDeletedAt)
  5269. }
  5270. if m.FieldCleared(batchmsg.FieldStatus) {
  5271. fields = append(fields, batchmsg.FieldStatus)
  5272. }
  5273. if m.FieldCleared(batchmsg.FieldBatchNo) {
  5274. fields = append(fields, batchmsg.FieldBatchNo)
  5275. }
  5276. if m.FieldCleared(batchmsg.FieldTaskName) {
  5277. fields = append(fields, batchmsg.FieldTaskName)
  5278. }
  5279. if m.FieldCleared(batchmsg.FieldFromwxid) {
  5280. fields = append(fields, batchmsg.FieldFromwxid)
  5281. }
  5282. if m.FieldCleared(batchmsg.FieldMsg) {
  5283. fields = append(fields, batchmsg.FieldMsg)
  5284. }
  5285. if m.FieldCleared(batchmsg.FieldTag) {
  5286. fields = append(fields, batchmsg.FieldTag)
  5287. }
  5288. if m.FieldCleared(batchmsg.FieldTagids) {
  5289. fields = append(fields, batchmsg.FieldTagids)
  5290. }
  5291. if m.FieldCleared(batchmsg.FieldTotal) {
  5292. fields = append(fields, batchmsg.FieldTotal)
  5293. }
  5294. if m.FieldCleared(batchmsg.FieldSuccess) {
  5295. fields = append(fields, batchmsg.FieldSuccess)
  5296. }
  5297. if m.FieldCleared(batchmsg.FieldFail) {
  5298. fields = append(fields, batchmsg.FieldFail)
  5299. }
  5300. if m.FieldCleared(batchmsg.FieldStartTime) {
  5301. fields = append(fields, batchmsg.FieldStartTime)
  5302. }
  5303. if m.FieldCleared(batchmsg.FieldStopTime) {
  5304. fields = append(fields, batchmsg.FieldStopTime)
  5305. }
  5306. if m.FieldCleared(batchmsg.FieldSendTime) {
  5307. fields = append(fields, batchmsg.FieldSendTime)
  5308. }
  5309. if m.FieldCleared(batchmsg.FieldType) {
  5310. fields = append(fields, batchmsg.FieldType)
  5311. }
  5312. return fields
  5313. }
  5314. // FieldCleared returns a boolean indicating if a field with the given name was
  5315. // cleared in this mutation.
  5316. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  5317. _, ok := m.clearedFields[name]
  5318. return ok
  5319. }
  5320. // ClearField clears the value of the field with the given name. It returns an
  5321. // error if the field is not defined in the schema.
  5322. func (m *BatchMsgMutation) ClearField(name string) error {
  5323. switch name {
  5324. case batchmsg.FieldDeletedAt:
  5325. m.ClearDeletedAt()
  5326. return nil
  5327. case batchmsg.FieldStatus:
  5328. m.ClearStatus()
  5329. return nil
  5330. case batchmsg.FieldBatchNo:
  5331. m.ClearBatchNo()
  5332. return nil
  5333. case batchmsg.FieldTaskName:
  5334. m.ClearTaskName()
  5335. return nil
  5336. case batchmsg.FieldFromwxid:
  5337. m.ClearFromwxid()
  5338. return nil
  5339. case batchmsg.FieldMsg:
  5340. m.ClearMsg()
  5341. return nil
  5342. case batchmsg.FieldTag:
  5343. m.ClearTag()
  5344. return nil
  5345. case batchmsg.FieldTagids:
  5346. m.ClearTagids()
  5347. return nil
  5348. case batchmsg.FieldTotal:
  5349. m.ClearTotal()
  5350. return nil
  5351. case batchmsg.FieldSuccess:
  5352. m.ClearSuccess()
  5353. return nil
  5354. case batchmsg.FieldFail:
  5355. m.ClearFail()
  5356. return nil
  5357. case batchmsg.FieldStartTime:
  5358. m.ClearStartTime()
  5359. return nil
  5360. case batchmsg.FieldStopTime:
  5361. m.ClearStopTime()
  5362. return nil
  5363. case batchmsg.FieldSendTime:
  5364. m.ClearSendTime()
  5365. return nil
  5366. case batchmsg.FieldType:
  5367. m.ClearType()
  5368. return nil
  5369. }
  5370. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  5371. }
  5372. // ResetField resets all changes in the mutation for the field with the given name.
  5373. // It returns an error if the field is not defined in the schema.
  5374. func (m *BatchMsgMutation) ResetField(name string) error {
  5375. switch name {
  5376. case batchmsg.FieldCreatedAt:
  5377. m.ResetCreatedAt()
  5378. return nil
  5379. case batchmsg.FieldUpdatedAt:
  5380. m.ResetUpdatedAt()
  5381. return nil
  5382. case batchmsg.FieldDeletedAt:
  5383. m.ResetDeletedAt()
  5384. return nil
  5385. case batchmsg.FieldStatus:
  5386. m.ResetStatus()
  5387. return nil
  5388. case batchmsg.FieldBatchNo:
  5389. m.ResetBatchNo()
  5390. return nil
  5391. case batchmsg.FieldTaskName:
  5392. m.ResetTaskName()
  5393. return nil
  5394. case batchmsg.FieldFromwxid:
  5395. m.ResetFromwxid()
  5396. return nil
  5397. case batchmsg.FieldMsg:
  5398. m.ResetMsg()
  5399. return nil
  5400. case batchmsg.FieldTag:
  5401. m.ResetTag()
  5402. return nil
  5403. case batchmsg.FieldTagids:
  5404. m.ResetTagids()
  5405. return nil
  5406. case batchmsg.FieldTotal:
  5407. m.ResetTotal()
  5408. return nil
  5409. case batchmsg.FieldSuccess:
  5410. m.ResetSuccess()
  5411. return nil
  5412. case batchmsg.FieldFail:
  5413. m.ResetFail()
  5414. return nil
  5415. case batchmsg.FieldStartTime:
  5416. m.ResetStartTime()
  5417. return nil
  5418. case batchmsg.FieldStopTime:
  5419. m.ResetStopTime()
  5420. return nil
  5421. case batchmsg.FieldSendTime:
  5422. m.ResetSendTime()
  5423. return nil
  5424. case batchmsg.FieldType:
  5425. m.ResetType()
  5426. return nil
  5427. case batchmsg.FieldOrganizationID:
  5428. m.ResetOrganizationID()
  5429. return nil
  5430. }
  5431. return fmt.Errorf("unknown BatchMsg field %s", name)
  5432. }
  5433. // AddedEdges returns all edge names that were set/added in this mutation.
  5434. func (m *BatchMsgMutation) AddedEdges() []string {
  5435. edges := make([]string, 0, 0)
  5436. return edges
  5437. }
  5438. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5439. // name in this mutation.
  5440. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  5441. return nil
  5442. }
  5443. // RemovedEdges returns all edge names that were removed in this mutation.
  5444. func (m *BatchMsgMutation) RemovedEdges() []string {
  5445. edges := make([]string, 0, 0)
  5446. return edges
  5447. }
  5448. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5449. // the given name in this mutation.
  5450. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  5451. return nil
  5452. }
  5453. // ClearedEdges returns all edge names that were cleared in this mutation.
  5454. func (m *BatchMsgMutation) ClearedEdges() []string {
  5455. edges := make([]string, 0, 0)
  5456. return edges
  5457. }
  5458. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5459. // was cleared in this mutation.
  5460. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  5461. return false
  5462. }
  5463. // ClearEdge clears the value of the edge with the given name. It returns an error
  5464. // if that edge is not defined in the schema.
  5465. func (m *BatchMsgMutation) ClearEdge(name string) error {
  5466. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  5467. }
  5468. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5469. // It returns an error if the edge is not defined in the schema.
  5470. func (m *BatchMsgMutation) ResetEdge(name string) error {
  5471. return fmt.Errorf("unknown BatchMsg edge %s", name)
  5472. }
  5473. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  5474. type CategoryMutation struct {
  5475. config
  5476. op Op
  5477. typ string
  5478. id *uint64
  5479. created_at *time.Time
  5480. updated_at *time.Time
  5481. deleted_at *time.Time
  5482. name *string
  5483. organization_id *uint64
  5484. addorganization_id *int64
  5485. clearedFields map[string]struct{}
  5486. done bool
  5487. oldValue func(context.Context) (*Category, error)
  5488. predicates []predicate.Category
  5489. }
  5490. var _ ent.Mutation = (*CategoryMutation)(nil)
  5491. // categoryOption allows management of the mutation configuration using functional options.
  5492. type categoryOption func(*CategoryMutation)
  5493. // newCategoryMutation creates new mutation for the Category entity.
  5494. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  5495. m := &CategoryMutation{
  5496. config: c,
  5497. op: op,
  5498. typ: TypeCategory,
  5499. clearedFields: make(map[string]struct{}),
  5500. }
  5501. for _, opt := range opts {
  5502. opt(m)
  5503. }
  5504. return m
  5505. }
  5506. // withCategoryID sets the ID field of the mutation.
  5507. func withCategoryID(id uint64) categoryOption {
  5508. return func(m *CategoryMutation) {
  5509. var (
  5510. err error
  5511. once sync.Once
  5512. value *Category
  5513. )
  5514. m.oldValue = func(ctx context.Context) (*Category, error) {
  5515. once.Do(func() {
  5516. if m.done {
  5517. err = errors.New("querying old values post mutation is not allowed")
  5518. } else {
  5519. value, err = m.Client().Category.Get(ctx, id)
  5520. }
  5521. })
  5522. return value, err
  5523. }
  5524. m.id = &id
  5525. }
  5526. }
  5527. // withCategory sets the old Category of the mutation.
  5528. func withCategory(node *Category) categoryOption {
  5529. return func(m *CategoryMutation) {
  5530. m.oldValue = func(context.Context) (*Category, error) {
  5531. return node, nil
  5532. }
  5533. m.id = &node.ID
  5534. }
  5535. }
  5536. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5537. // executed in a transaction (ent.Tx), a transactional client is returned.
  5538. func (m CategoryMutation) Client() *Client {
  5539. client := &Client{config: m.config}
  5540. client.init()
  5541. return client
  5542. }
  5543. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5544. // it returns an error otherwise.
  5545. func (m CategoryMutation) Tx() (*Tx, error) {
  5546. if _, ok := m.driver.(*txDriver); !ok {
  5547. return nil, errors.New("ent: mutation is not running in a transaction")
  5548. }
  5549. tx := &Tx{config: m.config}
  5550. tx.init()
  5551. return tx, nil
  5552. }
  5553. // SetID sets the value of the id field. Note that this
  5554. // operation is only accepted on creation of Category entities.
  5555. func (m *CategoryMutation) SetID(id uint64) {
  5556. m.id = &id
  5557. }
  5558. // ID returns the ID value in the mutation. Note that the ID is only available
  5559. // if it was provided to the builder or after it was returned from the database.
  5560. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  5561. if m.id == nil {
  5562. return
  5563. }
  5564. return *m.id, true
  5565. }
  5566. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5567. // That means, if the mutation is applied within a transaction with an isolation level such
  5568. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5569. // or updated by the mutation.
  5570. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  5571. switch {
  5572. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5573. id, exists := m.ID()
  5574. if exists {
  5575. return []uint64{id}, nil
  5576. }
  5577. fallthrough
  5578. case m.op.Is(OpUpdate | OpDelete):
  5579. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  5580. default:
  5581. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5582. }
  5583. }
  5584. // SetCreatedAt sets the "created_at" field.
  5585. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  5586. m.created_at = &t
  5587. }
  5588. // CreatedAt returns the value of the "created_at" field in the mutation.
  5589. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  5590. v := m.created_at
  5591. if v == nil {
  5592. return
  5593. }
  5594. return *v, true
  5595. }
  5596. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  5597. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5599. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5600. if !m.op.Is(OpUpdateOne) {
  5601. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5602. }
  5603. if m.id == nil || m.oldValue == nil {
  5604. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5605. }
  5606. oldValue, err := m.oldValue(ctx)
  5607. if err != nil {
  5608. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5609. }
  5610. return oldValue.CreatedAt, nil
  5611. }
  5612. // ResetCreatedAt resets all changes to the "created_at" field.
  5613. func (m *CategoryMutation) ResetCreatedAt() {
  5614. m.created_at = nil
  5615. }
  5616. // SetUpdatedAt sets the "updated_at" field.
  5617. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  5618. m.updated_at = &t
  5619. }
  5620. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5621. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  5622. v := m.updated_at
  5623. if v == nil {
  5624. return
  5625. }
  5626. return *v, true
  5627. }
  5628. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  5629. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5631. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5632. if !m.op.Is(OpUpdateOne) {
  5633. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5634. }
  5635. if m.id == nil || m.oldValue == nil {
  5636. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5637. }
  5638. oldValue, err := m.oldValue(ctx)
  5639. if err != nil {
  5640. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5641. }
  5642. return oldValue.UpdatedAt, nil
  5643. }
  5644. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5645. func (m *CategoryMutation) ResetUpdatedAt() {
  5646. m.updated_at = nil
  5647. }
  5648. // SetDeletedAt sets the "deleted_at" field.
  5649. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  5650. m.deleted_at = &t
  5651. }
  5652. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5653. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  5654. v := m.deleted_at
  5655. if v == nil {
  5656. return
  5657. }
  5658. return *v, true
  5659. }
  5660. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  5661. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5663. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5664. if !m.op.Is(OpUpdateOne) {
  5665. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5666. }
  5667. if m.id == nil || m.oldValue == nil {
  5668. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5669. }
  5670. oldValue, err := m.oldValue(ctx)
  5671. if err != nil {
  5672. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5673. }
  5674. return oldValue.DeletedAt, nil
  5675. }
  5676. // ClearDeletedAt clears the value of the "deleted_at" field.
  5677. func (m *CategoryMutation) ClearDeletedAt() {
  5678. m.deleted_at = nil
  5679. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  5680. }
  5681. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5682. func (m *CategoryMutation) DeletedAtCleared() bool {
  5683. _, ok := m.clearedFields[category.FieldDeletedAt]
  5684. return ok
  5685. }
  5686. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5687. func (m *CategoryMutation) ResetDeletedAt() {
  5688. m.deleted_at = nil
  5689. delete(m.clearedFields, category.FieldDeletedAt)
  5690. }
  5691. // SetName sets the "name" field.
  5692. func (m *CategoryMutation) SetName(s string) {
  5693. m.name = &s
  5694. }
  5695. // Name returns the value of the "name" field in the mutation.
  5696. func (m *CategoryMutation) Name() (r string, exists bool) {
  5697. v := m.name
  5698. if v == nil {
  5699. return
  5700. }
  5701. return *v, true
  5702. }
  5703. // OldName returns the old "name" field's value of the Category entity.
  5704. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5705. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5706. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  5707. if !m.op.Is(OpUpdateOne) {
  5708. return v, errors.New("OldName is only allowed on UpdateOne operations")
  5709. }
  5710. if m.id == nil || m.oldValue == nil {
  5711. return v, errors.New("OldName requires an ID field in the mutation")
  5712. }
  5713. oldValue, err := m.oldValue(ctx)
  5714. if err != nil {
  5715. return v, fmt.Errorf("querying old value for OldName: %w", err)
  5716. }
  5717. return oldValue.Name, nil
  5718. }
  5719. // ResetName resets all changes to the "name" field.
  5720. func (m *CategoryMutation) ResetName() {
  5721. m.name = nil
  5722. }
  5723. // SetOrganizationID sets the "organization_id" field.
  5724. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  5725. m.organization_id = &u
  5726. m.addorganization_id = nil
  5727. }
  5728. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5729. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  5730. v := m.organization_id
  5731. if v == nil {
  5732. return
  5733. }
  5734. return *v, true
  5735. }
  5736. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  5737. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5739. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5740. if !m.op.Is(OpUpdateOne) {
  5741. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5742. }
  5743. if m.id == nil || m.oldValue == nil {
  5744. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5745. }
  5746. oldValue, err := m.oldValue(ctx)
  5747. if err != nil {
  5748. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5749. }
  5750. return oldValue.OrganizationID, nil
  5751. }
  5752. // AddOrganizationID adds u to the "organization_id" field.
  5753. func (m *CategoryMutation) AddOrganizationID(u int64) {
  5754. if m.addorganization_id != nil {
  5755. *m.addorganization_id += u
  5756. } else {
  5757. m.addorganization_id = &u
  5758. }
  5759. }
  5760. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5761. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  5762. v := m.addorganization_id
  5763. if v == nil {
  5764. return
  5765. }
  5766. return *v, true
  5767. }
  5768. // ResetOrganizationID resets all changes to the "organization_id" field.
  5769. func (m *CategoryMutation) ResetOrganizationID() {
  5770. m.organization_id = nil
  5771. m.addorganization_id = nil
  5772. }
  5773. // Where appends a list predicates to the CategoryMutation builder.
  5774. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  5775. m.predicates = append(m.predicates, ps...)
  5776. }
  5777. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  5778. // users can use type-assertion to append predicates that do not depend on any generated package.
  5779. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  5780. p := make([]predicate.Category, len(ps))
  5781. for i := range ps {
  5782. p[i] = ps[i]
  5783. }
  5784. m.Where(p...)
  5785. }
  5786. // Op returns the operation name.
  5787. func (m *CategoryMutation) Op() Op {
  5788. return m.op
  5789. }
  5790. // SetOp allows setting the mutation operation.
  5791. func (m *CategoryMutation) SetOp(op Op) {
  5792. m.op = op
  5793. }
  5794. // Type returns the node type of this mutation (Category).
  5795. func (m *CategoryMutation) Type() string {
  5796. return m.typ
  5797. }
  5798. // Fields returns all fields that were changed during this mutation. Note that in
  5799. // order to get all numeric fields that were incremented/decremented, call
  5800. // AddedFields().
  5801. func (m *CategoryMutation) Fields() []string {
  5802. fields := make([]string, 0, 5)
  5803. if m.created_at != nil {
  5804. fields = append(fields, category.FieldCreatedAt)
  5805. }
  5806. if m.updated_at != nil {
  5807. fields = append(fields, category.FieldUpdatedAt)
  5808. }
  5809. if m.deleted_at != nil {
  5810. fields = append(fields, category.FieldDeletedAt)
  5811. }
  5812. if m.name != nil {
  5813. fields = append(fields, category.FieldName)
  5814. }
  5815. if m.organization_id != nil {
  5816. fields = append(fields, category.FieldOrganizationID)
  5817. }
  5818. return fields
  5819. }
  5820. // Field returns the value of a field with the given name. The second boolean
  5821. // return value indicates that this field was not set, or was not defined in the
  5822. // schema.
  5823. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  5824. switch name {
  5825. case category.FieldCreatedAt:
  5826. return m.CreatedAt()
  5827. case category.FieldUpdatedAt:
  5828. return m.UpdatedAt()
  5829. case category.FieldDeletedAt:
  5830. return m.DeletedAt()
  5831. case category.FieldName:
  5832. return m.Name()
  5833. case category.FieldOrganizationID:
  5834. return m.OrganizationID()
  5835. }
  5836. return nil, false
  5837. }
  5838. // OldField returns the old value of the field from the database. An error is
  5839. // returned if the mutation operation is not UpdateOne, or the query to the
  5840. // database failed.
  5841. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5842. switch name {
  5843. case category.FieldCreatedAt:
  5844. return m.OldCreatedAt(ctx)
  5845. case category.FieldUpdatedAt:
  5846. return m.OldUpdatedAt(ctx)
  5847. case category.FieldDeletedAt:
  5848. return m.OldDeletedAt(ctx)
  5849. case category.FieldName:
  5850. return m.OldName(ctx)
  5851. case category.FieldOrganizationID:
  5852. return m.OldOrganizationID(ctx)
  5853. }
  5854. return nil, fmt.Errorf("unknown Category field %s", name)
  5855. }
  5856. // SetField sets the value of a field with the given name. It returns an error if
  5857. // the field is not defined in the schema, or if the type mismatched the field
  5858. // type.
  5859. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  5860. switch name {
  5861. case category.FieldCreatedAt:
  5862. v, ok := value.(time.Time)
  5863. if !ok {
  5864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5865. }
  5866. m.SetCreatedAt(v)
  5867. return nil
  5868. case category.FieldUpdatedAt:
  5869. v, ok := value.(time.Time)
  5870. if !ok {
  5871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5872. }
  5873. m.SetUpdatedAt(v)
  5874. return nil
  5875. case category.FieldDeletedAt:
  5876. v, ok := value.(time.Time)
  5877. if !ok {
  5878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5879. }
  5880. m.SetDeletedAt(v)
  5881. return nil
  5882. case category.FieldName:
  5883. v, ok := value.(string)
  5884. if !ok {
  5885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5886. }
  5887. m.SetName(v)
  5888. return nil
  5889. case category.FieldOrganizationID:
  5890. v, ok := value.(uint64)
  5891. if !ok {
  5892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5893. }
  5894. m.SetOrganizationID(v)
  5895. return nil
  5896. }
  5897. return fmt.Errorf("unknown Category field %s", name)
  5898. }
  5899. // AddedFields returns all numeric fields that were incremented/decremented during
  5900. // this mutation.
  5901. func (m *CategoryMutation) AddedFields() []string {
  5902. var fields []string
  5903. if m.addorganization_id != nil {
  5904. fields = append(fields, category.FieldOrganizationID)
  5905. }
  5906. return fields
  5907. }
  5908. // AddedField returns the numeric value that was incremented/decremented on a field
  5909. // with the given name. The second boolean return value indicates that this field
  5910. // was not set, or was not defined in the schema.
  5911. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  5912. switch name {
  5913. case category.FieldOrganizationID:
  5914. return m.AddedOrganizationID()
  5915. }
  5916. return nil, false
  5917. }
  5918. // AddField adds the value to the field with the given name. It returns an error if
  5919. // the field is not defined in the schema, or if the type mismatched the field
  5920. // type.
  5921. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  5922. switch name {
  5923. case category.FieldOrganizationID:
  5924. v, ok := value.(int64)
  5925. if !ok {
  5926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5927. }
  5928. m.AddOrganizationID(v)
  5929. return nil
  5930. }
  5931. return fmt.Errorf("unknown Category numeric field %s", name)
  5932. }
  5933. // ClearedFields returns all nullable fields that were cleared during this
  5934. // mutation.
  5935. func (m *CategoryMutation) ClearedFields() []string {
  5936. var fields []string
  5937. if m.FieldCleared(category.FieldDeletedAt) {
  5938. fields = append(fields, category.FieldDeletedAt)
  5939. }
  5940. return fields
  5941. }
  5942. // FieldCleared returns a boolean indicating if a field with the given name was
  5943. // cleared in this mutation.
  5944. func (m *CategoryMutation) FieldCleared(name string) bool {
  5945. _, ok := m.clearedFields[name]
  5946. return ok
  5947. }
  5948. // ClearField clears the value of the field with the given name. It returns an
  5949. // error if the field is not defined in the schema.
  5950. func (m *CategoryMutation) ClearField(name string) error {
  5951. switch name {
  5952. case category.FieldDeletedAt:
  5953. m.ClearDeletedAt()
  5954. return nil
  5955. }
  5956. return fmt.Errorf("unknown Category nullable field %s", name)
  5957. }
  5958. // ResetField resets all changes in the mutation for the field with the given name.
  5959. // It returns an error if the field is not defined in the schema.
  5960. func (m *CategoryMutation) ResetField(name string) error {
  5961. switch name {
  5962. case category.FieldCreatedAt:
  5963. m.ResetCreatedAt()
  5964. return nil
  5965. case category.FieldUpdatedAt:
  5966. m.ResetUpdatedAt()
  5967. return nil
  5968. case category.FieldDeletedAt:
  5969. m.ResetDeletedAt()
  5970. return nil
  5971. case category.FieldName:
  5972. m.ResetName()
  5973. return nil
  5974. case category.FieldOrganizationID:
  5975. m.ResetOrganizationID()
  5976. return nil
  5977. }
  5978. return fmt.Errorf("unknown Category field %s", name)
  5979. }
  5980. // AddedEdges returns all edge names that were set/added in this mutation.
  5981. func (m *CategoryMutation) AddedEdges() []string {
  5982. edges := make([]string, 0, 0)
  5983. return edges
  5984. }
  5985. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5986. // name in this mutation.
  5987. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  5988. return nil
  5989. }
  5990. // RemovedEdges returns all edge names that were removed in this mutation.
  5991. func (m *CategoryMutation) RemovedEdges() []string {
  5992. edges := make([]string, 0, 0)
  5993. return edges
  5994. }
  5995. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5996. // the given name in this mutation.
  5997. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  5998. return nil
  5999. }
  6000. // ClearedEdges returns all edge names that were cleared in this mutation.
  6001. func (m *CategoryMutation) ClearedEdges() []string {
  6002. edges := make([]string, 0, 0)
  6003. return edges
  6004. }
  6005. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6006. // was cleared in this mutation.
  6007. func (m *CategoryMutation) EdgeCleared(name string) bool {
  6008. return false
  6009. }
  6010. // ClearEdge clears the value of the edge with the given name. It returns an error
  6011. // if that edge is not defined in the schema.
  6012. func (m *CategoryMutation) ClearEdge(name string) error {
  6013. return fmt.Errorf("unknown Category unique edge %s", name)
  6014. }
  6015. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6016. // It returns an error if the edge is not defined in the schema.
  6017. func (m *CategoryMutation) ResetEdge(name string) error {
  6018. return fmt.Errorf("unknown Category edge %s", name)
  6019. }
  6020. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  6021. type ChatRecordsMutation struct {
  6022. config
  6023. op Op
  6024. typ string
  6025. id *uint64
  6026. created_at *time.Time
  6027. updated_at *time.Time
  6028. deleted_at *time.Time
  6029. content *string
  6030. content_type *uint8
  6031. addcontent_type *int8
  6032. session_id *uint64
  6033. addsession_id *int64
  6034. user_id *uint64
  6035. adduser_id *int64
  6036. bot_id *uint64
  6037. addbot_id *int64
  6038. bot_type *uint8
  6039. addbot_type *int8
  6040. clearedFields map[string]struct{}
  6041. done bool
  6042. oldValue func(context.Context) (*ChatRecords, error)
  6043. predicates []predicate.ChatRecords
  6044. }
  6045. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  6046. // chatrecordsOption allows management of the mutation configuration using functional options.
  6047. type chatrecordsOption func(*ChatRecordsMutation)
  6048. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  6049. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  6050. m := &ChatRecordsMutation{
  6051. config: c,
  6052. op: op,
  6053. typ: TypeChatRecords,
  6054. clearedFields: make(map[string]struct{}),
  6055. }
  6056. for _, opt := range opts {
  6057. opt(m)
  6058. }
  6059. return m
  6060. }
  6061. // withChatRecordsID sets the ID field of the mutation.
  6062. func withChatRecordsID(id uint64) chatrecordsOption {
  6063. return func(m *ChatRecordsMutation) {
  6064. var (
  6065. err error
  6066. once sync.Once
  6067. value *ChatRecords
  6068. )
  6069. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  6070. once.Do(func() {
  6071. if m.done {
  6072. err = errors.New("querying old values post mutation is not allowed")
  6073. } else {
  6074. value, err = m.Client().ChatRecords.Get(ctx, id)
  6075. }
  6076. })
  6077. return value, err
  6078. }
  6079. m.id = &id
  6080. }
  6081. }
  6082. // withChatRecords sets the old ChatRecords of the mutation.
  6083. func withChatRecords(node *ChatRecords) chatrecordsOption {
  6084. return func(m *ChatRecordsMutation) {
  6085. m.oldValue = func(context.Context) (*ChatRecords, error) {
  6086. return node, nil
  6087. }
  6088. m.id = &node.ID
  6089. }
  6090. }
  6091. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6092. // executed in a transaction (ent.Tx), a transactional client is returned.
  6093. func (m ChatRecordsMutation) Client() *Client {
  6094. client := &Client{config: m.config}
  6095. client.init()
  6096. return client
  6097. }
  6098. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6099. // it returns an error otherwise.
  6100. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  6101. if _, ok := m.driver.(*txDriver); !ok {
  6102. return nil, errors.New("ent: mutation is not running in a transaction")
  6103. }
  6104. tx := &Tx{config: m.config}
  6105. tx.init()
  6106. return tx, nil
  6107. }
  6108. // SetID sets the value of the id field. Note that this
  6109. // operation is only accepted on creation of ChatRecords entities.
  6110. func (m *ChatRecordsMutation) SetID(id uint64) {
  6111. m.id = &id
  6112. }
  6113. // ID returns the ID value in the mutation. Note that the ID is only available
  6114. // if it was provided to the builder or after it was returned from the database.
  6115. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  6116. if m.id == nil {
  6117. return
  6118. }
  6119. return *m.id, true
  6120. }
  6121. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6122. // That means, if the mutation is applied within a transaction with an isolation level such
  6123. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6124. // or updated by the mutation.
  6125. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  6126. switch {
  6127. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6128. id, exists := m.ID()
  6129. if exists {
  6130. return []uint64{id}, nil
  6131. }
  6132. fallthrough
  6133. case m.op.Is(OpUpdate | OpDelete):
  6134. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  6135. default:
  6136. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6137. }
  6138. }
  6139. // SetCreatedAt sets the "created_at" field.
  6140. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  6141. m.created_at = &t
  6142. }
  6143. // CreatedAt returns the value of the "created_at" field in the mutation.
  6144. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  6145. v := m.created_at
  6146. if v == nil {
  6147. return
  6148. }
  6149. return *v, true
  6150. }
  6151. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  6152. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6154. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6155. if !m.op.Is(OpUpdateOne) {
  6156. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6157. }
  6158. if m.id == nil || m.oldValue == nil {
  6159. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6160. }
  6161. oldValue, err := m.oldValue(ctx)
  6162. if err != nil {
  6163. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6164. }
  6165. return oldValue.CreatedAt, nil
  6166. }
  6167. // ResetCreatedAt resets all changes to the "created_at" field.
  6168. func (m *ChatRecordsMutation) ResetCreatedAt() {
  6169. m.created_at = nil
  6170. }
  6171. // SetUpdatedAt sets the "updated_at" field.
  6172. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  6173. m.updated_at = &t
  6174. }
  6175. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6176. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  6177. v := m.updated_at
  6178. if v == nil {
  6179. return
  6180. }
  6181. return *v, true
  6182. }
  6183. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  6184. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6186. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6187. if !m.op.Is(OpUpdateOne) {
  6188. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6189. }
  6190. if m.id == nil || m.oldValue == nil {
  6191. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6192. }
  6193. oldValue, err := m.oldValue(ctx)
  6194. if err != nil {
  6195. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6196. }
  6197. return oldValue.UpdatedAt, nil
  6198. }
  6199. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6200. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  6201. m.updated_at = nil
  6202. }
  6203. // SetDeletedAt sets the "deleted_at" field.
  6204. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  6205. m.deleted_at = &t
  6206. }
  6207. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6208. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  6209. v := m.deleted_at
  6210. if v == nil {
  6211. return
  6212. }
  6213. return *v, true
  6214. }
  6215. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  6216. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6218. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6219. if !m.op.Is(OpUpdateOne) {
  6220. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6221. }
  6222. if m.id == nil || m.oldValue == nil {
  6223. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6224. }
  6225. oldValue, err := m.oldValue(ctx)
  6226. if err != nil {
  6227. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6228. }
  6229. return oldValue.DeletedAt, nil
  6230. }
  6231. // ClearDeletedAt clears the value of the "deleted_at" field.
  6232. func (m *ChatRecordsMutation) ClearDeletedAt() {
  6233. m.deleted_at = nil
  6234. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  6235. }
  6236. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6237. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  6238. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  6239. return ok
  6240. }
  6241. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6242. func (m *ChatRecordsMutation) ResetDeletedAt() {
  6243. m.deleted_at = nil
  6244. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  6245. }
  6246. // SetContent sets the "content" field.
  6247. func (m *ChatRecordsMutation) SetContent(s string) {
  6248. m.content = &s
  6249. }
  6250. // Content returns the value of the "content" field in the mutation.
  6251. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  6252. v := m.content
  6253. if v == nil {
  6254. return
  6255. }
  6256. return *v, true
  6257. }
  6258. // OldContent returns the old "content" field's value of the ChatRecords entity.
  6259. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6261. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  6262. if !m.op.Is(OpUpdateOne) {
  6263. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6264. }
  6265. if m.id == nil || m.oldValue == nil {
  6266. return v, errors.New("OldContent requires an ID field in the mutation")
  6267. }
  6268. oldValue, err := m.oldValue(ctx)
  6269. if err != nil {
  6270. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  6271. }
  6272. return oldValue.Content, nil
  6273. }
  6274. // ResetContent resets all changes to the "content" field.
  6275. func (m *ChatRecordsMutation) ResetContent() {
  6276. m.content = nil
  6277. }
  6278. // SetContentType sets the "content_type" field.
  6279. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  6280. m.content_type = &u
  6281. m.addcontent_type = nil
  6282. }
  6283. // ContentType returns the value of the "content_type" field in the mutation.
  6284. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  6285. v := m.content_type
  6286. if v == nil {
  6287. return
  6288. }
  6289. return *v, true
  6290. }
  6291. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  6292. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6294. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  6295. if !m.op.Is(OpUpdateOne) {
  6296. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  6297. }
  6298. if m.id == nil || m.oldValue == nil {
  6299. return v, errors.New("OldContentType requires an ID field in the mutation")
  6300. }
  6301. oldValue, err := m.oldValue(ctx)
  6302. if err != nil {
  6303. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  6304. }
  6305. return oldValue.ContentType, nil
  6306. }
  6307. // AddContentType adds u to the "content_type" field.
  6308. func (m *ChatRecordsMutation) AddContentType(u int8) {
  6309. if m.addcontent_type != nil {
  6310. *m.addcontent_type += u
  6311. } else {
  6312. m.addcontent_type = &u
  6313. }
  6314. }
  6315. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  6316. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  6317. v := m.addcontent_type
  6318. if v == nil {
  6319. return
  6320. }
  6321. return *v, true
  6322. }
  6323. // ResetContentType resets all changes to the "content_type" field.
  6324. func (m *ChatRecordsMutation) ResetContentType() {
  6325. m.content_type = nil
  6326. m.addcontent_type = nil
  6327. }
  6328. // SetSessionID sets the "session_id" field.
  6329. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  6330. m.session_id = &u
  6331. m.addsession_id = nil
  6332. }
  6333. // SessionID returns the value of the "session_id" field in the mutation.
  6334. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  6335. v := m.session_id
  6336. if v == nil {
  6337. return
  6338. }
  6339. return *v, true
  6340. }
  6341. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  6342. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6344. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  6345. if !m.op.Is(OpUpdateOne) {
  6346. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  6347. }
  6348. if m.id == nil || m.oldValue == nil {
  6349. return v, errors.New("OldSessionID requires an ID field in the mutation")
  6350. }
  6351. oldValue, err := m.oldValue(ctx)
  6352. if err != nil {
  6353. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  6354. }
  6355. return oldValue.SessionID, nil
  6356. }
  6357. // AddSessionID adds u to the "session_id" field.
  6358. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  6359. if m.addsession_id != nil {
  6360. *m.addsession_id += u
  6361. } else {
  6362. m.addsession_id = &u
  6363. }
  6364. }
  6365. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  6366. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  6367. v := m.addsession_id
  6368. if v == nil {
  6369. return
  6370. }
  6371. return *v, true
  6372. }
  6373. // ResetSessionID resets all changes to the "session_id" field.
  6374. func (m *ChatRecordsMutation) ResetSessionID() {
  6375. m.session_id = nil
  6376. m.addsession_id = nil
  6377. }
  6378. // SetUserID sets the "user_id" field.
  6379. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  6380. m.user_id = &u
  6381. m.adduser_id = nil
  6382. }
  6383. // UserID returns the value of the "user_id" field in the mutation.
  6384. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  6385. v := m.user_id
  6386. if v == nil {
  6387. return
  6388. }
  6389. return *v, true
  6390. }
  6391. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  6392. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6394. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6395. if !m.op.Is(OpUpdateOne) {
  6396. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6397. }
  6398. if m.id == nil || m.oldValue == nil {
  6399. return v, errors.New("OldUserID requires an ID field in the mutation")
  6400. }
  6401. oldValue, err := m.oldValue(ctx)
  6402. if err != nil {
  6403. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6404. }
  6405. return oldValue.UserID, nil
  6406. }
  6407. // AddUserID adds u to the "user_id" field.
  6408. func (m *ChatRecordsMutation) AddUserID(u int64) {
  6409. if m.adduser_id != nil {
  6410. *m.adduser_id += u
  6411. } else {
  6412. m.adduser_id = &u
  6413. }
  6414. }
  6415. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6416. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  6417. v := m.adduser_id
  6418. if v == nil {
  6419. return
  6420. }
  6421. return *v, true
  6422. }
  6423. // ResetUserID resets all changes to the "user_id" field.
  6424. func (m *ChatRecordsMutation) ResetUserID() {
  6425. m.user_id = nil
  6426. m.adduser_id = nil
  6427. }
  6428. // SetBotID sets the "bot_id" field.
  6429. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  6430. m.bot_id = &u
  6431. m.addbot_id = nil
  6432. }
  6433. // BotID returns the value of the "bot_id" field in the mutation.
  6434. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  6435. v := m.bot_id
  6436. if v == nil {
  6437. return
  6438. }
  6439. return *v, true
  6440. }
  6441. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  6442. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6443. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6444. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6445. if !m.op.Is(OpUpdateOne) {
  6446. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6447. }
  6448. if m.id == nil || m.oldValue == nil {
  6449. return v, errors.New("OldBotID requires an ID field in the mutation")
  6450. }
  6451. oldValue, err := m.oldValue(ctx)
  6452. if err != nil {
  6453. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6454. }
  6455. return oldValue.BotID, nil
  6456. }
  6457. // AddBotID adds u to the "bot_id" field.
  6458. func (m *ChatRecordsMutation) AddBotID(u int64) {
  6459. if m.addbot_id != nil {
  6460. *m.addbot_id += u
  6461. } else {
  6462. m.addbot_id = &u
  6463. }
  6464. }
  6465. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6466. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  6467. v := m.addbot_id
  6468. if v == nil {
  6469. return
  6470. }
  6471. return *v, true
  6472. }
  6473. // ResetBotID resets all changes to the "bot_id" field.
  6474. func (m *ChatRecordsMutation) ResetBotID() {
  6475. m.bot_id = nil
  6476. m.addbot_id = nil
  6477. }
  6478. // SetBotType sets the "bot_type" field.
  6479. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  6480. m.bot_type = &u
  6481. m.addbot_type = nil
  6482. }
  6483. // BotType returns the value of the "bot_type" field in the mutation.
  6484. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  6485. v := m.bot_type
  6486. if v == nil {
  6487. return
  6488. }
  6489. return *v, true
  6490. }
  6491. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  6492. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6494. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6495. if !m.op.Is(OpUpdateOne) {
  6496. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6497. }
  6498. if m.id == nil || m.oldValue == nil {
  6499. return v, errors.New("OldBotType requires an ID field in the mutation")
  6500. }
  6501. oldValue, err := m.oldValue(ctx)
  6502. if err != nil {
  6503. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  6504. }
  6505. return oldValue.BotType, nil
  6506. }
  6507. // AddBotType adds u to the "bot_type" field.
  6508. func (m *ChatRecordsMutation) AddBotType(u int8) {
  6509. if m.addbot_type != nil {
  6510. *m.addbot_type += u
  6511. } else {
  6512. m.addbot_type = &u
  6513. }
  6514. }
  6515. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  6516. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  6517. v := m.addbot_type
  6518. if v == nil {
  6519. return
  6520. }
  6521. return *v, true
  6522. }
  6523. // ResetBotType resets all changes to the "bot_type" field.
  6524. func (m *ChatRecordsMutation) ResetBotType() {
  6525. m.bot_type = nil
  6526. m.addbot_type = nil
  6527. }
  6528. // Where appends a list predicates to the ChatRecordsMutation builder.
  6529. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  6530. m.predicates = append(m.predicates, ps...)
  6531. }
  6532. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  6533. // users can use type-assertion to append predicates that do not depend on any generated package.
  6534. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  6535. p := make([]predicate.ChatRecords, len(ps))
  6536. for i := range ps {
  6537. p[i] = ps[i]
  6538. }
  6539. m.Where(p...)
  6540. }
  6541. // Op returns the operation name.
  6542. func (m *ChatRecordsMutation) Op() Op {
  6543. return m.op
  6544. }
  6545. // SetOp allows setting the mutation operation.
  6546. func (m *ChatRecordsMutation) SetOp(op Op) {
  6547. m.op = op
  6548. }
  6549. // Type returns the node type of this mutation (ChatRecords).
  6550. func (m *ChatRecordsMutation) Type() string {
  6551. return m.typ
  6552. }
  6553. // Fields returns all fields that were changed during this mutation. Note that in
  6554. // order to get all numeric fields that were incremented/decremented, call
  6555. // AddedFields().
  6556. func (m *ChatRecordsMutation) Fields() []string {
  6557. fields := make([]string, 0, 9)
  6558. if m.created_at != nil {
  6559. fields = append(fields, chatrecords.FieldCreatedAt)
  6560. }
  6561. if m.updated_at != nil {
  6562. fields = append(fields, chatrecords.FieldUpdatedAt)
  6563. }
  6564. if m.deleted_at != nil {
  6565. fields = append(fields, chatrecords.FieldDeletedAt)
  6566. }
  6567. if m.content != nil {
  6568. fields = append(fields, chatrecords.FieldContent)
  6569. }
  6570. if m.content_type != nil {
  6571. fields = append(fields, chatrecords.FieldContentType)
  6572. }
  6573. if m.session_id != nil {
  6574. fields = append(fields, chatrecords.FieldSessionID)
  6575. }
  6576. if m.user_id != nil {
  6577. fields = append(fields, chatrecords.FieldUserID)
  6578. }
  6579. if m.bot_id != nil {
  6580. fields = append(fields, chatrecords.FieldBotID)
  6581. }
  6582. if m.bot_type != nil {
  6583. fields = append(fields, chatrecords.FieldBotType)
  6584. }
  6585. return fields
  6586. }
  6587. // Field returns the value of a field with the given name. The second boolean
  6588. // return value indicates that this field was not set, or was not defined in the
  6589. // schema.
  6590. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  6591. switch name {
  6592. case chatrecords.FieldCreatedAt:
  6593. return m.CreatedAt()
  6594. case chatrecords.FieldUpdatedAt:
  6595. return m.UpdatedAt()
  6596. case chatrecords.FieldDeletedAt:
  6597. return m.DeletedAt()
  6598. case chatrecords.FieldContent:
  6599. return m.Content()
  6600. case chatrecords.FieldContentType:
  6601. return m.ContentType()
  6602. case chatrecords.FieldSessionID:
  6603. return m.SessionID()
  6604. case chatrecords.FieldUserID:
  6605. return m.UserID()
  6606. case chatrecords.FieldBotID:
  6607. return m.BotID()
  6608. case chatrecords.FieldBotType:
  6609. return m.BotType()
  6610. }
  6611. return nil, false
  6612. }
  6613. // OldField returns the old value of the field from the database. An error is
  6614. // returned if the mutation operation is not UpdateOne, or the query to the
  6615. // database failed.
  6616. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6617. switch name {
  6618. case chatrecords.FieldCreatedAt:
  6619. return m.OldCreatedAt(ctx)
  6620. case chatrecords.FieldUpdatedAt:
  6621. return m.OldUpdatedAt(ctx)
  6622. case chatrecords.FieldDeletedAt:
  6623. return m.OldDeletedAt(ctx)
  6624. case chatrecords.FieldContent:
  6625. return m.OldContent(ctx)
  6626. case chatrecords.FieldContentType:
  6627. return m.OldContentType(ctx)
  6628. case chatrecords.FieldSessionID:
  6629. return m.OldSessionID(ctx)
  6630. case chatrecords.FieldUserID:
  6631. return m.OldUserID(ctx)
  6632. case chatrecords.FieldBotID:
  6633. return m.OldBotID(ctx)
  6634. case chatrecords.FieldBotType:
  6635. return m.OldBotType(ctx)
  6636. }
  6637. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  6638. }
  6639. // SetField sets the value of a field with the given name. It returns an error if
  6640. // the field is not defined in the schema, or if the type mismatched the field
  6641. // type.
  6642. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  6643. switch name {
  6644. case chatrecords.FieldCreatedAt:
  6645. v, ok := value.(time.Time)
  6646. if !ok {
  6647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6648. }
  6649. m.SetCreatedAt(v)
  6650. return nil
  6651. case chatrecords.FieldUpdatedAt:
  6652. v, ok := value.(time.Time)
  6653. if !ok {
  6654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6655. }
  6656. m.SetUpdatedAt(v)
  6657. return nil
  6658. case chatrecords.FieldDeletedAt:
  6659. v, ok := value.(time.Time)
  6660. if !ok {
  6661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6662. }
  6663. m.SetDeletedAt(v)
  6664. return nil
  6665. case chatrecords.FieldContent:
  6666. v, ok := value.(string)
  6667. if !ok {
  6668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6669. }
  6670. m.SetContent(v)
  6671. return nil
  6672. case chatrecords.FieldContentType:
  6673. v, ok := value.(uint8)
  6674. if !ok {
  6675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6676. }
  6677. m.SetContentType(v)
  6678. return nil
  6679. case chatrecords.FieldSessionID:
  6680. v, ok := value.(uint64)
  6681. if !ok {
  6682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6683. }
  6684. m.SetSessionID(v)
  6685. return nil
  6686. case chatrecords.FieldUserID:
  6687. v, ok := value.(uint64)
  6688. if !ok {
  6689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6690. }
  6691. m.SetUserID(v)
  6692. return nil
  6693. case chatrecords.FieldBotID:
  6694. v, ok := value.(uint64)
  6695. if !ok {
  6696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6697. }
  6698. m.SetBotID(v)
  6699. return nil
  6700. case chatrecords.FieldBotType:
  6701. v, ok := value.(uint8)
  6702. if !ok {
  6703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6704. }
  6705. m.SetBotType(v)
  6706. return nil
  6707. }
  6708. return fmt.Errorf("unknown ChatRecords field %s", name)
  6709. }
  6710. // AddedFields returns all numeric fields that were incremented/decremented during
  6711. // this mutation.
  6712. func (m *ChatRecordsMutation) AddedFields() []string {
  6713. var fields []string
  6714. if m.addcontent_type != nil {
  6715. fields = append(fields, chatrecords.FieldContentType)
  6716. }
  6717. if m.addsession_id != nil {
  6718. fields = append(fields, chatrecords.FieldSessionID)
  6719. }
  6720. if m.adduser_id != nil {
  6721. fields = append(fields, chatrecords.FieldUserID)
  6722. }
  6723. if m.addbot_id != nil {
  6724. fields = append(fields, chatrecords.FieldBotID)
  6725. }
  6726. if m.addbot_type != nil {
  6727. fields = append(fields, chatrecords.FieldBotType)
  6728. }
  6729. return fields
  6730. }
  6731. // AddedField returns the numeric value that was incremented/decremented on a field
  6732. // with the given name. The second boolean return value indicates that this field
  6733. // was not set, or was not defined in the schema.
  6734. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  6735. switch name {
  6736. case chatrecords.FieldContentType:
  6737. return m.AddedContentType()
  6738. case chatrecords.FieldSessionID:
  6739. return m.AddedSessionID()
  6740. case chatrecords.FieldUserID:
  6741. return m.AddedUserID()
  6742. case chatrecords.FieldBotID:
  6743. return m.AddedBotID()
  6744. case chatrecords.FieldBotType:
  6745. return m.AddedBotType()
  6746. }
  6747. return nil, false
  6748. }
  6749. // AddField adds the value to the field with the given name. It returns an error if
  6750. // the field is not defined in the schema, or if the type mismatched the field
  6751. // type.
  6752. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  6753. switch name {
  6754. case chatrecords.FieldContentType:
  6755. v, ok := value.(int8)
  6756. if !ok {
  6757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6758. }
  6759. m.AddContentType(v)
  6760. return nil
  6761. case chatrecords.FieldSessionID:
  6762. v, ok := value.(int64)
  6763. if !ok {
  6764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6765. }
  6766. m.AddSessionID(v)
  6767. return nil
  6768. case chatrecords.FieldUserID:
  6769. v, ok := value.(int64)
  6770. if !ok {
  6771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6772. }
  6773. m.AddUserID(v)
  6774. return nil
  6775. case chatrecords.FieldBotID:
  6776. v, ok := value.(int64)
  6777. if !ok {
  6778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6779. }
  6780. m.AddBotID(v)
  6781. return nil
  6782. case chatrecords.FieldBotType:
  6783. v, ok := value.(int8)
  6784. if !ok {
  6785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6786. }
  6787. m.AddBotType(v)
  6788. return nil
  6789. }
  6790. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  6791. }
  6792. // ClearedFields returns all nullable fields that were cleared during this
  6793. // mutation.
  6794. func (m *ChatRecordsMutation) ClearedFields() []string {
  6795. var fields []string
  6796. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  6797. fields = append(fields, chatrecords.FieldDeletedAt)
  6798. }
  6799. return fields
  6800. }
  6801. // FieldCleared returns a boolean indicating if a field with the given name was
  6802. // cleared in this mutation.
  6803. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  6804. _, ok := m.clearedFields[name]
  6805. return ok
  6806. }
  6807. // ClearField clears the value of the field with the given name. It returns an
  6808. // error if the field is not defined in the schema.
  6809. func (m *ChatRecordsMutation) ClearField(name string) error {
  6810. switch name {
  6811. case chatrecords.FieldDeletedAt:
  6812. m.ClearDeletedAt()
  6813. return nil
  6814. }
  6815. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  6816. }
  6817. // ResetField resets all changes in the mutation for the field with the given name.
  6818. // It returns an error if the field is not defined in the schema.
  6819. func (m *ChatRecordsMutation) ResetField(name string) error {
  6820. switch name {
  6821. case chatrecords.FieldCreatedAt:
  6822. m.ResetCreatedAt()
  6823. return nil
  6824. case chatrecords.FieldUpdatedAt:
  6825. m.ResetUpdatedAt()
  6826. return nil
  6827. case chatrecords.FieldDeletedAt:
  6828. m.ResetDeletedAt()
  6829. return nil
  6830. case chatrecords.FieldContent:
  6831. m.ResetContent()
  6832. return nil
  6833. case chatrecords.FieldContentType:
  6834. m.ResetContentType()
  6835. return nil
  6836. case chatrecords.FieldSessionID:
  6837. m.ResetSessionID()
  6838. return nil
  6839. case chatrecords.FieldUserID:
  6840. m.ResetUserID()
  6841. return nil
  6842. case chatrecords.FieldBotID:
  6843. m.ResetBotID()
  6844. return nil
  6845. case chatrecords.FieldBotType:
  6846. m.ResetBotType()
  6847. return nil
  6848. }
  6849. return fmt.Errorf("unknown ChatRecords field %s", name)
  6850. }
  6851. // AddedEdges returns all edge names that were set/added in this mutation.
  6852. func (m *ChatRecordsMutation) AddedEdges() []string {
  6853. edges := make([]string, 0, 0)
  6854. return edges
  6855. }
  6856. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6857. // name in this mutation.
  6858. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  6859. return nil
  6860. }
  6861. // RemovedEdges returns all edge names that were removed in this mutation.
  6862. func (m *ChatRecordsMutation) RemovedEdges() []string {
  6863. edges := make([]string, 0, 0)
  6864. return edges
  6865. }
  6866. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6867. // the given name in this mutation.
  6868. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  6869. return nil
  6870. }
  6871. // ClearedEdges returns all edge names that were cleared in this mutation.
  6872. func (m *ChatRecordsMutation) ClearedEdges() []string {
  6873. edges := make([]string, 0, 0)
  6874. return edges
  6875. }
  6876. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6877. // was cleared in this mutation.
  6878. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  6879. return false
  6880. }
  6881. // ClearEdge clears the value of the edge with the given name. It returns an error
  6882. // if that edge is not defined in the schema.
  6883. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  6884. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  6885. }
  6886. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6887. // It returns an error if the edge is not defined in the schema.
  6888. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  6889. return fmt.Errorf("unknown ChatRecords edge %s", name)
  6890. }
  6891. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  6892. type ChatSessionMutation struct {
  6893. config
  6894. op Op
  6895. typ string
  6896. id *uint64
  6897. created_at *time.Time
  6898. updated_at *time.Time
  6899. deleted_at *time.Time
  6900. name *string
  6901. user_id *uint64
  6902. adduser_id *int64
  6903. bot_id *uint64
  6904. addbot_id *int64
  6905. bot_type *uint8
  6906. addbot_type *int8
  6907. clearedFields map[string]struct{}
  6908. done bool
  6909. oldValue func(context.Context) (*ChatSession, error)
  6910. predicates []predicate.ChatSession
  6911. }
  6912. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  6913. // chatsessionOption allows management of the mutation configuration using functional options.
  6914. type chatsessionOption func(*ChatSessionMutation)
  6915. // newChatSessionMutation creates new mutation for the ChatSession entity.
  6916. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  6917. m := &ChatSessionMutation{
  6918. config: c,
  6919. op: op,
  6920. typ: TypeChatSession,
  6921. clearedFields: make(map[string]struct{}),
  6922. }
  6923. for _, opt := range opts {
  6924. opt(m)
  6925. }
  6926. return m
  6927. }
  6928. // withChatSessionID sets the ID field of the mutation.
  6929. func withChatSessionID(id uint64) chatsessionOption {
  6930. return func(m *ChatSessionMutation) {
  6931. var (
  6932. err error
  6933. once sync.Once
  6934. value *ChatSession
  6935. )
  6936. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  6937. once.Do(func() {
  6938. if m.done {
  6939. err = errors.New("querying old values post mutation is not allowed")
  6940. } else {
  6941. value, err = m.Client().ChatSession.Get(ctx, id)
  6942. }
  6943. })
  6944. return value, err
  6945. }
  6946. m.id = &id
  6947. }
  6948. }
  6949. // withChatSession sets the old ChatSession of the mutation.
  6950. func withChatSession(node *ChatSession) chatsessionOption {
  6951. return func(m *ChatSessionMutation) {
  6952. m.oldValue = func(context.Context) (*ChatSession, error) {
  6953. return node, nil
  6954. }
  6955. m.id = &node.ID
  6956. }
  6957. }
  6958. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6959. // executed in a transaction (ent.Tx), a transactional client is returned.
  6960. func (m ChatSessionMutation) Client() *Client {
  6961. client := &Client{config: m.config}
  6962. client.init()
  6963. return client
  6964. }
  6965. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6966. // it returns an error otherwise.
  6967. func (m ChatSessionMutation) Tx() (*Tx, error) {
  6968. if _, ok := m.driver.(*txDriver); !ok {
  6969. return nil, errors.New("ent: mutation is not running in a transaction")
  6970. }
  6971. tx := &Tx{config: m.config}
  6972. tx.init()
  6973. return tx, nil
  6974. }
  6975. // SetID sets the value of the id field. Note that this
  6976. // operation is only accepted on creation of ChatSession entities.
  6977. func (m *ChatSessionMutation) SetID(id uint64) {
  6978. m.id = &id
  6979. }
  6980. // ID returns the ID value in the mutation. Note that the ID is only available
  6981. // if it was provided to the builder or after it was returned from the database.
  6982. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  6983. if m.id == nil {
  6984. return
  6985. }
  6986. return *m.id, true
  6987. }
  6988. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6989. // That means, if the mutation is applied within a transaction with an isolation level such
  6990. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6991. // or updated by the mutation.
  6992. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  6993. switch {
  6994. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6995. id, exists := m.ID()
  6996. if exists {
  6997. return []uint64{id}, nil
  6998. }
  6999. fallthrough
  7000. case m.op.Is(OpUpdate | OpDelete):
  7001. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  7002. default:
  7003. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7004. }
  7005. }
  7006. // SetCreatedAt sets the "created_at" field.
  7007. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  7008. m.created_at = &t
  7009. }
  7010. // CreatedAt returns the value of the "created_at" field in the mutation.
  7011. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  7012. v := m.created_at
  7013. if v == nil {
  7014. return
  7015. }
  7016. return *v, true
  7017. }
  7018. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  7019. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7021. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7022. if !m.op.Is(OpUpdateOne) {
  7023. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7024. }
  7025. if m.id == nil || m.oldValue == nil {
  7026. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7027. }
  7028. oldValue, err := m.oldValue(ctx)
  7029. if err != nil {
  7030. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7031. }
  7032. return oldValue.CreatedAt, nil
  7033. }
  7034. // ResetCreatedAt resets all changes to the "created_at" field.
  7035. func (m *ChatSessionMutation) ResetCreatedAt() {
  7036. m.created_at = nil
  7037. }
  7038. // SetUpdatedAt sets the "updated_at" field.
  7039. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  7040. m.updated_at = &t
  7041. }
  7042. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7043. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  7044. v := m.updated_at
  7045. if v == nil {
  7046. return
  7047. }
  7048. return *v, true
  7049. }
  7050. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  7051. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7053. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7054. if !m.op.Is(OpUpdateOne) {
  7055. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7056. }
  7057. if m.id == nil || m.oldValue == nil {
  7058. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7059. }
  7060. oldValue, err := m.oldValue(ctx)
  7061. if err != nil {
  7062. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7063. }
  7064. return oldValue.UpdatedAt, nil
  7065. }
  7066. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7067. func (m *ChatSessionMutation) ResetUpdatedAt() {
  7068. m.updated_at = nil
  7069. }
  7070. // SetDeletedAt sets the "deleted_at" field.
  7071. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  7072. m.deleted_at = &t
  7073. }
  7074. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7075. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  7076. v := m.deleted_at
  7077. if v == nil {
  7078. return
  7079. }
  7080. return *v, true
  7081. }
  7082. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  7083. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7084. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7085. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7086. if !m.op.Is(OpUpdateOne) {
  7087. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7088. }
  7089. if m.id == nil || m.oldValue == nil {
  7090. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7091. }
  7092. oldValue, err := m.oldValue(ctx)
  7093. if err != nil {
  7094. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7095. }
  7096. return oldValue.DeletedAt, nil
  7097. }
  7098. // ClearDeletedAt clears the value of the "deleted_at" field.
  7099. func (m *ChatSessionMutation) ClearDeletedAt() {
  7100. m.deleted_at = nil
  7101. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  7102. }
  7103. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7104. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  7105. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  7106. return ok
  7107. }
  7108. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7109. func (m *ChatSessionMutation) ResetDeletedAt() {
  7110. m.deleted_at = nil
  7111. delete(m.clearedFields, chatsession.FieldDeletedAt)
  7112. }
  7113. // SetName sets the "name" field.
  7114. func (m *ChatSessionMutation) SetName(s string) {
  7115. m.name = &s
  7116. }
  7117. // Name returns the value of the "name" field in the mutation.
  7118. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  7119. v := m.name
  7120. if v == nil {
  7121. return
  7122. }
  7123. return *v, true
  7124. }
  7125. // OldName returns the old "name" field's value of the ChatSession entity.
  7126. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7128. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  7129. if !m.op.Is(OpUpdateOne) {
  7130. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7131. }
  7132. if m.id == nil || m.oldValue == nil {
  7133. return v, errors.New("OldName requires an ID field in the mutation")
  7134. }
  7135. oldValue, err := m.oldValue(ctx)
  7136. if err != nil {
  7137. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7138. }
  7139. return oldValue.Name, nil
  7140. }
  7141. // ResetName resets all changes to the "name" field.
  7142. func (m *ChatSessionMutation) ResetName() {
  7143. m.name = nil
  7144. }
  7145. // SetUserID sets the "user_id" field.
  7146. func (m *ChatSessionMutation) SetUserID(u uint64) {
  7147. m.user_id = &u
  7148. m.adduser_id = nil
  7149. }
  7150. // UserID returns the value of the "user_id" field in the mutation.
  7151. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  7152. v := m.user_id
  7153. if v == nil {
  7154. return
  7155. }
  7156. return *v, true
  7157. }
  7158. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  7159. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7160. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7161. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  7162. if !m.op.Is(OpUpdateOne) {
  7163. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  7164. }
  7165. if m.id == nil || m.oldValue == nil {
  7166. return v, errors.New("OldUserID requires an ID field in the mutation")
  7167. }
  7168. oldValue, err := m.oldValue(ctx)
  7169. if err != nil {
  7170. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  7171. }
  7172. return oldValue.UserID, nil
  7173. }
  7174. // AddUserID adds u to the "user_id" field.
  7175. func (m *ChatSessionMutation) AddUserID(u int64) {
  7176. if m.adduser_id != nil {
  7177. *m.adduser_id += u
  7178. } else {
  7179. m.adduser_id = &u
  7180. }
  7181. }
  7182. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  7183. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  7184. v := m.adduser_id
  7185. if v == nil {
  7186. return
  7187. }
  7188. return *v, true
  7189. }
  7190. // ResetUserID resets all changes to the "user_id" field.
  7191. func (m *ChatSessionMutation) ResetUserID() {
  7192. m.user_id = nil
  7193. m.adduser_id = nil
  7194. }
  7195. // SetBotID sets the "bot_id" field.
  7196. func (m *ChatSessionMutation) SetBotID(u uint64) {
  7197. m.bot_id = &u
  7198. m.addbot_id = nil
  7199. }
  7200. // BotID returns the value of the "bot_id" field in the mutation.
  7201. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  7202. v := m.bot_id
  7203. if v == nil {
  7204. return
  7205. }
  7206. return *v, true
  7207. }
  7208. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  7209. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7210. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7211. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  7212. if !m.op.Is(OpUpdateOne) {
  7213. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  7214. }
  7215. if m.id == nil || m.oldValue == nil {
  7216. return v, errors.New("OldBotID requires an ID field in the mutation")
  7217. }
  7218. oldValue, err := m.oldValue(ctx)
  7219. if err != nil {
  7220. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  7221. }
  7222. return oldValue.BotID, nil
  7223. }
  7224. // AddBotID adds u to the "bot_id" field.
  7225. func (m *ChatSessionMutation) AddBotID(u int64) {
  7226. if m.addbot_id != nil {
  7227. *m.addbot_id += u
  7228. } else {
  7229. m.addbot_id = &u
  7230. }
  7231. }
  7232. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  7233. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  7234. v := m.addbot_id
  7235. if v == nil {
  7236. return
  7237. }
  7238. return *v, true
  7239. }
  7240. // ResetBotID resets all changes to the "bot_id" field.
  7241. func (m *ChatSessionMutation) ResetBotID() {
  7242. m.bot_id = nil
  7243. m.addbot_id = nil
  7244. }
  7245. // SetBotType sets the "bot_type" field.
  7246. func (m *ChatSessionMutation) SetBotType(u uint8) {
  7247. m.bot_type = &u
  7248. m.addbot_type = nil
  7249. }
  7250. // BotType returns the value of the "bot_type" field in the mutation.
  7251. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  7252. v := m.bot_type
  7253. if v == nil {
  7254. return
  7255. }
  7256. return *v, true
  7257. }
  7258. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  7259. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7261. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  7262. if !m.op.Is(OpUpdateOne) {
  7263. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  7264. }
  7265. if m.id == nil || m.oldValue == nil {
  7266. return v, errors.New("OldBotType requires an ID field in the mutation")
  7267. }
  7268. oldValue, err := m.oldValue(ctx)
  7269. if err != nil {
  7270. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  7271. }
  7272. return oldValue.BotType, nil
  7273. }
  7274. // AddBotType adds u to the "bot_type" field.
  7275. func (m *ChatSessionMutation) AddBotType(u int8) {
  7276. if m.addbot_type != nil {
  7277. *m.addbot_type += u
  7278. } else {
  7279. m.addbot_type = &u
  7280. }
  7281. }
  7282. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  7283. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  7284. v := m.addbot_type
  7285. if v == nil {
  7286. return
  7287. }
  7288. return *v, true
  7289. }
  7290. // ResetBotType resets all changes to the "bot_type" field.
  7291. func (m *ChatSessionMutation) ResetBotType() {
  7292. m.bot_type = nil
  7293. m.addbot_type = nil
  7294. }
  7295. // Where appends a list predicates to the ChatSessionMutation builder.
  7296. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  7297. m.predicates = append(m.predicates, ps...)
  7298. }
  7299. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  7300. // users can use type-assertion to append predicates that do not depend on any generated package.
  7301. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  7302. p := make([]predicate.ChatSession, len(ps))
  7303. for i := range ps {
  7304. p[i] = ps[i]
  7305. }
  7306. m.Where(p...)
  7307. }
  7308. // Op returns the operation name.
  7309. func (m *ChatSessionMutation) Op() Op {
  7310. return m.op
  7311. }
  7312. // SetOp allows setting the mutation operation.
  7313. func (m *ChatSessionMutation) SetOp(op Op) {
  7314. m.op = op
  7315. }
  7316. // Type returns the node type of this mutation (ChatSession).
  7317. func (m *ChatSessionMutation) Type() string {
  7318. return m.typ
  7319. }
  7320. // Fields returns all fields that were changed during this mutation. Note that in
  7321. // order to get all numeric fields that were incremented/decremented, call
  7322. // AddedFields().
  7323. func (m *ChatSessionMutation) Fields() []string {
  7324. fields := make([]string, 0, 7)
  7325. if m.created_at != nil {
  7326. fields = append(fields, chatsession.FieldCreatedAt)
  7327. }
  7328. if m.updated_at != nil {
  7329. fields = append(fields, chatsession.FieldUpdatedAt)
  7330. }
  7331. if m.deleted_at != nil {
  7332. fields = append(fields, chatsession.FieldDeletedAt)
  7333. }
  7334. if m.name != nil {
  7335. fields = append(fields, chatsession.FieldName)
  7336. }
  7337. if m.user_id != nil {
  7338. fields = append(fields, chatsession.FieldUserID)
  7339. }
  7340. if m.bot_id != nil {
  7341. fields = append(fields, chatsession.FieldBotID)
  7342. }
  7343. if m.bot_type != nil {
  7344. fields = append(fields, chatsession.FieldBotType)
  7345. }
  7346. return fields
  7347. }
  7348. // Field returns the value of a field with the given name. The second boolean
  7349. // return value indicates that this field was not set, or was not defined in the
  7350. // schema.
  7351. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  7352. switch name {
  7353. case chatsession.FieldCreatedAt:
  7354. return m.CreatedAt()
  7355. case chatsession.FieldUpdatedAt:
  7356. return m.UpdatedAt()
  7357. case chatsession.FieldDeletedAt:
  7358. return m.DeletedAt()
  7359. case chatsession.FieldName:
  7360. return m.Name()
  7361. case chatsession.FieldUserID:
  7362. return m.UserID()
  7363. case chatsession.FieldBotID:
  7364. return m.BotID()
  7365. case chatsession.FieldBotType:
  7366. return m.BotType()
  7367. }
  7368. return nil, false
  7369. }
  7370. // OldField returns the old value of the field from the database. An error is
  7371. // returned if the mutation operation is not UpdateOne, or the query to the
  7372. // database failed.
  7373. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7374. switch name {
  7375. case chatsession.FieldCreatedAt:
  7376. return m.OldCreatedAt(ctx)
  7377. case chatsession.FieldUpdatedAt:
  7378. return m.OldUpdatedAt(ctx)
  7379. case chatsession.FieldDeletedAt:
  7380. return m.OldDeletedAt(ctx)
  7381. case chatsession.FieldName:
  7382. return m.OldName(ctx)
  7383. case chatsession.FieldUserID:
  7384. return m.OldUserID(ctx)
  7385. case chatsession.FieldBotID:
  7386. return m.OldBotID(ctx)
  7387. case chatsession.FieldBotType:
  7388. return m.OldBotType(ctx)
  7389. }
  7390. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  7391. }
  7392. // SetField sets the value of a field with the given name. It returns an error if
  7393. // the field is not defined in the schema, or if the type mismatched the field
  7394. // type.
  7395. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  7396. switch name {
  7397. case chatsession.FieldCreatedAt:
  7398. v, ok := value.(time.Time)
  7399. if !ok {
  7400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7401. }
  7402. m.SetCreatedAt(v)
  7403. return nil
  7404. case chatsession.FieldUpdatedAt:
  7405. v, ok := value.(time.Time)
  7406. if !ok {
  7407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7408. }
  7409. m.SetUpdatedAt(v)
  7410. return nil
  7411. case chatsession.FieldDeletedAt:
  7412. v, ok := value.(time.Time)
  7413. if !ok {
  7414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7415. }
  7416. m.SetDeletedAt(v)
  7417. return nil
  7418. case chatsession.FieldName:
  7419. v, ok := value.(string)
  7420. if !ok {
  7421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7422. }
  7423. m.SetName(v)
  7424. return nil
  7425. case chatsession.FieldUserID:
  7426. v, ok := value.(uint64)
  7427. if !ok {
  7428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7429. }
  7430. m.SetUserID(v)
  7431. return nil
  7432. case chatsession.FieldBotID:
  7433. v, ok := value.(uint64)
  7434. if !ok {
  7435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7436. }
  7437. m.SetBotID(v)
  7438. return nil
  7439. case chatsession.FieldBotType:
  7440. v, ok := value.(uint8)
  7441. if !ok {
  7442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7443. }
  7444. m.SetBotType(v)
  7445. return nil
  7446. }
  7447. return fmt.Errorf("unknown ChatSession field %s", name)
  7448. }
  7449. // AddedFields returns all numeric fields that were incremented/decremented during
  7450. // this mutation.
  7451. func (m *ChatSessionMutation) AddedFields() []string {
  7452. var fields []string
  7453. if m.adduser_id != nil {
  7454. fields = append(fields, chatsession.FieldUserID)
  7455. }
  7456. if m.addbot_id != nil {
  7457. fields = append(fields, chatsession.FieldBotID)
  7458. }
  7459. if m.addbot_type != nil {
  7460. fields = append(fields, chatsession.FieldBotType)
  7461. }
  7462. return fields
  7463. }
  7464. // AddedField returns the numeric value that was incremented/decremented on a field
  7465. // with the given name. The second boolean return value indicates that this field
  7466. // was not set, or was not defined in the schema.
  7467. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  7468. switch name {
  7469. case chatsession.FieldUserID:
  7470. return m.AddedUserID()
  7471. case chatsession.FieldBotID:
  7472. return m.AddedBotID()
  7473. case chatsession.FieldBotType:
  7474. return m.AddedBotType()
  7475. }
  7476. return nil, false
  7477. }
  7478. // AddField adds the value to the field with the given name. It returns an error if
  7479. // the field is not defined in the schema, or if the type mismatched the field
  7480. // type.
  7481. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  7482. switch name {
  7483. case chatsession.FieldUserID:
  7484. v, ok := value.(int64)
  7485. if !ok {
  7486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7487. }
  7488. m.AddUserID(v)
  7489. return nil
  7490. case chatsession.FieldBotID:
  7491. v, ok := value.(int64)
  7492. if !ok {
  7493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7494. }
  7495. m.AddBotID(v)
  7496. return nil
  7497. case chatsession.FieldBotType:
  7498. v, ok := value.(int8)
  7499. if !ok {
  7500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7501. }
  7502. m.AddBotType(v)
  7503. return nil
  7504. }
  7505. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  7506. }
  7507. // ClearedFields returns all nullable fields that were cleared during this
  7508. // mutation.
  7509. func (m *ChatSessionMutation) ClearedFields() []string {
  7510. var fields []string
  7511. if m.FieldCleared(chatsession.FieldDeletedAt) {
  7512. fields = append(fields, chatsession.FieldDeletedAt)
  7513. }
  7514. return fields
  7515. }
  7516. // FieldCleared returns a boolean indicating if a field with the given name was
  7517. // cleared in this mutation.
  7518. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  7519. _, ok := m.clearedFields[name]
  7520. return ok
  7521. }
  7522. // ClearField clears the value of the field with the given name. It returns an
  7523. // error if the field is not defined in the schema.
  7524. func (m *ChatSessionMutation) ClearField(name string) error {
  7525. switch name {
  7526. case chatsession.FieldDeletedAt:
  7527. m.ClearDeletedAt()
  7528. return nil
  7529. }
  7530. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  7531. }
  7532. // ResetField resets all changes in the mutation for the field with the given name.
  7533. // It returns an error if the field is not defined in the schema.
  7534. func (m *ChatSessionMutation) ResetField(name string) error {
  7535. switch name {
  7536. case chatsession.FieldCreatedAt:
  7537. m.ResetCreatedAt()
  7538. return nil
  7539. case chatsession.FieldUpdatedAt:
  7540. m.ResetUpdatedAt()
  7541. return nil
  7542. case chatsession.FieldDeletedAt:
  7543. m.ResetDeletedAt()
  7544. return nil
  7545. case chatsession.FieldName:
  7546. m.ResetName()
  7547. return nil
  7548. case chatsession.FieldUserID:
  7549. m.ResetUserID()
  7550. return nil
  7551. case chatsession.FieldBotID:
  7552. m.ResetBotID()
  7553. return nil
  7554. case chatsession.FieldBotType:
  7555. m.ResetBotType()
  7556. return nil
  7557. }
  7558. return fmt.Errorf("unknown ChatSession field %s", name)
  7559. }
  7560. // AddedEdges returns all edge names that were set/added in this mutation.
  7561. func (m *ChatSessionMutation) AddedEdges() []string {
  7562. edges := make([]string, 0, 0)
  7563. return edges
  7564. }
  7565. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7566. // name in this mutation.
  7567. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  7568. return nil
  7569. }
  7570. // RemovedEdges returns all edge names that were removed in this mutation.
  7571. func (m *ChatSessionMutation) RemovedEdges() []string {
  7572. edges := make([]string, 0, 0)
  7573. return edges
  7574. }
  7575. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7576. // the given name in this mutation.
  7577. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  7578. return nil
  7579. }
  7580. // ClearedEdges returns all edge names that were cleared in this mutation.
  7581. func (m *ChatSessionMutation) ClearedEdges() []string {
  7582. edges := make([]string, 0, 0)
  7583. return edges
  7584. }
  7585. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7586. // was cleared in this mutation.
  7587. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  7588. return false
  7589. }
  7590. // ClearEdge clears the value of the edge with the given name. It returns an error
  7591. // if that edge is not defined in the schema.
  7592. func (m *ChatSessionMutation) ClearEdge(name string) error {
  7593. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  7594. }
  7595. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7596. // It returns an error if the edge is not defined in the schema.
  7597. func (m *ChatSessionMutation) ResetEdge(name string) error {
  7598. return fmt.Errorf("unknown ChatSession edge %s", name)
  7599. }
  7600. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  7601. type ContactMutation struct {
  7602. config
  7603. op Op
  7604. typ string
  7605. id *uint64
  7606. created_at *time.Time
  7607. updated_at *time.Time
  7608. status *uint8
  7609. addstatus *int8
  7610. deleted_at *time.Time
  7611. wx_wxid *string
  7612. _type *int
  7613. add_type *int
  7614. wxid *string
  7615. account *string
  7616. nickname *string
  7617. markname *string
  7618. headimg *string
  7619. sex *int
  7620. addsex *int
  7621. starrole *string
  7622. dontseeit *int
  7623. adddontseeit *int
  7624. dontseeme *int
  7625. adddontseeme *int
  7626. lag *string
  7627. gid *string
  7628. gname *string
  7629. v3 *string
  7630. organization_id *uint64
  7631. addorganization_id *int64
  7632. clearedFields map[string]struct{}
  7633. contact_relationships map[uint64]struct{}
  7634. removedcontact_relationships map[uint64]struct{}
  7635. clearedcontact_relationships bool
  7636. contact_messages map[uint64]struct{}
  7637. removedcontact_messages map[uint64]struct{}
  7638. clearedcontact_messages bool
  7639. done bool
  7640. oldValue func(context.Context) (*Contact, error)
  7641. predicates []predicate.Contact
  7642. }
  7643. var _ ent.Mutation = (*ContactMutation)(nil)
  7644. // contactOption allows management of the mutation configuration using functional options.
  7645. type contactOption func(*ContactMutation)
  7646. // newContactMutation creates new mutation for the Contact entity.
  7647. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  7648. m := &ContactMutation{
  7649. config: c,
  7650. op: op,
  7651. typ: TypeContact,
  7652. clearedFields: make(map[string]struct{}),
  7653. }
  7654. for _, opt := range opts {
  7655. opt(m)
  7656. }
  7657. return m
  7658. }
  7659. // withContactID sets the ID field of the mutation.
  7660. func withContactID(id uint64) contactOption {
  7661. return func(m *ContactMutation) {
  7662. var (
  7663. err error
  7664. once sync.Once
  7665. value *Contact
  7666. )
  7667. m.oldValue = func(ctx context.Context) (*Contact, error) {
  7668. once.Do(func() {
  7669. if m.done {
  7670. err = errors.New("querying old values post mutation is not allowed")
  7671. } else {
  7672. value, err = m.Client().Contact.Get(ctx, id)
  7673. }
  7674. })
  7675. return value, err
  7676. }
  7677. m.id = &id
  7678. }
  7679. }
  7680. // withContact sets the old Contact of the mutation.
  7681. func withContact(node *Contact) contactOption {
  7682. return func(m *ContactMutation) {
  7683. m.oldValue = func(context.Context) (*Contact, error) {
  7684. return node, nil
  7685. }
  7686. m.id = &node.ID
  7687. }
  7688. }
  7689. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7690. // executed in a transaction (ent.Tx), a transactional client is returned.
  7691. func (m ContactMutation) Client() *Client {
  7692. client := &Client{config: m.config}
  7693. client.init()
  7694. return client
  7695. }
  7696. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7697. // it returns an error otherwise.
  7698. func (m ContactMutation) Tx() (*Tx, error) {
  7699. if _, ok := m.driver.(*txDriver); !ok {
  7700. return nil, errors.New("ent: mutation is not running in a transaction")
  7701. }
  7702. tx := &Tx{config: m.config}
  7703. tx.init()
  7704. return tx, nil
  7705. }
  7706. // SetID sets the value of the id field. Note that this
  7707. // operation is only accepted on creation of Contact entities.
  7708. func (m *ContactMutation) SetID(id uint64) {
  7709. m.id = &id
  7710. }
  7711. // ID returns the ID value in the mutation. Note that the ID is only available
  7712. // if it was provided to the builder or after it was returned from the database.
  7713. func (m *ContactMutation) ID() (id uint64, exists bool) {
  7714. if m.id == nil {
  7715. return
  7716. }
  7717. return *m.id, true
  7718. }
  7719. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7720. // That means, if the mutation is applied within a transaction with an isolation level such
  7721. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7722. // or updated by the mutation.
  7723. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  7724. switch {
  7725. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7726. id, exists := m.ID()
  7727. if exists {
  7728. return []uint64{id}, nil
  7729. }
  7730. fallthrough
  7731. case m.op.Is(OpUpdate | OpDelete):
  7732. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  7733. default:
  7734. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7735. }
  7736. }
  7737. // SetCreatedAt sets the "created_at" field.
  7738. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  7739. m.created_at = &t
  7740. }
  7741. // CreatedAt returns the value of the "created_at" field in the mutation.
  7742. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  7743. v := m.created_at
  7744. if v == nil {
  7745. return
  7746. }
  7747. return *v, true
  7748. }
  7749. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  7750. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7751. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7752. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7753. if !m.op.Is(OpUpdateOne) {
  7754. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7755. }
  7756. if m.id == nil || m.oldValue == nil {
  7757. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7758. }
  7759. oldValue, err := m.oldValue(ctx)
  7760. if err != nil {
  7761. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7762. }
  7763. return oldValue.CreatedAt, nil
  7764. }
  7765. // ResetCreatedAt resets all changes to the "created_at" field.
  7766. func (m *ContactMutation) ResetCreatedAt() {
  7767. m.created_at = nil
  7768. }
  7769. // SetUpdatedAt sets the "updated_at" field.
  7770. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  7771. m.updated_at = &t
  7772. }
  7773. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7774. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  7775. v := m.updated_at
  7776. if v == nil {
  7777. return
  7778. }
  7779. return *v, true
  7780. }
  7781. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  7782. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7784. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7785. if !m.op.Is(OpUpdateOne) {
  7786. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7787. }
  7788. if m.id == nil || m.oldValue == nil {
  7789. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7790. }
  7791. oldValue, err := m.oldValue(ctx)
  7792. if err != nil {
  7793. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7794. }
  7795. return oldValue.UpdatedAt, nil
  7796. }
  7797. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7798. func (m *ContactMutation) ResetUpdatedAt() {
  7799. m.updated_at = nil
  7800. }
  7801. // SetStatus sets the "status" field.
  7802. func (m *ContactMutation) SetStatus(u uint8) {
  7803. m.status = &u
  7804. m.addstatus = nil
  7805. }
  7806. // Status returns the value of the "status" field in the mutation.
  7807. func (m *ContactMutation) Status() (r uint8, exists bool) {
  7808. v := m.status
  7809. if v == nil {
  7810. return
  7811. }
  7812. return *v, true
  7813. }
  7814. // OldStatus returns the old "status" field's value of the Contact entity.
  7815. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7817. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7818. if !m.op.Is(OpUpdateOne) {
  7819. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7820. }
  7821. if m.id == nil || m.oldValue == nil {
  7822. return v, errors.New("OldStatus requires an ID field in the mutation")
  7823. }
  7824. oldValue, err := m.oldValue(ctx)
  7825. if err != nil {
  7826. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7827. }
  7828. return oldValue.Status, nil
  7829. }
  7830. // AddStatus adds u to the "status" field.
  7831. func (m *ContactMutation) AddStatus(u int8) {
  7832. if m.addstatus != nil {
  7833. *m.addstatus += u
  7834. } else {
  7835. m.addstatus = &u
  7836. }
  7837. }
  7838. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7839. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  7840. v := m.addstatus
  7841. if v == nil {
  7842. return
  7843. }
  7844. return *v, true
  7845. }
  7846. // ClearStatus clears the value of the "status" field.
  7847. func (m *ContactMutation) ClearStatus() {
  7848. m.status = nil
  7849. m.addstatus = nil
  7850. m.clearedFields[contact.FieldStatus] = struct{}{}
  7851. }
  7852. // StatusCleared returns if the "status" field was cleared in this mutation.
  7853. func (m *ContactMutation) StatusCleared() bool {
  7854. _, ok := m.clearedFields[contact.FieldStatus]
  7855. return ok
  7856. }
  7857. // ResetStatus resets all changes to the "status" field.
  7858. func (m *ContactMutation) ResetStatus() {
  7859. m.status = nil
  7860. m.addstatus = nil
  7861. delete(m.clearedFields, contact.FieldStatus)
  7862. }
  7863. // SetDeletedAt sets the "deleted_at" field.
  7864. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  7865. m.deleted_at = &t
  7866. }
  7867. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7868. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  7869. v := m.deleted_at
  7870. if v == nil {
  7871. return
  7872. }
  7873. return *v, true
  7874. }
  7875. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  7876. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7878. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7879. if !m.op.Is(OpUpdateOne) {
  7880. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7881. }
  7882. if m.id == nil || m.oldValue == nil {
  7883. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7884. }
  7885. oldValue, err := m.oldValue(ctx)
  7886. if err != nil {
  7887. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7888. }
  7889. return oldValue.DeletedAt, nil
  7890. }
  7891. // ClearDeletedAt clears the value of the "deleted_at" field.
  7892. func (m *ContactMutation) ClearDeletedAt() {
  7893. m.deleted_at = nil
  7894. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  7895. }
  7896. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7897. func (m *ContactMutation) DeletedAtCleared() bool {
  7898. _, ok := m.clearedFields[contact.FieldDeletedAt]
  7899. return ok
  7900. }
  7901. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7902. func (m *ContactMutation) ResetDeletedAt() {
  7903. m.deleted_at = nil
  7904. delete(m.clearedFields, contact.FieldDeletedAt)
  7905. }
  7906. // SetWxWxid sets the "wx_wxid" field.
  7907. func (m *ContactMutation) SetWxWxid(s string) {
  7908. m.wx_wxid = &s
  7909. }
  7910. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7911. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  7912. v := m.wx_wxid
  7913. if v == nil {
  7914. return
  7915. }
  7916. return *v, true
  7917. }
  7918. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  7919. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7921. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  7922. if !m.op.Is(OpUpdateOne) {
  7923. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  7924. }
  7925. if m.id == nil || m.oldValue == nil {
  7926. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  7927. }
  7928. oldValue, err := m.oldValue(ctx)
  7929. if err != nil {
  7930. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  7931. }
  7932. return oldValue.WxWxid, nil
  7933. }
  7934. // ResetWxWxid resets all changes to the "wx_wxid" field.
  7935. func (m *ContactMutation) ResetWxWxid() {
  7936. m.wx_wxid = nil
  7937. }
  7938. // SetType sets the "type" field.
  7939. func (m *ContactMutation) SetType(i int) {
  7940. m._type = &i
  7941. m.add_type = nil
  7942. }
  7943. // GetType returns the value of the "type" field in the mutation.
  7944. func (m *ContactMutation) GetType() (r int, exists bool) {
  7945. v := m._type
  7946. if v == nil {
  7947. return
  7948. }
  7949. return *v, true
  7950. }
  7951. // OldType returns the old "type" field's value of the Contact entity.
  7952. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7954. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  7955. if !m.op.Is(OpUpdateOne) {
  7956. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7957. }
  7958. if m.id == nil || m.oldValue == nil {
  7959. return v, errors.New("OldType requires an ID field in the mutation")
  7960. }
  7961. oldValue, err := m.oldValue(ctx)
  7962. if err != nil {
  7963. return v, fmt.Errorf("querying old value for OldType: %w", err)
  7964. }
  7965. return oldValue.Type, nil
  7966. }
  7967. // AddType adds i to the "type" field.
  7968. func (m *ContactMutation) AddType(i int) {
  7969. if m.add_type != nil {
  7970. *m.add_type += i
  7971. } else {
  7972. m.add_type = &i
  7973. }
  7974. }
  7975. // AddedType returns the value that was added to the "type" field in this mutation.
  7976. func (m *ContactMutation) AddedType() (r int, exists bool) {
  7977. v := m.add_type
  7978. if v == nil {
  7979. return
  7980. }
  7981. return *v, true
  7982. }
  7983. // ClearType clears the value of the "type" field.
  7984. func (m *ContactMutation) ClearType() {
  7985. m._type = nil
  7986. m.add_type = nil
  7987. m.clearedFields[contact.FieldType] = struct{}{}
  7988. }
  7989. // TypeCleared returns if the "type" field was cleared in this mutation.
  7990. func (m *ContactMutation) TypeCleared() bool {
  7991. _, ok := m.clearedFields[contact.FieldType]
  7992. return ok
  7993. }
  7994. // ResetType resets all changes to the "type" field.
  7995. func (m *ContactMutation) ResetType() {
  7996. m._type = nil
  7997. m.add_type = nil
  7998. delete(m.clearedFields, contact.FieldType)
  7999. }
  8000. // SetWxid sets the "wxid" field.
  8001. func (m *ContactMutation) SetWxid(s string) {
  8002. m.wxid = &s
  8003. }
  8004. // Wxid returns the value of the "wxid" field in the mutation.
  8005. func (m *ContactMutation) Wxid() (r string, exists bool) {
  8006. v := m.wxid
  8007. if v == nil {
  8008. return
  8009. }
  8010. return *v, true
  8011. }
  8012. // OldWxid returns the old "wxid" field's value of the Contact entity.
  8013. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8015. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  8016. if !m.op.Is(OpUpdateOne) {
  8017. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  8018. }
  8019. if m.id == nil || m.oldValue == nil {
  8020. return v, errors.New("OldWxid requires an ID field in the mutation")
  8021. }
  8022. oldValue, err := m.oldValue(ctx)
  8023. if err != nil {
  8024. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  8025. }
  8026. return oldValue.Wxid, nil
  8027. }
  8028. // ResetWxid resets all changes to the "wxid" field.
  8029. func (m *ContactMutation) ResetWxid() {
  8030. m.wxid = nil
  8031. }
  8032. // SetAccount sets the "account" field.
  8033. func (m *ContactMutation) SetAccount(s string) {
  8034. m.account = &s
  8035. }
  8036. // Account returns the value of the "account" field in the mutation.
  8037. func (m *ContactMutation) Account() (r string, exists bool) {
  8038. v := m.account
  8039. if v == nil {
  8040. return
  8041. }
  8042. return *v, true
  8043. }
  8044. // OldAccount returns the old "account" field's value of the Contact entity.
  8045. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8047. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  8048. if !m.op.Is(OpUpdateOne) {
  8049. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  8050. }
  8051. if m.id == nil || m.oldValue == nil {
  8052. return v, errors.New("OldAccount requires an ID field in the mutation")
  8053. }
  8054. oldValue, err := m.oldValue(ctx)
  8055. if err != nil {
  8056. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  8057. }
  8058. return oldValue.Account, nil
  8059. }
  8060. // ResetAccount resets all changes to the "account" field.
  8061. func (m *ContactMutation) ResetAccount() {
  8062. m.account = nil
  8063. }
  8064. // SetNickname sets the "nickname" field.
  8065. func (m *ContactMutation) SetNickname(s string) {
  8066. m.nickname = &s
  8067. }
  8068. // Nickname returns the value of the "nickname" field in the mutation.
  8069. func (m *ContactMutation) Nickname() (r string, exists bool) {
  8070. v := m.nickname
  8071. if v == nil {
  8072. return
  8073. }
  8074. return *v, true
  8075. }
  8076. // OldNickname returns the old "nickname" field's value of the Contact entity.
  8077. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8079. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  8080. if !m.op.Is(OpUpdateOne) {
  8081. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  8082. }
  8083. if m.id == nil || m.oldValue == nil {
  8084. return v, errors.New("OldNickname requires an ID field in the mutation")
  8085. }
  8086. oldValue, err := m.oldValue(ctx)
  8087. if err != nil {
  8088. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  8089. }
  8090. return oldValue.Nickname, nil
  8091. }
  8092. // ResetNickname resets all changes to the "nickname" field.
  8093. func (m *ContactMutation) ResetNickname() {
  8094. m.nickname = nil
  8095. }
  8096. // SetMarkname sets the "markname" field.
  8097. func (m *ContactMutation) SetMarkname(s string) {
  8098. m.markname = &s
  8099. }
  8100. // Markname returns the value of the "markname" field in the mutation.
  8101. func (m *ContactMutation) Markname() (r string, exists bool) {
  8102. v := m.markname
  8103. if v == nil {
  8104. return
  8105. }
  8106. return *v, true
  8107. }
  8108. // OldMarkname returns the old "markname" field's value of the Contact entity.
  8109. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8110. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8111. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  8112. if !m.op.Is(OpUpdateOne) {
  8113. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  8114. }
  8115. if m.id == nil || m.oldValue == nil {
  8116. return v, errors.New("OldMarkname requires an ID field in the mutation")
  8117. }
  8118. oldValue, err := m.oldValue(ctx)
  8119. if err != nil {
  8120. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  8121. }
  8122. return oldValue.Markname, nil
  8123. }
  8124. // ResetMarkname resets all changes to the "markname" field.
  8125. func (m *ContactMutation) ResetMarkname() {
  8126. m.markname = nil
  8127. }
  8128. // SetHeadimg sets the "headimg" field.
  8129. func (m *ContactMutation) SetHeadimg(s string) {
  8130. m.headimg = &s
  8131. }
  8132. // Headimg returns the value of the "headimg" field in the mutation.
  8133. func (m *ContactMutation) Headimg() (r string, exists bool) {
  8134. v := m.headimg
  8135. if v == nil {
  8136. return
  8137. }
  8138. return *v, true
  8139. }
  8140. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  8141. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8142. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8143. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  8144. if !m.op.Is(OpUpdateOne) {
  8145. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  8146. }
  8147. if m.id == nil || m.oldValue == nil {
  8148. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  8149. }
  8150. oldValue, err := m.oldValue(ctx)
  8151. if err != nil {
  8152. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  8153. }
  8154. return oldValue.Headimg, nil
  8155. }
  8156. // ResetHeadimg resets all changes to the "headimg" field.
  8157. func (m *ContactMutation) ResetHeadimg() {
  8158. m.headimg = nil
  8159. }
  8160. // SetSex sets the "sex" field.
  8161. func (m *ContactMutation) SetSex(i int) {
  8162. m.sex = &i
  8163. m.addsex = nil
  8164. }
  8165. // Sex returns the value of the "sex" field in the mutation.
  8166. func (m *ContactMutation) Sex() (r int, exists bool) {
  8167. v := m.sex
  8168. if v == nil {
  8169. return
  8170. }
  8171. return *v, true
  8172. }
  8173. // OldSex returns the old "sex" field's value of the Contact entity.
  8174. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8176. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  8177. if !m.op.Is(OpUpdateOne) {
  8178. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  8179. }
  8180. if m.id == nil || m.oldValue == nil {
  8181. return v, errors.New("OldSex requires an ID field in the mutation")
  8182. }
  8183. oldValue, err := m.oldValue(ctx)
  8184. if err != nil {
  8185. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  8186. }
  8187. return oldValue.Sex, nil
  8188. }
  8189. // AddSex adds i to the "sex" field.
  8190. func (m *ContactMutation) AddSex(i int) {
  8191. if m.addsex != nil {
  8192. *m.addsex += i
  8193. } else {
  8194. m.addsex = &i
  8195. }
  8196. }
  8197. // AddedSex returns the value that was added to the "sex" field in this mutation.
  8198. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  8199. v := m.addsex
  8200. if v == nil {
  8201. return
  8202. }
  8203. return *v, true
  8204. }
  8205. // ResetSex resets all changes to the "sex" field.
  8206. func (m *ContactMutation) ResetSex() {
  8207. m.sex = nil
  8208. m.addsex = nil
  8209. }
  8210. // SetStarrole sets the "starrole" field.
  8211. func (m *ContactMutation) SetStarrole(s string) {
  8212. m.starrole = &s
  8213. }
  8214. // Starrole returns the value of the "starrole" field in the mutation.
  8215. func (m *ContactMutation) Starrole() (r string, exists bool) {
  8216. v := m.starrole
  8217. if v == nil {
  8218. return
  8219. }
  8220. return *v, true
  8221. }
  8222. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  8223. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8225. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  8226. if !m.op.Is(OpUpdateOne) {
  8227. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  8228. }
  8229. if m.id == nil || m.oldValue == nil {
  8230. return v, errors.New("OldStarrole requires an ID field in the mutation")
  8231. }
  8232. oldValue, err := m.oldValue(ctx)
  8233. if err != nil {
  8234. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  8235. }
  8236. return oldValue.Starrole, nil
  8237. }
  8238. // ResetStarrole resets all changes to the "starrole" field.
  8239. func (m *ContactMutation) ResetStarrole() {
  8240. m.starrole = nil
  8241. }
  8242. // SetDontseeit sets the "dontseeit" field.
  8243. func (m *ContactMutation) SetDontseeit(i int) {
  8244. m.dontseeit = &i
  8245. m.adddontseeit = nil
  8246. }
  8247. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  8248. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  8249. v := m.dontseeit
  8250. if v == nil {
  8251. return
  8252. }
  8253. return *v, true
  8254. }
  8255. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  8256. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8258. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  8259. if !m.op.Is(OpUpdateOne) {
  8260. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  8261. }
  8262. if m.id == nil || m.oldValue == nil {
  8263. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  8264. }
  8265. oldValue, err := m.oldValue(ctx)
  8266. if err != nil {
  8267. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  8268. }
  8269. return oldValue.Dontseeit, nil
  8270. }
  8271. // AddDontseeit adds i to the "dontseeit" field.
  8272. func (m *ContactMutation) AddDontseeit(i int) {
  8273. if m.adddontseeit != nil {
  8274. *m.adddontseeit += i
  8275. } else {
  8276. m.adddontseeit = &i
  8277. }
  8278. }
  8279. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  8280. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  8281. v := m.adddontseeit
  8282. if v == nil {
  8283. return
  8284. }
  8285. return *v, true
  8286. }
  8287. // ResetDontseeit resets all changes to the "dontseeit" field.
  8288. func (m *ContactMutation) ResetDontseeit() {
  8289. m.dontseeit = nil
  8290. m.adddontseeit = nil
  8291. }
  8292. // SetDontseeme sets the "dontseeme" field.
  8293. func (m *ContactMutation) SetDontseeme(i int) {
  8294. m.dontseeme = &i
  8295. m.adddontseeme = nil
  8296. }
  8297. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  8298. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  8299. v := m.dontseeme
  8300. if v == nil {
  8301. return
  8302. }
  8303. return *v, true
  8304. }
  8305. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  8306. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8308. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  8309. if !m.op.Is(OpUpdateOne) {
  8310. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  8311. }
  8312. if m.id == nil || m.oldValue == nil {
  8313. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  8314. }
  8315. oldValue, err := m.oldValue(ctx)
  8316. if err != nil {
  8317. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  8318. }
  8319. return oldValue.Dontseeme, nil
  8320. }
  8321. // AddDontseeme adds i to the "dontseeme" field.
  8322. func (m *ContactMutation) AddDontseeme(i int) {
  8323. if m.adddontseeme != nil {
  8324. *m.adddontseeme += i
  8325. } else {
  8326. m.adddontseeme = &i
  8327. }
  8328. }
  8329. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  8330. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  8331. v := m.adddontseeme
  8332. if v == nil {
  8333. return
  8334. }
  8335. return *v, true
  8336. }
  8337. // ResetDontseeme resets all changes to the "dontseeme" field.
  8338. func (m *ContactMutation) ResetDontseeme() {
  8339. m.dontseeme = nil
  8340. m.adddontseeme = nil
  8341. }
  8342. // SetLag sets the "lag" field.
  8343. func (m *ContactMutation) SetLag(s string) {
  8344. m.lag = &s
  8345. }
  8346. // Lag returns the value of the "lag" field in the mutation.
  8347. func (m *ContactMutation) Lag() (r string, exists bool) {
  8348. v := m.lag
  8349. if v == nil {
  8350. return
  8351. }
  8352. return *v, true
  8353. }
  8354. // OldLag returns the old "lag" field's value of the Contact entity.
  8355. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8357. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  8358. if !m.op.Is(OpUpdateOne) {
  8359. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  8360. }
  8361. if m.id == nil || m.oldValue == nil {
  8362. return v, errors.New("OldLag requires an ID field in the mutation")
  8363. }
  8364. oldValue, err := m.oldValue(ctx)
  8365. if err != nil {
  8366. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  8367. }
  8368. return oldValue.Lag, nil
  8369. }
  8370. // ResetLag resets all changes to the "lag" field.
  8371. func (m *ContactMutation) ResetLag() {
  8372. m.lag = nil
  8373. }
  8374. // SetGid sets the "gid" field.
  8375. func (m *ContactMutation) SetGid(s string) {
  8376. m.gid = &s
  8377. }
  8378. // Gid returns the value of the "gid" field in the mutation.
  8379. func (m *ContactMutation) Gid() (r string, exists bool) {
  8380. v := m.gid
  8381. if v == nil {
  8382. return
  8383. }
  8384. return *v, true
  8385. }
  8386. // OldGid returns the old "gid" field's value of the Contact entity.
  8387. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8389. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  8390. if !m.op.Is(OpUpdateOne) {
  8391. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  8392. }
  8393. if m.id == nil || m.oldValue == nil {
  8394. return v, errors.New("OldGid requires an ID field in the mutation")
  8395. }
  8396. oldValue, err := m.oldValue(ctx)
  8397. if err != nil {
  8398. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  8399. }
  8400. return oldValue.Gid, nil
  8401. }
  8402. // ResetGid resets all changes to the "gid" field.
  8403. func (m *ContactMutation) ResetGid() {
  8404. m.gid = nil
  8405. }
  8406. // SetGname sets the "gname" field.
  8407. func (m *ContactMutation) SetGname(s string) {
  8408. m.gname = &s
  8409. }
  8410. // Gname returns the value of the "gname" field in the mutation.
  8411. func (m *ContactMutation) Gname() (r string, exists bool) {
  8412. v := m.gname
  8413. if v == nil {
  8414. return
  8415. }
  8416. return *v, true
  8417. }
  8418. // OldGname returns the old "gname" field's value of the Contact entity.
  8419. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8421. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  8422. if !m.op.Is(OpUpdateOne) {
  8423. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  8424. }
  8425. if m.id == nil || m.oldValue == nil {
  8426. return v, errors.New("OldGname requires an ID field in the mutation")
  8427. }
  8428. oldValue, err := m.oldValue(ctx)
  8429. if err != nil {
  8430. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  8431. }
  8432. return oldValue.Gname, nil
  8433. }
  8434. // ResetGname resets all changes to the "gname" field.
  8435. func (m *ContactMutation) ResetGname() {
  8436. m.gname = nil
  8437. }
  8438. // SetV3 sets the "v3" field.
  8439. func (m *ContactMutation) SetV3(s string) {
  8440. m.v3 = &s
  8441. }
  8442. // V3 returns the value of the "v3" field in the mutation.
  8443. func (m *ContactMutation) V3() (r string, exists bool) {
  8444. v := m.v3
  8445. if v == nil {
  8446. return
  8447. }
  8448. return *v, true
  8449. }
  8450. // OldV3 returns the old "v3" field's value of the Contact entity.
  8451. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8453. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  8454. if !m.op.Is(OpUpdateOne) {
  8455. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  8456. }
  8457. if m.id == nil || m.oldValue == nil {
  8458. return v, errors.New("OldV3 requires an ID field in the mutation")
  8459. }
  8460. oldValue, err := m.oldValue(ctx)
  8461. if err != nil {
  8462. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  8463. }
  8464. return oldValue.V3, nil
  8465. }
  8466. // ResetV3 resets all changes to the "v3" field.
  8467. func (m *ContactMutation) ResetV3() {
  8468. m.v3 = nil
  8469. }
  8470. // SetOrganizationID sets the "organization_id" field.
  8471. func (m *ContactMutation) SetOrganizationID(u uint64) {
  8472. m.organization_id = &u
  8473. m.addorganization_id = nil
  8474. }
  8475. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8476. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  8477. v := m.organization_id
  8478. if v == nil {
  8479. return
  8480. }
  8481. return *v, true
  8482. }
  8483. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  8484. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8486. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8487. if !m.op.Is(OpUpdateOne) {
  8488. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8489. }
  8490. if m.id == nil || m.oldValue == nil {
  8491. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8492. }
  8493. oldValue, err := m.oldValue(ctx)
  8494. if err != nil {
  8495. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8496. }
  8497. return oldValue.OrganizationID, nil
  8498. }
  8499. // AddOrganizationID adds u to the "organization_id" field.
  8500. func (m *ContactMutation) AddOrganizationID(u int64) {
  8501. if m.addorganization_id != nil {
  8502. *m.addorganization_id += u
  8503. } else {
  8504. m.addorganization_id = &u
  8505. }
  8506. }
  8507. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8508. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  8509. v := m.addorganization_id
  8510. if v == nil {
  8511. return
  8512. }
  8513. return *v, true
  8514. }
  8515. // ClearOrganizationID clears the value of the "organization_id" field.
  8516. func (m *ContactMutation) ClearOrganizationID() {
  8517. m.organization_id = nil
  8518. m.addorganization_id = nil
  8519. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  8520. }
  8521. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  8522. func (m *ContactMutation) OrganizationIDCleared() bool {
  8523. _, ok := m.clearedFields[contact.FieldOrganizationID]
  8524. return ok
  8525. }
  8526. // ResetOrganizationID resets all changes to the "organization_id" field.
  8527. func (m *ContactMutation) ResetOrganizationID() {
  8528. m.organization_id = nil
  8529. m.addorganization_id = nil
  8530. delete(m.clearedFields, contact.FieldOrganizationID)
  8531. }
  8532. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  8533. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  8534. if m.contact_relationships == nil {
  8535. m.contact_relationships = make(map[uint64]struct{})
  8536. }
  8537. for i := range ids {
  8538. m.contact_relationships[ids[i]] = struct{}{}
  8539. }
  8540. }
  8541. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  8542. func (m *ContactMutation) ClearContactRelationships() {
  8543. m.clearedcontact_relationships = true
  8544. }
  8545. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  8546. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  8547. return m.clearedcontact_relationships
  8548. }
  8549. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  8550. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  8551. if m.removedcontact_relationships == nil {
  8552. m.removedcontact_relationships = make(map[uint64]struct{})
  8553. }
  8554. for i := range ids {
  8555. delete(m.contact_relationships, ids[i])
  8556. m.removedcontact_relationships[ids[i]] = struct{}{}
  8557. }
  8558. }
  8559. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  8560. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  8561. for id := range m.removedcontact_relationships {
  8562. ids = append(ids, id)
  8563. }
  8564. return
  8565. }
  8566. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  8567. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  8568. for id := range m.contact_relationships {
  8569. ids = append(ids, id)
  8570. }
  8571. return
  8572. }
  8573. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  8574. func (m *ContactMutation) ResetContactRelationships() {
  8575. m.contact_relationships = nil
  8576. m.clearedcontact_relationships = false
  8577. m.removedcontact_relationships = nil
  8578. }
  8579. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  8580. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  8581. if m.contact_messages == nil {
  8582. m.contact_messages = make(map[uint64]struct{})
  8583. }
  8584. for i := range ids {
  8585. m.contact_messages[ids[i]] = struct{}{}
  8586. }
  8587. }
  8588. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  8589. func (m *ContactMutation) ClearContactMessages() {
  8590. m.clearedcontact_messages = true
  8591. }
  8592. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  8593. func (m *ContactMutation) ContactMessagesCleared() bool {
  8594. return m.clearedcontact_messages
  8595. }
  8596. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  8597. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  8598. if m.removedcontact_messages == nil {
  8599. m.removedcontact_messages = make(map[uint64]struct{})
  8600. }
  8601. for i := range ids {
  8602. delete(m.contact_messages, ids[i])
  8603. m.removedcontact_messages[ids[i]] = struct{}{}
  8604. }
  8605. }
  8606. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  8607. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  8608. for id := range m.removedcontact_messages {
  8609. ids = append(ids, id)
  8610. }
  8611. return
  8612. }
  8613. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  8614. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  8615. for id := range m.contact_messages {
  8616. ids = append(ids, id)
  8617. }
  8618. return
  8619. }
  8620. // ResetContactMessages resets all changes to the "contact_messages" edge.
  8621. func (m *ContactMutation) ResetContactMessages() {
  8622. m.contact_messages = nil
  8623. m.clearedcontact_messages = false
  8624. m.removedcontact_messages = nil
  8625. }
  8626. // Where appends a list predicates to the ContactMutation builder.
  8627. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  8628. m.predicates = append(m.predicates, ps...)
  8629. }
  8630. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  8631. // users can use type-assertion to append predicates that do not depend on any generated package.
  8632. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  8633. p := make([]predicate.Contact, len(ps))
  8634. for i := range ps {
  8635. p[i] = ps[i]
  8636. }
  8637. m.Where(p...)
  8638. }
  8639. // Op returns the operation name.
  8640. func (m *ContactMutation) Op() Op {
  8641. return m.op
  8642. }
  8643. // SetOp allows setting the mutation operation.
  8644. func (m *ContactMutation) SetOp(op Op) {
  8645. m.op = op
  8646. }
  8647. // Type returns the node type of this mutation (Contact).
  8648. func (m *ContactMutation) Type() string {
  8649. return m.typ
  8650. }
  8651. // Fields returns all fields that were changed during this mutation. Note that in
  8652. // order to get all numeric fields that were incremented/decremented, call
  8653. // AddedFields().
  8654. func (m *ContactMutation) Fields() []string {
  8655. fields := make([]string, 0, 20)
  8656. if m.created_at != nil {
  8657. fields = append(fields, contact.FieldCreatedAt)
  8658. }
  8659. if m.updated_at != nil {
  8660. fields = append(fields, contact.FieldUpdatedAt)
  8661. }
  8662. if m.status != nil {
  8663. fields = append(fields, contact.FieldStatus)
  8664. }
  8665. if m.deleted_at != nil {
  8666. fields = append(fields, contact.FieldDeletedAt)
  8667. }
  8668. if m.wx_wxid != nil {
  8669. fields = append(fields, contact.FieldWxWxid)
  8670. }
  8671. if m._type != nil {
  8672. fields = append(fields, contact.FieldType)
  8673. }
  8674. if m.wxid != nil {
  8675. fields = append(fields, contact.FieldWxid)
  8676. }
  8677. if m.account != nil {
  8678. fields = append(fields, contact.FieldAccount)
  8679. }
  8680. if m.nickname != nil {
  8681. fields = append(fields, contact.FieldNickname)
  8682. }
  8683. if m.markname != nil {
  8684. fields = append(fields, contact.FieldMarkname)
  8685. }
  8686. if m.headimg != nil {
  8687. fields = append(fields, contact.FieldHeadimg)
  8688. }
  8689. if m.sex != nil {
  8690. fields = append(fields, contact.FieldSex)
  8691. }
  8692. if m.starrole != nil {
  8693. fields = append(fields, contact.FieldStarrole)
  8694. }
  8695. if m.dontseeit != nil {
  8696. fields = append(fields, contact.FieldDontseeit)
  8697. }
  8698. if m.dontseeme != nil {
  8699. fields = append(fields, contact.FieldDontseeme)
  8700. }
  8701. if m.lag != nil {
  8702. fields = append(fields, contact.FieldLag)
  8703. }
  8704. if m.gid != nil {
  8705. fields = append(fields, contact.FieldGid)
  8706. }
  8707. if m.gname != nil {
  8708. fields = append(fields, contact.FieldGname)
  8709. }
  8710. if m.v3 != nil {
  8711. fields = append(fields, contact.FieldV3)
  8712. }
  8713. if m.organization_id != nil {
  8714. fields = append(fields, contact.FieldOrganizationID)
  8715. }
  8716. return fields
  8717. }
  8718. // Field returns the value of a field with the given name. The second boolean
  8719. // return value indicates that this field was not set, or was not defined in the
  8720. // schema.
  8721. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  8722. switch name {
  8723. case contact.FieldCreatedAt:
  8724. return m.CreatedAt()
  8725. case contact.FieldUpdatedAt:
  8726. return m.UpdatedAt()
  8727. case contact.FieldStatus:
  8728. return m.Status()
  8729. case contact.FieldDeletedAt:
  8730. return m.DeletedAt()
  8731. case contact.FieldWxWxid:
  8732. return m.WxWxid()
  8733. case contact.FieldType:
  8734. return m.GetType()
  8735. case contact.FieldWxid:
  8736. return m.Wxid()
  8737. case contact.FieldAccount:
  8738. return m.Account()
  8739. case contact.FieldNickname:
  8740. return m.Nickname()
  8741. case contact.FieldMarkname:
  8742. return m.Markname()
  8743. case contact.FieldHeadimg:
  8744. return m.Headimg()
  8745. case contact.FieldSex:
  8746. return m.Sex()
  8747. case contact.FieldStarrole:
  8748. return m.Starrole()
  8749. case contact.FieldDontseeit:
  8750. return m.Dontseeit()
  8751. case contact.FieldDontseeme:
  8752. return m.Dontseeme()
  8753. case contact.FieldLag:
  8754. return m.Lag()
  8755. case contact.FieldGid:
  8756. return m.Gid()
  8757. case contact.FieldGname:
  8758. return m.Gname()
  8759. case contact.FieldV3:
  8760. return m.V3()
  8761. case contact.FieldOrganizationID:
  8762. return m.OrganizationID()
  8763. }
  8764. return nil, false
  8765. }
  8766. // OldField returns the old value of the field from the database. An error is
  8767. // returned if the mutation operation is not UpdateOne, or the query to the
  8768. // database failed.
  8769. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8770. switch name {
  8771. case contact.FieldCreatedAt:
  8772. return m.OldCreatedAt(ctx)
  8773. case contact.FieldUpdatedAt:
  8774. return m.OldUpdatedAt(ctx)
  8775. case contact.FieldStatus:
  8776. return m.OldStatus(ctx)
  8777. case contact.FieldDeletedAt:
  8778. return m.OldDeletedAt(ctx)
  8779. case contact.FieldWxWxid:
  8780. return m.OldWxWxid(ctx)
  8781. case contact.FieldType:
  8782. return m.OldType(ctx)
  8783. case contact.FieldWxid:
  8784. return m.OldWxid(ctx)
  8785. case contact.FieldAccount:
  8786. return m.OldAccount(ctx)
  8787. case contact.FieldNickname:
  8788. return m.OldNickname(ctx)
  8789. case contact.FieldMarkname:
  8790. return m.OldMarkname(ctx)
  8791. case contact.FieldHeadimg:
  8792. return m.OldHeadimg(ctx)
  8793. case contact.FieldSex:
  8794. return m.OldSex(ctx)
  8795. case contact.FieldStarrole:
  8796. return m.OldStarrole(ctx)
  8797. case contact.FieldDontseeit:
  8798. return m.OldDontseeit(ctx)
  8799. case contact.FieldDontseeme:
  8800. return m.OldDontseeme(ctx)
  8801. case contact.FieldLag:
  8802. return m.OldLag(ctx)
  8803. case contact.FieldGid:
  8804. return m.OldGid(ctx)
  8805. case contact.FieldGname:
  8806. return m.OldGname(ctx)
  8807. case contact.FieldV3:
  8808. return m.OldV3(ctx)
  8809. case contact.FieldOrganizationID:
  8810. return m.OldOrganizationID(ctx)
  8811. }
  8812. return nil, fmt.Errorf("unknown Contact field %s", name)
  8813. }
  8814. // SetField sets the value of a field with the given name. It returns an error if
  8815. // the field is not defined in the schema, or if the type mismatched the field
  8816. // type.
  8817. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  8818. switch name {
  8819. case contact.FieldCreatedAt:
  8820. v, ok := value.(time.Time)
  8821. if !ok {
  8822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8823. }
  8824. m.SetCreatedAt(v)
  8825. return nil
  8826. case contact.FieldUpdatedAt:
  8827. v, ok := value.(time.Time)
  8828. if !ok {
  8829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8830. }
  8831. m.SetUpdatedAt(v)
  8832. return nil
  8833. case contact.FieldStatus:
  8834. v, ok := value.(uint8)
  8835. if !ok {
  8836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8837. }
  8838. m.SetStatus(v)
  8839. return nil
  8840. case contact.FieldDeletedAt:
  8841. v, ok := value.(time.Time)
  8842. if !ok {
  8843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8844. }
  8845. m.SetDeletedAt(v)
  8846. return nil
  8847. case contact.FieldWxWxid:
  8848. v, ok := value.(string)
  8849. if !ok {
  8850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8851. }
  8852. m.SetWxWxid(v)
  8853. return nil
  8854. case contact.FieldType:
  8855. v, ok := value.(int)
  8856. if !ok {
  8857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8858. }
  8859. m.SetType(v)
  8860. return nil
  8861. case contact.FieldWxid:
  8862. v, ok := value.(string)
  8863. if !ok {
  8864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8865. }
  8866. m.SetWxid(v)
  8867. return nil
  8868. case contact.FieldAccount:
  8869. v, ok := value.(string)
  8870. if !ok {
  8871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8872. }
  8873. m.SetAccount(v)
  8874. return nil
  8875. case contact.FieldNickname:
  8876. v, ok := value.(string)
  8877. if !ok {
  8878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8879. }
  8880. m.SetNickname(v)
  8881. return nil
  8882. case contact.FieldMarkname:
  8883. v, ok := value.(string)
  8884. if !ok {
  8885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8886. }
  8887. m.SetMarkname(v)
  8888. return nil
  8889. case contact.FieldHeadimg:
  8890. v, ok := value.(string)
  8891. if !ok {
  8892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8893. }
  8894. m.SetHeadimg(v)
  8895. return nil
  8896. case contact.FieldSex:
  8897. v, ok := value.(int)
  8898. if !ok {
  8899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8900. }
  8901. m.SetSex(v)
  8902. return nil
  8903. case contact.FieldStarrole:
  8904. v, ok := value.(string)
  8905. if !ok {
  8906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8907. }
  8908. m.SetStarrole(v)
  8909. return nil
  8910. case contact.FieldDontseeit:
  8911. v, ok := value.(int)
  8912. if !ok {
  8913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8914. }
  8915. m.SetDontseeit(v)
  8916. return nil
  8917. case contact.FieldDontseeme:
  8918. v, ok := value.(int)
  8919. if !ok {
  8920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8921. }
  8922. m.SetDontseeme(v)
  8923. return nil
  8924. case contact.FieldLag:
  8925. v, ok := value.(string)
  8926. if !ok {
  8927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8928. }
  8929. m.SetLag(v)
  8930. return nil
  8931. case contact.FieldGid:
  8932. v, ok := value.(string)
  8933. if !ok {
  8934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8935. }
  8936. m.SetGid(v)
  8937. return nil
  8938. case contact.FieldGname:
  8939. v, ok := value.(string)
  8940. if !ok {
  8941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8942. }
  8943. m.SetGname(v)
  8944. return nil
  8945. case contact.FieldV3:
  8946. v, ok := value.(string)
  8947. if !ok {
  8948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8949. }
  8950. m.SetV3(v)
  8951. return nil
  8952. case contact.FieldOrganizationID:
  8953. v, ok := value.(uint64)
  8954. if !ok {
  8955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8956. }
  8957. m.SetOrganizationID(v)
  8958. return nil
  8959. }
  8960. return fmt.Errorf("unknown Contact field %s", name)
  8961. }
  8962. // AddedFields returns all numeric fields that were incremented/decremented during
  8963. // this mutation.
  8964. func (m *ContactMutation) AddedFields() []string {
  8965. var fields []string
  8966. if m.addstatus != nil {
  8967. fields = append(fields, contact.FieldStatus)
  8968. }
  8969. if m.add_type != nil {
  8970. fields = append(fields, contact.FieldType)
  8971. }
  8972. if m.addsex != nil {
  8973. fields = append(fields, contact.FieldSex)
  8974. }
  8975. if m.adddontseeit != nil {
  8976. fields = append(fields, contact.FieldDontseeit)
  8977. }
  8978. if m.adddontseeme != nil {
  8979. fields = append(fields, contact.FieldDontseeme)
  8980. }
  8981. if m.addorganization_id != nil {
  8982. fields = append(fields, contact.FieldOrganizationID)
  8983. }
  8984. return fields
  8985. }
  8986. // AddedField returns the numeric value that was incremented/decremented on a field
  8987. // with the given name. The second boolean return value indicates that this field
  8988. // was not set, or was not defined in the schema.
  8989. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  8990. switch name {
  8991. case contact.FieldStatus:
  8992. return m.AddedStatus()
  8993. case contact.FieldType:
  8994. return m.AddedType()
  8995. case contact.FieldSex:
  8996. return m.AddedSex()
  8997. case contact.FieldDontseeit:
  8998. return m.AddedDontseeit()
  8999. case contact.FieldDontseeme:
  9000. return m.AddedDontseeme()
  9001. case contact.FieldOrganizationID:
  9002. return m.AddedOrganizationID()
  9003. }
  9004. return nil, false
  9005. }
  9006. // AddField adds the value to the field with the given name. It returns an error if
  9007. // the field is not defined in the schema, or if the type mismatched the field
  9008. // type.
  9009. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  9010. switch name {
  9011. case contact.FieldStatus:
  9012. v, ok := value.(int8)
  9013. if !ok {
  9014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9015. }
  9016. m.AddStatus(v)
  9017. return nil
  9018. case contact.FieldType:
  9019. v, ok := value.(int)
  9020. if !ok {
  9021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9022. }
  9023. m.AddType(v)
  9024. return nil
  9025. case contact.FieldSex:
  9026. v, ok := value.(int)
  9027. if !ok {
  9028. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9029. }
  9030. m.AddSex(v)
  9031. return nil
  9032. case contact.FieldDontseeit:
  9033. v, ok := value.(int)
  9034. if !ok {
  9035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9036. }
  9037. m.AddDontseeit(v)
  9038. return nil
  9039. case contact.FieldDontseeme:
  9040. v, ok := value.(int)
  9041. if !ok {
  9042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9043. }
  9044. m.AddDontseeme(v)
  9045. return nil
  9046. case contact.FieldOrganizationID:
  9047. v, ok := value.(int64)
  9048. if !ok {
  9049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9050. }
  9051. m.AddOrganizationID(v)
  9052. return nil
  9053. }
  9054. return fmt.Errorf("unknown Contact numeric field %s", name)
  9055. }
  9056. // ClearedFields returns all nullable fields that were cleared during this
  9057. // mutation.
  9058. func (m *ContactMutation) ClearedFields() []string {
  9059. var fields []string
  9060. if m.FieldCleared(contact.FieldStatus) {
  9061. fields = append(fields, contact.FieldStatus)
  9062. }
  9063. if m.FieldCleared(contact.FieldDeletedAt) {
  9064. fields = append(fields, contact.FieldDeletedAt)
  9065. }
  9066. if m.FieldCleared(contact.FieldType) {
  9067. fields = append(fields, contact.FieldType)
  9068. }
  9069. if m.FieldCleared(contact.FieldOrganizationID) {
  9070. fields = append(fields, contact.FieldOrganizationID)
  9071. }
  9072. return fields
  9073. }
  9074. // FieldCleared returns a boolean indicating if a field with the given name was
  9075. // cleared in this mutation.
  9076. func (m *ContactMutation) FieldCleared(name string) bool {
  9077. _, ok := m.clearedFields[name]
  9078. return ok
  9079. }
  9080. // ClearField clears the value of the field with the given name. It returns an
  9081. // error if the field is not defined in the schema.
  9082. func (m *ContactMutation) ClearField(name string) error {
  9083. switch name {
  9084. case contact.FieldStatus:
  9085. m.ClearStatus()
  9086. return nil
  9087. case contact.FieldDeletedAt:
  9088. m.ClearDeletedAt()
  9089. return nil
  9090. case contact.FieldType:
  9091. m.ClearType()
  9092. return nil
  9093. case contact.FieldOrganizationID:
  9094. m.ClearOrganizationID()
  9095. return nil
  9096. }
  9097. return fmt.Errorf("unknown Contact nullable field %s", name)
  9098. }
  9099. // ResetField resets all changes in the mutation for the field with the given name.
  9100. // It returns an error if the field is not defined in the schema.
  9101. func (m *ContactMutation) ResetField(name string) error {
  9102. switch name {
  9103. case contact.FieldCreatedAt:
  9104. m.ResetCreatedAt()
  9105. return nil
  9106. case contact.FieldUpdatedAt:
  9107. m.ResetUpdatedAt()
  9108. return nil
  9109. case contact.FieldStatus:
  9110. m.ResetStatus()
  9111. return nil
  9112. case contact.FieldDeletedAt:
  9113. m.ResetDeletedAt()
  9114. return nil
  9115. case contact.FieldWxWxid:
  9116. m.ResetWxWxid()
  9117. return nil
  9118. case contact.FieldType:
  9119. m.ResetType()
  9120. return nil
  9121. case contact.FieldWxid:
  9122. m.ResetWxid()
  9123. return nil
  9124. case contact.FieldAccount:
  9125. m.ResetAccount()
  9126. return nil
  9127. case contact.FieldNickname:
  9128. m.ResetNickname()
  9129. return nil
  9130. case contact.FieldMarkname:
  9131. m.ResetMarkname()
  9132. return nil
  9133. case contact.FieldHeadimg:
  9134. m.ResetHeadimg()
  9135. return nil
  9136. case contact.FieldSex:
  9137. m.ResetSex()
  9138. return nil
  9139. case contact.FieldStarrole:
  9140. m.ResetStarrole()
  9141. return nil
  9142. case contact.FieldDontseeit:
  9143. m.ResetDontseeit()
  9144. return nil
  9145. case contact.FieldDontseeme:
  9146. m.ResetDontseeme()
  9147. return nil
  9148. case contact.FieldLag:
  9149. m.ResetLag()
  9150. return nil
  9151. case contact.FieldGid:
  9152. m.ResetGid()
  9153. return nil
  9154. case contact.FieldGname:
  9155. m.ResetGname()
  9156. return nil
  9157. case contact.FieldV3:
  9158. m.ResetV3()
  9159. return nil
  9160. case contact.FieldOrganizationID:
  9161. m.ResetOrganizationID()
  9162. return nil
  9163. }
  9164. return fmt.Errorf("unknown Contact field %s", name)
  9165. }
  9166. // AddedEdges returns all edge names that were set/added in this mutation.
  9167. func (m *ContactMutation) AddedEdges() []string {
  9168. edges := make([]string, 0, 2)
  9169. if m.contact_relationships != nil {
  9170. edges = append(edges, contact.EdgeContactRelationships)
  9171. }
  9172. if m.contact_messages != nil {
  9173. edges = append(edges, contact.EdgeContactMessages)
  9174. }
  9175. return edges
  9176. }
  9177. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9178. // name in this mutation.
  9179. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  9180. switch name {
  9181. case contact.EdgeContactRelationships:
  9182. ids := make([]ent.Value, 0, len(m.contact_relationships))
  9183. for id := range m.contact_relationships {
  9184. ids = append(ids, id)
  9185. }
  9186. return ids
  9187. case contact.EdgeContactMessages:
  9188. ids := make([]ent.Value, 0, len(m.contact_messages))
  9189. for id := range m.contact_messages {
  9190. ids = append(ids, id)
  9191. }
  9192. return ids
  9193. }
  9194. return nil
  9195. }
  9196. // RemovedEdges returns all edge names that were removed in this mutation.
  9197. func (m *ContactMutation) RemovedEdges() []string {
  9198. edges := make([]string, 0, 2)
  9199. if m.removedcontact_relationships != nil {
  9200. edges = append(edges, contact.EdgeContactRelationships)
  9201. }
  9202. if m.removedcontact_messages != nil {
  9203. edges = append(edges, contact.EdgeContactMessages)
  9204. }
  9205. return edges
  9206. }
  9207. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9208. // the given name in this mutation.
  9209. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  9210. switch name {
  9211. case contact.EdgeContactRelationships:
  9212. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  9213. for id := range m.removedcontact_relationships {
  9214. ids = append(ids, id)
  9215. }
  9216. return ids
  9217. case contact.EdgeContactMessages:
  9218. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  9219. for id := range m.removedcontact_messages {
  9220. ids = append(ids, id)
  9221. }
  9222. return ids
  9223. }
  9224. return nil
  9225. }
  9226. // ClearedEdges returns all edge names that were cleared in this mutation.
  9227. func (m *ContactMutation) ClearedEdges() []string {
  9228. edges := make([]string, 0, 2)
  9229. if m.clearedcontact_relationships {
  9230. edges = append(edges, contact.EdgeContactRelationships)
  9231. }
  9232. if m.clearedcontact_messages {
  9233. edges = append(edges, contact.EdgeContactMessages)
  9234. }
  9235. return edges
  9236. }
  9237. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9238. // was cleared in this mutation.
  9239. func (m *ContactMutation) EdgeCleared(name string) bool {
  9240. switch name {
  9241. case contact.EdgeContactRelationships:
  9242. return m.clearedcontact_relationships
  9243. case contact.EdgeContactMessages:
  9244. return m.clearedcontact_messages
  9245. }
  9246. return false
  9247. }
  9248. // ClearEdge clears the value of the edge with the given name. It returns an error
  9249. // if that edge is not defined in the schema.
  9250. func (m *ContactMutation) ClearEdge(name string) error {
  9251. switch name {
  9252. }
  9253. return fmt.Errorf("unknown Contact unique edge %s", name)
  9254. }
  9255. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9256. // It returns an error if the edge is not defined in the schema.
  9257. func (m *ContactMutation) ResetEdge(name string) error {
  9258. switch name {
  9259. case contact.EdgeContactRelationships:
  9260. m.ResetContactRelationships()
  9261. return nil
  9262. case contact.EdgeContactMessages:
  9263. m.ResetContactMessages()
  9264. return nil
  9265. }
  9266. return fmt.Errorf("unknown Contact edge %s", name)
  9267. }
  9268. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  9269. type CreditBalanceMutation struct {
  9270. config
  9271. op Op
  9272. typ string
  9273. id *uint64
  9274. created_at *time.Time
  9275. updated_at *time.Time
  9276. deleted_at *time.Time
  9277. user_id *string
  9278. balance *float32
  9279. addbalance *float32
  9280. status *int
  9281. addstatus *int
  9282. organization_id *uint64
  9283. addorganization_id *int64
  9284. clearedFields map[string]struct{}
  9285. done bool
  9286. oldValue func(context.Context) (*CreditBalance, error)
  9287. predicates []predicate.CreditBalance
  9288. }
  9289. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  9290. // creditbalanceOption allows management of the mutation configuration using functional options.
  9291. type creditbalanceOption func(*CreditBalanceMutation)
  9292. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  9293. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  9294. m := &CreditBalanceMutation{
  9295. config: c,
  9296. op: op,
  9297. typ: TypeCreditBalance,
  9298. clearedFields: make(map[string]struct{}),
  9299. }
  9300. for _, opt := range opts {
  9301. opt(m)
  9302. }
  9303. return m
  9304. }
  9305. // withCreditBalanceID sets the ID field of the mutation.
  9306. func withCreditBalanceID(id uint64) creditbalanceOption {
  9307. return func(m *CreditBalanceMutation) {
  9308. var (
  9309. err error
  9310. once sync.Once
  9311. value *CreditBalance
  9312. )
  9313. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  9314. once.Do(func() {
  9315. if m.done {
  9316. err = errors.New("querying old values post mutation is not allowed")
  9317. } else {
  9318. value, err = m.Client().CreditBalance.Get(ctx, id)
  9319. }
  9320. })
  9321. return value, err
  9322. }
  9323. m.id = &id
  9324. }
  9325. }
  9326. // withCreditBalance sets the old CreditBalance of the mutation.
  9327. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  9328. return func(m *CreditBalanceMutation) {
  9329. m.oldValue = func(context.Context) (*CreditBalance, error) {
  9330. return node, nil
  9331. }
  9332. m.id = &node.ID
  9333. }
  9334. }
  9335. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9336. // executed in a transaction (ent.Tx), a transactional client is returned.
  9337. func (m CreditBalanceMutation) Client() *Client {
  9338. client := &Client{config: m.config}
  9339. client.init()
  9340. return client
  9341. }
  9342. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9343. // it returns an error otherwise.
  9344. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  9345. if _, ok := m.driver.(*txDriver); !ok {
  9346. return nil, errors.New("ent: mutation is not running in a transaction")
  9347. }
  9348. tx := &Tx{config: m.config}
  9349. tx.init()
  9350. return tx, nil
  9351. }
  9352. // SetID sets the value of the id field. Note that this
  9353. // operation is only accepted on creation of CreditBalance entities.
  9354. func (m *CreditBalanceMutation) SetID(id uint64) {
  9355. m.id = &id
  9356. }
  9357. // ID returns the ID value in the mutation. Note that the ID is only available
  9358. // if it was provided to the builder or after it was returned from the database.
  9359. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  9360. if m.id == nil {
  9361. return
  9362. }
  9363. return *m.id, true
  9364. }
  9365. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9366. // That means, if the mutation is applied within a transaction with an isolation level such
  9367. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9368. // or updated by the mutation.
  9369. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  9370. switch {
  9371. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9372. id, exists := m.ID()
  9373. if exists {
  9374. return []uint64{id}, nil
  9375. }
  9376. fallthrough
  9377. case m.op.Is(OpUpdate | OpDelete):
  9378. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  9379. default:
  9380. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9381. }
  9382. }
  9383. // SetCreatedAt sets the "created_at" field.
  9384. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  9385. m.created_at = &t
  9386. }
  9387. // CreatedAt returns the value of the "created_at" field in the mutation.
  9388. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  9389. v := m.created_at
  9390. if v == nil {
  9391. return
  9392. }
  9393. return *v, true
  9394. }
  9395. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  9396. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9398. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9399. if !m.op.Is(OpUpdateOne) {
  9400. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9401. }
  9402. if m.id == nil || m.oldValue == nil {
  9403. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9404. }
  9405. oldValue, err := m.oldValue(ctx)
  9406. if err != nil {
  9407. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9408. }
  9409. return oldValue.CreatedAt, nil
  9410. }
  9411. // ResetCreatedAt resets all changes to the "created_at" field.
  9412. func (m *CreditBalanceMutation) ResetCreatedAt() {
  9413. m.created_at = nil
  9414. }
  9415. // SetUpdatedAt sets the "updated_at" field.
  9416. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  9417. m.updated_at = &t
  9418. }
  9419. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9420. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  9421. v := m.updated_at
  9422. if v == nil {
  9423. return
  9424. }
  9425. return *v, true
  9426. }
  9427. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  9428. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9430. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9431. if !m.op.Is(OpUpdateOne) {
  9432. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9433. }
  9434. if m.id == nil || m.oldValue == nil {
  9435. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9436. }
  9437. oldValue, err := m.oldValue(ctx)
  9438. if err != nil {
  9439. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9440. }
  9441. return oldValue.UpdatedAt, nil
  9442. }
  9443. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9444. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  9445. m.updated_at = nil
  9446. }
  9447. // SetDeletedAt sets the "deleted_at" field.
  9448. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  9449. m.deleted_at = &t
  9450. }
  9451. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9452. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  9453. v := m.deleted_at
  9454. if v == nil {
  9455. return
  9456. }
  9457. return *v, true
  9458. }
  9459. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  9460. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9462. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9463. if !m.op.Is(OpUpdateOne) {
  9464. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9465. }
  9466. if m.id == nil || m.oldValue == nil {
  9467. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9468. }
  9469. oldValue, err := m.oldValue(ctx)
  9470. if err != nil {
  9471. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9472. }
  9473. return oldValue.DeletedAt, nil
  9474. }
  9475. // ClearDeletedAt clears the value of the "deleted_at" field.
  9476. func (m *CreditBalanceMutation) ClearDeletedAt() {
  9477. m.deleted_at = nil
  9478. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  9479. }
  9480. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9481. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  9482. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  9483. return ok
  9484. }
  9485. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9486. func (m *CreditBalanceMutation) ResetDeletedAt() {
  9487. m.deleted_at = nil
  9488. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  9489. }
  9490. // SetUserID sets the "user_id" field.
  9491. func (m *CreditBalanceMutation) SetUserID(s string) {
  9492. m.user_id = &s
  9493. }
  9494. // UserID returns the value of the "user_id" field in the mutation.
  9495. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  9496. v := m.user_id
  9497. if v == nil {
  9498. return
  9499. }
  9500. return *v, true
  9501. }
  9502. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  9503. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9505. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  9506. if !m.op.Is(OpUpdateOne) {
  9507. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  9508. }
  9509. if m.id == nil || m.oldValue == nil {
  9510. return v, errors.New("OldUserID requires an ID field in the mutation")
  9511. }
  9512. oldValue, err := m.oldValue(ctx)
  9513. if err != nil {
  9514. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  9515. }
  9516. return oldValue.UserID, nil
  9517. }
  9518. // ResetUserID resets all changes to the "user_id" field.
  9519. func (m *CreditBalanceMutation) ResetUserID() {
  9520. m.user_id = nil
  9521. }
  9522. // SetBalance sets the "balance" field.
  9523. func (m *CreditBalanceMutation) SetBalance(f float32) {
  9524. m.balance = &f
  9525. m.addbalance = nil
  9526. }
  9527. // Balance returns the value of the "balance" field in the mutation.
  9528. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  9529. v := m.balance
  9530. if v == nil {
  9531. return
  9532. }
  9533. return *v, true
  9534. }
  9535. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  9536. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9538. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  9539. if !m.op.Is(OpUpdateOne) {
  9540. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  9541. }
  9542. if m.id == nil || m.oldValue == nil {
  9543. return v, errors.New("OldBalance requires an ID field in the mutation")
  9544. }
  9545. oldValue, err := m.oldValue(ctx)
  9546. if err != nil {
  9547. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  9548. }
  9549. return oldValue.Balance, nil
  9550. }
  9551. // AddBalance adds f to the "balance" field.
  9552. func (m *CreditBalanceMutation) AddBalance(f float32) {
  9553. if m.addbalance != nil {
  9554. *m.addbalance += f
  9555. } else {
  9556. m.addbalance = &f
  9557. }
  9558. }
  9559. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  9560. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  9561. v := m.addbalance
  9562. if v == nil {
  9563. return
  9564. }
  9565. return *v, true
  9566. }
  9567. // ResetBalance resets all changes to the "balance" field.
  9568. func (m *CreditBalanceMutation) ResetBalance() {
  9569. m.balance = nil
  9570. m.addbalance = nil
  9571. }
  9572. // SetStatus sets the "status" field.
  9573. func (m *CreditBalanceMutation) SetStatus(i int) {
  9574. m.status = &i
  9575. m.addstatus = nil
  9576. }
  9577. // Status returns the value of the "status" field in the mutation.
  9578. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  9579. v := m.status
  9580. if v == nil {
  9581. return
  9582. }
  9583. return *v, true
  9584. }
  9585. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  9586. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9588. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  9589. if !m.op.Is(OpUpdateOne) {
  9590. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9591. }
  9592. if m.id == nil || m.oldValue == nil {
  9593. return v, errors.New("OldStatus requires an ID field in the mutation")
  9594. }
  9595. oldValue, err := m.oldValue(ctx)
  9596. if err != nil {
  9597. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9598. }
  9599. return oldValue.Status, nil
  9600. }
  9601. // AddStatus adds i to the "status" field.
  9602. func (m *CreditBalanceMutation) AddStatus(i int) {
  9603. if m.addstatus != nil {
  9604. *m.addstatus += i
  9605. } else {
  9606. m.addstatus = &i
  9607. }
  9608. }
  9609. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9610. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  9611. v := m.addstatus
  9612. if v == nil {
  9613. return
  9614. }
  9615. return *v, true
  9616. }
  9617. // ClearStatus clears the value of the "status" field.
  9618. func (m *CreditBalanceMutation) ClearStatus() {
  9619. m.status = nil
  9620. m.addstatus = nil
  9621. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  9622. }
  9623. // StatusCleared returns if the "status" field was cleared in this mutation.
  9624. func (m *CreditBalanceMutation) StatusCleared() bool {
  9625. _, ok := m.clearedFields[creditbalance.FieldStatus]
  9626. return ok
  9627. }
  9628. // ResetStatus resets all changes to the "status" field.
  9629. func (m *CreditBalanceMutation) ResetStatus() {
  9630. m.status = nil
  9631. m.addstatus = nil
  9632. delete(m.clearedFields, creditbalance.FieldStatus)
  9633. }
  9634. // SetOrganizationID sets the "organization_id" field.
  9635. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  9636. m.organization_id = &u
  9637. m.addorganization_id = nil
  9638. }
  9639. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9640. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  9641. v := m.organization_id
  9642. if v == nil {
  9643. return
  9644. }
  9645. return *v, true
  9646. }
  9647. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  9648. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9650. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9651. if !m.op.Is(OpUpdateOne) {
  9652. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9653. }
  9654. if m.id == nil || m.oldValue == nil {
  9655. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9656. }
  9657. oldValue, err := m.oldValue(ctx)
  9658. if err != nil {
  9659. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9660. }
  9661. return oldValue.OrganizationID, nil
  9662. }
  9663. // AddOrganizationID adds u to the "organization_id" field.
  9664. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  9665. if m.addorganization_id != nil {
  9666. *m.addorganization_id += u
  9667. } else {
  9668. m.addorganization_id = &u
  9669. }
  9670. }
  9671. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9672. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  9673. v := m.addorganization_id
  9674. if v == nil {
  9675. return
  9676. }
  9677. return *v, true
  9678. }
  9679. // ResetOrganizationID resets all changes to the "organization_id" field.
  9680. func (m *CreditBalanceMutation) ResetOrganizationID() {
  9681. m.organization_id = nil
  9682. m.addorganization_id = nil
  9683. }
  9684. // Where appends a list predicates to the CreditBalanceMutation builder.
  9685. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  9686. m.predicates = append(m.predicates, ps...)
  9687. }
  9688. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  9689. // users can use type-assertion to append predicates that do not depend on any generated package.
  9690. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  9691. p := make([]predicate.CreditBalance, len(ps))
  9692. for i := range ps {
  9693. p[i] = ps[i]
  9694. }
  9695. m.Where(p...)
  9696. }
  9697. // Op returns the operation name.
  9698. func (m *CreditBalanceMutation) Op() Op {
  9699. return m.op
  9700. }
  9701. // SetOp allows setting the mutation operation.
  9702. func (m *CreditBalanceMutation) SetOp(op Op) {
  9703. m.op = op
  9704. }
  9705. // Type returns the node type of this mutation (CreditBalance).
  9706. func (m *CreditBalanceMutation) Type() string {
  9707. return m.typ
  9708. }
  9709. // Fields returns all fields that were changed during this mutation. Note that in
  9710. // order to get all numeric fields that were incremented/decremented, call
  9711. // AddedFields().
  9712. func (m *CreditBalanceMutation) Fields() []string {
  9713. fields := make([]string, 0, 7)
  9714. if m.created_at != nil {
  9715. fields = append(fields, creditbalance.FieldCreatedAt)
  9716. }
  9717. if m.updated_at != nil {
  9718. fields = append(fields, creditbalance.FieldUpdatedAt)
  9719. }
  9720. if m.deleted_at != nil {
  9721. fields = append(fields, creditbalance.FieldDeletedAt)
  9722. }
  9723. if m.user_id != nil {
  9724. fields = append(fields, creditbalance.FieldUserID)
  9725. }
  9726. if m.balance != nil {
  9727. fields = append(fields, creditbalance.FieldBalance)
  9728. }
  9729. if m.status != nil {
  9730. fields = append(fields, creditbalance.FieldStatus)
  9731. }
  9732. if m.organization_id != nil {
  9733. fields = append(fields, creditbalance.FieldOrganizationID)
  9734. }
  9735. return fields
  9736. }
  9737. // Field returns the value of a field with the given name. The second boolean
  9738. // return value indicates that this field was not set, or was not defined in the
  9739. // schema.
  9740. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  9741. switch name {
  9742. case creditbalance.FieldCreatedAt:
  9743. return m.CreatedAt()
  9744. case creditbalance.FieldUpdatedAt:
  9745. return m.UpdatedAt()
  9746. case creditbalance.FieldDeletedAt:
  9747. return m.DeletedAt()
  9748. case creditbalance.FieldUserID:
  9749. return m.UserID()
  9750. case creditbalance.FieldBalance:
  9751. return m.Balance()
  9752. case creditbalance.FieldStatus:
  9753. return m.Status()
  9754. case creditbalance.FieldOrganizationID:
  9755. return m.OrganizationID()
  9756. }
  9757. return nil, false
  9758. }
  9759. // OldField returns the old value of the field from the database. An error is
  9760. // returned if the mutation operation is not UpdateOne, or the query to the
  9761. // database failed.
  9762. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9763. switch name {
  9764. case creditbalance.FieldCreatedAt:
  9765. return m.OldCreatedAt(ctx)
  9766. case creditbalance.FieldUpdatedAt:
  9767. return m.OldUpdatedAt(ctx)
  9768. case creditbalance.FieldDeletedAt:
  9769. return m.OldDeletedAt(ctx)
  9770. case creditbalance.FieldUserID:
  9771. return m.OldUserID(ctx)
  9772. case creditbalance.FieldBalance:
  9773. return m.OldBalance(ctx)
  9774. case creditbalance.FieldStatus:
  9775. return m.OldStatus(ctx)
  9776. case creditbalance.FieldOrganizationID:
  9777. return m.OldOrganizationID(ctx)
  9778. }
  9779. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  9780. }
  9781. // SetField sets the value of a field with the given name. It returns an error if
  9782. // the field is not defined in the schema, or if the type mismatched the field
  9783. // type.
  9784. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  9785. switch name {
  9786. case creditbalance.FieldCreatedAt:
  9787. v, ok := value.(time.Time)
  9788. if !ok {
  9789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9790. }
  9791. m.SetCreatedAt(v)
  9792. return nil
  9793. case creditbalance.FieldUpdatedAt:
  9794. v, ok := value.(time.Time)
  9795. if !ok {
  9796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9797. }
  9798. m.SetUpdatedAt(v)
  9799. return nil
  9800. case creditbalance.FieldDeletedAt:
  9801. v, ok := value.(time.Time)
  9802. if !ok {
  9803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9804. }
  9805. m.SetDeletedAt(v)
  9806. return nil
  9807. case creditbalance.FieldUserID:
  9808. v, ok := value.(string)
  9809. if !ok {
  9810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9811. }
  9812. m.SetUserID(v)
  9813. return nil
  9814. case creditbalance.FieldBalance:
  9815. v, ok := value.(float32)
  9816. if !ok {
  9817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9818. }
  9819. m.SetBalance(v)
  9820. return nil
  9821. case creditbalance.FieldStatus:
  9822. v, ok := value.(int)
  9823. if !ok {
  9824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9825. }
  9826. m.SetStatus(v)
  9827. return nil
  9828. case creditbalance.FieldOrganizationID:
  9829. v, ok := value.(uint64)
  9830. if !ok {
  9831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9832. }
  9833. m.SetOrganizationID(v)
  9834. return nil
  9835. }
  9836. return fmt.Errorf("unknown CreditBalance field %s", name)
  9837. }
  9838. // AddedFields returns all numeric fields that were incremented/decremented during
  9839. // this mutation.
  9840. func (m *CreditBalanceMutation) AddedFields() []string {
  9841. var fields []string
  9842. if m.addbalance != nil {
  9843. fields = append(fields, creditbalance.FieldBalance)
  9844. }
  9845. if m.addstatus != nil {
  9846. fields = append(fields, creditbalance.FieldStatus)
  9847. }
  9848. if m.addorganization_id != nil {
  9849. fields = append(fields, creditbalance.FieldOrganizationID)
  9850. }
  9851. return fields
  9852. }
  9853. // AddedField returns the numeric value that was incremented/decremented on a field
  9854. // with the given name. The second boolean return value indicates that this field
  9855. // was not set, or was not defined in the schema.
  9856. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  9857. switch name {
  9858. case creditbalance.FieldBalance:
  9859. return m.AddedBalance()
  9860. case creditbalance.FieldStatus:
  9861. return m.AddedStatus()
  9862. case creditbalance.FieldOrganizationID:
  9863. return m.AddedOrganizationID()
  9864. }
  9865. return nil, false
  9866. }
  9867. // AddField adds the value to the field with the given name. It returns an error if
  9868. // the field is not defined in the schema, or if the type mismatched the field
  9869. // type.
  9870. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  9871. switch name {
  9872. case creditbalance.FieldBalance:
  9873. v, ok := value.(float32)
  9874. if !ok {
  9875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9876. }
  9877. m.AddBalance(v)
  9878. return nil
  9879. case creditbalance.FieldStatus:
  9880. v, ok := value.(int)
  9881. if !ok {
  9882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9883. }
  9884. m.AddStatus(v)
  9885. return nil
  9886. case creditbalance.FieldOrganizationID:
  9887. v, ok := value.(int64)
  9888. if !ok {
  9889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9890. }
  9891. m.AddOrganizationID(v)
  9892. return nil
  9893. }
  9894. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  9895. }
  9896. // ClearedFields returns all nullable fields that were cleared during this
  9897. // mutation.
  9898. func (m *CreditBalanceMutation) ClearedFields() []string {
  9899. var fields []string
  9900. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  9901. fields = append(fields, creditbalance.FieldDeletedAt)
  9902. }
  9903. if m.FieldCleared(creditbalance.FieldStatus) {
  9904. fields = append(fields, creditbalance.FieldStatus)
  9905. }
  9906. return fields
  9907. }
  9908. // FieldCleared returns a boolean indicating if a field with the given name was
  9909. // cleared in this mutation.
  9910. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  9911. _, ok := m.clearedFields[name]
  9912. return ok
  9913. }
  9914. // ClearField clears the value of the field with the given name. It returns an
  9915. // error if the field is not defined in the schema.
  9916. func (m *CreditBalanceMutation) ClearField(name string) error {
  9917. switch name {
  9918. case creditbalance.FieldDeletedAt:
  9919. m.ClearDeletedAt()
  9920. return nil
  9921. case creditbalance.FieldStatus:
  9922. m.ClearStatus()
  9923. return nil
  9924. }
  9925. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  9926. }
  9927. // ResetField resets all changes in the mutation for the field with the given name.
  9928. // It returns an error if the field is not defined in the schema.
  9929. func (m *CreditBalanceMutation) ResetField(name string) error {
  9930. switch name {
  9931. case creditbalance.FieldCreatedAt:
  9932. m.ResetCreatedAt()
  9933. return nil
  9934. case creditbalance.FieldUpdatedAt:
  9935. m.ResetUpdatedAt()
  9936. return nil
  9937. case creditbalance.FieldDeletedAt:
  9938. m.ResetDeletedAt()
  9939. return nil
  9940. case creditbalance.FieldUserID:
  9941. m.ResetUserID()
  9942. return nil
  9943. case creditbalance.FieldBalance:
  9944. m.ResetBalance()
  9945. return nil
  9946. case creditbalance.FieldStatus:
  9947. m.ResetStatus()
  9948. return nil
  9949. case creditbalance.FieldOrganizationID:
  9950. m.ResetOrganizationID()
  9951. return nil
  9952. }
  9953. return fmt.Errorf("unknown CreditBalance field %s", name)
  9954. }
  9955. // AddedEdges returns all edge names that were set/added in this mutation.
  9956. func (m *CreditBalanceMutation) AddedEdges() []string {
  9957. edges := make([]string, 0, 0)
  9958. return edges
  9959. }
  9960. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9961. // name in this mutation.
  9962. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  9963. return nil
  9964. }
  9965. // RemovedEdges returns all edge names that were removed in this mutation.
  9966. func (m *CreditBalanceMutation) RemovedEdges() []string {
  9967. edges := make([]string, 0, 0)
  9968. return edges
  9969. }
  9970. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9971. // the given name in this mutation.
  9972. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  9973. return nil
  9974. }
  9975. // ClearedEdges returns all edge names that were cleared in this mutation.
  9976. func (m *CreditBalanceMutation) ClearedEdges() []string {
  9977. edges := make([]string, 0, 0)
  9978. return edges
  9979. }
  9980. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9981. // was cleared in this mutation.
  9982. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  9983. return false
  9984. }
  9985. // ClearEdge clears the value of the edge with the given name. It returns an error
  9986. // if that edge is not defined in the schema.
  9987. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  9988. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  9989. }
  9990. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9991. // It returns an error if the edge is not defined in the schema.
  9992. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  9993. return fmt.Errorf("unknown CreditBalance edge %s", name)
  9994. }
  9995. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  9996. type CreditUsageMutation struct {
  9997. config
  9998. op Op
  9999. typ string
  10000. id *uint64
  10001. created_at *time.Time
  10002. updated_at *time.Time
  10003. deleted_at *time.Time
  10004. user_id *string
  10005. number *float32
  10006. addnumber *float32
  10007. status *int
  10008. addstatus *int
  10009. ntype *int
  10010. addntype *int
  10011. table *string
  10012. organization_id *uint64
  10013. addorganization_id *int64
  10014. nid *uint64
  10015. addnid *int64
  10016. reason *string
  10017. operator *string
  10018. clearedFields map[string]struct{}
  10019. done bool
  10020. oldValue func(context.Context) (*CreditUsage, error)
  10021. predicates []predicate.CreditUsage
  10022. }
  10023. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  10024. // creditusageOption allows management of the mutation configuration using functional options.
  10025. type creditusageOption func(*CreditUsageMutation)
  10026. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  10027. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  10028. m := &CreditUsageMutation{
  10029. config: c,
  10030. op: op,
  10031. typ: TypeCreditUsage,
  10032. clearedFields: make(map[string]struct{}),
  10033. }
  10034. for _, opt := range opts {
  10035. opt(m)
  10036. }
  10037. return m
  10038. }
  10039. // withCreditUsageID sets the ID field of the mutation.
  10040. func withCreditUsageID(id uint64) creditusageOption {
  10041. return func(m *CreditUsageMutation) {
  10042. var (
  10043. err error
  10044. once sync.Once
  10045. value *CreditUsage
  10046. )
  10047. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  10048. once.Do(func() {
  10049. if m.done {
  10050. err = errors.New("querying old values post mutation is not allowed")
  10051. } else {
  10052. value, err = m.Client().CreditUsage.Get(ctx, id)
  10053. }
  10054. })
  10055. return value, err
  10056. }
  10057. m.id = &id
  10058. }
  10059. }
  10060. // withCreditUsage sets the old CreditUsage of the mutation.
  10061. func withCreditUsage(node *CreditUsage) creditusageOption {
  10062. return func(m *CreditUsageMutation) {
  10063. m.oldValue = func(context.Context) (*CreditUsage, error) {
  10064. return node, nil
  10065. }
  10066. m.id = &node.ID
  10067. }
  10068. }
  10069. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10070. // executed in a transaction (ent.Tx), a transactional client is returned.
  10071. func (m CreditUsageMutation) Client() *Client {
  10072. client := &Client{config: m.config}
  10073. client.init()
  10074. return client
  10075. }
  10076. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10077. // it returns an error otherwise.
  10078. func (m CreditUsageMutation) Tx() (*Tx, error) {
  10079. if _, ok := m.driver.(*txDriver); !ok {
  10080. return nil, errors.New("ent: mutation is not running in a transaction")
  10081. }
  10082. tx := &Tx{config: m.config}
  10083. tx.init()
  10084. return tx, nil
  10085. }
  10086. // SetID sets the value of the id field. Note that this
  10087. // operation is only accepted on creation of CreditUsage entities.
  10088. func (m *CreditUsageMutation) SetID(id uint64) {
  10089. m.id = &id
  10090. }
  10091. // ID returns the ID value in the mutation. Note that the ID is only available
  10092. // if it was provided to the builder or after it was returned from the database.
  10093. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  10094. if m.id == nil {
  10095. return
  10096. }
  10097. return *m.id, true
  10098. }
  10099. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10100. // That means, if the mutation is applied within a transaction with an isolation level such
  10101. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10102. // or updated by the mutation.
  10103. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  10104. switch {
  10105. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10106. id, exists := m.ID()
  10107. if exists {
  10108. return []uint64{id}, nil
  10109. }
  10110. fallthrough
  10111. case m.op.Is(OpUpdate | OpDelete):
  10112. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  10113. default:
  10114. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10115. }
  10116. }
  10117. // SetCreatedAt sets the "created_at" field.
  10118. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  10119. m.created_at = &t
  10120. }
  10121. // CreatedAt returns the value of the "created_at" field in the mutation.
  10122. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  10123. v := m.created_at
  10124. if v == nil {
  10125. return
  10126. }
  10127. return *v, true
  10128. }
  10129. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  10130. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10132. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10133. if !m.op.Is(OpUpdateOne) {
  10134. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10135. }
  10136. if m.id == nil || m.oldValue == nil {
  10137. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10138. }
  10139. oldValue, err := m.oldValue(ctx)
  10140. if err != nil {
  10141. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10142. }
  10143. return oldValue.CreatedAt, nil
  10144. }
  10145. // ResetCreatedAt resets all changes to the "created_at" field.
  10146. func (m *CreditUsageMutation) ResetCreatedAt() {
  10147. m.created_at = nil
  10148. }
  10149. // SetUpdatedAt sets the "updated_at" field.
  10150. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  10151. m.updated_at = &t
  10152. }
  10153. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10154. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  10155. v := m.updated_at
  10156. if v == nil {
  10157. return
  10158. }
  10159. return *v, true
  10160. }
  10161. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  10162. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10163. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10164. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10165. if !m.op.Is(OpUpdateOne) {
  10166. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10167. }
  10168. if m.id == nil || m.oldValue == nil {
  10169. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10170. }
  10171. oldValue, err := m.oldValue(ctx)
  10172. if err != nil {
  10173. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10174. }
  10175. return oldValue.UpdatedAt, nil
  10176. }
  10177. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10178. func (m *CreditUsageMutation) ResetUpdatedAt() {
  10179. m.updated_at = nil
  10180. }
  10181. // SetDeletedAt sets the "deleted_at" field.
  10182. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  10183. m.deleted_at = &t
  10184. }
  10185. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10186. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  10187. v := m.deleted_at
  10188. if v == nil {
  10189. return
  10190. }
  10191. return *v, true
  10192. }
  10193. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  10194. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10195. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10196. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10197. if !m.op.Is(OpUpdateOne) {
  10198. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10199. }
  10200. if m.id == nil || m.oldValue == nil {
  10201. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10202. }
  10203. oldValue, err := m.oldValue(ctx)
  10204. if err != nil {
  10205. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10206. }
  10207. return oldValue.DeletedAt, nil
  10208. }
  10209. // ClearDeletedAt clears the value of the "deleted_at" field.
  10210. func (m *CreditUsageMutation) ClearDeletedAt() {
  10211. m.deleted_at = nil
  10212. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  10213. }
  10214. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10215. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  10216. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  10217. return ok
  10218. }
  10219. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10220. func (m *CreditUsageMutation) ResetDeletedAt() {
  10221. m.deleted_at = nil
  10222. delete(m.clearedFields, creditusage.FieldDeletedAt)
  10223. }
  10224. // SetUserID sets the "user_id" field.
  10225. func (m *CreditUsageMutation) SetUserID(s string) {
  10226. m.user_id = &s
  10227. }
  10228. // UserID returns the value of the "user_id" field in the mutation.
  10229. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  10230. v := m.user_id
  10231. if v == nil {
  10232. return
  10233. }
  10234. return *v, true
  10235. }
  10236. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  10237. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10239. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  10240. if !m.op.Is(OpUpdateOne) {
  10241. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  10242. }
  10243. if m.id == nil || m.oldValue == nil {
  10244. return v, errors.New("OldUserID requires an ID field in the mutation")
  10245. }
  10246. oldValue, err := m.oldValue(ctx)
  10247. if err != nil {
  10248. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  10249. }
  10250. return oldValue.UserID, nil
  10251. }
  10252. // ResetUserID resets all changes to the "user_id" field.
  10253. func (m *CreditUsageMutation) ResetUserID() {
  10254. m.user_id = nil
  10255. }
  10256. // SetNumber sets the "number" field.
  10257. func (m *CreditUsageMutation) SetNumber(f float32) {
  10258. m.number = &f
  10259. m.addnumber = nil
  10260. }
  10261. // Number returns the value of the "number" field in the mutation.
  10262. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  10263. v := m.number
  10264. if v == nil {
  10265. return
  10266. }
  10267. return *v, true
  10268. }
  10269. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  10270. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10272. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  10273. if !m.op.Is(OpUpdateOne) {
  10274. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  10275. }
  10276. if m.id == nil || m.oldValue == nil {
  10277. return v, errors.New("OldNumber requires an ID field in the mutation")
  10278. }
  10279. oldValue, err := m.oldValue(ctx)
  10280. if err != nil {
  10281. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  10282. }
  10283. return oldValue.Number, nil
  10284. }
  10285. // AddNumber adds f to the "number" field.
  10286. func (m *CreditUsageMutation) AddNumber(f float32) {
  10287. if m.addnumber != nil {
  10288. *m.addnumber += f
  10289. } else {
  10290. m.addnumber = &f
  10291. }
  10292. }
  10293. // AddedNumber returns the value that was added to the "number" field in this mutation.
  10294. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  10295. v := m.addnumber
  10296. if v == nil {
  10297. return
  10298. }
  10299. return *v, true
  10300. }
  10301. // ResetNumber resets all changes to the "number" field.
  10302. func (m *CreditUsageMutation) ResetNumber() {
  10303. m.number = nil
  10304. m.addnumber = nil
  10305. }
  10306. // SetStatus sets the "status" field.
  10307. func (m *CreditUsageMutation) SetStatus(i int) {
  10308. m.status = &i
  10309. m.addstatus = nil
  10310. }
  10311. // Status returns the value of the "status" field in the mutation.
  10312. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  10313. v := m.status
  10314. if v == nil {
  10315. return
  10316. }
  10317. return *v, true
  10318. }
  10319. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  10320. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10322. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  10323. if !m.op.Is(OpUpdateOne) {
  10324. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10325. }
  10326. if m.id == nil || m.oldValue == nil {
  10327. return v, errors.New("OldStatus requires an ID field in the mutation")
  10328. }
  10329. oldValue, err := m.oldValue(ctx)
  10330. if err != nil {
  10331. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10332. }
  10333. return oldValue.Status, nil
  10334. }
  10335. // AddStatus adds i to the "status" field.
  10336. func (m *CreditUsageMutation) AddStatus(i int) {
  10337. if m.addstatus != nil {
  10338. *m.addstatus += i
  10339. } else {
  10340. m.addstatus = &i
  10341. }
  10342. }
  10343. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10344. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  10345. v := m.addstatus
  10346. if v == nil {
  10347. return
  10348. }
  10349. return *v, true
  10350. }
  10351. // ClearStatus clears the value of the "status" field.
  10352. func (m *CreditUsageMutation) ClearStatus() {
  10353. m.status = nil
  10354. m.addstatus = nil
  10355. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  10356. }
  10357. // StatusCleared returns if the "status" field was cleared in this mutation.
  10358. func (m *CreditUsageMutation) StatusCleared() bool {
  10359. _, ok := m.clearedFields[creditusage.FieldStatus]
  10360. return ok
  10361. }
  10362. // ResetStatus resets all changes to the "status" field.
  10363. func (m *CreditUsageMutation) ResetStatus() {
  10364. m.status = nil
  10365. m.addstatus = nil
  10366. delete(m.clearedFields, creditusage.FieldStatus)
  10367. }
  10368. // SetNtype sets the "ntype" field.
  10369. func (m *CreditUsageMutation) SetNtype(i int) {
  10370. m.ntype = &i
  10371. m.addntype = nil
  10372. }
  10373. // Ntype returns the value of the "ntype" field in the mutation.
  10374. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  10375. v := m.ntype
  10376. if v == nil {
  10377. return
  10378. }
  10379. return *v, true
  10380. }
  10381. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  10382. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10384. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  10385. if !m.op.Is(OpUpdateOne) {
  10386. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  10387. }
  10388. if m.id == nil || m.oldValue == nil {
  10389. return v, errors.New("OldNtype requires an ID field in the mutation")
  10390. }
  10391. oldValue, err := m.oldValue(ctx)
  10392. if err != nil {
  10393. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  10394. }
  10395. return oldValue.Ntype, nil
  10396. }
  10397. // AddNtype adds i to the "ntype" field.
  10398. func (m *CreditUsageMutation) AddNtype(i int) {
  10399. if m.addntype != nil {
  10400. *m.addntype += i
  10401. } else {
  10402. m.addntype = &i
  10403. }
  10404. }
  10405. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  10406. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  10407. v := m.addntype
  10408. if v == nil {
  10409. return
  10410. }
  10411. return *v, true
  10412. }
  10413. // ResetNtype resets all changes to the "ntype" field.
  10414. func (m *CreditUsageMutation) ResetNtype() {
  10415. m.ntype = nil
  10416. m.addntype = nil
  10417. }
  10418. // SetTable sets the "table" field.
  10419. func (m *CreditUsageMutation) SetTable(s string) {
  10420. m.table = &s
  10421. }
  10422. // Table returns the value of the "table" field in the mutation.
  10423. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  10424. v := m.table
  10425. if v == nil {
  10426. return
  10427. }
  10428. return *v, true
  10429. }
  10430. // OldTable returns the old "table" field's value of the CreditUsage entity.
  10431. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10433. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  10434. if !m.op.Is(OpUpdateOne) {
  10435. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  10436. }
  10437. if m.id == nil || m.oldValue == nil {
  10438. return v, errors.New("OldTable requires an ID field in the mutation")
  10439. }
  10440. oldValue, err := m.oldValue(ctx)
  10441. if err != nil {
  10442. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  10443. }
  10444. return oldValue.Table, nil
  10445. }
  10446. // ResetTable resets all changes to the "table" field.
  10447. func (m *CreditUsageMutation) ResetTable() {
  10448. m.table = nil
  10449. }
  10450. // SetOrganizationID sets the "organization_id" field.
  10451. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  10452. m.organization_id = &u
  10453. m.addorganization_id = nil
  10454. }
  10455. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10456. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  10457. v := m.organization_id
  10458. if v == nil {
  10459. return
  10460. }
  10461. return *v, true
  10462. }
  10463. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  10464. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10466. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10467. if !m.op.Is(OpUpdateOne) {
  10468. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10469. }
  10470. if m.id == nil || m.oldValue == nil {
  10471. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10472. }
  10473. oldValue, err := m.oldValue(ctx)
  10474. if err != nil {
  10475. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10476. }
  10477. return oldValue.OrganizationID, nil
  10478. }
  10479. // AddOrganizationID adds u to the "organization_id" field.
  10480. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  10481. if m.addorganization_id != nil {
  10482. *m.addorganization_id += u
  10483. } else {
  10484. m.addorganization_id = &u
  10485. }
  10486. }
  10487. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10488. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  10489. v := m.addorganization_id
  10490. if v == nil {
  10491. return
  10492. }
  10493. return *v, true
  10494. }
  10495. // ResetOrganizationID resets all changes to the "organization_id" field.
  10496. func (m *CreditUsageMutation) ResetOrganizationID() {
  10497. m.organization_id = nil
  10498. m.addorganization_id = nil
  10499. }
  10500. // SetNid sets the "nid" field.
  10501. func (m *CreditUsageMutation) SetNid(u uint64) {
  10502. m.nid = &u
  10503. m.addnid = nil
  10504. }
  10505. // Nid returns the value of the "nid" field in the mutation.
  10506. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  10507. v := m.nid
  10508. if v == nil {
  10509. return
  10510. }
  10511. return *v, true
  10512. }
  10513. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  10514. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10515. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10516. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  10517. if !m.op.Is(OpUpdateOne) {
  10518. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  10519. }
  10520. if m.id == nil || m.oldValue == nil {
  10521. return v, errors.New("OldNid requires an ID field in the mutation")
  10522. }
  10523. oldValue, err := m.oldValue(ctx)
  10524. if err != nil {
  10525. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  10526. }
  10527. return oldValue.Nid, nil
  10528. }
  10529. // AddNid adds u to the "nid" field.
  10530. func (m *CreditUsageMutation) AddNid(u int64) {
  10531. if m.addnid != nil {
  10532. *m.addnid += u
  10533. } else {
  10534. m.addnid = &u
  10535. }
  10536. }
  10537. // AddedNid returns the value that was added to the "nid" field in this mutation.
  10538. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  10539. v := m.addnid
  10540. if v == nil {
  10541. return
  10542. }
  10543. return *v, true
  10544. }
  10545. // ResetNid resets all changes to the "nid" field.
  10546. func (m *CreditUsageMutation) ResetNid() {
  10547. m.nid = nil
  10548. m.addnid = nil
  10549. }
  10550. // SetReason sets the "reason" field.
  10551. func (m *CreditUsageMutation) SetReason(s string) {
  10552. m.reason = &s
  10553. }
  10554. // Reason returns the value of the "reason" field in the mutation.
  10555. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  10556. v := m.reason
  10557. if v == nil {
  10558. return
  10559. }
  10560. return *v, true
  10561. }
  10562. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  10563. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10565. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  10566. if !m.op.Is(OpUpdateOne) {
  10567. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  10568. }
  10569. if m.id == nil || m.oldValue == nil {
  10570. return v, errors.New("OldReason requires an ID field in the mutation")
  10571. }
  10572. oldValue, err := m.oldValue(ctx)
  10573. if err != nil {
  10574. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  10575. }
  10576. return oldValue.Reason, nil
  10577. }
  10578. // ResetReason resets all changes to the "reason" field.
  10579. func (m *CreditUsageMutation) ResetReason() {
  10580. m.reason = nil
  10581. }
  10582. // SetOperator sets the "operator" field.
  10583. func (m *CreditUsageMutation) SetOperator(s string) {
  10584. m.operator = &s
  10585. }
  10586. // Operator returns the value of the "operator" field in the mutation.
  10587. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  10588. v := m.operator
  10589. if v == nil {
  10590. return
  10591. }
  10592. return *v, true
  10593. }
  10594. // OldOperator returns the old "operator" 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) OldOperator(ctx context.Context) (v string, err error) {
  10598. if !m.op.Is(OpUpdateOne) {
  10599. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  10600. }
  10601. if m.id == nil || m.oldValue == nil {
  10602. return v, errors.New("OldOperator 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 OldOperator: %w", err)
  10607. }
  10608. return oldValue.Operator, nil
  10609. }
  10610. // ResetOperator resets all changes to the "operator" field.
  10611. func (m *CreditUsageMutation) ResetOperator() {
  10612. m.operator = nil
  10613. }
  10614. // Where appends a list predicates to the CreditUsageMutation builder.
  10615. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  10616. m.predicates = append(m.predicates, ps...)
  10617. }
  10618. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  10619. // users can use type-assertion to append predicates that do not depend on any generated package.
  10620. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  10621. p := make([]predicate.CreditUsage, len(ps))
  10622. for i := range ps {
  10623. p[i] = ps[i]
  10624. }
  10625. m.Where(p...)
  10626. }
  10627. // Op returns the operation name.
  10628. func (m *CreditUsageMutation) Op() Op {
  10629. return m.op
  10630. }
  10631. // SetOp allows setting the mutation operation.
  10632. func (m *CreditUsageMutation) SetOp(op Op) {
  10633. m.op = op
  10634. }
  10635. // Type returns the node type of this mutation (CreditUsage).
  10636. func (m *CreditUsageMutation) Type() string {
  10637. return m.typ
  10638. }
  10639. // Fields returns all fields that were changed during this mutation. Note that in
  10640. // order to get all numeric fields that were incremented/decremented, call
  10641. // AddedFields().
  10642. func (m *CreditUsageMutation) Fields() []string {
  10643. fields := make([]string, 0, 12)
  10644. if m.created_at != nil {
  10645. fields = append(fields, creditusage.FieldCreatedAt)
  10646. }
  10647. if m.updated_at != nil {
  10648. fields = append(fields, creditusage.FieldUpdatedAt)
  10649. }
  10650. if m.deleted_at != nil {
  10651. fields = append(fields, creditusage.FieldDeletedAt)
  10652. }
  10653. if m.user_id != nil {
  10654. fields = append(fields, creditusage.FieldUserID)
  10655. }
  10656. if m.number != nil {
  10657. fields = append(fields, creditusage.FieldNumber)
  10658. }
  10659. if m.status != nil {
  10660. fields = append(fields, creditusage.FieldStatus)
  10661. }
  10662. if m.ntype != nil {
  10663. fields = append(fields, creditusage.FieldNtype)
  10664. }
  10665. if m.table != nil {
  10666. fields = append(fields, creditusage.FieldTable)
  10667. }
  10668. if m.organization_id != nil {
  10669. fields = append(fields, creditusage.FieldOrganizationID)
  10670. }
  10671. if m.nid != nil {
  10672. fields = append(fields, creditusage.FieldNid)
  10673. }
  10674. if m.reason != nil {
  10675. fields = append(fields, creditusage.FieldReason)
  10676. }
  10677. if m.operator != nil {
  10678. fields = append(fields, creditusage.FieldOperator)
  10679. }
  10680. return fields
  10681. }
  10682. // Field returns the value of a field with the given name. The second boolean
  10683. // return value indicates that this field was not set, or was not defined in the
  10684. // schema.
  10685. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  10686. switch name {
  10687. case creditusage.FieldCreatedAt:
  10688. return m.CreatedAt()
  10689. case creditusage.FieldUpdatedAt:
  10690. return m.UpdatedAt()
  10691. case creditusage.FieldDeletedAt:
  10692. return m.DeletedAt()
  10693. case creditusage.FieldUserID:
  10694. return m.UserID()
  10695. case creditusage.FieldNumber:
  10696. return m.Number()
  10697. case creditusage.FieldStatus:
  10698. return m.Status()
  10699. case creditusage.FieldNtype:
  10700. return m.Ntype()
  10701. case creditusage.FieldTable:
  10702. return m.Table()
  10703. case creditusage.FieldOrganizationID:
  10704. return m.OrganizationID()
  10705. case creditusage.FieldNid:
  10706. return m.Nid()
  10707. case creditusage.FieldReason:
  10708. return m.Reason()
  10709. case creditusage.FieldOperator:
  10710. return m.Operator()
  10711. }
  10712. return nil, false
  10713. }
  10714. // OldField returns the old value of the field from the database. An error is
  10715. // returned if the mutation operation is not UpdateOne, or the query to the
  10716. // database failed.
  10717. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10718. switch name {
  10719. case creditusage.FieldCreatedAt:
  10720. return m.OldCreatedAt(ctx)
  10721. case creditusage.FieldUpdatedAt:
  10722. return m.OldUpdatedAt(ctx)
  10723. case creditusage.FieldDeletedAt:
  10724. return m.OldDeletedAt(ctx)
  10725. case creditusage.FieldUserID:
  10726. return m.OldUserID(ctx)
  10727. case creditusage.FieldNumber:
  10728. return m.OldNumber(ctx)
  10729. case creditusage.FieldStatus:
  10730. return m.OldStatus(ctx)
  10731. case creditusage.FieldNtype:
  10732. return m.OldNtype(ctx)
  10733. case creditusage.FieldTable:
  10734. return m.OldTable(ctx)
  10735. case creditusage.FieldOrganizationID:
  10736. return m.OldOrganizationID(ctx)
  10737. case creditusage.FieldNid:
  10738. return m.OldNid(ctx)
  10739. case creditusage.FieldReason:
  10740. return m.OldReason(ctx)
  10741. case creditusage.FieldOperator:
  10742. return m.OldOperator(ctx)
  10743. }
  10744. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  10745. }
  10746. // SetField sets the value of a field with the given name. It returns an error if
  10747. // the field is not defined in the schema, or if the type mismatched the field
  10748. // type.
  10749. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  10750. switch name {
  10751. case creditusage.FieldCreatedAt:
  10752. v, ok := value.(time.Time)
  10753. if !ok {
  10754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10755. }
  10756. m.SetCreatedAt(v)
  10757. return nil
  10758. case creditusage.FieldUpdatedAt:
  10759. v, ok := value.(time.Time)
  10760. if !ok {
  10761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10762. }
  10763. m.SetUpdatedAt(v)
  10764. return nil
  10765. case creditusage.FieldDeletedAt:
  10766. v, ok := value.(time.Time)
  10767. if !ok {
  10768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10769. }
  10770. m.SetDeletedAt(v)
  10771. return nil
  10772. case creditusage.FieldUserID:
  10773. v, ok := value.(string)
  10774. if !ok {
  10775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10776. }
  10777. m.SetUserID(v)
  10778. return nil
  10779. case creditusage.FieldNumber:
  10780. v, ok := value.(float32)
  10781. if !ok {
  10782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10783. }
  10784. m.SetNumber(v)
  10785. return nil
  10786. case creditusage.FieldStatus:
  10787. v, ok := value.(int)
  10788. if !ok {
  10789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10790. }
  10791. m.SetStatus(v)
  10792. return nil
  10793. case creditusage.FieldNtype:
  10794. v, ok := value.(int)
  10795. if !ok {
  10796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10797. }
  10798. m.SetNtype(v)
  10799. return nil
  10800. case creditusage.FieldTable:
  10801. v, ok := value.(string)
  10802. if !ok {
  10803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10804. }
  10805. m.SetTable(v)
  10806. return nil
  10807. case creditusage.FieldOrganizationID:
  10808. v, ok := value.(uint64)
  10809. if !ok {
  10810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10811. }
  10812. m.SetOrganizationID(v)
  10813. return nil
  10814. case creditusage.FieldNid:
  10815. v, ok := value.(uint64)
  10816. if !ok {
  10817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10818. }
  10819. m.SetNid(v)
  10820. return nil
  10821. case creditusage.FieldReason:
  10822. v, ok := value.(string)
  10823. if !ok {
  10824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10825. }
  10826. m.SetReason(v)
  10827. return nil
  10828. case creditusage.FieldOperator:
  10829. v, ok := value.(string)
  10830. if !ok {
  10831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10832. }
  10833. m.SetOperator(v)
  10834. return nil
  10835. }
  10836. return fmt.Errorf("unknown CreditUsage field %s", name)
  10837. }
  10838. // AddedFields returns all numeric fields that were incremented/decremented during
  10839. // this mutation.
  10840. func (m *CreditUsageMutation) AddedFields() []string {
  10841. var fields []string
  10842. if m.addnumber != nil {
  10843. fields = append(fields, creditusage.FieldNumber)
  10844. }
  10845. if m.addstatus != nil {
  10846. fields = append(fields, creditusage.FieldStatus)
  10847. }
  10848. if m.addntype != nil {
  10849. fields = append(fields, creditusage.FieldNtype)
  10850. }
  10851. if m.addorganization_id != nil {
  10852. fields = append(fields, creditusage.FieldOrganizationID)
  10853. }
  10854. if m.addnid != nil {
  10855. fields = append(fields, creditusage.FieldNid)
  10856. }
  10857. return fields
  10858. }
  10859. // AddedField returns the numeric value that was incremented/decremented on a field
  10860. // with the given name. The second boolean return value indicates that this field
  10861. // was not set, or was not defined in the schema.
  10862. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  10863. switch name {
  10864. case creditusage.FieldNumber:
  10865. return m.AddedNumber()
  10866. case creditusage.FieldStatus:
  10867. return m.AddedStatus()
  10868. case creditusage.FieldNtype:
  10869. return m.AddedNtype()
  10870. case creditusage.FieldOrganizationID:
  10871. return m.AddedOrganizationID()
  10872. case creditusage.FieldNid:
  10873. return m.AddedNid()
  10874. }
  10875. return nil, false
  10876. }
  10877. // AddField adds the value to the field with the given name. It returns an error if
  10878. // the field is not defined in the schema, or if the type mismatched the field
  10879. // type.
  10880. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  10881. switch name {
  10882. case creditusage.FieldNumber:
  10883. v, ok := value.(float32)
  10884. if !ok {
  10885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10886. }
  10887. m.AddNumber(v)
  10888. return nil
  10889. case creditusage.FieldStatus:
  10890. v, ok := value.(int)
  10891. if !ok {
  10892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10893. }
  10894. m.AddStatus(v)
  10895. return nil
  10896. case creditusage.FieldNtype:
  10897. v, ok := value.(int)
  10898. if !ok {
  10899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10900. }
  10901. m.AddNtype(v)
  10902. return nil
  10903. case creditusage.FieldOrganizationID:
  10904. v, ok := value.(int64)
  10905. if !ok {
  10906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10907. }
  10908. m.AddOrganizationID(v)
  10909. return nil
  10910. case creditusage.FieldNid:
  10911. v, ok := value.(int64)
  10912. if !ok {
  10913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10914. }
  10915. m.AddNid(v)
  10916. return nil
  10917. }
  10918. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  10919. }
  10920. // ClearedFields returns all nullable fields that were cleared during this
  10921. // mutation.
  10922. func (m *CreditUsageMutation) ClearedFields() []string {
  10923. var fields []string
  10924. if m.FieldCleared(creditusage.FieldDeletedAt) {
  10925. fields = append(fields, creditusage.FieldDeletedAt)
  10926. }
  10927. if m.FieldCleared(creditusage.FieldStatus) {
  10928. fields = append(fields, creditusage.FieldStatus)
  10929. }
  10930. return fields
  10931. }
  10932. // FieldCleared returns a boolean indicating if a field with the given name was
  10933. // cleared in this mutation.
  10934. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  10935. _, ok := m.clearedFields[name]
  10936. return ok
  10937. }
  10938. // ClearField clears the value of the field with the given name. It returns an
  10939. // error if the field is not defined in the schema.
  10940. func (m *CreditUsageMutation) ClearField(name string) error {
  10941. switch name {
  10942. case creditusage.FieldDeletedAt:
  10943. m.ClearDeletedAt()
  10944. return nil
  10945. case creditusage.FieldStatus:
  10946. m.ClearStatus()
  10947. return nil
  10948. }
  10949. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  10950. }
  10951. // ResetField resets all changes in the mutation for the field with the given name.
  10952. // It returns an error if the field is not defined in the schema.
  10953. func (m *CreditUsageMutation) ResetField(name string) error {
  10954. switch name {
  10955. case creditusage.FieldCreatedAt:
  10956. m.ResetCreatedAt()
  10957. return nil
  10958. case creditusage.FieldUpdatedAt:
  10959. m.ResetUpdatedAt()
  10960. return nil
  10961. case creditusage.FieldDeletedAt:
  10962. m.ResetDeletedAt()
  10963. return nil
  10964. case creditusage.FieldUserID:
  10965. m.ResetUserID()
  10966. return nil
  10967. case creditusage.FieldNumber:
  10968. m.ResetNumber()
  10969. return nil
  10970. case creditusage.FieldStatus:
  10971. m.ResetStatus()
  10972. return nil
  10973. case creditusage.FieldNtype:
  10974. m.ResetNtype()
  10975. return nil
  10976. case creditusage.FieldTable:
  10977. m.ResetTable()
  10978. return nil
  10979. case creditusage.FieldOrganizationID:
  10980. m.ResetOrganizationID()
  10981. return nil
  10982. case creditusage.FieldNid:
  10983. m.ResetNid()
  10984. return nil
  10985. case creditusage.FieldReason:
  10986. m.ResetReason()
  10987. return nil
  10988. case creditusage.FieldOperator:
  10989. m.ResetOperator()
  10990. return nil
  10991. }
  10992. return fmt.Errorf("unknown CreditUsage field %s", name)
  10993. }
  10994. // AddedEdges returns all edge names that were set/added in this mutation.
  10995. func (m *CreditUsageMutation) AddedEdges() []string {
  10996. edges := make([]string, 0, 0)
  10997. return edges
  10998. }
  10999. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11000. // name in this mutation.
  11001. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  11002. return nil
  11003. }
  11004. // RemovedEdges returns all edge names that were removed in this mutation.
  11005. func (m *CreditUsageMutation) RemovedEdges() []string {
  11006. edges := make([]string, 0, 0)
  11007. return edges
  11008. }
  11009. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11010. // the given name in this mutation.
  11011. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  11012. return nil
  11013. }
  11014. // ClearedEdges returns all edge names that were cleared in this mutation.
  11015. func (m *CreditUsageMutation) ClearedEdges() []string {
  11016. edges := make([]string, 0, 0)
  11017. return edges
  11018. }
  11019. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11020. // was cleared in this mutation.
  11021. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  11022. return false
  11023. }
  11024. // ClearEdge clears the value of the edge with the given name. It returns an error
  11025. // if that edge is not defined in the schema.
  11026. func (m *CreditUsageMutation) ClearEdge(name string) error {
  11027. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  11028. }
  11029. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11030. // It returns an error if the edge is not defined in the schema.
  11031. func (m *CreditUsageMutation) ResetEdge(name string) error {
  11032. return fmt.Errorf("unknown CreditUsage edge %s", name)
  11033. }
  11034. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  11035. type EmployeeMutation struct {
  11036. config
  11037. op Op
  11038. typ string
  11039. id *uint64
  11040. created_at *time.Time
  11041. updated_at *time.Time
  11042. deleted_at *time.Time
  11043. title *string
  11044. avatar *string
  11045. tags *string
  11046. hire_count *int
  11047. addhire_count *int
  11048. service_count *int
  11049. addservice_count *int
  11050. achievement_count *int
  11051. addachievement_count *int
  11052. intro *string
  11053. estimate *string
  11054. skill *string
  11055. ability_type *string
  11056. scene *string
  11057. switch_in *string
  11058. video_url *string
  11059. organization_id *uint64
  11060. addorganization_id *int64
  11061. category_id *uint64
  11062. addcategory_id *int64
  11063. api_base *string
  11064. api_key *string
  11065. ai_info *string
  11066. is_vip *int
  11067. addis_vip *int
  11068. chat_url *string
  11069. clearedFields map[string]struct{}
  11070. em_work_experiences map[uint64]struct{}
  11071. removedem_work_experiences map[uint64]struct{}
  11072. clearedem_work_experiences bool
  11073. em_tutorial map[uint64]struct{}
  11074. removedem_tutorial map[uint64]struct{}
  11075. clearedem_tutorial bool
  11076. done bool
  11077. oldValue func(context.Context) (*Employee, error)
  11078. predicates []predicate.Employee
  11079. }
  11080. var _ ent.Mutation = (*EmployeeMutation)(nil)
  11081. // employeeOption allows management of the mutation configuration using functional options.
  11082. type employeeOption func(*EmployeeMutation)
  11083. // newEmployeeMutation creates new mutation for the Employee entity.
  11084. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  11085. m := &EmployeeMutation{
  11086. config: c,
  11087. op: op,
  11088. typ: TypeEmployee,
  11089. clearedFields: make(map[string]struct{}),
  11090. }
  11091. for _, opt := range opts {
  11092. opt(m)
  11093. }
  11094. return m
  11095. }
  11096. // withEmployeeID sets the ID field of the mutation.
  11097. func withEmployeeID(id uint64) employeeOption {
  11098. return func(m *EmployeeMutation) {
  11099. var (
  11100. err error
  11101. once sync.Once
  11102. value *Employee
  11103. )
  11104. m.oldValue = func(ctx context.Context) (*Employee, error) {
  11105. once.Do(func() {
  11106. if m.done {
  11107. err = errors.New("querying old values post mutation is not allowed")
  11108. } else {
  11109. value, err = m.Client().Employee.Get(ctx, id)
  11110. }
  11111. })
  11112. return value, err
  11113. }
  11114. m.id = &id
  11115. }
  11116. }
  11117. // withEmployee sets the old Employee of the mutation.
  11118. func withEmployee(node *Employee) employeeOption {
  11119. return func(m *EmployeeMutation) {
  11120. m.oldValue = func(context.Context) (*Employee, error) {
  11121. return node, nil
  11122. }
  11123. m.id = &node.ID
  11124. }
  11125. }
  11126. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11127. // executed in a transaction (ent.Tx), a transactional client is returned.
  11128. func (m EmployeeMutation) Client() *Client {
  11129. client := &Client{config: m.config}
  11130. client.init()
  11131. return client
  11132. }
  11133. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11134. // it returns an error otherwise.
  11135. func (m EmployeeMutation) Tx() (*Tx, error) {
  11136. if _, ok := m.driver.(*txDriver); !ok {
  11137. return nil, errors.New("ent: mutation is not running in a transaction")
  11138. }
  11139. tx := &Tx{config: m.config}
  11140. tx.init()
  11141. return tx, nil
  11142. }
  11143. // SetID sets the value of the id field. Note that this
  11144. // operation is only accepted on creation of Employee entities.
  11145. func (m *EmployeeMutation) SetID(id uint64) {
  11146. m.id = &id
  11147. }
  11148. // ID returns the ID value in the mutation. Note that the ID is only available
  11149. // if it was provided to the builder or after it was returned from the database.
  11150. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  11151. if m.id == nil {
  11152. return
  11153. }
  11154. return *m.id, true
  11155. }
  11156. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11157. // That means, if the mutation is applied within a transaction with an isolation level such
  11158. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11159. // or updated by the mutation.
  11160. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  11161. switch {
  11162. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11163. id, exists := m.ID()
  11164. if exists {
  11165. return []uint64{id}, nil
  11166. }
  11167. fallthrough
  11168. case m.op.Is(OpUpdate | OpDelete):
  11169. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  11170. default:
  11171. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11172. }
  11173. }
  11174. // SetCreatedAt sets the "created_at" field.
  11175. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  11176. m.created_at = &t
  11177. }
  11178. // CreatedAt returns the value of the "created_at" field in the mutation.
  11179. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  11180. v := m.created_at
  11181. if v == nil {
  11182. return
  11183. }
  11184. return *v, true
  11185. }
  11186. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  11187. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11189. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11190. if !m.op.Is(OpUpdateOne) {
  11191. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11192. }
  11193. if m.id == nil || m.oldValue == nil {
  11194. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11195. }
  11196. oldValue, err := m.oldValue(ctx)
  11197. if err != nil {
  11198. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11199. }
  11200. return oldValue.CreatedAt, nil
  11201. }
  11202. // ResetCreatedAt resets all changes to the "created_at" field.
  11203. func (m *EmployeeMutation) ResetCreatedAt() {
  11204. m.created_at = nil
  11205. }
  11206. // SetUpdatedAt sets the "updated_at" field.
  11207. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  11208. m.updated_at = &t
  11209. }
  11210. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11211. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  11212. v := m.updated_at
  11213. if v == nil {
  11214. return
  11215. }
  11216. return *v, true
  11217. }
  11218. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  11219. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11221. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11222. if !m.op.Is(OpUpdateOne) {
  11223. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11224. }
  11225. if m.id == nil || m.oldValue == nil {
  11226. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11227. }
  11228. oldValue, err := m.oldValue(ctx)
  11229. if err != nil {
  11230. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11231. }
  11232. return oldValue.UpdatedAt, nil
  11233. }
  11234. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11235. func (m *EmployeeMutation) ResetUpdatedAt() {
  11236. m.updated_at = nil
  11237. }
  11238. // SetDeletedAt sets the "deleted_at" field.
  11239. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  11240. m.deleted_at = &t
  11241. }
  11242. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11243. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  11244. v := m.deleted_at
  11245. if v == nil {
  11246. return
  11247. }
  11248. return *v, true
  11249. }
  11250. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  11251. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11253. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11254. if !m.op.Is(OpUpdateOne) {
  11255. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11256. }
  11257. if m.id == nil || m.oldValue == nil {
  11258. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11259. }
  11260. oldValue, err := m.oldValue(ctx)
  11261. if err != nil {
  11262. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11263. }
  11264. return oldValue.DeletedAt, nil
  11265. }
  11266. // ClearDeletedAt clears the value of the "deleted_at" field.
  11267. func (m *EmployeeMutation) ClearDeletedAt() {
  11268. m.deleted_at = nil
  11269. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  11270. }
  11271. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11272. func (m *EmployeeMutation) DeletedAtCleared() bool {
  11273. _, ok := m.clearedFields[employee.FieldDeletedAt]
  11274. return ok
  11275. }
  11276. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11277. func (m *EmployeeMutation) ResetDeletedAt() {
  11278. m.deleted_at = nil
  11279. delete(m.clearedFields, employee.FieldDeletedAt)
  11280. }
  11281. // SetTitle sets the "title" field.
  11282. func (m *EmployeeMutation) SetTitle(s string) {
  11283. m.title = &s
  11284. }
  11285. // Title returns the value of the "title" field in the mutation.
  11286. func (m *EmployeeMutation) Title() (r string, exists bool) {
  11287. v := m.title
  11288. if v == nil {
  11289. return
  11290. }
  11291. return *v, true
  11292. }
  11293. // OldTitle returns the old "title" field's value of the Employee entity.
  11294. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11296. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  11297. if !m.op.Is(OpUpdateOne) {
  11298. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  11299. }
  11300. if m.id == nil || m.oldValue == nil {
  11301. return v, errors.New("OldTitle requires an ID field in the mutation")
  11302. }
  11303. oldValue, err := m.oldValue(ctx)
  11304. if err != nil {
  11305. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  11306. }
  11307. return oldValue.Title, nil
  11308. }
  11309. // ResetTitle resets all changes to the "title" field.
  11310. func (m *EmployeeMutation) ResetTitle() {
  11311. m.title = nil
  11312. }
  11313. // SetAvatar sets the "avatar" field.
  11314. func (m *EmployeeMutation) SetAvatar(s string) {
  11315. m.avatar = &s
  11316. }
  11317. // Avatar returns the value of the "avatar" field in the mutation.
  11318. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  11319. v := m.avatar
  11320. if v == nil {
  11321. return
  11322. }
  11323. return *v, true
  11324. }
  11325. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  11326. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11328. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  11329. if !m.op.Is(OpUpdateOne) {
  11330. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  11331. }
  11332. if m.id == nil || m.oldValue == nil {
  11333. return v, errors.New("OldAvatar requires an ID field in the mutation")
  11334. }
  11335. oldValue, err := m.oldValue(ctx)
  11336. if err != nil {
  11337. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  11338. }
  11339. return oldValue.Avatar, nil
  11340. }
  11341. // ResetAvatar resets all changes to the "avatar" field.
  11342. func (m *EmployeeMutation) ResetAvatar() {
  11343. m.avatar = nil
  11344. }
  11345. // SetTags sets the "tags" field.
  11346. func (m *EmployeeMutation) SetTags(s string) {
  11347. m.tags = &s
  11348. }
  11349. // Tags returns the value of the "tags" field in the mutation.
  11350. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  11351. v := m.tags
  11352. if v == nil {
  11353. return
  11354. }
  11355. return *v, true
  11356. }
  11357. // OldTags returns the old "tags" field's value of the Employee entity.
  11358. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11360. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  11361. if !m.op.Is(OpUpdateOne) {
  11362. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  11363. }
  11364. if m.id == nil || m.oldValue == nil {
  11365. return v, errors.New("OldTags requires an ID field in the mutation")
  11366. }
  11367. oldValue, err := m.oldValue(ctx)
  11368. if err != nil {
  11369. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  11370. }
  11371. return oldValue.Tags, nil
  11372. }
  11373. // ResetTags resets all changes to the "tags" field.
  11374. func (m *EmployeeMutation) ResetTags() {
  11375. m.tags = nil
  11376. }
  11377. // SetHireCount sets the "hire_count" field.
  11378. func (m *EmployeeMutation) SetHireCount(i int) {
  11379. m.hire_count = &i
  11380. m.addhire_count = nil
  11381. }
  11382. // HireCount returns the value of the "hire_count" field in the mutation.
  11383. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  11384. v := m.hire_count
  11385. if v == nil {
  11386. return
  11387. }
  11388. return *v, true
  11389. }
  11390. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  11391. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11393. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  11394. if !m.op.Is(OpUpdateOne) {
  11395. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  11396. }
  11397. if m.id == nil || m.oldValue == nil {
  11398. return v, errors.New("OldHireCount requires an ID field in the mutation")
  11399. }
  11400. oldValue, err := m.oldValue(ctx)
  11401. if err != nil {
  11402. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  11403. }
  11404. return oldValue.HireCount, nil
  11405. }
  11406. // AddHireCount adds i to the "hire_count" field.
  11407. func (m *EmployeeMutation) AddHireCount(i int) {
  11408. if m.addhire_count != nil {
  11409. *m.addhire_count += i
  11410. } else {
  11411. m.addhire_count = &i
  11412. }
  11413. }
  11414. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  11415. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  11416. v := m.addhire_count
  11417. if v == nil {
  11418. return
  11419. }
  11420. return *v, true
  11421. }
  11422. // ResetHireCount resets all changes to the "hire_count" field.
  11423. func (m *EmployeeMutation) ResetHireCount() {
  11424. m.hire_count = nil
  11425. m.addhire_count = nil
  11426. }
  11427. // SetServiceCount sets the "service_count" field.
  11428. func (m *EmployeeMutation) SetServiceCount(i int) {
  11429. m.service_count = &i
  11430. m.addservice_count = nil
  11431. }
  11432. // ServiceCount returns the value of the "service_count" field in the mutation.
  11433. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  11434. v := m.service_count
  11435. if v == nil {
  11436. return
  11437. }
  11438. return *v, true
  11439. }
  11440. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  11441. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11443. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  11444. if !m.op.Is(OpUpdateOne) {
  11445. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  11446. }
  11447. if m.id == nil || m.oldValue == nil {
  11448. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  11449. }
  11450. oldValue, err := m.oldValue(ctx)
  11451. if err != nil {
  11452. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  11453. }
  11454. return oldValue.ServiceCount, nil
  11455. }
  11456. // AddServiceCount adds i to the "service_count" field.
  11457. func (m *EmployeeMutation) AddServiceCount(i int) {
  11458. if m.addservice_count != nil {
  11459. *m.addservice_count += i
  11460. } else {
  11461. m.addservice_count = &i
  11462. }
  11463. }
  11464. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  11465. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  11466. v := m.addservice_count
  11467. if v == nil {
  11468. return
  11469. }
  11470. return *v, true
  11471. }
  11472. // ResetServiceCount resets all changes to the "service_count" field.
  11473. func (m *EmployeeMutation) ResetServiceCount() {
  11474. m.service_count = nil
  11475. m.addservice_count = nil
  11476. }
  11477. // SetAchievementCount sets the "achievement_count" field.
  11478. func (m *EmployeeMutation) SetAchievementCount(i int) {
  11479. m.achievement_count = &i
  11480. m.addachievement_count = nil
  11481. }
  11482. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  11483. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  11484. v := m.achievement_count
  11485. if v == nil {
  11486. return
  11487. }
  11488. return *v, true
  11489. }
  11490. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  11491. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11493. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  11494. if !m.op.Is(OpUpdateOne) {
  11495. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  11496. }
  11497. if m.id == nil || m.oldValue == nil {
  11498. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  11499. }
  11500. oldValue, err := m.oldValue(ctx)
  11501. if err != nil {
  11502. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  11503. }
  11504. return oldValue.AchievementCount, nil
  11505. }
  11506. // AddAchievementCount adds i to the "achievement_count" field.
  11507. func (m *EmployeeMutation) AddAchievementCount(i int) {
  11508. if m.addachievement_count != nil {
  11509. *m.addachievement_count += i
  11510. } else {
  11511. m.addachievement_count = &i
  11512. }
  11513. }
  11514. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  11515. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  11516. v := m.addachievement_count
  11517. if v == nil {
  11518. return
  11519. }
  11520. return *v, true
  11521. }
  11522. // ResetAchievementCount resets all changes to the "achievement_count" field.
  11523. func (m *EmployeeMutation) ResetAchievementCount() {
  11524. m.achievement_count = nil
  11525. m.addachievement_count = nil
  11526. }
  11527. // SetIntro sets the "intro" field.
  11528. func (m *EmployeeMutation) SetIntro(s string) {
  11529. m.intro = &s
  11530. }
  11531. // Intro returns the value of the "intro" field in the mutation.
  11532. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  11533. v := m.intro
  11534. if v == nil {
  11535. return
  11536. }
  11537. return *v, true
  11538. }
  11539. // OldIntro returns the old "intro" field's value of the Employee entity.
  11540. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11542. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  11543. if !m.op.Is(OpUpdateOne) {
  11544. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  11545. }
  11546. if m.id == nil || m.oldValue == nil {
  11547. return v, errors.New("OldIntro requires an ID field in the mutation")
  11548. }
  11549. oldValue, err := m.oldValue(ctx)
  11550. if err != nil {
  11551. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  11552. }
  11553. return oldValue.Intro, nil
  11554. }
  11555. // ResetIntro resets all changes to the "intro" field.
  11556. func (m *EmployeeMutation) ResetIntro() {
  11557. m.intro = nil
  11558. }
  11559. // SetEstimate sets the "estimate" field.
  11560. func (m *EmployeeMutation) SetEstimate(s string) {
  11561. m.estimate = &s
  11562. }
  11563. // Estimate returns the value of the "estimate" field in the mutation.
  11564. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  11565. v := m.estimate
  11566. if v == nil {
  11567. return
  11568. }
  11569. return *v, true
  11570. }
  11571. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  11572. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11574. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  11575. if !m.op.Is(OpUpdateOne) {
  11576. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  11577. }
  11578. if m.id == nil || m.oldValue == nil {
  11579. return v, errors.New("OldEstimate requires an ID field in the mutation")
  11580. }
  11581. oldValue, err := m.oldValue(ctx)
  11582. if err != nil {
  11583. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  11584. }
  11585. return oldValue.Estimate, nil
  11586. }
  11587. // ResetEstimate resets all changes to the "estimate" field.
  11588. func (m *EmployeeMutation) ResetEstimate() {
  11589. m.estimate = nil
  11590. }
  11591. // SetSkill sets the "skill" field.
  11592. func (m *EmployeeMutation) SetSkill(s string) {
  11593. m.skill = &s
  11594. }
  11595. // Skill returns the value of the "skill" field in the mutation.
  11596. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  11597. v := m.skill
  11598. if v == nil {
  11599. return
  11600. }
  11601. return *v, true
  11602. }
  11603. // OldSkill returns the old "skill" field's value of the Employee entity.
  11604. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11606. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  11607. if !m.op.Is(OpUpdateOne) {
  11608. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  11609. }
  11610. if m.id == nil || m.oldValue == nil {
  11611. return v, errors.New("OldSkill requires an ID field in the mutation")
  11612. }
  11613. oldValue, err := m.oldValue(ctx)
  11614. if err != nil {
  11615. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  11616. }
  11617. return oldValue.Skill, nil
  11618. }
  11619. // ResetSkill resets all changes to the "skill" field.
  11620. func (m *EmployeeMutation) ResetSkill() {
  11621. m.skill = nil
  11622. }
  11623. // SetAbilityType sets the "ability_type" field.
  11624. func (m *EmployeeMutation) SetAbilityType(s string) {
  11625. m.ability_type = &s
  11626. }
  11627. // AbilityType returns the value of the "ability_type" field in the mutation.
  11628. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  11629. v := m.ability_type
  11630. if v == nil {
  11631. return
  11632. }
  11633. return *v, true
  11634. }
  11635. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  11636. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11637. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11638. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  11639. if !m.op.Is(OpUpdateOne) {
  11640. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  11641. }
  11642. if m.id == nil || m.oldValue == nil {
  11643. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  11644. }
  11645. oldValue, err := m.oldValue(ctx)
  11646. if err != nil {
  11647. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  11648. }
  11649. return oldValue.AbilityType, nil
  11650. }
  11651. // ResetAbilityType resets all changes to the "ability_type" field.
  11652. func (m *EmployeeMutation) ResetAbilityType() {
  11653. m.ability_type = nil
  11654. }
  11655. // SetScene sets the "scene" field.
  11656. func (m *EmployeeMutation) SetScene(s string) {
  11657. m.scene = &s
  11658. }
  11659. // Scene returns the value of the "scene" field in the mutation.
  11660. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  11661. v := m.scene
  11662. if v == nil {
  11663. return
  11664. }
  11665. return *v, true
  11666. }
  11667. // OldScene returns the old "scene" field's value of the Employee entity.
  11668. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11670. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  11671. if !m.op.Is(OpUpdateOne) {
  11672. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  11673. }
  11674. if m.id == nil || m.oldValue == nil {
  11675. return v, errors.New("OldScene requires an ID field in the mutation")
  11676. }
  11677. oldValue, err := m.oldValue(ctx)
  11678. if err != nil {
  11679. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  11680. }
  11681. return oldValue.Scene, nil
  11682. }
  11683. // ResetScene resets all changes to the "scene" field.
  11684. func (m *EmployeeMutation) ResetScene() {
  11685. m.scene = nil
  11686. }
  11687. // SetSwitchIn sets the "switch_in" field.
  11688. func (m *EmployeeMutation) SetSwitchIn(s string) {
  11689. m.switch_in = &s
  11690. }
  11691. // SwitchIn returns the value of the "switch_in" field in the mutation.
  11692. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  11693. v := m.switch_in
  11694. if v == nil {
  11695. return
  11696. }
  11697. return *v, true
  11698. }
  11699. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  11700. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11702. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  11703. if !m.op.Is(OpUpdateOne) {
  11704. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  11705. }
  11706. if m.id == nil || m.oldValue == nil {
  11707. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  11708. }
  11709. oldValue, err := m.oldValue(ctx)
  11710. if err != nil {
  11711. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  11712. }
  11713. return oldValue.SwitchIn, nil
  11714. }
  11715. // ResetSwitchIn resets all changes to the "switch_in" field.
  11716. func (m *EmployeeMutation) ResetSwitchIn() {
  11717. m.switch_in = nil
  11718. }
  11719. // SetVideoURL sets the "video_url" field.
  11720. func (m *EmployeeMutation) SetVideoURL(s string) {
  11721. m.video_url = &s
  11722. }
  11723. // VideoURL returns the value of the "video_url" field in the mutation.
  11724. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  11725. v := m.video_url
  11726. if v == nil {
  11727. return
  11728. }
  11729. return *v, true
  11730. }
  11731. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  11732. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11734. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  11735. if !m.op.Is(OpUpdateOne) {
  11736. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  11737. }
  11738. if m.id == nil || m.oldValue == nil {
  11739. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  11740. }
  11741. oldValue, err := m.oldValue(ctx)
  11742. if err != nil {
  11743. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  11744. }
  11745. return oldValue.VideoURL, nil
  11746. }
  11747. // ResetVideoURL resets all changes to the "video_url" field.
  11748. func (m *EmployeeMutation) ResetVideoURL() {
  11749. m.video_url = nil
  11750. }
  11751. // SetOrganizationID sets the "organization_id" field.
  11752. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  11753. m.organization_id = &u
  11754. m.addorganization_id = nil
  11755. }
  11756. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11757. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  11758. v := m.organization_id
  11759. if v == nil {
  11760. return
  11761. }
  11762. return *v, true
  11763. }
  11764. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  11765. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11767. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11768. if !m.op.Is(OpUpdateOne) {
  11769. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11770. }
  11771. if m.id == nil || m.oldValue == nil {
  11772. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11773. }
  11774. oldValue, err := m.oldValue(ctx)
  11775. if err != nil {
  11776. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11777. }
  11778. return oldValue.OrganizationID, nil
  11779. }
  11780. // AddOrganizationID adds u to the "organization_id" field.
  11781. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  11782. if m.addorganization_id != nil {
  11783. *m.addorganization_id += u
  11784. } else {
  11785. m.addorganization_id = &u
  11786. }
  11787. }
  11788. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11789. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  11790. v := m.addorganization_id
  11791. if v == nil {
  11792. return
  11793. }
  11794. return *v, true
  11795. }
  11796. // ResetOrganizationID resets all changes to the "organization_id" field.
  11797. func (m *EmployeeMutation) ResetOrganizationID() {
  11798. m.organization_id = nil
  11799. m.addorganization_id = nil
  11800. }
  11801. // SetCategoryID sets the "category_id" field.
  11802. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  11803. m.category_id = &u
  11804. m.addcategory_id = nil
  11805. }
  11806. // CategoryID returns the value of the "category_id" field in the mutation.
  11807. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  11808. v := m.category_id
  11809. if v == nil {
  11810. return
  11811. }
  11812. return *v, true
  11813. }
  11814. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  11815. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11817. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  11818. if !m.op.Is(OpUpdateOne) {
  11819. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  11820. }
  11821. if m.id == nil || m.oldValue == nil {
  11822. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  11823. }
  11824. oldValue, err := m.oldValue(ctx)
  11825. if err != nil {
  11826. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  11827. }
  11828. return oldValue.CategoryID, nil
  11829. }
  11830. // AddCategoryID adds u to the "category_id" field.
  11831. func (m *EmployeeMutation) AddCategoryID(u int64) {
  11832. if m.addcategory_id != nil {
  11833. *m.addcategory_id += u
  11834. } else {
  11835. m.addcategory_id = &u
  11836. }
  11837. }
  11838. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  11839. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  11840. v := m.addcategory_id
  11841. if v == nil {
  11842. return
  11843. }
  11844. return *v, true
  11845. }
  11846. // ResetCategoryID resets all changes to the "category_id" field.
  11847. func (m *EmployeeMutation) ResetCategoryID() {
  11848. m.category_id = nil
  11849. m.addcategory_id = nil
  11850. }
  11851. // SetAPIBase sets the "api_base" field.
  11852. func (m *EmployeeMutation) SetAPIBase(s string) {
  11853. m.api_base = &s
  11854. }
  11855. // APIBase returns the value of the "api_base" field in the mutation.
  11856. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  11857. v := m.api_base
  11858. if v == nil {
  11859. return
  11860. }
  11861. return *v, true
  11862. }
  11863. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  11864. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11865. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11866. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  11867. if !m.op.Is(OpUpdateOne) {
  11868. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  11869. }
  11870. if m.id == nil || m.oldValue == nil {
  11871. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  11872. }
  11873. oldValue, err := m.oldValue(ctx)
  11874. if err != nil {
  11875. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  11876. }
  11877. return oldValue.APIBase, nil
  11878. }
  11879. // ResetAPIBase resets all changes to the "api_base" field.
  11880. func (m *EmployeeMutation) ResetAPIBase() {
  11881. m.api_base = nil
  11882. }
  11883. // SetAPIKey sets the "api_key" field.
  11884. func (m *EmployeeMutation) SetAPIKey(s string) {
  11885. m.api_key = &s
  11886. }
  11887. // APIKey returns the value of the "api_key" field in the mutation.
  11888. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  11889. v := m.api_key
  11890. if v == nil {
  11891. return
  11892. }
  11893. return *v, true
  11894. }
  11895. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  11896. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11897. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11898. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  11899. if !m.op.Is(OpUpdateOne) {
  11900. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  11901. }
  11902. if m.id == nil || m.oldValue == nil {
  11903. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  11904. }
  11905. oldValue, err := m.oldValue(ctx)
  11906. if err != nil {
  11907. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  11908. }
  11909. return oldValue.APIKey, nil
  11910. }
  11911. // ResetAPIKey resets all changes to the "api_key" field.
  11912. func (m *EmployeeMutation) ResetAPIKey() {
  11913. m.api_key = nil
  11914. }
  11915. // SetAiInfo sets the "ai_info" field.
  11916. func (m *EmployeeMutation) SetAiInfo(s string) {
  11917. m.ai_info = &s
  11918. }
  11919. // AiInfo returns the value of the "ai_info" field in the mutation.
  11920. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  11921. v := m.ai_info
  11922. if v == nil {
  11923. return
  11924. }
  11925. return *v, true
  11926. }
  11927. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  11928. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11930. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  11931. if !m.op.Is(OpUpdateOne) {
  11932. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  11933. }
  11934. if m.id == nil || m.oldValue == nil {
  11935. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  11936. }
  11937. oldValue, err := m.oldValue(ctx)
  11938. if err != nil {
  11939. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  11940. }
  11941. return oldValue.AiInfo, nil
  11942. }
  11943. // ClearAiInfo clears the value of the "ai_info" field.
  11944. func (m *EmployeeMutation) ClearAiInfo() {
  11945. m.ai_info = nil
  11946. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  11947. }
  11948. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  11949. func (m *EmployeeMutation) AiInfoCleared() bool {
  11950. _, ok := m.clearedFields[employee.FieldAiInfo]
  11951. return ok
  11952. }
  11953. // ResetAiInfo resets all changes to the "ai_info" field.
  11954. func (m *EmployeeMutation) ResetAiInfo() {
  11955. m.ai_info = nil
  11956. delete(m.clearedFields, employee.FieldAiInfo)
  11957. }
  11958. // SetIsVip sets the "is_vip" field.
  11959. func (m *EmployeeMutation) SetIsVip(i int) {
  11960. m.is_vip = &i
  11961. m.addis_vip = nil
  11962. }
  11963. // IsVip returns the value of the "is_vip" field in the mutation.
  11964. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  11965. v := m.is_vip
  11966. if v == nil {
  11967. return
  11968. }
  11969. return *v, true
  11970. }
  11971. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  11972. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11974. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  11975. if !m.op.Is(OpUpdateOne) {
  11976. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  11977. }
  11978. if m.id == nil || m.oldValue == nil {
  11979. return v, errors.New("OldIsVip requires an ID field in the mutation")
  11980. }
  11981. oldValue, err := m.oldValue(ctx)
  11982. if err != nil {
  11983. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  11984. }
  11985. return oldValue.IsVip, nil
  11986. }
  11987. // AddIsVip adds i to the "is_vip" field.
  11988. func (m *EmployeeMutation) AddIsVip(i int) {
  11989. if m.addis_vip != nil {
  11990. *m.addis_vip += i
  11991. } else {
  11992. m.addis_vip = &i
  11993. }
  11994. }
  11995. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  11996. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  11997. v := m.addis_vip
  11998. if v == nil {
  11999. return
  12000. }
  12001. return *v, true
  12002. }
  12003. // ResetIsVip resets all changes to the "is_vip" field.
  12004. func (m *EmployeeMutation) ResetIsVip() {
  12005. m.is_vip = nil
  12006. m.addis_vip = nil
  12007. }
  12008. // SetChatURL sets the "chat_url" field.
  12009. func (m *EmployeeMutation) SetChatURL(s string) {
  12010. m.chat_url = &s
  12011. }
  12012. // ChatURL returns the value of the "chat_url" field in the mutation.
  12013. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  12014. v := m.chat_url
  12015. if v == nil {
  12016. return
  12017. }
  12018. return *v, true
  12019. }
  12020. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  12021. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12023. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  12024. if !m.op.Is(OpUpdateOne) {
  12025. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  12026. }
  12027. if m.id == nil || m.oldValue == nil {
  12028. return v, errors.New("OldChatURL requires an ID field in the mutation")
  12029. }
  12030. oldValue, err := m.oldValue(ctx)
  12031. if err != nil {
  12032. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  12033. }
  12034. return oldValue.ChatURL, nil
  12035. }
  12036. // ResetChatURL resets all changes to the "chat_url" field.
  12037. func (m *EmployeeMutation) ResetChatURL() {
  12038. m.chat_url = nil
  12039. }
  12040. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  12041. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  12042. if m.em_work_experiences == nil {
  12043. m.em_work_experiences = make(map[uint64]struct{})
  12044. }
  12045. for i := range ids {
  12046. m.em_work_experiences[ids[i]] = struct{}{}
  12047. }
  12048. }
  12049. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  12050. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  12051. m.clearedem_work_experiences = true
  12052. }
  12053. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  12054. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  12055. return m.clearedem_work_experiences
  12056. }
  12057. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  12058. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  12059. if m.removedem_work_experiences == nil {
  12060. m.removedem_work_experiences = make(map[uint64]struct{})
  12061. }
  12062. for i := range ids {
  12063. delete(m.em_work_experiences, ids[i])
  12064. m.removedem_work_experiences[ids[i]] = struct{}{}
  12065. }
  12066. }
  12067. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  12068. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  12069. for id := range m.removedem_work_experiences {
  12070. ids = append(ids, id)
  12071. }
  12072. return
  12073. }
  12074. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  12075. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  12076. for id := range m.em_work_experiences {
  12077. ids = append(ids, id)
  12078. }
  12079. return
  12080. }
  12081. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  12082. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  12083. m.em_work_experiences = nil
  12084. m.clearedem_work_experiences = false
  12085. m.removedem_work_experiences = nil
  12086. }
  12087. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  12088. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  12089. if m.em_tutorial == nil {
  12090. m.em_tutorial = make(map[uint64]struct{})
  12091. }
  12092. for i := range ids {
  12093. m.em_tutorial[ids[i]] = struct{}{}
  12094. }
  12095. }
  12096. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  12097. func (m *EmployeeMutation) ClearEmTutorial() {
  12098. m.clearedem_tutorial = true
  12099. }
  12100. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  12101. func (m *EmployeeMutation) EmTutorialCleared() bool {
  12102. return m.clearedem_tutorial
  12103. }
  12104. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  12105. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  12106. if m.removedem_tutorial == nil {
  12107. m.removedem_tutorial = make(map[uint64]struct{})
  12108. }
  12109. for i := range ids {
  12110. delete(m.em_tutorial, ids[i])
  12111. m.removedem_tutorial[ids[i]] = struct{}{}
  12112. }
  12113. }
  12114. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  12115. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  12116. for id := range m.removedem_tutorial {
  12117. ids = append(ids, id)
  12118. }
  12119. return
  12120. }
  12121. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  12122. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  12123. for id := range m.em_tutorial {
  12124. ids = append(ids, id)
  12125. }
  12126. return
  12127. }
  12128. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  12129. func (m *EmployeeMutation) ResetEmTutorial() {
  12130. m.em_tutorial = nil
  12131. m.clearedem_tutorial = false
  12132. m.removedem_tutorial = nil
  12133. }
  12134. // Where appends a list predicates to the EmployeeMutation builder.
  12135. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  12136. m.predicates = append(m.predicates, ps...)
  12137. }
  12138. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  12139. // users can use type-assertion to append predicates that do not depend on any generated package.
  12140. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  12141. p := make([]predicate.Employee, len(ps))
  12142. for i := range ps {
  12143. p[i] = ps[i]
  12144. }
  12145. m.Where(p...)
  12146. }
  12147. // Op returns the operation name.
  12148. func (m *EmployeeMutation) Op() Op {
  12149. return m.op
  12150. }
  12151. // SetOp allows setting the mutation operation.
  12152. func (m *EmployeeMutation) SetOp(op Op) {
  12153. m.op = op
  12154. }
  12155. // Type returns the node type of this mutation (Employee).
  12156. func (m *EmployeeMutation) Type() string {
  12157. return m.typ
  12158. }
  12159. // Fields returns all fields that were changed during this mutation. Note that in
  12160. // order to get all numeric fields that were incremented/decremented, call
  12161. // AddedFields().
  12162. func (m *EmployeeMutation) Fields() []string {
  12163. fields := make([]string, 0, 23)
  12164. if m.created_at != nil {
  12165. fields = append(fields, employee.FieldCreatedAt)
  12166. }
  12167. if m.updated_at != nil {
  12168. fields = append(fields, employee.FieldUpdatedAt)
  12169. }
  12170. if m.deleted_at != nil {
  12171. fields = append(fields, employee.FieldDeletedAt)
  12172. }
  12173. if m.title != nil {
  12174. fields = append(fields, employee.FieldTitle)
  12175. }
  12176. if m.avatar != nil {
  12177. fields = append(fields, employee.FieldAvatar)
  12178. }
  12179. if m.tags != nil {
  12180. fields = append(fields, employee.FieldTags)
  12181. }
  12182. if m.hire_count != nil {
  12183. fields = append(fields, employee.FieldHireCount)
  12184. }
  12185. if m.service_count != nil {
  12186. fields = append(fields, employee.FieldServiceCount)
  12187. }
  12188. if m.achievement_count != nil {
  12189. fields = append(fields, employee.FieldAchievementCount)
  12190. }
  12191. if m.intro != nil {
  12192. fields = append(fields, employee.FieldIntro)
  12193. }
  12194. if m.estimate != nil {
  12195. fields = append(fields, employee.FieldEstimate)
  12196. }
  12197. if m.skill != nil {
  12198. fields = append(fields, employee.FieldSkill)
  12199. }
  12200. if m.ability_type != nil {
  12201. fields = append(fields, employee.FieldAbilityType)
  12202. }
  12203. if m.scene != nil {
  12204. fields = append(fields, employee.FieldScene)
  12205. }
  12206. if m.switch_in != nil {
  12207. fields = append(fields, employee.FieldSwitchIn)
  12208. }
  12209. if m.video_url != nil {
  12210. fields = append(fields, employee.FieldVideoURL)
  12211. }
  12212. if m.organization_id != nil {
  12213. fields = append(fields, employee.FieldOrganizationID)
  12214. }
  12215. if m.category_id != nil {
  12216. fields = append(fields, employee.FieldCategoryID)
  12217. }
  12218. if m.api_base != nil {
  12219. fields = append(fields, employee.FieldAPIBase)
  12220. }
  12221. if m.api_key != nil {
  12222. fields = append(fields, employee.FieldAPIKey)
  12223. }
  12224. if m.ai_info != nil {
  12225. fields = append(fields, employee.FieldAiInfo)
  12226. }
  12227. if m.is_vip != nil {
  12228. fields = append(fields, employee.FieldIsVip)
  12229. }
  12230. if m.chat_url != nil {
  12231. fields = append(fields, employee.FieldChatURL)
  12232. }
  12233. return fields
  12234. }
  12235. // Field returns the value of a field with the given name. The second boolean
  12236. // return value indicates that this field was not set, or was not defined in the
  12237. // schema.
  12238. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  12239. switch name {
  12240. case employee.FieldCreatedAt:
  12241. return m.CreatedAt()
  12242. case employee.FieldUpdatedAt:
  12243. return m.UpdatedAt()
  12244. case employee.FieldDeletedAt:
  12245. return m.DeletedAt()
  12246. case employee.FieldTitle:
  12247. return m.Title()
  12248. case employee.FieldAvatar:
  12249. return m.Avatar()
  12250. case employee.FieldTags:
  12251. return m.Tags()
  12252. case employee.FieldHireCount:
  12253. return m.HireCount()
  12254. case employee.FieldServiceCount:
  12255. return m.ServiceCount()
  12256. case employee.FieldAchievementCount:
  12257. return m.AchievementCount()
  12258. case employee.FieldIntro:
  12259. return m.Intro()
  12260. case employee.FieldEstimate:
  12261. return m.Estimate()
  12262. case employee.FieldSkill:
  12263. return m.Skill()
  12264. case employee.FieldAbilityType:
  12265. return m.AbilityType()
  12266. case employee.FieldScene:
  12267. return m.Scene()
  12268. case employee.FieldSwitchIn:
  12269. return m.SwitchIn()
  12270. case employee.FieldVideoURL:
  12271. return m.VideoURL()
  12272. case employee.FieldOrganizationID:
  12273. return m.OrganizationID()
  12274. case employee.FieldCategoryID:
  12275. return m.CategoryID()
  12276. case employee.FieldAPIBase:
  12277. return m.APIBase()
  12278. case employee.FieldAPIKey:
  12279. return m.APIKey()
  12280. case employee.FieldAiInfo:
  12281. return m.AiInfo()
  12282. case employee.FieldIsVip:
  12283. return m.IsVip()
  12284. case employee.FieldChatURL:
  12285. return m.ChatURL()
  12286. }
  12287. return nil, false
  12288. }
  12289. // OldField returns the old value of the field from the database. An error is
  12290. // returned if the mutation operation is not UpdateOne, or the query to the
  12291. // database failed.
  12292. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12293. switch name {
  12294. case employee.FieldCreatedAt:
  12295. return m.OldCreatedAt(ctx)
  12296. case employee.FieldUpdatedAt:
  12297. return m.OldUpdatedAt(ctx)
  12298. case employee.FieldDeletedAt:
  12299. return m.OldDeletedAt(ctx)
  12300. case employee.FieldTitle:
  12301. return m.OldTitle(ctx)
  12302. case employee.FieldAvatar:
  12303. return m.OldAvatar(ctx)
  12304. case employee.FieldTags:
  12305. return m.OldTags(ctx)
  12306. case employee.FieldHireCount:
  12307. return m.OldHireCount(ctx)
  12308. case employee.FieldServiceCount:
  12309. return m.OldServiceCount(ctx)
  12310. case employee.FieldAchievementCount:
  12311. return m.OldAchievementCount(ctx)
  12312. case employee.FieldIntro:
  12313. return m.OldIntro(ctx)
  12314. case employee.FieldEstimate:
  12315. return m.OldEstimate(ctx)
  12316. case employee.FieldSkill:
  12317. return m.OldSkill(ctx)
  12318. case employee.FieldAbilityType:
  12319. return m.OldAbilityType(ctx)
  12320. case employee.FieldScene:
  12321. return m.OldScene(ctx)
  12322. case employee.FieldSwitchIn:
  12323. return m.OldSwitchIn(ctx)
  12324. case employee.FieldVideoURL:
  12325. return m.OldVideoURL(ctx)
  12326. case employee.FieldOrganizationID:
  12327. return m.OldOrganizationID(ctx)
  12328. case employee.FieldCategoryID:
  12329. return m.OldCategoryID(ctx)
  12330. case employee.FieldAPIBase:
  12331. return m.OldAPIBase(ctx)
  12332. case employee.FieldAPIKey:
  12333. return m.OldAPIKey(ctx)
  12334. case employee.FieldAiInfo:
  12335. return m.OldAiInfo(ctx)
  12336. case employee.FieldIsVip:
  12337. return m.OldIsVip(ctx)
  12338. case employee.FieldChatURL:
  12339. return m.OldChatURL(ctx)
  12340. }
  12341. return nil, fmt.Errorf("unknown Employee field %s", name)
  12342. }
  12343. // SetField sets the value of a field with the given name. It returns an error if
  12344. // the field is not defined in the schema, or if the type mismatched the field
  12345. // type.
  12346. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  12347. switch name {
  12348. case employee.FieldCreatedAt:
  12349. v, ok := value.(time.Time)
  12350. if !ok {
  12351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12352. }
  12353. m.SetCreatedAt(v)
  12354. return nil
  12355. case employee.FieldUpdatedAt:
  12356. v, ok := value.(time.Time)
  12357. if !ok {
  12358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12359. }
  12360. m.SetUpdatedAt(v)
  12361. return nil
  12362. case employee.FieldDeletedAt:
  12363. v, ok := value.(time.Time)
  12364. if !ok {
  12365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12366. }
  12367. m.SetDeletedAt(v)
  12368. return nil
  12369. case employee.FieldTitle:
  12370. v, ok := value.(string)
  12371. if !ok {
  12372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12373. }
  12374. m.SetTitle(v)
  12375. return nil
  12376. case employee.FieldAvatar:
  12377. v, ok := value.(string)
  12378. if !ok {
  12379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12380. }
  12381. m.SetAvatar(v)
  12382. return nil
  12383. case employee.FieldTags:
  12384. v, ok := value.(string)
  12385. if !ok {
  12386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12387. }
  12388. m.SetTags(v)
  12389. return nil
  12390. case employee.FieldHireCount:
  12391. v, ok := value.(int)
  12392. if !ok {
  12393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12394. }
  12395. m.SetHireCount(v)
  12396. return nil
  12397. case employee.FieldServiceCount:
  12398. v, ok := value.(int)
  12399. if !ok {
  12400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12401. }
  12402. m.SetServiceCount(v)
  12403. return nil
  12404. case employee.FieldAchievementCount:
  12405. v, ok := value.(int)
  12406. if !ok {
  12407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12408. }
  12409. m.SetAchievementCount(v)
  12410. return nil
  12411. case employee.FieldIntro:
  12412. v, ok := value.(string)
  12413. if !ok {
  12414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12415. }
  12416. m.SetIntro(v)
  12417. return nil
  12418. case employee.FieldEstimate:
  12419. v, ok := value.(string)
  12420. if !ok {
  12421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12422. }
  12423. m.SetEstimate(v)
  12424. return nil
  12425. case employee.FieldSkill:
  12426. v, ok := value.(string)
  12427. if !ok {
  12428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12429. }
  12430. m.SetSkill(v)
  12431. return nil
  12432. case employee.FieldAbilityType:
  12433. v, ok := value.(string)
  12434. if !ok {
  12435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12436. }
  12437. m.SetAbilityType(v)
  12438. return nil
  12439. case employee.FieldScene:
  12440. v, ok := value.(string)
  12441. if !ok {
  12442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12443. }
  12444. m.SetScene(v)
  12445. return nil
  12446. case employee.FieldSwitchIn:
  12447. v, ok := value.(string)
  12448. if !ok {
  12449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12450. }
  12451. m.SetSwitchIn(v)
  12452. return nil
  12453. case employee.FieldVideoURL:
  12454. v, ok := value.(string)
  12455. if !ok {
  12456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12457. }
  12458. m.SetVideoURL(v)
  12459. return nil
  12460. case employee.FieldOrganizationID:
  12461. v, ok := value.(uint64)
  12462. if !ok {
  12463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12464. }
  12465. m.SetOrganizationID(v)
  12466. return nil
  12467. case employee.FieldCategoryID:
  12468. v, ok := value.(uint64)
  12469. if !ok {
  12470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12471. }
  12472. m.SetCategoryID(v)
  12473. return nil
  12474. case employee.FieldAPIBase:
  12475. v, ok := value.(string)
  12476. if !ok {
  12477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12478. }
  12479. m.SetAPIBase(v)
  12480. return nil
  12481. case employee.FieldAPIKey:
  12482. v, ok := value.(string)
  12483. if !ok {
  12484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12485. }
  12486. m.SetAPIKey(v)
  12487. return nil
  12488. case employee.FieldAiInfo:
  12489. v, ok := value.(string)
  12490. if !ok {
  12491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12492. }
  12493. m.SetAiInfo(v)
  12494. return nil
  12495. case employee.FieldIsVip:
  12496. v, ok := value.(int)
  12497. if !ok {
  12498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12499. }
  12500. m.SetIsVip(v)
  12501. return nil
  12502. case employee.FieldChatURL:
  12503. v, ok := value.(string)
  12504. if !ok {
  12505. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12506. }
  12507. m.SetChatURL(v)
  12508. return nil
  12509. }
  12510. return fmt.Errorf("unknown Employee field %s", name)
  12511. }
  12512. // AddedFields returns all numeric fields that were incremented/decremented during
  12513. // this mutation.
  12514. func (m *EmployeeMutation) AddedFields() []string {
  12515. var fields []string
  12516. if m.addhire_count != nil {
  12517. fields = append(fields, employee.FieldHireCount)
  12518. }
  12519. if m.addservice_count != nil {
  12520. fields = append(fields, employee.FieldServiceCount)
  12521. }
  12522. if m.addachievement_count != nil {
  12523. fields = append(fields, employee.FieldAchievementCount)
  12524. }
  12525. if m.addorganization_id != nil {
  12526. fields = append(fields, employee.FieldOrganizationID)
  12527. }
  12528. if m.addcategory_id != nil {
  12529. fields = append(fields, employee.FieldCategoryID)
  12530. }
  12531. if m.addis_vip != nil {
  12532. fields = append(fields, employee.FieldIsVip)
  12533. }
  12534. return fields
  12535. }
  12536. // AddedField returns the numeric value that was incremented/decremented on a field
  12537. // with the given name. The second boolean return value indicates that this field
  12538. // was not set, or was not defined in the schema.
  12539. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  12540. switch name {
  12541. case employee.FieldHireCount:
  12542. return m.AddedHireCount()
  12543. case employee.FieldServiceCount:
  12544. return m.AddedServiceCount()
  12545. case employee.FieldAchievementCount:
  12546. return m.AddedAchievementCount()
  12547. case employee.FieldOrganizationID:
  12548. return m.AddedOrganizationID()
  12549. case employee.FieldCategoryID:
  12550. return m.AddedCategoryID()
  12551. case employee.FieldIsVip:
  12552. return m.AddedIsVip()
  12553. }
  12554. return nil, false
  12555. }
  12556. // AddField adds the value to the field with the given name. It returns an error if
  12557. // the field is not defined in the schema, or if the type mismatched the field
  12558. // type.
  12559. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  12560. switch name {
  12561. case employee.FieldHireCount:
  12562. v, ok := value.(int)
  12563. if !ok {
  12564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12565. }
  12566. m.AddHireCount(v)
  12567. return nil
  12568. case employee.FieldServiceCount:
  12569. v, ok := value.(int)
  12570. if !ok {
  12571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12572. }
  12573. m.AddServiceCount(v)
  12574. return nil
  12575. case employee.FieldAchievementCount:
  12576. v, ok := value.(int)
  12577. if !ok {
  12578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12579. }
  12580. m.AddAchievementCount(v)
  12581. return nil
  12582. case employee.FieldOrganizationID:
  12583. v, ok := value.(int64)
  12584. if !ok {
  12585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12586. }
  12587. m.AddOrganizationID(v)
  12588. return nil
  12589. case employee.FieldCategoryID:
  12590. v, ok := value.(int64)
  12591. if !ok {
  12592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12593. }
  12594. m.AddCategoryID(v)
  12595. return nil
  12596. case employee.FieldIsVip:
  12597. v, ok := value.(int)
  12598. if !ok {
  12599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12600. }
  12601. m.AddIsVip(v)
  12602. return nil
  12603. }
  12604. return fmt.Errorf("unknown Employee numeric field %s", name)
  12605. }
  12606. // ClearedFields returns all nullable fields that were cleared during this
  12607. // mutation.
  12608. func (m *EmployeeMutation) ClearedFields() []string {
  12609. var fields []string
  12610. if m.FieldCleared(employee.FieldDeletedAt) {
  12611. fields = append(fields, employee.FieldDeletedAt)
  12612. }
  12613. if m.FieldCleared(employee.FieldAiInfo) {
  12614. fields = append(fields, employee.FieldAiInfo)
  12615. }
  12616. return fields
  12617. }
  12618. // FieldCleared returns a boolean indicating if a field with the given name was
  12619. // cleared in this mutation.
  12620. func (m *EmployeeMutation) FieldCleared(name string) bool {
  12621. _, ok := m.clearedFields[name]
  12622. return ok
  12623. }
  12624. // ClearField clears the value of the field with the given name. It returns an
  12625. // error if the field is not defined in the schema.
  12626. func (m *EmployeeMutation) ClearField(name string) error {
  12627. switch name {
  12628. case employee.FieldDeletedAt:
  12629. m.ClearDeletedAt()
  12630. return nil
  12631. case employee.FieldAiInfo:
  12632. m.ClearAiInfo()
  12633. return nil
  12634. }
  12635. return fmt.Errorf("unknown Employee nullable field %s", name)
  12636. }
  12637. // ResetField resets all changes in the mutation for the field with the given name.
  12638. // It returns an error if the field is not defined in the schema.
  12639. func (m *EmployeeMutation) ResetField(name string) error {
  12640. switch name {
  12641. case employee.FieldCreatedAt:
  12642. m.ResetCreatedAt()
  12643. return nil
  12644. case employee.FieldUpdatedAt:
  12645. m.ResetUpdatedAt()
  12646. return nil
  12647. case employee.FieldDeletedAt:
  12648. m.ResetDeletedAt()
  12649. return nil
  12650. case employee.FieldTitle:
  12651. m.ResetTitle()
  12652. return nil
  12653. case employee.FieldAvatar:
  12654. m.ResetAvatar()
  12655. return nil
  12656. case employee.FieldTags:
  12657. m.ResetTags()
  12658. return nil
  12659. case employee.FieldHireCount:
  12660. m.ResetHireCount()
  12661. return nil
  12662. case employee.FieldServiceCount:
  12663. m.ResetServiceCount()
  12664. return nil
  12665. case employee.FieldAchievementCount:
  12666. m.ResetAchievementCount()
  12667. return nil
  12668. case employee.FieldIntro:
  12669. m.ResetIntro()
  12670. return nil
  12671. case employee.FieldEstimate:
  12672. m.ResetEstimate()
  12673. return nil
  12674. case employee.FieldSkill:
  12675. m.ResetSkill()
  12676. return nil
  12677. case employee.FieldAbilityType:
  12678. m.ResetAbilityType()
  12679. return nil
  12680. case employee.FieldScene:
  12681. m.ResetScene()
  12682. return nil
  12683. case employee.FieldSwitchIn:
  12684. m.ResetSwitchIn()
  12685. return nil
  12686. case employee.FieldVideoURL:
  12687. m.ResetVideoURL()
  12688. return nil
  12689. case employee.FieldOrganizationID:
  12690. m.ResetOrganizationID()
  12691. return nil
  12692. case employee.FieldCategoryID:
  12693. m.ResetCategoryID()
  12694. return nil
  12695. case employee.FieldAPIBase:
  12696. m.ResetAPIBase()
  12697. return nil
  12698. case employee.FieldAPIKey:
  12699. m.ResetAPIKey()
  12700. return nil
  12701. case employee.FieldAiInfo:
  12702. m.ResetAiInfo()
  12703. return nil
  12704. case employee.FieldIsVip:
  12705. m.ResetIsVip()
  12706. return nil
  12707. case employee.FieldChatURL:
  12708. m.ResetChatURL()
  12709. return nil
  12710. }
  12711. return fmt.Errorf("unknown Employee field %s", name)
  12712. }
  12713. // AddedEdges returns all edge names that were set/added in this mutation.
  12714. func (m *EmployeeMutation) AddedEdges() []string {
  12715. edges := make([]string, 0, 2)
  12716. if m.em_work_experiences != nil {
  12717. edges = append(edges, employee.EdgeEmWorkExperiences)
  12718. }
  12719. if m.em_tutorial != nil {
  12720. edges = append(edges, employee.EdgeEmTutorial)
  12721. }
  12722. return edges
  12723. }
  12724. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12725. // name in this mutation.
  12726. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  12727. switch name {
  12728. case employee.EdgeEmWorkExperiences:
  12729. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  12730. for id := range m.em_work_experiences {
  12731. ids = append(ids, id)
  12732. }
  12733. return ids
  12734. case employee.EdgeEmTutorial:
  12735. ids := make([]ent.Value, 0, len(m.em_tutorial))
  12736. for id := range m.em_tutorial {
  12737. ids = append(ids, id)
  12738. }
  12739. return ids
  12740. }
  12741. return nil
  12742. }
  12743. // RemovedEdges returns all edge names that were removed in this mutation.
  12744. func (m *EmployeeMutation) RemovedEdges() []string {
  12745. edges := make([]string, 0, 2)
  12746. if m.removedem_work_experiences != nil {
  12747. edges = append(edges, employee.EdgeEmWorkExperiences)
  12748. }
  12749. if m.removedem_tutorial != nil {
  12750. edges = append(edges, employee.EdgeEmTutorial)
  12751. }
  12752. return edges
  12753. }
  12754. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12755. // the given name in this mutation.
  12756. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  12757. switch name {
  12758. case employee.EdgeEmWorkExperiences:
  12759. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  12760. for id := range m.removedem_work_experiences {
  12761. ids = append(ids, id)
  12762. }
  12763. return ids
  12764. case employee.EdgeEmTutorial:
  12765. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  12766. for id := range m.removedem_tutorial {
  12767. ids = append(ids, id)
  12768. }
  12769. return ids
  12770. }
  12771. return nil
  12772. }
  12773. // ClearedEdges returns all edge names that were cleared in this mutation.
  12774. func (m *EmployeeMutation) ClearedEdges() []string {
  12775. edges := make([]string, 0, 2)
  12776. if m.clearedem_work_experiences {
  12777. edges = append(edges, employee.EdgeEmWorkExperiences)
  12778. }
  12779. if m.clearedem_tutorial {
  12780. edges = append(edges, employee.EdgeEmTutorial)
  12781. }
  12782. return edges
  12783. }
  12784. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12785. // was cleared in this mutation.
  12786. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  12787. switch name {
  12788. case employee.EdgeEmWorkExperiences:
  12789. return m.clearedem_work_experiences
  12790. case employee.EdgeEmTutorial:
  12791. return m.clearedem_tutorial
  12792. }
  12793. return false
  12794. }
  12795. // ClearEdge clears the value of the edge with the given name. It returns an error
  12796. // if that edge is not defined in the schema.
  12797. func (m *EmployeeMutation) ClearEdge(name string) error {
  12798. switch name {
  12799. }
  12800. return fmt.Errorf("unknown Employee unique edge %s", name)
  12801. }
  12802. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12803. // It returns an error if the edge is not defined in the schema.
  12804. func (m *EmployeeMutation) ResetEdge(name string) error {
  12805. switch name {
  12806. case employee.EdgeEmWorkExperiences:
  12807. m.ResetEmWorkExperiences()
  12808. return nil
  12809. case employee.EdgeEmTutorial:
  12810. m.ResetEmTutorial()
  12811. return nil
  12812. }
  12813. return fmt.Errorf("unknown Employee edge %s", name)
  12814. }
  12815. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  12816. type EmployeeConfigMutation struct {
  12817. config
  12818. op Op
  12819. typ string
  12820. id *uint64
  12821. created_at *time.Time
  12822. updated_at *time.Time
  12823. deleted_at *time.Time
  12824. stype *string
  12825. title *string
  12826. photo *string
  12827. organization_id *uint64
  12828. addorganization_id *int64
  12829. clearedFields map[string]struct{}
  12830. done bool
  12831. oldValue func(context.Context) (*EmployeeConfig, error)
  12832. predicates []predicate.EmployeeConfig
  12833. }
  12834. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  12835. // employeeconfigOption allows management of the mutation configuration using functional options.
  12836. type employeeconfigOption func(*EmployeeConfigMutation)
  12837. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  12838. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  12839. m := &EmployeeConfigMutation{
  12840. config: c,
  12841. op: op,
  12842. typ: TypeEmployeeConfig,
  12843. clearedFields: make(map[string]struct{}),
  12844. }
  12845. for _, opt := range opts {
  12846. opt(m)
  12847. }
  12848. return m
  12849. }
  12850. // withEmployeeConfigID sets the ID field of the mutation.
  12851. func withEmployeeConfigID(id uint64) employeeconfigOption {
  12852. return func(m *EmployeeConfigMutation) {
  12853. var (
  12854. err error
  12855. once sync.Once
  12856. value *EmployeeConfig
  12857. )
  12858. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  12859. once.Do(func() {
  12860. if m.done {
  12861. err = errors.New("querying old values post mutation is not allowed")
  12862. } else {
  12863. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  12864. }
  12865. })
  12866. return value, err
  12867. }
  12868. m.id = &id
  12869. }
  12870. }
  12871. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  12872. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  12873. return func(m *EmployeeConfigMutation) {
  12874. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  12875. return node, nil
  12876. }
  12877. m.id = &node.ID
  12878. }
  12879. }
  12880. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12881. // executed in a transaction (ent.Tx), a transactional client is returned.
  12882. func (m EmployeeConfigMutation) Client() *Client {
  12883. client := &Client{config: m.config}
  12884. client.init()
  12885. return client
  12886. }
  12887. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12888. // it returns an error otherwise.
  12889. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  12890. if _, ok := m.driver.(*txDriver); !ok {
  12891. return nil, errors.New("ent: mutation is not running in a transaction")
  12892. }
  12893. tx := &Tx{config: m.config}
  12894. tx.init()
  12895. return tx, nil
  12896. }
  12897. // SetID sets the value of the id field. Note that this
  12898. // operation is only accepted on creation of EmployeeConfig entities.
  12899. func (m *EmployeeConfigMutation) SetID(id uint64) {
  12900. m.id = &id
  12901. }
  12902. // ID returns the ID value in the mutation. Note that the ID is only available
  12903. // if it was provided to the builder or after it was returned from the database.
  12904. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  12905. if m.id == nil {
  12906. return
  12907. }
  12908. return *m.id, true
  12909. }
  12910. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12911. // That means, if the mutation is applied within a transaction with an isolation level such
  12912. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12913. // or updated by the mutation.
  12914. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  12915. switch {
  12916. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12917. id, exists := m.ID()
  12918. if exists {
  12919. return []uint64{id}, nil
  12920. }
  12921. fallthrough
  12922. case m.op.Is(OpUpdate | OpDelete):
  12923. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  12924. default:
  12925. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12926. }
  12927. }
  12928. // SetCreatedAt sets the "created_at" field.
  12929. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  12930. m.created_at = &t
  12931. }
  12932. // CreatedAt returns the value of the "created_at" field in the mutation.
  12933. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  12934. v := m.created_at
  12935. if v == nil {
  12936. return
  12937. }
  12938. return *v, true
  12939. }
  12940. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  12941. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  12942. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12943. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12944. if !m.op.Is(OpUpdateOne) {
  12945. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12946. }
  12947. if m.id == nil || m.oldValue == nil {
  12948. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12949. }
  12950. oldValue, err := m.oldValue(ctx)
  12951. if err != nil {
  12952. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12953. }
  12954. return oldValue.CreatedAt, nil
  12955. }
  12956. // ResetCreatedAt resets all changes to the "created_at" field.
  12957. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  12958. m.created_at = nil
  12959. }
  12960. // SetUpdatedAt sets the "updated_at" field.
  12961. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  12962. m.updated_at = &t
  12963. }
  12964. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12965. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  12966. v := m.updated_at
  12967. if v == nil {
  12968. return
  12969. }
  12970. return *v, true
  12971. }
  12972. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  12973. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  12974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12975. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12976. if !m.op.Is(OpUpdateOne) {
  12977. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12978. }
  12979. if m.id == nil || m.oldValue == nil {
  12980. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12981. }
  12982. oldValue, err := m.oldValue(ctx)
  12983. if err != nil {
  12984. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12985. }
  12986. return oldValue.UpdatedAt, nil
  12987. }
  12988. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12989. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  12990. m.updated_at = nil
  12991. }
  12992. // SetDeletedAt sets the "deleted_at" field.
  12993. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  12994. m.deleted_at = &t
  12995. }
  12996. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12997. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  12998. v := m.deleted_at
  12999. if v == nil {
  13000. return
  13001. }
  13002. return *v, true
  13003. }
  13004. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  13005. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13007. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13008. if !m.op.Is(OpUpdateOne) {
  13009. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13010. }
  13011. if m.id == nil || m.oldValue == nil {
  13012. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13013. }
  13014. oldValue, err := m.oldValue(ctx)
  13015. if err != nil {
  13016. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13017. }
  13018. return oldValue.DeletedAt, nil
  13019. }
  13020. // ClearDeletedAt clears the value of the "deleted_at" field.
  13021. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  13022. m.deleted_at = nil
  13023. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  13024. }
  13025. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13026. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  13027. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  13028. return ok
  13029. }
  13030. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13031. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  13032. m.deleted_at = nil
  13033. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  13034. }
  13035. // SetStype sets the "stype" field.
  13036. func (m *EmployeeConfigMutation) SetStype(s string) {
  13037. m.stype = &s
  13038. }
  13039. // Stype returns the value of the "stype" field in the mutation.
  13040. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  13041. v := m.stype
  13042. if v == nil {
  13043. return
  13044. }
  13045. return *v, true
  13046. }
  13047. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  13048. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13050. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  13051. if !m.op.Is(OpUpdateOne) {
  13052. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  13053. }
  13054. if m.id == nil || m.oldValue == nil {
  13055. return v, errors.New("OldStype requires an ID field in the mutation")
  13056. }
  13057. oldValue, err := m.oldValue(ctx)
  13058. if err != nil {
  13059. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  13060. }
  13061. return oldValue.Stype, nil
  13062. }
  13063. // ResetStype resets all changes to the "stype" field.
  13064. func (m *EmployeeConfigMutation) ResetStype() {
  13065. m.stype = nil
  13066. }
  13067. // SetTitle sets the "title" field.
  13068. func (m *EmployeeConfigMutation) SetTitle(s string) {
  13069. m.title = &s
  13070. }
  13071. // Title returns the value of the "title" field in the mutation.
  13072. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  13073. v := m.title
  13074. if v == nil {
  13075. return
  13076. }
  13077. return *v, true
  13078. }
  13079. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  13080. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13082. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  13083. if !m.op.Is(OpUpdateOne) {
  13084. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  13085. }
  13086. if m.id == nil || m.oldValue == nil {
  13087. return v, errors.New("OldTitle requires an ID field in the mutation")
  13088. }
  13089. oldValue, err := m.oldValue(ctx)
  13090. if err != nil {
  13091. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  13092. }
  13093. return oldValue.Title, nil
  13094. }
  13095. // ResetTitle resets all changes to the "title" field.
  13096. func (m *EmployeeConfigMutation) ResetTitle() {
  13097. m.title = nil
  13098. }
  13099. // SetPhoto sets the "photo" field.
  13100. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  13101. m.photo = &s
  13102. }
  13103. // Photo returns the value of the "photo" field in the mutation.
  13104. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  13105. v := m.photo
  13106. if v == nil {
  13107. return
  13108. }
  13109. return *v, true
  13110. }
  13111. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  13112. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13114. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  13115. if !m.op.Is(OpUpdateOne) {
  13116. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  13117. }
  13118. if m.id == nil || m.oldValue == nil {
  13119. return v, errors.New("OldPhoto requires an ID field in the mutation")
  13120. }
  13121. oldValue, err := m.oldValue(ctx)
  13122. if err != nil {
  13123. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  13124. }
  13125. return oldValue.Photo, nil
  13126. }
  13127. // ResetPhoto resets all changes to the "photo" field.
  13128. func (m *EmployeeConfigMutation) ResetPhoto() {
  13129. m.photo = nil
  13130. }
  13131. // SetOrganizationID sets the "organization_id" field.
  13132. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  13133. m.organization_id = &u
  13134. m.addorganization_id = nil
  13135. }
  13136. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13137. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  13138. v := m.organization_id
  13139. if v == nil {
  13140. return
  13141. }
  13142. return *v, true
  13143. }
  13144. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  13145. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13146. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13147. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13148. if !m.op.Is(OpUpdateOne) {
  13149. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13150. }
  13151. if m.id == nil || m.oldValue == nil {
  13152. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13153. }
  13154. oldValue, err := m.oldValue(ctx)
  13155. if err != nil {
  13156. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13157. }
  13158. return oldValue.OrganizationID, nil
  13159. }
  13160. // AddOrganizationID adds u to the "organization_id" field.
  13161. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  13162. if m.addorganization_id != nil {
  13163. *m.addorganization_id += u
  13164. } else {
  13165. m.addorganization_id = &u
  13166. }
  13167. }
  13168. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13169. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  13170. v := m.addorganization_id
  13171. if v == nil {
  13172. return
  13173. }
  13174. return *v, true
  13175. }
  13176. // ClearOrganizationID clears the value of the "organization_id" field.
  13177. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  13178. m.organization_id = nil
  13179. m.addorganization_id = nil
  13180. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  13181. }
  13182. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13183. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  13184. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  13185. return ok
  13186. }
  13187. // ResetOrganizationID resets all changes to the "organization_id" field.
  13188. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  13189. m.organization_id = nil
  13190. m.addorganization_id = nil
  13191. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  13192. }
  13193. // Where appends a list predicates to the EmployeeConfigMutation builder.
  13194. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  13195. m.predicates = append(m.predicates, ps...)
  13196. }
  13197. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  13198. // users can use type-assertion to append predicates that do not depend on any generated package.
  13199. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  13200. p := make([]predicate.EmployeeConfig, len(ps))
  13201. for i := range ps {
  13202. p[i] = ps[i]
  13203. }
  13204. m.Where(p...)
  13205. }
  13206. // Op returns the operation name.
  13207. func (m *EmployeeConfigMutation) Op() Op {
  13208. return m.op
  13209. }
  13210. // SetOp allows setting the mutation operation.
  13211. func (m *EmployeeConfigMutation) SetOp(op Op) {
  13212. m.op = op
  13213. }
  13214. // Type returns the node type of this mutation (EmployeeConfig).
  13215. func (m *EmployeeConfigMutation) Type() string {
  13216. return m.typ
  13217. }
  13218. // Fields returns all fields that were changed during this mutation. Note that in
  13219. // order to get all numeric fields that were incremented/decremented, call
  13220. // AddedFields().
  13221. func (m *EmployeeConfigMutation) Fields() []string {
  13222. fields := make([]string, 0, 7)
  13223. if m.created_at != nil {
  13224. fields = append(fields, employeeconfig.FieldCreatedAt)
  13225. }
  13226. if m.updated_at != nil {
  13227. fields = append(fields, employeeconfig.FieldUpdatedAt)
  13228. }
  13229. if m.deleted_at != nil {
  13230. fields = append(fields, employeeconfig.FieldDeletedAt)
  13231. }
  13232. if m.stype != nil {
  13233. fields = append(fields, employeeconfig.FieldStype)
  13234. }
  13235. if m.title != nil {
  13236. fields = append(fields, employeeconfig.FieldTitle)
  13237. }
  13238. if m.photo != nil {
  13239. fields = append(fields, employeeconfig.FieldPhoto)
  13240. }
  13241. if m.organization_id != nil {
  13242. fields = append(fields, employeeconfig.FieldOrganizationID)
  13243. }
  13244. return fields
  13245. }
  13246. // Field returns the value of a field with the given name. The second boolean
  13247. // return value indicates that this field was not set, or was not defined in the
  13248. // schema.
  13249. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  13250. switch name {
  13251. case employeeconfig.FieldCreatedAt:
  13252. return m.CreatedAt()
  13253. case employeeconfig.FieldUpdatedAt:
  13254. return m.UpdatedAt()
  13255. case employeeconfig.FieldDeletedAt:
  13256. return m.DeletedAt()
  13257. case employeeconfig.FieldStype:
  13258. return m.Stype()
  13259. case employeeconfig.FieldTitle:
  13260. return m.Title()
  13261. case employeeconfig.FieldPhoto:
  13262. return m.Photo()
  13263. case employeeconfig.FieldOrganizationID:
  13264. return m.OrganizationID()
  13265. }
  13266. return nil, false
  13267. }
  13268. // OldField returns the old value of the field from the database. An error is
  13269. // returned if the mutation operation is not UpdateOne, or the query to the
  13270. // database failed.
  13271. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13272. switch name {
  13273. case employeeconfig.FieldCreatedAt:
  13274. return m.OldCreatedAt(ctx)
  13275. case employeeconfig.FieldUpdatedAt:
  13276. return m.OldUpdatedAt(ctx)
  13277. case employeeconfig.FieldDeletedAt:
  13278. return m.OldDeletedAt(ctx)
  13279. case employeeconfig.FieldStype:
  13280. return m.OldStype(ctx)
  13281. case employeeconfig.FieldTitle:
  13282. return m.OldTitle(ctx)
  13283. case employeeconfig.FieldPhoto:
  13284. return m.OldPhoto(ctx)
  13285. case employeeconfig.FieldOrganizationID:
  13286. return m.OldOrganizationID(ctx)
  13287. }
  13288. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  13289. }
  13290. // SetField sets the value of a field with the given name. It returns an error if
  13291. // the field is not defined in the schema, or if the type mismatched the field
  13292. // type.
  13293. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  13294. switch name {
  13295. case employeeconfig.FieldCreatedAt:
  13296. v, ok := value.(time.Time)
  13297. if !ok {
  13298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13299. }
  13300. m.SetCreatedAt(v)
  13301. return nil
  13302. case employeeconfig.FieldUpdatedAt:
  13303. v, ok := value.(time.Time)
  13304. if !ok {
  13305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13306. }
  13307. m.SetUpdatedAt(v)
  13308. return nil
  13309. case employeeconfig.FieldDeletedAt:
  13310. v, ok := value.(time.Time)
  13311. if !ok {
  13312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13313. }
  13314. m.SetDeletedAt(v)
  13315. return nil
  13316. case employeeconfig.FieldStype:
  13317. v, ok := value.(string)
  13318. if !ok {
  13319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13320. }
  13321. m.SetStype(v)
  13322. return nil
  13323. case employeeconfig.FieldTitle:
  13324. v, ok := value.(string)
  13325. if !ok {
  13326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13327. }
  13328. m.SetTitle(v)
  13329. return nil
  13330. case employeeconfig.FieldPhoto:
  13331. v, ok := value.(string)
  13332. if !ok {
  13333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13334. }
  13335. m.SetPhoto(v)
  13336. return nil
  13337. case employeeconfig.FieldOrganizationID:
  13338. v, ok := value.(uint64)
  13339. if !ok {
  13340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13341. }
  13342. m.SetOrganizationID(v)
  13343. return nil
  13344. }
  13345. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  13346. }
  13347. // AddedFields returns all numeric fields that were incremented/decremented during
  13348. // this mutation.
  13349. func (m *EmployeeConfigMutation) AddedFields() []string {
  13350. var fields []string
  13351. if m.addorganization_id != nil {
  13352. fields = append(fields, employeeconfig.FieldOrganizationID)
  13353. }
  13354. return fields
  13355. }
  13356. // AddedField returns the numeric value that was incremented/decremented on a field
  13357. // with the given name. The second boolean return value indicates that this field
  13358. // was not set, or was not defined in the schema.
  13359. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  13360. switch name {
  13361. case employeeconfig.FieldOrganizationID:
  13362. return m.AddedOrganizationID()
  13363. }
  13364. return nil, false
  13365. }
  13366. // AddField adds the value to the field with the given name. It returns an error if
  13367. // the field is not defined in the schema, or if the type mismatched the field
  13368. // type.
  13369. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  13370. switch name {
  13371. case employeeconfig.FieldOrganizationID:
  13372. v, ok := value.(int64)
  13373. if !ok {
  13374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13375. }
  13376. m.AddOrganizationID(v)
  13377. return nil
  13378. }
  13379. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  13380. }
  13381. // ClearedFields returns all nullable fields that were cleared during this
  13382. // mutation.
  13383. func (m *EmployeeConfigMutation) ClearedFields() []string {
  13384. var fields []string
  13385. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  13386. fields = append(fields, employeeconfig.FieldDeletedAt)
  13387. }
  13388. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  13389. fields = append(fields, employeeconfig.FieldOrganizationID)
  13390. }
  13391. return fields
  13392. }
  13393. // FieldCleared returns a boolean indicating if a field with the given name was
  13394. // cleared in this mutation.
  13395. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  13396. _, ok := m.clearedFields[name]
  13397. return ok
  13398. }
  13399. // ClearField clears the value of the field with the given name. It returns an
  13400. // error if the field is not defined in the schema.
  13401. func (m *EmployeeConfigMutation) ClearField(name string) error {
  13402. switch name {
  13403. case employeeconfig.FieldDeletedAt:
  13404. m.ClearDeletedAt()
  13405. return nil
  13406. case employeeconfig.FieldOrganizationID:
  13407. m.ClearOrganizationID()
  13408. return nil
  13409. }
  13410. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  13411. }
  13412. // ResetField resets all changes in the mutation for the field with the given name.
  13413. // It returns an error if the field is not defined in the schema.
  13414. func (m *EmployeeConfigMutation) ResetField(name string) error {
  13415. switch name {
  13416. case employeeconfig.FieldCreatedAt:
  13417. m.ResetCreatedAt()
  13418. return nil
  13419. case employeeconfig.FieldUpdatedAt:
  13420. m.ResetUpdatedAt()
  13421. return nil
  13422. case employeeconfig.FieldDeletedAt:
  13423. m.ResetDeletedAt()
  13424. return nil
  13425. case employeeconfig.FieldStype:
  13426. m.ResetStype()
  13427. return nil
  13428. case employeeconfig.FieldTitle:
  13429. m.ResetTitle()
  13430. return nil
  13431. case employeeconfig.FieldPhoto:
  13432. m.ResetPhoto()
  13433. return nil
  13434. case employeeconfig.FieldOrganizationID:
  13435. m.ResetOrganizationID()
  13436. return nil
  13437. }
  13438. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  13439. }
  13440. // AddedEdges returns all edge names that were set/added in this mutation.
  13441. func (m *EmployeeConfigMutation) AddedEdges() []string {
  13442. edges := make([]string, 0, 0)
  13443. return edges
  13444. }
  13445. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13446. // name in this mutation.
  13447. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  13448. return nil
  13449. }
  13450. // RemovedEdges returns all edge names that were removed in this mutation.
  13451. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  13452. edges := make([]string, 0, 0)
  13453. return edges
  13454. }
  13455. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13456. // the given name in this mutation.
  13457. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  13458. return nil
  13459. }
  13460. // ClearedEdges returns all edge names that were cleared in this mutation.
  13461. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  13462. edges := make([]string, 0, 0)
  13463. return edges
  13464. }
  13465. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13466. // was cleared in this mutation.
  13467. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  13468. return false
  13469. }
  13470. // ClearEdge clears the value of the edge with the given name. It returns an error
  13471. // if that edge is not defined in the schema.
  13472. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  13473. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  13474. }
  13475. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13476. // It returns an error if the edge is not defined in the schema.
  13477. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  13478. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  13479. }
  13480. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  13481. type LabelMutation struct {
  13482. config
  13483. op Op
  13484. typ string
  13485. id *uint64
  13486. created_at *time.Time
  13487. updated_at *time.Time
  13488. status *uint8
  13489. addstatus *int8
  13490. _type *int
  13491. add_type *int
  13492. name *string
  13493. from *int
  13494. addfrom *int
  13495. mode *int
  13496. addmode *int
  13497. conditions *string
  13498. organization_id *uint64
  13499. addorganization_id *int64
  13500. clearedFields map[string]struct{}
  13501. label_relationships map[uint64]struct{}
  13502. removedlabel_relationships map[uint64]struct{}
  13503. clearedlabel_relationships bool
  13504. done bool
  13505. oldValue func(context.Context) (*Label, error)
  13506. predicates []predicate.Label
  13507. }
  13508. var _ ent.Mutation = (*LabelMutation)(nil)
  13509. // labelOption allows management of the mutation configuration using functional options.
  13510. type labelOption func(*LabelMutation)
  13511. // newLabelMutation creates new mutation for the Label entity.
  13512. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  13513. m := &LabelMutation{
  13514. config: c,
  13515. op: op,
  13516. typ: TypeLabel,
  13517. clearedFields: make(map[string]struct{}),
  13518. }
  13519. for _, opt := range opts {
  13520. opt(m)
  13521. }
  13522. return m
  13523. }
  13524. // withLabelID sets the ID field of the mutation.
  13525. func withLabelID(id uint64) labelOption {
  13526. return func(m *LabelMutation) {
  13527. var (
  13528. err error
  13529. once sync.Once
  13530. value *Label
  13531. )
  13532. m.oldValue = func(ctx context.Context) (*Label, error) {
  13533. once.Do(func() {
  13534. if m.done {
  13535. err = errors.New("querying old values post mutation is not allowed")
  13536. } else {
  13537. value, err = m.Client().Label.Get(ctx, id)
  13538. }
  13539. })
  13540. return value, err
  13541. }
  13542. m.id = &id
  13543. }
  13544. }
  13545. // withLabel sets the old Label of the mutation.
  13546. func withLabel(node *Label) labelOption {
  13547. return func(m *LabelMutation) {
  13548. m.oldValue = func(context.Context) (*Label, error) {
  13549. return node, nil
  13550. }
  13551. m.id = &node.ID
  13552. }
  13553. }
  13554. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13555. // executed in a transaction (ent.Tx), a transactional client is returned.
  13556. func (m LabelMutation) Client() *Client {
  13557. client := &Client{config: m.config}
  13558. client.init()
  13559. return client
  13560. }
  13561. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13562. // it returns an error otherwise.
  13563. func (m LabelMutation) Tx() (*Tx, error) {
  13564. if _, ok := m.driver.(*txDriver); !ok {
  13565. return nil, errors.New("ent: mutation is not running in a transaction")
  13566. }
  13567. tx := &Tx{config: m.config}
  13568. tx.init()
  13569. return tx, nil
  13570. }
  13571. // SetID sets the value of the id field. Note that this
  13572. // operation is only accepted on creation of Label entities.
  13573. func (m *LabelMutation) SetID(id uint64) {
  13574. m.id = &id
  13575. }
  13576. // ID returns the ID value in the mutation. Note that the ID is only available
  13577. // if it was provided to the builder or after it was returned from the database.
  13578. func (m *LabelMutation) ID() (id uint64, exists bool) {
  13579. if m.id == nil {
  13580. return
  13581. }
  13582. return *m.id, true
  13583. }
  13584. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13585. // That means, if the mutation is applied within a transaction with an isolation level such
  13586. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13587. // or updated by the mutation.
  13588. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  13589. switch {
  13590. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13591. id, exists := m.ID()
  13592. if exists {
  13593. return []uint64{id}, nil
  13594. }
  13595. fallthrough
  13596. case m.op.Is(OpUpdate | OpDelete):
  13597. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  13598. default:
  13599. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13600. }
  13601. }
  13602. // SetCreatedAt sets the "created_at" field.
  13603. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  13604. m.created_at = &t
  13605. }
  13606. // CreatedAt returns the value of the "created_at" field in the mutation.
  13607. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  13608. v := m.created_at
  13609. if v == nil {
  13610. return
  13611. }
  13612. return *v, true
  13613. }
  13614. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  13615. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13617. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13618. if !m.op.Is(OpUpdateOne) {
  13619. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13620. }
  13621. if m.id == nil || m.oldValue == nil {
  13622. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13623. }
  13624. oldValue, err := m.oldValue(ctx)
  13625. if err != nil {
  13626. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13627. }
  13628. return oldValue.CreatedAt, nil
  13629. }
  13630. // ResetCreatedAt resets all changes to the "created_at" field.
  13631. func (m *LabelMutation) ResetCreatedAt() {
  13632. m.created_at = nil
  13633. }
  13634. // SetUpdatedAt sets the "updated_at" field.
  13635. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  13636. m.updated_at = &t
  13637. }
  13638. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13639. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  13640. v := m.updated_at
  13641. if v == nil {
  13642. return
  13643. }
  13644. return *v, true
  13645. }
  13646. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  13647. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13649. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13650. if !m.op.Is(OpUpdateOne) {
  13651. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13652. }
  13653. if m.id == nil || m.oldValue == nil {
  13654. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13655. }
  13656. oldValue, err := m.oldValue(ctx)
  13657. if err != nil {
  13658. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13659. }
  13660. return oldValue.UpdatedAt, nil
  13661. }
  13662. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13663. func (m *LabelMutation) ResetUpdatedAt() {
  13664. m.updated_at = nil
  13665. }
  13666. // SetStatus sets the "status" field.
  13667. func (m *LabelMutation) SetStatus(u uint8) {
  13668. m.status = &u
  13669. m.addstatus = nil
  13670. }
  13671. // Status returns the value of the "status" field in the mutation.
  13672. func (m *LabelMutation) Status() (r uint8, exists bool) {
  13673. v := m.status
  13674. if v == nil {
  13675. return
  13676. }
  13677. return *v, true
  13678. }
  13679. // OldStatus returns the old "status" field's value of the Label entity.
  13680. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13682. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13683. if !m.op.Is(OpUpdateOne) {
  13684. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13685. }
  13686. if m.id == nil || m.oldValue == nil {
  13687. return v, errors.New("OldStatus requires an ID field in the mutation")
  13688. }
  13689. oldValue, err := m.oldValue(ctx)
  13690. if err != nil {
  13691. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13692. }
  13693. return oldValue.Status, nil
  13694. }
  13695. // AddStatus adds u to the "status" field.
  13696. func (m *LabelMutation) AddStatus(u int8) {
  13697. if m.addstatus != nil {
  13698. *m.addstatus += u
  13699. } else {
  13700. m.addstatus = &u
  13701. }
  13702. }
  13703. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13704. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  13705. v := m.addstatus
  13706. if v == nil {
  13707. return
  13708. }
  13709. return *v, true
  13710. }
  13711. // ClearStatus clears the value of the "status" field.
  13712. func (m *LabelMutation) ClearStatus() {
  13713. m.status = nil
  13714. m.addstatus = nil
  13715. m.clearedFields[label.FieldStatus] = struct{}{}
  13716. }
  13717. // StatusCleared returns if the "status" field was cleared in this mutation.
  13718. func (m *LabelMutation) StatusCleared() bool {
  13719. _, ok := m.clearedFields[label.FieldStatus]
  13720. return ok
  13721. }
  13722. // ResetStatus resets all changes to the "status" field.
  13723. func (m *LabelMutation) ResetStatus() {
  13724. m.status = nil
  13725. m.addstatus = nil
  13726. delete(m.clearedFields, label.FieldStatus)
  13727. }
  13728. // SetType sets the "type" field.
  13729. func (m *LabelMutation) SetType(i int) {
  13730. m._type = &i
  13731. m.add_type = nil
  13732. }
  13733. // GetType returns the value of the "type" field in the mutation.
  13734. func (m *LabelMutation) GetType() (r int, exists bool) {
  13735. v := m._type
  13736. if v == nil {
  13737. return
  13738. }
  13739. return *v, true
  13740. }
  13741. // OldType returns the old "type" field's value of the Label entity.
  13742. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13744. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  13745. if !m.op.Is(OpUpdateOne) {
  13746. return v, errors.New("OldType is only allowed on UpdateOne operations")
  13747. }
  13748. if m.id == nil || m.oldValue == nil {
  13749. return v, errors.New("OldType requires an ID field in the mutation")
  13750. }
  13751. oldValue, err := m.oldValue(ctx)
  13752. if err != nil {
  13753. return v, fmt.Errorf("querying old value for OldType: %w", err)
  13754. }
  13755. return oldValue.Type, nil
  13756. }
  13757. // AddType adds i to the "type" field.
  13758. func (m *LabelMutation) AddType(i int) {
  13759. if m.add_type != nil {
  13760. *m.add_type += i
  13761. } else {
  13762. m.add_type = &i
  13763. }
  13764. }
  13765. // AddedType returns the value that was added to the "type" field in this mutation.
  13766. func (m *LabelMutation) AddedType() (r int, exists bool) {
  13767. v := m.add_type
  13768. if v == nil {
  13769. return
  13770. }
  13771. return *v, true
  13772. }
  13773. // ResetType resets all changes to the "type" field.
  13774. func (m *LabelMutation) ResetType() {
  13775. m._type = nil
  13776. m.add_type = nil
  13777. }
  13778. // SetName sets the "name" field.
  13779. func (m *LabelMutation) SetName(s string) {
  13780. m.name = &s
  13781. }
  13782. // Name returns the value of the "name" field in the mutation.
  13783. func (m *LabelMutation) Name() (r string, exists bool) {
  13784. v := m.name
  13785. if v == nil {
  13786. return
  13787. }
  13788. return *v, true
  13789. }
  13790. // OldName returns the old "name" field's value of the Label entity.
  13791. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13793. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  13794. if !m.op.Is(OpUpdateOne) {
  13795. return v, errors.New("OldName is only allowed on UpdateOne operations")
  13796. }
  13797. if m.id == nil || m.oldValue == nil {
  13798. return v, errors.New("OldName requires an ID field in the mutation")
  13799. }
  13800. oldValue, err := m.oldValue(ctx)
  13801. if err != nil {
  13802. return v, fmt.Errorf("querying old value for OldName: %w", err)
  13803. }
  13804. return oldValue.Name, nil
  13805. }
  13806. // ResetName resets all changes to the "name" field.
  13807. func (m *LabelMutation) ResetName() {
  13808. m.name = nil
  13809. }
  13810. // SetFrom sets the "from" field.
  13811. func (m *LabelMutation) SetFrom(i int) {
  13812. m.from = &i
  13813. m.addfrom = nil
  13814. }
  13815. // From returns the value of the "from" field in the mutation.
  13816. func (m *LabelMutation) From() (r int, exists bool) {
  13817. v := m.from
  13818. if v == nil {
  13819. return
  13820. }
  13821. return *v, true
  13822. }
  13823. // OldFrom returns the old "from" field's value of the Label entity.
  13824. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13825. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13826. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  13827. if !m.op.Is(OpUpdateOne) {
  13828. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  13829. }
  13830. if m.id == nil || m.oldValue == nil {
  13831. return v, errors.New("OldFrom requires an ID field in the mutation")
  13832. }
  13833. oldValue, err := m.oldValue(ctx)
  13834. if err != nil {
  13835. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  13836. }
  13837. return oldValue.From, nil
  13838. }
  13839. // AddFrom adds i to the "from" field.
  13840. func (m *LabelMutation) AddFrom(i int) {
  13841. if m.addfrom != nil {
  13842. *m.addfrom += i
  13843. } else {
  13844. m.addfrom = &i
  13845. }
  13846. }
  13847. // AddedFrom returns the value that was added to the "from" field in this mutation.
  13848. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  13849. v := m.addfrom
  13850. if v == nil {
  13851. return
  13852. }
  13853. return *v, true
  13854. }
  13855. // ResetFrom resets all changes to the "from" field.
  13856. func (m *LabelMutation) ResetFrom() {
  13857. m.from = nil
  13858. m.addfrom = nil
  13859. }
  13860. // SetMode sets the "mode" field.
  13861. func (m *LabelMutation) SetMode(i int) {
  13862. m.mode = &i
  13863. m.addmode = nil
  13864. }
  13865. // Mode returns the value of the "mode" field in the mutation.
  13866. func (m *LabelMutation) Mode() (r int, exists bool) {
  13867. v := m.mode
  13868. if v == nil {
  13869. return
  13870. }
  13871. return *v, true
  13872. }
  13873. // OldMode returns the old "mode" field's value of the Label entity.
  13874. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13876. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  13877. if !m.op.Is(OpUpdateOne) {
  13878. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  13879. }
  13880. if m.id == nil || m.oldValue == nil {
  13881. return v, errors.New("OldMode requires an ID field in the mutation")
  13882. }
  13883. oldValue, err := m.oldValue(ctx)
  13884. if err != nil {
  13885. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  13886. }
  13887. return oldValue.Mode, nil
  13888. }
  13889. // AddMode adds i to the "mode" field.
  13890. func (m *LabelMutation) AddMode(i int) {
  13891. if m.addmode != nil {
  13892. *m.addmode += i
  13893. } else {
  13894. m.addmode = &i
  13895. }
  13896. }
  13897. // AddedMode returns the value that was added to the "mode" field in this mutation.
  13898. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  13899. v := m.addmode
  13900. if v == nil {
  13901. return
  13902. }
  13903. return *v, true
  13904. }
  13905. // ResetMode resets all changes to the "mode" field.
  13906. func (m *LabelMutation) ResetMode() {
  13907. m.mode = nil
  13908. m.addmode = nil
  13909. }
  13910. // SetConditions sets the "conditions" field.
  13911. func (m *LabelMutation) SetConditions(s string) {
  13912. m.conditions = &s
  13913. }
  13914. // Conditions returns the value of the "conditions" field in the mutation.
  13915. func (m *LabelMutation) Conditions() (r string, exists bool) {
  13916. v := m.conditions
  13917. if v == nil {
  13918. return
  13919. }
  13920. return *v, true
  13921. }
  13922. // OldConditions returns the old "conditions" field's value of the Label entity.
  13923. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13924. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13925. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  13926. if !m.op.Is(OpUpdateOne) {
  13927. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  13928. }
  13929. if m.id == nil || m.oldValue == nil {
  13930. return v, errors.New("OldConditions requires an ID field in the mutation")
  13931. }
  13932. oldValue, err := m.oldValue(ctx)
  13933. if err != nil {
  13934. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  13935. }
  13936. return oldValue.Conditions, nil
  13937. }
  13938. // ClearConditions clears the value of the "conditions" field.
  13939. func (m *LabelMutation) ClearConditions() {
  13940. m.conditions = nil
  13941. m.clearedFields[label.FieldConditions] = struct{}{}
  13942. }
  13943. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  13944. func (m *LabelMutation) ConditionsCleared() bool {
  13945. _, ok := m.clearedFields[label.FieldConditions]
  13946. return ok
  13947. }
  13948. // ResetConditions resets all changes to the "conditions" field.
  13949. func (m *LabelMutation) ResetConditions() {
  13950. m.conditions = nil
  13951. delete(m.clearedFields, label.FieldConditions)
  13952. }
  13953. // SetOrganizationID sets the "organization_id" field.
  13954. func (m *LabelMutation) SetOrganizationID(u uint64) {
  13955. m.organization_id = &u
  13956. m.addorganization_id = nil
  13957. }
  13958. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13959. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  13960. v := m.organization_id
  13961. if v == nil {
  13962. return
  13963. }
  13964. return *v, true
  13965. }
  13966. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  13967. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13969. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13970. if !m.op.Is(OpUpdateOne) {
  13971. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13972. }
  13973. if m.id == nil || m.oldValue == nil {
  13974. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13975. }
  13976. oldValue, err := m.oldValue(ctx)
  13977. if err != nil {
  13978. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13979. }
  13980. return oldValue.OrganizationID, nil
  13981. }
  13982. // AddOrganizationID adds u to the "organization_id" field.
  13983. func (m *LabelMutation) AddOrganizationID(u int64) {
  13984. if m.addorganization_id != nil {
  13985. *m.addorganization_id += u
  13986. } else {
  13987. m.addorganization_id = &u
  13988. }
  13989. }
  13990. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13991. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  13992. v := m.addorganization_id
  13993. if v == nil {
  13994. return
  13995. }
  13996. return *v, true
  13997. }
  13998. // ClearOrganizationID clears the value of the "organization_id" field.
  13999. func (m *LabelMutation) ClearOrganizationID() {
  14000. m.organization_id = nil
  14001. m.addorganization_id = nil
  14002. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  14003. }
  14004. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14005. func (m *LabelMutation) OrganizationIDCleared() bool {
  14006. _, ok := m.clearedFields[label.FieldOrganizationID]
  14007. return ok
  14008. }
  14009. // ResetOrganizationID resets all changes to the "organization_id" field.
  14010. func (m *LabelMutation) ResetOrganizationID() {
  14011. m.organization_id = nil
  14012. m.addorganization_id = nil
  14013. delete(m.clearedFields, label.FieldOrganizationID)
  14014. }
  14015. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  14016. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  14017. if m.label_relationships == nil {
  14018. m.label_relationships = make(map[uint64]struct{})
  14019. }
  14020. for i := range ids {
  14021. m.label_relationships[ids[i]] = struct{}{}
  14022. }
  14023. }
  14024. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  14025. func (m *LabelMutation) ClearLabelRelationships() {
  14026. m.clearedlabel_relationships = true
  14027. }
  14028. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  14029. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  14030. return m.clearedlabel_relationships
  14031. }
  14032. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  14033. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  14034. if m.removedlabel_relationships == nil {
  14035. m.removedlabel_relationships = make(map[uint64]struct{})
  14036. }
  14037. for i := range ids {
  14038. delete(m.label_relationships, ids[i])
  14039. m.removedlabel_relationships[ids[i]] = struct{}{}
  14040. }
  14041. }
  14042. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  14043. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  14044. for id := range m.removedlabel_relationships {
  14045. ids = append(ids, id)
  14046. }
  14047. return
  14048. }
  14049. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  14050. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  14051. for id := range m.label_relationships {
  14052. ids = append(ids, id)
  14053. }
  14054. return
  14055. }
  14056. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  14057. func (m *LabelMutation) ResetLabelRelationships() {
  14058. m.label_relationships = nil
  14059. m.clearedlabel_relationships = false
  14060. m.removedlabel_relationships = nil
  14061. }
  14062. // Where appends a list predicates to the LabelMutation builder.
  14063. func (m *LabelMutation) Where(ps ...predicate.Label) {
  14064. m.predicates = append(m.predicates, ps...)
  14065. }
  14066. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  14067. // users can use type-assertion to append predicates that do not depend on any generated package.
  14068. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  14069. p := make([]predicate.Label, len(ps))
  14070. for i := range ps {
  14071. p[i] = ps[i]
  14072. }
  14073. m.Where(p...)
  14074. }
  14075. // Op returns the operation name.
  14076. func (m *LabelMutation) Op() Op {
  14077. return m.op
  14078. }
  14079. // SetOp allows setting the mutation operation.
  14080. func (m *LabelMutation) SetOp(op Op) {
  14081. m.op = op
  14082. }
  14083. // Type returns the node type of this mutation (Label).
  14084. func (m *LabelMutation) Type() string {
  14085. return m.typ
  14086. }
  14087. // Fields returns all fields that were changed during this mutation. Note that in
  14088. // order to get all numeric fields that were incremented/decremented, call
  14089. // AddedFields().
  14090. func (m *LabelMutation) Fields() []string {
  14091. fields := make([]string, 0, 9)
  14092. if m.created_at != nil {
  14093. fields = append(fields, label.FieldCreatedAt)
  14094. }
  14095. if m.updated_at != nil {
  14096. fields = append(fields, label.FieldUpdatedAt)
  14097. }
  14098. if m.status != nil {
  14099. fields = append(fields, label.FieldStatus)
  14100. }
  14101. if m._type != nil {
  14102. fields = append(fields, label.FieldType)
  14103. }
  14104. if m.name != nil {
  14105. fields = append(fields, label.FieldName)
  14106. }
  14107. if m.from != nil {
  14108. fields = append(fields, label.FieldFrom)
  14109. }
  14110. if m.mode != nil {
  14111. fields = append(fields, label.FieldMode)
  14112. }
  14113. if m.conditions != nil {
  14114. fields = append(fields, label.FieldConditions)
  14115. }
  14116. if m.organization_id != nil {
  14117. fields = append(fields, label.FieldOrganizationID)
  14118. }
  14119. return fields
  14120. }
  14121. // Field returns the value of a field with the given name. The second boolean
  14122. // return value indicates that this field was not set, or was not defined in the
  14123. // schema.
  14124. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  14125. switch name {
  14126. case label.FieldCreatedAt:
  14127. return m.CreatedAt()
  14128. case label.FieldUpdatedAt:
  14129. return m.UpdatedAt()
  14130. case label.FieldStatus:
  14131. return m.Status()
  14132. case label.FieldType:
  14133. return m.GetType()
  14134. case label.FieldName:
  14135. return m.Name()
  14136. case label.FieldFrom:
  14137. return m.From()
  14138. case label.FieldMode:
  14139. return m.Mode()
  14140. case label.FieldConditions:
  14141. return m.Conditions()
  14142. case label.FieldOrganizationID:
  14143. return m.OrganizationID()
  14144. }
  14145. return nil, false
  14146. }
  14147. // OldField returns the old value of the field from the database. An error is
  14148. // returned if the mutation operation is not UpdateOne, or the query to the
  14149. // database failed.
  14150. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14151. switch name {
  14152. case label.FieldCreatedAt:
  14153. return m.OldCreatedAt(ctx)
  14154. case label.FieldUpdatedAt:
  14155. return m.OldUpdatedAt(ctx)
  14156. case label.FieldStatus:
  14157. return m.OldStatus(ctx)
  14158. case label.FieldType:
  14159. return m.OldType(ctx)
  14160. case label.FieldName:
  14161. return m.OldName(ctx)
  14162. case label.FieldFrom:
  14163. return m.OldFrom(ctx)
  14164. case label.FieldMode:
  14165. return m.OldMode(ctx)
  14166. case label.FieldConditions:
  14167. return m.OldConditions(ctx)
  14168. case label.FieldOrganizationID:
  14169. return m.OldOrganizationID(ctx)
  14170. }
  14171. return nil, fmt.Errorf("unknown Label field %s", name)
  14172. }
  14173. // SetField sets the value of a field with the given name. It returns an error if
  14174. // the field is not defined in the schema, or if the type mismatched the field
  14175. // type.
  14176. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  14177. switch name {
  14178. case label.FieldCreatedAt:
  14179. v, ok := value.(time.Time)
  14180. if !ok {
  14181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14182. }
  14183. m.SetCreatedAt(v)
  14184. return nil
  14185. case label.FieldUpdatedAt:
  14186. v, ok := value.(time.Time)
  14187. if !ok {
  14188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14189. }
  14190. m.SetUpdatedAt(v)
  14191. return nil
  14192. case label.FieldStatus:
  14193. v, ok := value.(uint8)
  14194. if !ok {
  14195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14196. }
  14197. m.SetStatus(v)
  14198. return nil
  14199. case label.FieldType:
  14200. v, ok := value.(int)
  14201. if !ok {
  14202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14203. }
  14204. m.SetType(v)
  14205. return nil
  14206. case label.FieldName:
  14207. v, ok := value.(string)
  14208. if !ok {
  14209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14210. }
  14211. m.SetName(v)
  14212. return nil
  14213. case label.FieldFrom:
  14214. v, ok := value.(int)
  14215. if !ok {
  14216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14217. }
  14218. m.SetFrom(v)
  14219. return nil
  14220. case label.FieldMode:
  14221. v, ok := value.(int)
  14222. if !ok {
  14223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14224. }
  14225. m.SetMode(v)
  14226. return nil
  14227. case label.FieldConditions:
  14228. v, ok := value.(string)
  14229. if !ok {
  14230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14231. }
  14232. m.SetConditions(v)
  14233. return nil
  14234. case label.FieldOrganizationID:
  14235. v, ok := value.(uint64)
  14236. if !ok {
  14237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14238. }
  14239. m.SetOrganizationID(v)
  14240. return nil
  14241. }
  14242. return fmt.Errorf("unknown Label field %s", name)
  14243. }
  14244. // AddedFields returns all numeric fields that were incremented/decremented during
  14245. // this mutation.
  14246. func (m *LabelMutation) AddedFields() []string {
  14247. var fields []string
  14248. if m.addstatus != nil {
  14249. fields = append(fields, label.FieldStatus)
  14250. }
  14251. if m.add_type != nil {
  14252. fields = append(fields, label.FieldType)
  14253. }
  14254. if m.addfrom != nil {
  14255. fields = append(fields, label.FieldFrom)
  14256. }
  14257. if m.addmode != nil {
  14258. fields = append(fields, label.FieldMode)
  14259. }
  14260. if m.addorganization_id != nil {
  14261. fields = append(fields, label.FieldOrganizationID)
  14262. }
  14263. return fields
  14264. }
  14265. // AddedField returns the numeric value that was incremented/decremented on a field
  14266. // with the given name. The second boolean return value indicates that this field
  14267. // was not set, or was not defined in the schema.
  14268. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  14269. switch name {
  14270. case label.FieldStatus:
  14271. return m.AddedStatus()
  14272. case label.FieldType:
  14273. return m.AddedType()
  14274. case label.FieldFrom:
  14275. return m.AddedFrom()
  14276. case label.FieldMode:
  14277. return m.AddedMode()
  14278. case label.FieldOrganizationID:
  14279. return m.AddedOrganizationID()
  14280. }
  14281. return nil, false
  14282. }
  14283. // AddField adds the value to the field with the given name. It returns an error if
  14284. // the field is not defined in the schema, or if the type mismatched the field
  14285. // type.
  14286. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  14287. switch name {
  14288. case label.FieldStatus:
  14289. v, ok := value.(int8)
  14290. if !ok {
  14291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14292. }
  14293. m.AddStatus(v)
  14294. return nil
  14295. case label.FieldType:
  14296. v, ok := value.(int)
  14297. if !ok {
  14298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14299. }
  14300. m.AddType(v)
  14301. return nil
  14302. case label.FieldFrom:
  14303. v, ok := value.(int)
  14304. if !ok {
  14305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14306. }
  14307. m.AddFrom(v)
  14308. return nil
  14309. case label.FieldMode:
  14310. v, ok := value.(int)
  14311. if !ok {
  14312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14313. }
  14314. m.AddMode(v)
  14315. return nil
  14316. case label.FieldOrganizationID:
  14317. v, ok := value.(int64)
  14318. if !ok {
  14319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14320. }
  14321. m.AddOrganizationID(v)
  14322. return nil
  14323. }
  14324. return fmt.Errorf("unknown Label numeric field %s", name)
  14325. }
  14326. // ClearedFields returns all nullable fields that were cleared during this
  14327. // mutation.
  14328. func (m *LabelMutation) ClearedFields() []string {
  14329. var fields []string
  14330. if m.FieldCleared(label.FieldStatus) {
  14331. fields = append(fields, label.FieldStatus)
  14332. }
  14333. if m.FieldCleared(label.FieldConditions) {
  14334. fields = append(fields, label.FieldConditions)
  14335. }
  14336. if m.FieldCleared(label.FieldOrganizationID) {
  14337. fields = append(fields, label.FieldOrganizationID)
  14338. }
  14339. return fields
  14340. }
  14341. // FieldCleared returns a boolean indicating if a field with the given name was
  14342. // cleared in this mutation.
  14343. func (m *LabelMutation) FieldCleared(name string) bool {
  14344. _, ok := m.clearedFields[name]
  14345. return ok
  14346. }
  14347. // ClearField clears the value of the field with the given name. It returns an
  14348. // error if the field is not defined in the schema.
  14349. func (m *LabelMutation) ClearField(name string) error {
  14350. switch name {
  14351. case label.FieldStatus:
  14352. m.ClearStatus()
  14353. return nil
  14354. case label.FieldConditions:
  14355. m.ClearConditions()
  14356. return nil
  14357. case label.FieldOrganizationID:
  14358. m.ClearOrganizationID()
  14359. return nil
  14360. }
  14361. return fmt.Errorf("unknown Label nullable field %s", name)
  14362. }
  14363. // ResetField resets all changes in the mutation for the field with the given name.
  14364. // It returns an error if the field is not defined in the schema.
  14365. func (m *LabelMutation) ResetField(name string) error {
  14366. switch name {
  14367. case label.FieldCreatedAt:
  14368. m.ResetCreatedAt()
  14369. return nil
  14370. case label.FieldUpdatedAt:
  14371. m.ResetUpdatedAt()
  14372. return nil
  14373. case label.FieldStatus:
  14374. m.ResetStatus()
  14375. return nil
  14376. case label.FieldType:
  14377. m.ResetType()
  14378. return nil
  14379. case label.FieldName:
  14380. m.ResetName()
  14381. return nil
  14382. case label.FieldFrom:
  14383. m.ResetFrom()
  14384. return nil
  14385. case label.FieldMode:
  14386. m.ResetMode()
  14387. return nil
  14388. case label.FieldConditions:
  14389. m.ResetConditions()
  14390. return nil
  14391. case label.FieldOrganizationID:
  14392. m.ResetOrganizationID()
  14393. return nil
  14394. }
  14395. return fmt.Errorf("unknown Label field %s", name)
  14396. }
  14397. // AddedEdges returns all edge names that were set/added in this mutation.
  14398. func (m *LabelMutation) AddedEdges() []string {
  14399. edges := make([]string, 0, 1)
  14400. if m.label_relationships != nil {
  14401. edges = append(edges, label.EdgeLabelRelationships)
  14402. }
  14403. return edges
  14404. }
  14405. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14406. // name in this mutation.
  14407. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  14408. switch name {
  14409. case label.EdgeLabelRelationships:
  14410. ids := make([]ent.Value, 0, len(m.label_relationships))
  14411. for id := range m.label_relationships {
  14412. ids = append(ids, id)
  14413. }
  14414. return ids
  14415. }
  14416. return nil
  14417. }
  14418. // RemovedEdges returns all edge names that were removed in this mutation.
  14419. func (m *LabelMutation) RemovedEdges() []string {
  14420. edges := make([]string, 0, 1)
  14421. if m.removedlabel_relationships != nil {
  14422. edges = append(edges, label.EdgeLabelRelationships)
  14423. }
  14424. return edges
  14425. }
  14426. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14427. // the given name in this mutation.
  14428. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  14429. switch name {
  14430. case label.EdgeLabelRelationships:
  14431. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  14432. for id := range m.removedlabel_relationships {
  14433. ids = append(ids, id)
  14434. }
  14435. return ids
  14436. }
  14437. return nil
  14438. }
  14439. // ClearedEdges returns all edge names that were cleared in this mutation.
  14440. func (m *LabelMutation) ClearedEdges() []string {
  14441. edges := make([]string, 0, 1)
  14442. if m.clearedlabel_relationships {
  14443. edges = append(edges, label.EdgeLabelRelationships)
  14444. }
  14445. return edges
  14446. }
  14447. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14448. // was cleared in this mutation.
  14449. func (m *LabelMutation) EdgeCleared(name string) bool {
  14450. switch name {
  14451. case label.EdgeLabelRelationships:
  14452. return m.clearedlabel_relationships
  14453. }
  14454. return false
  14455. }
  14456. // ClearEdge clears the value of the edge with the given name. It returns an error
  14457. // if that edge is not defined in the schema.
  14458. func (m *LabelMutation) ClearEdge(name string) error {
  14459. switch name {
  14460. }
  14461. return fmt.Errorf("unknown Label unique edge %s", name)
  14462. }
  14463. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14464. // It returns an error if the edge is not defined in the schema.
  14465. func (m *LabelMutation) ResetEdge(name string) error {
  14466. switch name {
  14467. case label.EdgeLabelRelationships:
  14468. m.ResetLabelRelationships()
  14469. return nil
  14470. }
  14471. return fmt.Errorf("unknown Label edge %s", name)
  14472. }
  14473. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  14474. type LabelRelationshipMutation struct {
  14475. config
  14476. op Op
  14477. typ string
  14478. id *uint64
  14479. created_at *time.Time
  14480. updated_at *time.Time
  14481. status *uint8
  14482. addstatus *int8
  14483. organization_id *uint64
  14484. addorganization_id *int64
  14485. clearedFields map[string]struct{}
  14486. contacts *uint64
  14487. clearedcontacts bool
  14488. labels *uint64
  14489. clearedlabels bool
  14490. done bool
  14491. oldValue func(context.Context) (*LabelRelationship, error)
  14492. predicates []predicate.LabelRelationship
  14493. }
  14494. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  14495. // labelrelationshipOption allows management of the mutation configuration using functional options.
  14496. type labelrelationshipOption func(*LabelRelationshipMutation)
  14497. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  14498. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  14499. m := &LabelRelationshipMutation{
  14500. config: c,
  14501. op: op,
  14502. typ: TypeLabelRelationship,
  14503. clearedFields: make(map[string]struct{}),
  14504. }
  14505. for _, opt := range opts {
  14506. opt(m)
  14507. }
  14508. return m
  14509. }
  14510. // withLabelRelationshipID sets the ID field of the mutation.
  14511. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  14512. return func(m *LabelRelationshipMutation) {
  14513. var (
  14514. err error
  14515. once sync.Once
  14516. value *LabelRelationship
  14517. )
  14518. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  14519. once.Do(func() {
  14520. if m.done {
  14521. err = errors.New("querying old values post mutation is not allowed")
  14522. } else {
  14523. value, err = m.Client().LabelRelationship.Get(ctx, id)
  14524. }
  14525. })
  14526. return value, err
  14527. }
  14528. m.id = &id
  14529. }
  14530. }
  14531. // withLabelRelationship sets the old LabelRelationship of the mutation.
  14532. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  14533. return func(m *LabelRelationshipMutation) {
  14534. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  14535. return node, nil
  14536. }
  14537. m.id = &node.ID
  14538. }
  14539. }
  14540. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14541. // executed in a transaction (ent.Tx), a transactional client is returned.
  14542. func (m LabelRelationshipMutation) Client() *Client {
  14543. client := &Client{config: m.config}
  14544. client.init()
  14545. return client
  14546. }
  14547. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14548. // it returns an error otherwise.
  14549. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  14550. if _, ok := m.driver.(*txDriver); !ok {
  14551. return nil, errors.New("ent: mutation is not running in a transaction")
  14552. }
  14553. tx := &Tx{config: m.config}
  14554. tx.init()
  14555. return tx, nil
  14556. }
  14557. // SetID sets the value of the id field. Note that this
  14558. // operation is only accepted on creation of LabelRelationship entities.
  14559. func (m *LabelRelationshipMutation) SetID(id uint64) {
  14560. m.id = &id
  14561. }
  14562. // ID returns the ID value in the mutation. Note that the ID is only available
  14563. // if it was provided to the builder or after it was returned from the database.
  14564. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  14565. if m.id == nil {
  14566. return
  14567. }
  14568. return *m.id, true
  14569. }
  14570. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14571. // That means, if the mutation is applied within a transaction with an isolation level such
  14572. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14573. // or updated by the mutation.
  14574. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  14575. switch {
  14576. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14577. id, exists := m.ID()
  14578. if exists {
  14579. return []uint64{id}, nil
  14580. }
  14581. fallthrough
  14582. case m.op.Is(OpUpdate | OpDelete):
  14583. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  14584. default:
  14585. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14586. }
  14587. }
  14588. // SetCreatedAt sets the "created_at" field.
  14589. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  14590. m.created_at = &t
  14591. }
  14592. // CreatedAt returns the value of the "created_at" field in the mutation.
  14593. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  14594. v := m.created_at
  14595. if v == nil {
  14596. return
  14597. }
  14598. return *v, true
  14599. }
  14600. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  14601. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14603. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14604. if !m.op.Is(OpUpdateOne) {
  14605. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14606. }
  14607. if m.id == nil || m.oldValue == nil {
  14608. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14609. }
  14610. oldValue, err := m.oldValue(ctx)
  14611. if err != nil {
  14612. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14613. }
  14614. return oldValue.CreatedAt, nil
  14615. }
  14616. // ResetCreatedAt resets all changes to the "created_at" field.
  14617. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  14618. m.created_at = nil
  14619. }
  14620. // SetUpdatedAt sets the "updated_at" field.
  14621. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  14622. m.updated_at = &t
  14623. }
  14624. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14625. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  14626. v := m.updated_at
  14627. if v == nil {
  14628. return
  14629. }
  14630. return *v, true
  14631. }
  14632. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  14633. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14634. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14635. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14636. if !m.op.Is(OpUpdateOne) {
  14637. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14638. }
  14639. if m.id == nil || m.oldValue == nil {
  14640. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14641. }
  14642. oldValue, err := m.oldValue(ctx)
  14643. if err != nil {
  14644. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14645. }
  14646. return oldValue.UpdatedAt, nil
  14647. }
  14648. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14649. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  14650. m.updated_at = nil
  14651. }
  14652. // SetStatus sets the "status" field.
  14653. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  14654. m.status = &u
  14655. m.addstatus = nil
  14656. }
  14657. // Status returns the value of the "status" field in the mutation.
  14658. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  14659. v := m.status
  14660. if v == nil {
  14661. return
  14662. }
  14663. return *v, true
  14664. }
  14665. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  14666. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14668. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14669. if !m.op.Is(OpUpdateOne) {
  14670. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14671. }
  14672. if m.id == nil || m.oldValue == nil {
  14673. return v, errors.New("OldStatus requires an ID field in the mutation")
  14674. }
  14675. oldValue, err := m.oldValue(ctx)
  14676. if err != nil {
  14677. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14678. }
  14679. return oldValue.Status, nil
  14680. }
  14681. // AddStatus adds u to the "status" field.
  14682. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  14683. if m.addstatus != nil {
  14684. *m.addstatus += u
  14685. } else {
  14686. m.addstatus = &u
  14687. }
  14688. }
  14689. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14690. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  14691. v := m.addstatus
  14692. if v == nil {
  14693. return
  14694. }
  14695. return *v, true
  14696. }
  14697. // ClearStatus clears the value of the "status" field.
  14698. func (m *LabelRelationshipMutation) ClearStatus() {
  14699. m.status = nil
  14700. m.addstatus = nil
  14701. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  14702. }
  14703. // StatusCleared returns if the "status" field was cleared in this mutation.
  14704. func (m *LabelRelationshipMutation) StatusCleared() bool {
  14705. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  14706. return ok
  14707. }
  14708. // ResetStatus resets all changes to the "status" field.
  14709. func (m *LabelRelationshipMutation) ResetStatus() {
  14710. m.status = nil
  14711. m.addstatus = nil
  14712. delete(m.clearedFields, labelrelationship.FieldStatus)
  14713. }
  14714. // SetLabelID sets the "label_id" field.
  14715. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  14716. m.labels = &u
  14717. }
  14718. // LabelID returns the value of the "label_id" field in the mutation.
  14719. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  14720. v := m.labels
  14721. if v == nil {
  14722. return
  14723. }
  14724. return *v, true
  14725. }
  14726. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  14727. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14729. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  14730. if !m.op.Is(OpUpdateOne) {
  14731. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  14732. }
  14733. if m.id == nil || m.oldValue == nil {
  14734. return v, errors.New("OldLabelID requires an ID field in the mutation")
  14735. }
  14736. oldValue, err := m.oldValue(ctx)
  14737. if err != nil {
  14738. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  14739. }
  14740. return oldValue.LabelID, nil
  14741. }
  14742. // ResetLabelID resets all changes to the "label_id" field.
  14743. func (m *LabelRelationshipMutation) ResetLabelID() {
  14744. m.labels = nil
  14745. }
  14746. // SetContactID sets the "contact_id" field.
  14747. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  14748. m.contacts = &u
  14749. }
  14750. // ContactID returns the value of the "contact_id" field in the mutation.
  14751. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  14752. v := m.contacts
  14753. if v == nil {
  14754. return
  14755. }
  14756. return *v, true
  14757. }
  14758. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  14759. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14761. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  14762. if !m.op.Is(OpUpdateOne) {
  14763. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  14764. }
  14765. if m.id == nil || m.oldValue == nil {
  14766. return v, errors.New("OldContactID requires an ID field in the mutation")
  14767. }
  14768. oldValue, err := m.oldValue(ctx)
  14769. if err != nil {
  14770. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  14771. }
  14772. return oldValue.ContactID, nil
  14773. }
  14774. // ResetContactID resets all changes to the "contact_id" field.
  14775. func (m *LabelRelationshipMutation) ResetContactID() {
  14776. m.contacts = nil
  14777. }
  14778. // SetOrganizationID sets the "organization_id" field.
  14779. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  14780. m.organization_id = &u
  14781. m.addorganization_id = nil
  14782. }
  14783. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14784. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  14785. v := m.organization_id
  14786. if v == nil {
  14787. return
  14788. }
  14789. return *v, true
  14790. }
  14791. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  14792. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14793. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14794. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14795. if !m.op.Is(OpUpdateOne) {
  14796. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14797. }
  14798. if m.id == nil || m.oldValue == nil {
  14799. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14800. }
  14801. oldValue, err := m.oldValue(ctx)
  14802. if err != nil {
  14803. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14804. }
  14805. return oldValue.OrganizationID, nil
  14806. }
  14807. // AddOrganizationID adds u to the "organization_id" field.
  14808. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  14809. if m.addorganization_id != nil {
  14810. *m.addorganization_id += u
  14811. } else {
  14812. m.addorganization_id = &u
  14813. }
  14814. }
  14815. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14816. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  14817. v := m.addorganization_id
  14818. if v == nil {
  14819. return
  14820. }
  14821. return *v, true
  14822. }
  14823. // ClearOrganizationID clears the value of the "organization_id" field.
  14824. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  14825. m.organization_id = nil
  14826. m.addorganization_id = nil
  14827. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  14828. }
  14829. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14830. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  14831. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  14832. return ok
  14833. }
  14834. // ResetOrganizationID resets all changes to the "organization_id" field.
  14835. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  14836. m.organization_id = nil
  14837. m.addorganization_id = nil
  14838. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  14839. }
  14840. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  14841. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  14842. m.contacts = &id
  14843. }
  14844. // ClearContacts clears the "contacts" edge to the Contact entity.
  14845. func (m *LabelRelationshipMutation) ClearContacts() {
  14846. m.clearedcontacts = true
  14847. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  14848. }
  14849. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  14850. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  14851. return m.clearedcontacts
  14852. }
  14853. // ContactsID returns the "contacts" edge ID in the mutation.
  14854. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  14855. if m.contacts != nil {
  14856. return *m.contacts, true
  14857. }
  14858. return
  14859. }
  14860. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  14861. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14862. // ContactsID instead. It exists only for internal usage by the builders.
  14863. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  14864. if id := m.contacts; id != nil {
  14865. ids = append(ids, *id)
  14866. }
  14867. return
  14868. }
  14869. // ResetContacts resets all changes to the "contacts" edge.
  14870. func (m *LabelRelationshipMutation) ResetContacts() {
  14871. m.contacts = nil
  14872. m.clearedcontacts = false
  14873. }
  14874. // SetLabelsID sets the "labels" edge to the Label entity by id.
  14875. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  14876. m.labels = &id
  14877. }
  14878. // ClearLabels clears the "labels" edge to the Label entity.
  14879. func (m *LabelRelationshipMutation) ClearLabels() {
  14880. m.clearedlabels = true
  14881. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  14882. }
  14883. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  14884. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  14885. return m.clearedlabels
  14886. }
  14887. // LabelsID returns the "labels" edge ID in the mutation.
  14888. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  14889. if m.labels != nil {
  14890. return *m.labels, true
  14891. }
  14892. return
  14893. }
  14894. // LabelsIDs returns the "labels" edge IDs in the mutation.
  14895. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14896. // LabelsID instead. It exists only for internal usage by the builders.
  14897. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  14898. if id := m.labels; id != nil {
  14899. ids = append(ids, *id)
  14900. }
  14901. return
  14902. }
  14903. // ResetLabels resets all changes to the "labels" edge.
  14904. func (m *LabelRelationshipMutation) ResetLabels() {
  14905. m.labels = nil
  14906. m.clearedlabels = false
  14907. }
  14908. // Where appends a list predicates to the LabelRelationshipMutation builder.
  14909. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  14910. m.predicates = append(m.predicates, ps...)
  14911. }
  14912. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  14913. // users can use type-assertion to append predicates that do not depend on any generated package.
  14914. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  14915. p := make([]predicate.LabelRelationship, len(ps))
  14916. for i := range ps {
  14917. p[i] = ps[i]
  14918. }
  14919. m.Where(p...)
  14920. }
  14921. // Op returns the operation name.
  14922. func (m *LabelRelationshipMutation) Op() Op {
  14923. return m.op
  14924. }
  14925. // SetOp allows setting the mutation operation.
  14926. func (m *LabelRelationshipMutation) SetOp(op Op) {
  14927. m.op = op
  14928. }
  14929. // Type returns the node type of this mutation (LabelRelationship).
  14930. func (m *LabelRelationshipMutation) Type() string {
  14931. return m.typ
  14932. }
  14933. // Fields returns all fields that were changed during this mutation. Note that in
  14934. // order to get all numeric fields that were incremented/decremented, call
  14935. // AddedFields().
  14936. func (m *LabelRelationshipMutation) Fields() []string {
  14937. fields := make([]string, 0, 6)
  14938. if m.created_at != nil {
  14939. fields = append(fields, labelrelationship.FieldCreatedAt)
  14940. }
  14941. if m.updated_at != nil {
  14942. fields = append(fields, labelrelationship.FieldUpdatedAt)
  14943. }
  14944. if m.status != nil {
  14945. fields = append(fields, labelrelationship.FieldStatus)
  14946. }
  14947. if m.labels != nil {
  14948. fields = append(fields, labelrelationship.FieldLabelID)
  14949. }
  14950. if m.contacts != nil {
  14951. fields = append(fields, labelrelationship.FieldContactID)
  14952. }
  14953. if m.organization_id != nil {
  14954. fields = append(fields, labelrelationship.FieldOrganizationID)
  14955. }
  14956. return fields
  14957. }
  14958. // Field returns the value of a field with the given name. The second boolean
  14959. // return value indicates that this field was not set, or was not defined in the
  14960. // schema.
  14961. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  14962. switch name {
  14963. case labelrelationship.FieldCreatedAt:
  14964. return m.CreatedAt()
  14965. case labelrelationship.FieldUpdatedAt:
  14966. return m.UpdatedAt()
  14967. case labelrelationship.FieldStatus:
  14968. return m.Status()
  14969. case labelrelationship.FieldLabelID:
  14970. return m.LabelID()
  14971. case labelrelationship.FieldContactID:
  14972. return m.ContactID()
  14973. case labelrelationship.FieldOrganizationID:
  14974. return m.OrganizationID()
  14975. }
  14976. return nil, false
  14977. }
  14978. // OldField returns the old value of the field from the database. An error is
  14979. // returned if the mutation operation is not UpdateOne, or the query to the
  14980. // database failed.
  14981. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14982. switch name {
  14983. case labelrelationship.FieldCreatedAt:
  14984. return m.OldCreatedAt(ctx)
  14985. case labelrelationship.FieldUpdatedAt:
  14986. return m.OldUpdatedAt(ctx)
  14987. case labelrelationship.FieldStatus:
  14988. return m.OldStatus(ctx)
  14989. case labelrelationship.FieldLabelID:
  14990. return m.OldLabelID(ctx)
  14991. case labelrelationship.FieldContactID:
  14992. return m.OldContactID(ctx)
  14993. case labelrelationship.FieldOrganizationID:
  14994. return m.OldOrganizationID(ctx)
  14995. }
  14996. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  14997. }
  14998. // SetField sets the value of a field with the given name. It returns an error if
  14999. // the field is not defined in the schema, or if the type mismatched the field
  15000. // type.
  15001. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  15002. switch name {
  15003. case labelrelationship.FieldCreatedAt:
  15004. v, ok := value.(time.Time)
  15005. if !ok {
  15006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15007. }
  15008. m.SetCreatedAt(v)
  15009. return nil
  15010. case labelrelationship.FieldUpdatedAt:
  15011. v, ok := value.(time.Time)
  15012. if !ok {
  15013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15014. }
  15015. m.SetUpdatedAt(v)
  15016. return nil
  15017. case labelrelationship.FieldStatus:
  15018. v, ok := value.(uint8)
  15019. if !ok {
  15020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15021. }
  15022. m.SetStatus(v)
  15023. return nil
  15024. case labelrelationship.FieldLabelID:
  15025. v, ok := value.(uint64)
  15026. if !ok {
  15027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15028. }
  15029. m.SetLabelID(v)
  15030. return nil
  15031. case labelrelationship.FieldContactID:
  15032. v, ok := value.(uint64)
  15033. if !ok {
  15034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15035. }
  15036. m.SetContactID(v)
  15037. return nil
  15038. case labelrelationship.FieldOrganizationID:
  15039. v, ok := value.(uint64)
  15040. if !ok {
  15041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15042. }
  15043. m.SetOrganizationID(v)
  15044. return nil
  15045. }
  15046. return fmt.Errorf("unknown LabelRelationship field %s", name)
  15047. }
  15048. // AddedFields returns all numeric fields that were incremented/decremented during
  15049. // this mutation.
  15050. func (m *LabelRelationshipMutation) AddedFields() []string {
  15051. var fields []string
  15052. if m.addstatus != nil {
  15053. fields = append(fields, labelrelationship.FieldStatus)
  15054. }
  15055. if m.addorganization_id != nil {
  15056. fields = append(fields, labelrelationship.FieldOrganizationID)
  15057. }
  15058. return fields
  15059. }
  15060. // AddedField returns the numeric value that was incremented/decremented on a field
  15061. // with the given name. The second boolean return value indicates that this field
  15062. // was not set, or was not defined in the schema.
  15063. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  15064. switch name {
  15065. case labelrelationship.FieldStatus:
  15066. return m.AddedStatus()
  15067. case labelrelationship.FieldOrganizationID:
  15068. return m.AddedOrganizationID()
  15069. }
  15070. return nil, false
  15071. }
  15072. // AddField adds the value to the field with the given name. It returns an error if
  15073. // the field is not defined in the schema, or if the type mismatched the field
  15074. // type.
  15075. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  15076. switch name {
  15077. case labelrelationship.FieldStatus:
  15078. v, ok := value.(int8)
  15079. if !ok {
  15080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15081. }
  15082. m.AddStatus(v)
  15083. return nil
  15084. case labelrelationship.FieldOrganizationID:
  15085. v, ok := value.(int64)
  15086. if !ok {
  15087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15088. }
  15089. m.AddOrganizationID(v)
  15090. return nil
  15091. }
  15092. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  15093. }
  15094. // ClearedFields returns all nullable fields that were cleared during this
  15095. // mutation.
  15096. func (m *LabelRelationshipMutation) ClearedFields() []string {
  15097. var fields []string
  15098. if m.FieldCleared(labelrelationship.FieldStatus) {
  15099. fields = append(fields, labelrelationship.FieldStatus)
  15100. }
  15101. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  15102. fields = append(fields, labelrelationship.FieldOrganizationID)
  15103. }
  15104. return fields
  15105. }
  15106. // FieldCleared returns a boolean indicating if a field with the given name was
  15107. // cleared in this mutation.
  15108. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  15109. _, ok := m.clearedFields[name]
  15110. return ok
  15111. }
  15112. // ClearField clears the value of the field with the given name. It returns an
  15113. // error if the field is not defined in the schema.
  15114. func (m *LabelRelationshipMutation) ClearField(name string) error {
  15115. switch name {
  15116. case labelrelationship.FieldStatus:
  15117. m.ClearStatus()
  15118. return nil
  15119. case labelrelationship.FieldOrganizationID:
  15120. m.ClearOrganizationID()
  15121. return nil
  15122. }
  15123. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  15124. }
  15125. // ResetField resets all changes in the mutation for the field with the given name.
  15126. // It returns an error if the field is not defined in the schema.
  15127. func (m *LabelRelationshipMutation) ResetField(name string) error {
  15128. switch name {
  15129. case labelrelationship.FieldCreatedAt:
  15130. m.ResetCreatedAt()
  15131. return nil
  15132. case labelrelationship.FieldUpdatedAt:
  15133. m.ResetUpdatedAt()
  15134. return nil
  15135. case labelrelationship.FieldStatus:
  15136. m.ResetStatus()
  15137. return nil
  15138. case labelrelationship.FieldLabelID:
  15139. m.ResetLabelID()
  15140. return nil
  15141. case labelrelationship.FieldContactID:
  15142. m.ResetContactID()
  15143. return nil
  15144. case labelrelationship.FieldOrganizationID:
  15145. m.ResetOrganizationID()
  15146. return nil
  15147. }
  15148. return fmt.Errorf("unknown LabelRelationship field %s", name)
  15149. }
  15150. // AddedEdges returns all edge names that were set/added in this mutation.
  15151. func (m *LabelRelationshipMutation) AddedEdges() []string {
  15152. edges := make([]string, 0, 2)
  15153. if m.contacts != nil {
  15154. edges = append(edges, labelrelationship.EdgeContacts)
  15155. }
  15156. if m.labels != nil {
  15157. edges = append(edges, labelrelationship.EdgeLabels)
  15158. }
  15159. return edges
  15160. }
  15161. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15162. // name in this mutation.
  15163. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  15164. switch name {
  15165. case labelrelationship.EdgeContacts:
  15166. if id := m.contacts; id != nil {
  15167. return []ent.Value{*id}
  15168. }
  15169. case labelrelationship.EdgeLabels:
  15170. if id := m.labels; id != nil {
  15171. return []ent.Value{*id}
  15172. }
  15173. }
  15174. return nil
  15175. }
  15176. // RemovedEdges returns all edge names that were removed in this mutation.
  15177. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  15178. edges := make([]string, 0, 2)
  15179. return edges
  15180. }
  15181. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15182. // the given name in this mutation.
  15183. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  15184. return nil
  15185. }
  15186. // ClearedEdges returns all edge names that were cleared in this mutation.
  15187. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  15188. edges := make([]string, 0, 2)
  15189. if m.clearedcontacts {
  15190. edges = append(edges, labelrelationship.EdgeContacts)
  15191. }
  15192. if m.clearedlabels {
  15193. edges = append(edges, labelrelationship.EdgeLabels)
  15194. }
  15195. return edges
  15196. }
  15197. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15198. // was cleared in this mutation.
  15199. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  15200. switch name {
  15201. case labelrelationship.EdgeContacts:
  15202. return m.clearedcontacts
  15203. case labelrelationship.EdgeLabels:
  15204. return m.clearedlabels
  15205. }
  15206. return false
  15207. }
  15208. // ClearEdge clears the value of the edge with the given name. It returns an error
  15209. // if that edge is not defined in the schema.
  15210. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  15211. switch name {
  15212. case labelrelationship.EdgeContacts:
  15213. m.ClearContacts()
  15214. return nil
  15215. case labelrelationship.EdgeLabels:
  15216. m.ClearLabels()
  15217. return nil
  15218. }
  15219. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  15220. }
  15221. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15222. // It returns an error if the edge is not defined in the schema.
  15223. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  15224. switch name {
  15225. case labelrelationship.EdgeContacts:
  15226. m.ResetContacts()
  15227. return nil
  15228. case labelrelationship.EdgeLabels:
  15229. m.ResetLabels()
  15230. return nil
  15231. }
  15232. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  15233. }
  15234. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  15235. type LabelTaggingMutation struct {
  15236. config
  15237. op Op
  15238. typ string
  15239. id *uint64
  15240. created_at *time.Time
  15241. updated_at *time.Time
  15242. status *uint8
  15243. addstatus *int8
  15244. deleted_at *time.Time
  15245. organization_id *uint64
  15246. addorganization_id *int64
  15247. _type *int
  15248. add_type *int
  15249. conditions *string
  15250. action_label_add *[]uint64
  15251. appendaction_label_add []uint64
  15252. action_label_del *[]uint64
  15253. appendaction_label_del []uint64
  15254. clearedFields map[string]struct{}
  15255. done bool
  15256. oldValue func(context.Context) (*LabelTagging, error)
  15257. predicates []predicate.LabelTagging
  15258. }
  15259. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  15260. // labeltaggingOption allows management of the mutation configuration using functional options.
  15261. type labeltaggingOption func(*LabelTaggingMutation)
  15262. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  15263. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  15264. m := &LabelTaggingMutation{
  15265. config: c,
  15266. op: op,
  15267. typ: TypeLabelTagging,
  15268. clearedFields: make(map[string]struct{}),
  15269. }
  15270. for _, opt := range opts {
  15271. opt(m)
  15272. }
  15273. return m
  15274. }
  15275. // withLabelTaggingID sets the ID field of the mutation.
  15276. func withLabelTaggingID(id uint64) labeltaggingOption {
  15277. return func(m *LabelTaggingMutation) {
  15278. var (
  15279. err error
  15280. once sync.Once
  15281. value *LabelTagging
  15282. )
  15283. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  15284. once.Do(func() {
  15285. if m.done {
  15286. err = errors.New("querying old values post mutation is not allowed")
  15287. } else {
  15288. value, err = m.Client().LabelTagging.Get(ctx, id)
  15289. }
  15290. })
  15291. return value, err
  15292. }
  15293. m.id = &id
  15294. }
  15295. }
  15296. // withLabelTagging sets the old LabelTagging of the mutation.
  15297. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  15298. return func(m *LabelTaggingMutation) {
  15299. m.oldValue = func(context.Context) (*LabelTagging, error) {
  15300. return node, nil
  15301. }
  15302. m.id = &node.ID
  15303. }
  15304. }
  15305. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15306. // executed in a transaction (ent.Tx), a transactional client is returned.
  15307. func (m LabelTaggingMutation) Client() *Client {
  15308. client := &Client{config: m.config}
  15309. client.init()
  15310. return client
  15311. }
  15312. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15313. // it returns an error otherwise.
  15314. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  15315. if _, ok := m.driver.(*txDriver); !ok {
  15316. return nil, errors.New("ent: mutation is not running in a transaction")
  15317. }
  15318. tx := &Tx{config: m.config}
  15319. tx.init()
  15320. return tx, nil
  15321. }
  15322. // SetID sets the value of the id field. Note that this
  15323. // operation is only accepted on creation of LabelTagging entities.
  15324. func (m *LabelTaggingMutation) SetID(id uint64) {
  15325. m.id = &id
  15326. }
  15327. // ID returns the ID value in the mutation. Note that the ID is only available
  15328. // if it was provided to the builder or after it was returned from the database.
  15329. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  15330. if m.id == nil {
  15331. return
  15332. }
  15333. return *m.id, true
  15334. }
  15335. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15336. // That means, if the mutation is applied within a transaction with an isolation level such
  15337. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15338. // or updated by the mutation.
  15339. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  15340. switch {
  15341. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15342. id, exists := m.ID()
  15343. if exists {
  15344. return []uint64{id}, nil
  15345. }
  15346. fallthrough
  15347. case m.op.Is(OpUpdate | OpDelete):
  15348. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  15349. default:
  15350. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15351. }
  15352. }
  15353. // SetCreatedAt sets the "created_at" field.
  15354. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  15355. m.created_at = &t
  15356. }
  15357. // CreatedAt returns the value of the "created_at" field in the mutation.
  15358. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  15359. v := m.created_at
  15360. if v == nil {
  15361. return
  15362. }
  15363. return *v, true
  15364. }
  15365. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  15366. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15368. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15369. if !m.op.Is(OpUpdateOne) {
  15370. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15371. }
  15372. if m.id == nil || m.oldValue == nil {
  15373. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15374. }
  15375. oldValue, err := m.oldValue(ctx)
  15376. if err != nil {
  15377. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15378. }
  15379. return oldValue.CreatedAt, nil
  15380. }
  15381. // ResetCreatedAt resets all changes to the "created_at" field.
  15382. func (m *LabelTaggingMutation) ResetCreatedAt() {
  15383. m.created_at = nil
  15384. }
  15385. // SetUpdatedAt sets the "updated_at" field.
  15386. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  15387. m.updated_at = &t
  15388. }
  15389. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15390. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  15391. v := m.updated_at
  15392. if v == nil {
  15393. return
  15394. }
  15395. return *v, true
  15396. }
  15397. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  15398. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15400. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15401. if !m.op.Is(OpUpdateOne) {
  15402. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15403. }
  15404. if m.id == nil || m.oldValue == nil {
  15405. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15406. }
  15407. oldValue, err := m.oldValue(ctx)
  15408. if err != nil {
  15409. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15410. }
  15411. return oldValue.UpdatedAt, nil
  15412. }
  15413. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15414. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  15415. m.updated_at = nil
  15416. }
  15417. // SetStatus sets the "status" field.
  15418. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  15419. m.status = &u
  15420. m.addstatus = nil
  15421. }
  15422. // Status returns the value of the "status" field in the mutation.
  15423. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  15424. v := m.status
  15425. if v == nil {
  15426. return
  15427. }
  15428. return *v, true
  15429. }
  15430. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  15431. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15433. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15434. if !m.op.Is(OpUpdateOne) {
  15435. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15436. }
  15437. if m.id == nil || m.oldValue == nil {
  15438. return v, errors.New("OldStatus requires an ID field in the mutation")
  15439. }
  15440. oldValue, err := m.oldValue(ctx)
  15441. if err != nil {
  15442. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15443. }
  15444. return oldValue.Status, nil
  15445. }
  15446. // AddStatus adds u to the "status" field.
  15447. func (m *LabelTaggingMutation) AddStatus(u int8) {
  15448. if m.addstatus != nil {
  15449. *m.addstatus += u
  15450. } else {
  15451. m.addstatus = &u
  15452. }
  15453. }
  15454. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15455. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  15456. v := m.addstatus
  15457. if v == nil {
  15458. return
  15459. }
  15460. return *v, true
  15461. }
  15462. // ClearStatus clears the value of the "status" field.
  15463. func (m *LabelTaggingMutation) ClearStatus() {
  15464. m.status = nil
  15465. m.addstatus = nil
  15466. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  15467. }
  15468. // StatusCleared returns if the "status" field was cleared in this mutation.
  15469. func (m *LabelTaggingMutation) StatusCleared() bool {
  15470. _, ok := m.clearedFields[labeltagging.FieldStatus]
  15471. return ok
  15472. }
  15473. // ResetStatus resets all changes to the "status" field.
  15474. func (m *LabelTaggingMutation) ResetStatus() {
  15475. m.status = nil
  15476. m.addstatus = nil
  15477. delete(m.clearedFields, labeltagging.FieldStatus)
  15478. }
  15479. // SetDeletedAt sets the "deleted_at" field.
  15480. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  15481. m.deleted_at = &t
  15482. }
  15483. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15484. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  15485. v := m.deleted_at
  15486. if v == nil {
  15487. return
  15488. }
  15489. return *v, true
  15490. }
  15491. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  15492. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15494. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15495. if !m.op.Is(OpUpdateOne) {
  15496. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15497. }
  15498. if m.id == nil || m.oldValue == nil {
  15499. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15500. }
  15501. oldValue, err := m.oldValue(ctx)
  15502. if err != nil {
  15503. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15504. }
  15505. return oldValue.DeletedAt, nil
  15506. }
  15507. // ClearDeletedAt clears the value of the "deleted_at" field.
  15508. func (m *LabelTaggingMutation) ClearDeletedAt() {
  15509. m.deleted_at = nil
  15510. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  15511. }
  15512. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15513. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  15514. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  15515. return ok
  15516. }
  15517. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15518. func (m *LabelTaggingMutation) ResetDeletedAt() {
  15519. m.deleted_at = nil
  15520. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  15521. }
  15522. // SetOrganizationID sets the "organization_id" field.
  15523. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  15524. m.organization_id = &u
  15525. m.addorganization_id = nil
  15526. }
  15527. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15528. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  15529. v := m.organization_id
  15530. if v == nil {
  15531. return
  15532. }
  15533. return *v, true
  15534. }
  15535. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  15536. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15538. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15539. if !m.op.Is(OpUpdateOne) {
  15540. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15541. }
  15542. if m.id == nil || m.oldValue == nil {
  15543. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15544. }
  15545. oldValue, err := m.oldValue(ctx)
  15546. if err != nil {
  15547. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15548. }
  15549. return oldValue.OrganizationID, nil
  15550. }
  15551. // AddOrganizationID adds u to the "organization_id" field.
  15552. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  15553. if m.addorganization_id != nil {
  15554. *m.addorganization_id += u
  15555. } else {
  15556. m.addorganization_id = &u
  15557. }
  15558. }
  15559. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15560. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  15561. v := m.addorganization_id
  15562. if v == nil {
  15563. return
  15564. }
  15565. return *v, true
  15566. }
  15567. // ResetOrganizationID resets all changes to the "organization_id" field.
  15568. func (m *LabelTaggingMutation) ResetOrganizationID() {
  15569. m.organization_id = nil
  15570. m.addorganization_id = nil
  15571. }
  15572. // SetType sets the "type" field.
  15573. func (m *LabelTaggingMutation) SetType(i int) {
  15574. m._type = &i
  15575. m.add_type = nil
  15576. }
  15577. // GetType returns the value of the "type" field in the mutation.
  15578. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  15579. v := m._type
  15580. if v == nil {
  15581. return
  15582. }
  15583. return *v, true
  15584. }
  15585. // OldType returns the old "type" field's value of the LabelTagging entity.
  15586. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15587. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15588. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  15589. if !m.op.Is(OpUpdateOne) {
  15590. return v, errors.New("OldType is only allowed on UpdateOne operations")
  15591. }
  15592. if m.id == nil || m.oldValue == nil {
  15593. return v, errors.New("OldType requires an ID field in the mutation")
  15594. }
  15595. oldValue, err := m.oldValue(ctx)
  15596. if err != nil {
  15597. return v, fmt.Errorf("querying old value for OldType: %w", err)
  15598. }
  15599. return oldValue.Type, nil
  15600. }
  15601. // AddType adds i to the "type" field.
  15602. func (m *LabelTaggingMutation) AddType(i int) {
  15603. if m.add_type != nil {
  15604. *m.add_type += i
  15605. } else {
  15606. m.add_type = &i
  15607. }
  15608. }
  15609. // AddedType returns the value that was added to the "type" field in this mutation.
  15610. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  15611. v := m.add_type
  15612. if v == nil {
  15613. return
  15614. }
  15615. return *v, true
  15616. }
  15617. // ResetType resets all changes to the "type" field.
  15618. func (m *LabelTaggingMutation) ResetType() {
  15619. m._type = nil
  15620. m.add_type = nil
  15621. }
  15622. // SetConditions sets the "conditions" field.
  15623. func (m *LabelTaggingMutation) SetConditions(s string) {
  15624. m.conditions = &s
  15625. }
  15626. // Conditions returns the value of the "conditions" field in the mutation.
  15627. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  15628. v := m.conditions
  15629. if v == nil {
  15630. return
  15631. }
  15632. return *v, true
  15633. }
  15634. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  15635. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15637. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  15638. if !m.op.Is(OpUpdateOne) {
  15639. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  15640. }
  15641. if m.id == nil || m.oldValue == nil {
  15642. return v, errors.New("OldConditions requires an ID field in the mutation")
  15643. }
  15644. oldValue, err := m.oldValue(ctx)
  15645. if err != nil {
  15646. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  15647. }
  15648. return oldValue.Conditions, nil
  15649. }
  15650. // ResetConditions resets all changes to the "conditions" field.
  15651. func (m *LabelTaggingMutation) ResetConditions() {
  15652. m.conditions = nil
  15653. }
  15654. // SetActionLabelAdd sets the "action_label_add" field.
  15655. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  15656. m.action_label_add = &u
  15657. m.appendaction_label_add = nil
  15658. }
  15659. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  15660. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  15661. v := m.action_label_add
  15662. if v == nil {
  15663. return
  15664. }
  15665. return *v, true
  15666. }
  15667. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  15668. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15670. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  15671. if !m.op.Is(OpUpdateOne) {
  15672. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  15673. }
  15674. if m.id == nil || m.oldValue == nil {
  15675. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  15676. }
  15677. oldValue, err := m.oldValue(ctx)
  15678. if err != nil {
  15679. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  15680. }
  15681. return oldValue.ActionLabelAdd, nil
  15682. }
  15683. // AppendActionLabelAdd adds u to the "action_label_add" field.
  15684. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  15685. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  15686. }
  15687. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  15688. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  15689. if len(m.appendaction_label_add) == 0 {
  15690. return nil, false
  15691. }
  15692. return m.appendaction_label_add, true
  15693. }
  15694. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  15695. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  15696. m.action_label_add = nil
  15697. m.appendaction_label_add = nil
  15698. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  15699. }
  15700. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  15701. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  15702. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  15703. return ok
  15704. }
  15705. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  15706. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  15707. m.action_label_add = nil
  15708. m.appendaction_label_add = nil
  15709. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  15710. }
  15711. // SetActionLabelDel sets the "action_label_del" field.
  15712. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  15713. m.action_label_del = &u
  15714. m.appendaction_label_del = nil
  15715. }
  15716. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  15717. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  15718. v := m.action_label_del
  15719. if v == nil {
  15720. return
  15721. }
  15722. return *v, true
  15723. }
  15724. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  15725. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15727. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  15728. if !m.op.Is(OpUpdateOne) {
  15729. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  15730. }
  15731. if m.id == nil || m.oldValue == nil {
  15732. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  15733. }
  15734. oldValue, err := m.oldValue(ctx)
  15735. if err != nil {
  15736. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  15737. }
  15738. return oldValue.ActionLabelDel, nil
  15739. }
  15740. // AppendActionLabelDel adds u to the "action_label_del" field.
  15741. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  15742. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  15743. }
  15744. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  15745. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  15746. if len(m.appendaction_label_del) == 0 {
  15747. return nil, false
  15748. }
  15749. return m.appendaction_label_del, true
  15750. }
  15751. // ClearActionLabelDel clears the value of the "action_label_del" field.
  15752. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  15753. m.action_label_del = nil
  15754. m.appendaction_label_del = nil
  15755. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  15756. }
  15757. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  15758. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  15759. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  15760. return ok
  15761. }
  15762. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  15763. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  15764. m.action_label_del = nil
  15765. m.appendaction_label_del = nil
  15766. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  15767. }
  15768. // Where appends a list predicates to the LabelTaggingMutation builder.
  15769. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  15770. m.predicates = append(m.predicates, ps...)
  15771. }
  15772. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  15773. // users can use type-assertion to append predicates that do not depend on any generated package.
  15774. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  15775. p := make([]predicate.LabelTagging, len(ps))
  15776. for i := range ps {
  15777. p[i] = ps[i]
  15778. }
  15779. m.Where(p...)
  15780. }
  15781. // Op returns the operation name.
  15782. func (m *LabelTaggingMutation) Op() Op {
  15783. return m.op
  15784. }
  15785. // SetOp allows setting the mutation operation.
  15786. func (m *LabelTaggingMutation) SetOp(op Op) {
  15787. m.op = op
  15788. }
  15789. // Type returns the node type of this mutation (LabelTagging).
  15790. func (m *LabelTaggingMutation) Type() string {
  15791. return m.typ
  15792. }
  15793. // Fields returns all fields that were changed during this mutation. Note that in
  15794. // order to get all numeric fields that were incremented/decremented, call
  15795. // AddedFields().
  15796. func (m *LabelTaggingMutation) Fields() []string {
  15797. fields := make([]string, 0, 9)
  15798. if m.created_at != nil {
  15799. fields = append(fields, labeltagging.FieldCreatedAt)
  15800. }
  15801. if m.updated_at != nil {
  15802. fields = append(fields, labeltagging.FieldUpdatedAt)
  15803. }
  15804. if m.status != nil {
  15805. fields = append(fields, labeltagging.FieldStatus)
  15806. }
  15807. if m.deleted_at != nil {
  15808. fields = append(fields, labeltagging.FieldDeletedAt)
  15809. }
  15810. if m.organization_id != nil {
  15811. fields = append(fields, labeltagging.FieldOrganizationID)
  15812. }
  15813. if m._type != nil {
  15814. fields = append(fields, labeltagging.FieldType)
  15815. }
  15816. if m.conditions != nil {
  15817. fields = append(fields, labeltagging.FieldConditions)
  15818. }
  15819. if m.action_label_add != nil {
  15820. fields = append(fields, labeltagging.FieldActionLabelAdd)
  15821. }
  15822. if m.action_label_del != nil {
  15823. fields = append(fields, labeltagging.FieldActionLabelDel)
  15824. }
  15825. return fields
  15826. }
  15827. // Field returns the value of a field with the given name. The second boolean
  15828. // return value indicates that this field was not set, or was not defined in the
  15829. // schema.
  15830. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  15831. switch name {
  15832. case labeltagging.FieldCreatedAt:
  15833. return m.CreatedAt()
  15834. case labeltagging.FieldUpdatedAt:
  15835. return m.UpdatedAt()
  15836. case labeltagging.FieldStatus:
  15837. return m.Status()
  15838. case labeltagging.FieldDeletedAt:
  15839. return m.DeletedAt()
  15840. case labeltagging.FieldOrganizationID:
  15841. return m.OrganizationID()
  15842. case labeltagging.FieldType:
  15843. return m.GetType()
  15844. case labeltagging.FieldConditions:
  15845. return m.Conditions()
  15846. case labeltagging.FieldActionLabelAdd:
  15847. return m.ActionLabelAdd()
  15848. case labeltagging.FieldActionLabelDel:
  15849. return m.ActionLabelDel()
  15850. }
  15851. return nil, false
  15852. }
  15853. // OldField returns the old value of the field from the database. An error is
  15854. // returned if the mutation operation is not UpdateOne, or the query to the
  15855. // database failed.
  15856. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15857. switch name {
  15858. case labeltagging.FieldCreatedAt:
  15859. return m.OldCreatedAt(ctx)
  15860. case labeltagging.FieldUpdatedAt:
  15861. return m.OldUpdatedAt(ctx)
  15862. case labeltagging.FieldStatus:
  15863. return m.OldStatus(ctx)
  15864. case labeltagging.FieldDeletedAt:
  15865. return m.OldDeletedAt(ctx)
  15866. case labeltagging.FieldOrganizationID:
  15867. return m.OldOrganizationID(ctx)
  15868. case labeltagging.FieldType:
  15869. return m.OldType(ctx)
  15870. case labeltagging.FieldConditions:
  15871. return m.OldConditions(ctx)
  15872. case labeltagging.FieldActionLabelAdd:
  15873. return m.OldActionLabelAdd(ctx)
  15874. case labeltagging.FieldActionLabelDel:
  15875. return m.OldActionLabelDel(ctx)
  15876. }
  15877. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  15878. }
  15879. // SetField sets the value of a field with the given name. It returns an error if
  15880. // the field is not defined in the schema, or if the type mismatched the field
  15881. // type.
  15882. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  15883. switch name {
  15884. case labeltagging.FieldCreatedAt:
  15885. v, ok := value.(time.Time)
  15886. if !ok {
  15887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15888. }
  15889. m.SetCreatedAt(v)
  15890. return nil
  15891. case labeltagging.FieldUpdatedAt:
  15892. v, ok := value.(time.Time)
  15893. if !ok {
  15894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15895. }
  15896. m.SetUpdatedAt(v)
  15897. return nil
  15898. case labeltagging.FieldStatus:
  15899. v, ok := value.(uint8)
  15900. if !ok {
  15901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15902. }
  15903. m.SetStatus(v)
  15904. return nil
  15905. case labeltagging.FieldDeletedAt:
  15906. v, ok := value.(time.Time)
  15907. if !ok {
  15908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15909. }
  15910. m.SetDeletedAt(v)
  15911. return nil
  15912. case labeltagging.FieldOrganizationID:
  15913. v, ok := value.(uint64)
  15914. if !ok {
  15915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15916. }
  15917. m.SetOrganizationID(v)
  15918. return nil
  15919. case labeltagging.FieldType:
  15920. v, ok := value.(int)
  15921. if !ok {
  15922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15923. }
  15924. m.SetType(v)
  15925. return nil
  15926. case labeltagging.FieldConditions:
  15927. v, ok := value.(string)
  15928. if !ok {
  15929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15930. }
  15931. m.SetConditions(v)
  15932. return nil
  15933. case labeltagging.FieldActionLabelAdd:
  15934. v, ok := value.([]uint64)
  15935. if !ok {
  15936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15937. }
  15938. m.SetActionLabelAdd(v)
  15939. return nil
  15940. case labeltagging.FieldActionLabelDel:
  15941. v, ok := value.([]uint64)
  15942. if !ok {
  15943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15944. }
  15945. m.SetActionLabelDel(v)
  15946. return nil
  15947. }
  15948. return fmt.Errorf("unknown LabelTagging field %s", name)
  15949. }
  15950. // AddedFields returns all numeric fields that were incremented/decremented during
  15951. // this mutation.
  15952. func (m *LabelTaggingMutation) AddedFields() []string {
  15953. var fields []string
  15954. if m.addstatus != nil {
  15955. fields = append(fields, labeltagging.FieldStatus)
  15956. }
  15957. if m.addorganization_id != nil {
  15958. fields = append(fields, labeltagging.FieldOrganizationID)
  15959. }
  15960. if m.add_type != nil {
  15961. fields = append(fields, labeltagging.FieldType)
  15962. }
  15963. return fields
  15964. }
  15965. // AddedField returns the numeric value that was incremented/decremented on a field
  15966. // with the given name. The second boolean return value indicates that this field
  15967. // was not set, or was not defined in the schema.
  15968. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  15969. switch name {
  15970. case labeltagging.FieldStatus:
  15971. return m.AddedStatus()
  15972. case labeltagging.FieldOrganizationID:
  15973. return m.AddedOrganizationID()
  15974. case labeltagging.FieldType:
  15975. return m.AddedType()
  15976. }
  15977. return nil, false
  15978. }
  15979. // AddField adds the value to the field with the given name. It returns an error if
  15980. // the field is not defined in the schema, or if the type mismatched the field
  15981. // type.
  15982. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  15983. switch name {
  15984. case labeltagging.FieldStatus:
  15985. v, ok := value.(int8)
  15986. if !ok {
  15987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15988. }
  15989. m.AddStatus(v)
  15990. return nil
  15991. case labeltagging.FieldOrganizationID:
  15992. v, ok := value.(int64)
  15993. if !ok {
  15994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15995. }
  15996. m.AddOrganizationID(v)
  15997. return nil
  15998. case labeltagging.FieldType:
  15999. v, ok := value.(int)
  16000. if !ok {
  16001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16002. }
  16003. m.AddType(v)
  16004. return nil
  16005. }
  16006. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  16007. }
  16008. // ClearedFields returns all nullable fields that were cleared during this
  16009. // mutation.
  16010. func (m *LabelTaggingMutation) ClearedFields() []string {
  16011. var fields []string
  16012. if m.FieldCleared(labeltagging.FieldStatus) {
  16013. fields = append(fields, labeltagging.FieldStatus)
  16014. }
  16015. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  16016. fields = append(fields, labeltagging.FieldDeletedAt)
  16017. }
  16018. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  16019. fields = append(fields, labeltagging.FieldActionLabelAdd)
  16020. }
  16021. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  16022. fields = append(fields, labeltagging.FieldActionLabelDel)
  16023. }
  16024. return fields
  16025. }
  16026. // FieldCleared returns a boolean indicating if a field with the given name was
  16027. // cleared in this mutation.
  16028. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  16029. _, ok := m.clearedFields[name]
  16030. return ok
  16031. }
  16032. // ClearField clears the value of the field with the given name. It returns an
  16033. // error if the field is not defined in the schema.
  16034. func (m *LabelTaggingMutation) ClearField(name string) error {
  16035. switch name {
  16036. case labeltagging.FieldStatus:
  16037. m.ClearStatus()
  16038. return nil
  16039. case labeltagging.FieldDeletedAt:
  16040. m.ClearDeletedAt()
  16041. return nil
  16042. case labeltagging.FieldActionLabelAdd:
  16043. m.ClearActionLabelAdd()
  16044. return nil
  16045. case labeltagging.FieldActionLabelDel:
  16046. m.ClearActionLabelDel()
  16047. return nil
  16048. }
  16049. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  16050. }
  16051. // ResetField resets all changes in the mutation for the field with the given name.
  16052. // It returns an error if the field is not defined in the schema.
  16053. func (m *LabelTaggingMutation) ResetField(name string) error {
  16054. switch name {
  16055. case labeltagging.FieldCreatedAt:
  16056. m.ResetCreatedAt()
  16057. return nil
  16058. case labeltagging.FieldUpdatedAt:
  16059. m.ResetUpdatedAt()
  16060. return nil
  16061. case labeltagging.FieldStatus:
  16062. m.ResetStatus()
  16063. return nil
  16064. case labeltagging.FieldDeletedAt:
  16065. m.ResetDeletedAt()
  16066. return nil
  16067. case labeltagging.FieldOrganizationID:
  16068. m.ResetOrganizationID()
  16069. return nil
  16070. case labeltagging.FieldType:
  16071. m.ResetType()
  16072. return nil
  16073. case labeltagging.FieldConditions:
  16074. m.ResetConditions()
  16075. return nil
  16076. case labeltagging.FieldActionLabelAdd:
  16077. m.ResetActionLabelAdd()
  16078. return nil
  16079. case labeltagging.FieldActionLabelDel:
  16080. m.ResetActionLabelDel()
  16081. return nil
  16082. }
  16083. return fmt.Errorf("unknown LabelTagging field %s", name)
  16084. }
  16085. // AddedEdges returns all edge names that were set/added in this mutation.
  16086. func (m *LabelTaggingMutation) AddedEdges() []string {
  16087. edges := make([]string, 0, 0)
  16088. return edges
  16089. }
  16090. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16091. // name in this mutation.
  16092. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  16093. return nil
  16094. }
  16095. // RemovedEdges returns all edge names that were removed in this mutation.
  16096. func (m *LabelTaggingMutation) RemovedEdges() []string {
  16097. edges := make([]string, 0, 0)
  16098. return edges
  16099. }
  16100. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16101. // the given name in this mutation.
  16102. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  16103. return nil
  16104. }
  16105. // ClearedEdges returns all edge names that were cleared in this mutation.
  16106. func (m *LabelTaggingMutation) ClearedEdges() []string {
  16107. edges := make([]string, 0, 0)
  16108. return edges
  16109. }
  16110. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16111. // was cleared in this mutation.
  16112. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  16113. return false
  16114. }
  16115. // ClearEdge clears the value of the edge with the given name. It returns an error
  16116. // if that edge is not defined in the schema.
  16117. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  16118. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  16119. }
  16120. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16121. // It returns an error if the edge is not defined in the schema.
  16122. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  16123. return fmt.Errorf("unknown LabelTagging edge %s", name)
  16124. }
  16125. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  16126. type MessageMutation struct {
  16127. config
  16128. op Op
  16129. typ string
  16130. id *int
  16131. wx_wxid *string
  16132. wxid *string
  16133. content *string
  16134. clearedFields map[string]struct{}
  16135. done bool
  16136. oldValue func(context.Context) (*Message, error)
  16137. predicates []predicate.Message
  16138. }
  16139. var _ ent.Mutation = (*MessageMutation)(nil)
  16140. // messageOption allows management of the mutation configuration using functional options.
  16141. type messageOption func(*MessageMutation)
  16142. // newMessageMutation creates new mutation for the Message entity.
  16143. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  16144. m := &MessageMutation{
  16145. config: c,
  16146. op: op,
  16147. typ: TypeMessage,
  16148. clearedFields: make(map[string]struct{}),
  16149. }
  16150. for _, opt := range opts {
  16151. opt(m)
  16152. }
  16153. return m
  16154. }
  16155. // withMessageID sets the ID field of the mutation.
  16156. func withMessageID(id int) messageOption {
  16157. return func(m *MessageMutation) {
  16158. var (
  16159. err error
  16160. once sync.Once
  16161. value *Message
  16162. )
  16163. m.oldValue = func(ctx context.Context) (*Message, error) {
  16164. once.Do(func() {
  16165. if m.done {
  16166. err = errors.New("querying old values post mutation is not allowed")
  16167. } else {
  16168. value, err = m.Client().Message.Get(ctx, id)
  16169. }
  16170. })
  16171. return value, err
  16172. }
  16173. m.id = &id
  16174. }
  16175. }
  16176. // withMessage sets the old Message of the mutation.
  16177. func withMessage(node *Message) messageOption {
  16178. return func(m *MessageMutation) {
  16179. m.oldValue = func(context.Context) (*Message, error) {
  16180. return node, nil
  16181. }
  16182. m.id = &node.ID
  16183. }
  16184. }
  16185. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16186. // executed in a transaction (ent.Tx), a transactional client is returned.
  16187. func (m MessageMutation) Client() *Client {
  16188. client := &Client{config: m.config}
  16189. client.init()
  16190. return client
  16191. }
  16192. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16193. // it returns an error otherwise.
  16194. func (m MessageMutation) Tx() (*Tx, error) {
  16195. if _, ok := m.driver.(*txDriver); !ok {
  16196. return nil, errors.New("ent: mutation is not running in a transaction")
  16197. }
  16198. tx := &Tx{config: m.config}
  16199. tx.init()
  16200. return tx, nil
  16201. }
  16202. // ID returns the ID value in the mutation. Note that the ID is only available
  16203. // if it was provided to the builder or after it was returned from the database.
  16204. func (m *MessageMutation) ID() (id int, exists bool) {
  16205. if m.id == nil {
  16206. return
  16207. }
  16208. return *m.id, true
  16209. }
  16210. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16211. // That means, if the mutation is applied within a transaction with an isolation level such
  16212. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16213. // or updated by the mutation.
  16214. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  16215. switch {
  16216. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16217. id, exists := m.ID()
  16218. if exists {
  16219. return []int{id}, nil
  16220. }
  16221. fallthrough
  16222. case m.op.Is(OpUpdate | OpDelete):
  16223. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  16224. default:
  16225. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16226. }
  16227. }
  16228. // SetWxWxid sets the "wx_wxid" field.
  16229. func (m *MessageMutation) SetWxWxid(s string) {
  16230. m.wx_wxid = &s
  16231. }
  16232. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  16233. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  16234. v := m.wx_wxid
  16235. if v == nil {
  16236. return
  16237. }
  16238. return *v, true
  16239. }
  16240. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  16241. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16243. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  16244. if !m.op.Is(OpUpdateOne) {
  16245. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  16246. }
  16247. if m.id == nil || m.oldValue == nil {
  16248. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  16249. }
  16250. oldValue, err := m.oldValue(ctx)
  16251. if err != nil {
  16252. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  16253. }
  16254. return oldValue.WxWxid, nil
  16255. }
  16256. // ClearWxWxid clears the value of the "wx_wxid" field.
  16257. func (m *MessageMutation) ClearWxWxid() {
  16258. m.wx_wxid = nil
  16259. m.clearedFields[message.FieldWxWxid] = struct{}{}
  16260. }
  16261. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  16262. func (m *MessageMutation) WxWxidCleared() bool {
  16263. _, ok := m.clearedFields[message.FieldWxWxid]
  16264. return ok
  16265. }
  16266. // ResetWxWxid resets all changes to the "wx_wxid" field.
  16267. func (m *MessageMutation) ResetWxWxid() {
  16268. m.wx_wxid = nil
  16269. delete(m.clearedFields, message.FieldWxWxid)
  16270. }
  16271. // SetWxid sets the "wxid" field.
  16272. func (m *MessageMutation) SetWxid(s string) {
  16273. m.wxid = &s
  16274. }
  16275. // Wxid returns the value of the "wxid" field in the mutation.
  16276. func (m *MessageMutation) Wxid() (r string, exists bool) {
  16277. v := m.wxid
  16278. if v == nil {
  16279. return
  16280. }
  16281. return *v, true
  16282. }
  16283. // OldWxid returns the old "wxid" field's value of the Message entity.
  16284. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16286. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  16287. if !m.op.Is(OpUpdateOne) {
  16288. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  16289. }
  16290. if m.id == nil || m.oldValue == nil {
  16291. return v, errors.New("OldWxid requires an ID field in the mutation")
  16292. }
  16293. oldValue, err := m.oldValue(ctx)
  16294. if err != nil {
  16295. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  16296. }
  16297. return oldValue.Wxid, nil
  16298. }
  16299. // ResetWxid resets all changes to the "wxid" field.
  16300. func (m *MessageMutation) ResetWxid() {
  16301. m.wxid = nil
  16302. }
  16303. // SetContent sets the "content" field.
  16304. func (m *MessageMutation) SetContent(s string) {
  16305. m.content = &s
  16306. }
  16307. // Content returns the value of the "content" field in the mutation.
  16308. func (m *MessageMutation) Content() (r string, exists bool) {
  16309. v := m.content
  16310. if v == nil {
  16311. return
  16312. }
  16313. return *v, true
  16314. }
  16315. // OldContent returns the old "content" field's value of the Message entity.
  16316. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16318. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  16319. if !m.op.Is(OpUpdateOne) {
  16320. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  16321. }
  16322. if m.id == nil || m.oldValue == nil {
  16323. return v, errors.New("OldContent requires an ID field in the mutation")
  16324. }
  16325. oldValue, err := m.oldValue(ctx)
  16326. if err != nil {
  16327. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  16328. }
  16329. return oldValue.Content, nil
  16330. }
  16331. // ResetContent resets all changes to the "content" field.
  16332. func (m *MessageMutation) ResetContent() {
  16333. m.content = nil
  16334. }
  16335. // Where appends a list predicates to the MessageMutation builder.
  16336. func (m *MessageMutation) Where(ps ...predicate.Message) {
  16337. m.predicates = append(m.predicates, ps...)
  16338. }
  16339. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  16340. // users can use type-assertion to append predicates that do not depend on any generated package.
  16341. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  16342. p := make([]predicate.Message, len(ps))
  16343. for i := range ps {
  16344. p[i] = ps[i]
  16345. }
  16346. m.Where(p...)
  16347. }
  16348. // Op returns the operation name.
  16349. func (m *MessageMutation) Op() Op {
  16350. return m.op
  16351. }
  16352. // SetOp allows setting the mutation operation.
  16353. func (m *MessageMutation) SetOp(op Op) {
  16354. m.op = op
  16355. }
  16356. // Type returns the node type of this mutation (Message).
  16357. func (m *MessageMutation) Type() string {
  16358. return m.typ
  16359. }
  16360. // Fields returns all fields that were changed during this mutation. Note that in
  16361. // order to get all numeric fields that were incremented/decremented, call
  16362. // AddedFields().
  16363. func (m *MessageMutation) Fields() []string {
  16364. fields := make([]string, 0, 3)
  16365. if m.wx_wxid != nil {
  16366. fields = append(fields, message.FieldWxWxid)
  16367. }
  16368. if m.wxid != nil {
  16369. fields = append(fields, message.FieldWxid)
  16370. }
  16371. if m.content != nil {
  16372. fields = append(fields, message.FieldContent)
  16373. }
  16374. return fields
  16375. }
  16376. // Field returns the value of a field with the given name. The second boolean
  16377. // return value indicates that this field was not set, or was not defined in the
  16378. // schema.
  16379. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  16380. switch name {
  16381. case message.FieldWxWxid:
  16382. return m.WxWxid()
  16383. case message.FieldWxid:
  16384. return m.Wxid()
  16385. case message.FieldContent:
  16386. return m.Content()
  16387. }
  16388. return nil, false
  16389. }
  16390. // OldField returns the old value of the field from the database. An error is
  16391. // returned if the mutation operation is not UpdateOne, or the query to the
  16392. // database failed.
  16393. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16394. switch name {
  16395. case message.FieldWxWxid:
  16396. return m.OldWxWxid(ctx)
  16397. case message.FieldWxid:
  16398. return m.OldWxid(ctx)
  16399. case message.FieldContent:
  16400. return m.OldContent(ctx)
  16401. }
  16402. return nil, fmt.Errorf("unknown Message field %s", name)
  16403. }
  16404. // SetField sets the value of a field with the given name. It returns an error if
  16405. // the field is not defined in the schema, or if the type mismatched the field
  16406. // type.
  16407. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  16408. switch name {
  16409. case message.FieldWxWxid:
  16410. v, ok := value.(string)
  16411. if !ok {
  16412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16413. }
  16414. m.SetWxWxid(v)
  16415. return nil
  16416. case message.FieldWxid:
  16417. v, ok := value.(string)
  16418. if !ok {
  16419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16420. }
  16421. m.SetWxid(v)
  16422. return nil
  16423. case message.FieldContent:
  16424. v, ok := value.(string)
  16425. if !ok {
  16426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16427. }
  16428. m.SetContent(v)
  16429. return nil
  16430. }
  16431. return fmt.Errorf("unknown Message field %s", name)
  16432. }
  16433. // AddedFields returns all numeric fields that were incremented/decremented during
  16434. // this mutation.
  16435. func (m *MessageMutation) AddedFields() []string {
  16436. return nil
  16437. }
  16438. // AddedField returns the numeric value that was incremented/decremented on a field
  16439. // with the given name. The second boolean return value indicates that this field
  16440. // was not set, or was not defined in the schema.
  16441. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  16442. return nil, false
  16443. }
  16444. // AddField adds the value to the field with the given name. It returns an error if
  16445. // the field is not defined in the schema, or if the type mismatched the field
  16446. // type.
  16447. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  16448. switch name {
  16449. }
  16450. return fmt.Errorf("unknown Message numeric field %s", name)
  16451. }
  16452. // ClearedFields returns all nullable fields that were cleared during this
  16453. // mutation.
  16454. func (m *MessageMutation) ClearedFields() []string {
  16455. var fields []string
  16456. if m.FieldCleared(message.FieldWxWxid) {
  16457. fields = append(fields, message.FieldWxWxid)
  16458. }
  16459. return fields
  16460. }
  16461. // FieldCleared returns a boolean indicating if a field with the given name was
  16462. // cleared in this mutation.
  16463. func (m *MessageMutation) FieldCleared(name string) bool {
  16464. _, ok := m.clearedFields[name]
  16465. return ok
  16466. }
  16467. // ClearField clears the value of the field with the given name. It returns an
  16468. // error if the field is not defined in the schema.
  16469. func (m *MessageMutation) ClearField(name string) error {
  16470. switch name {
  16471. case message.FieldWxWxid:
  16472. m.ClearWxWxid()
  16473. return nil
  16474. }
  16475. return fmt.Errorf("unknown Message nullable field %s", name)
  16476. }
  16477. // ResetField resets all changes in the mutation for the field with the given name.
  16478. // It returns an error if the field is not defined in the schema.
  16479. func (m *MessageMutation) ResetField(name string) error {
  16480. switch name {
  16481. case message.FieldWxWxid:
  16482. m.ResetWxWxid()
  16483. return nil
  16484. case message.FieldWxid:
  16485. m.ResetWxid()
  16486. return nil
  16487. case message.FieldContent:
  16488. m.ResetContent()
  16489. return nil
  16490. }
  16491. return fmt.Errorf("unknown Message field %s", name)
  16492. }
  16493. // AddedEdges returns all edge names that were set/added in this mutation.
  16494. func (m *MessageMutation) AddedEdges() []string {
  16495. edges := make([]string, 0, 0)
  16496. return edges
  16497. }
  16498. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16499. // name in this mutation.
  16500. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  16501. return nil
  16502. }
  16503. // RemovedEdges returns all edge names that were removed in this mutation.
  16504. func (m *MessageMutation) RemovedEdges() []string {
  16505. edges := make([]string, 0, 0)
  16506. return edges
  16507. }
  16508. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16509. // the given name in this mutation.
  16510. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  16511. return nil
  16512. }
  16513. // ClearedEdges returns all edge names that were cleared in this mutation.
  16514. func (m *MessageMutation) ClearedEdges() []string {
  16515. edges := make([]string, 0, 0)
  16516. return edges
  16517. }
  16518. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16519. // was cleared in this mutation.
  16520. func (m *MessageMutation) EdgeCleared(name string) bool {
  16521. return false
  16522. }
  16523. // ClearEdge clears the value of the edge with the given name. It returns an error
  16524. // if that edge is not defined in the schema.
  16525. func (m *MessageMutation) ClearEdge(name string) error {
  16526. return fmt.Errorf("unknown Message unique edge %s", name)
  16527. }
  16528. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16529. // It returns an error if the edge is not defined in the schema.
  16530. func (m *MessageMutation) ResetEdge(name string) error {
  16531. return fmt.Errorf("unknown Message edge %s", name)
  16532. }
  16533. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  16534. type MessageRecordsMutation struct {
  16535. config
  16536. op Op
  16537. typ string
  16538. id *uint64
  16539. created_at *time.Time
  16540. updated_at *time.Time
  16541. status *uint8
  16542. addstatus *int8
  16543. bot_wxid *string
  16544. contact_type *int
  16545. addcontact_type *int
  16546. contact_wxid *string
  16547. content_type *int
  16548. addcontent_type *int
  16549. content *string
  16550. meta *custom_types.Meta
  16551. error_detail *string
  16552. send_time *time.Time
  16553. source_type *int
  16554. addsource_type *int
  16555. organization_id *uint64
  16556. addorganization_id *int64
  16557. clearedFields map[string]struct{}
  16558. sop_stage *uint64
  16559. clearedsop_stage bool
  16560. sop_node *uint64
  16561. clearedsop_node bool
  16562. message_contact *uint64
  16563. clearedmessage_contact bool
  16564. done bool
  16565. oldValue func(context.Context) (*MessageRecords, error)
  16566. predicates []predicate.MessageRecords
  16567. }
  16568. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  16569. // messagerecordsOption allows management of the mutation configuration using functional options.
  16570. type messagerecordsOption func(*MessageRecordsMutation)
  16571. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  16572. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  16573. m := &MessageRecordsMutation{
  16574. config: c,
  16575. op: op,
  16576. typ: TypeMessageRecords,
  16577. clearedFields: make(map[string]struct{}),
  16578. }
  16579. for _, opt := range opts {
  16580. opt(m)
  16581. }
  16582. return m
  16583. }
  16584. // withMessageRecordsID sets the ID field of the mutation.
  16585. func withMessageRecordsID(id uint64) messagerecordsOption {
  16586. return func(m *MessageRecordsMutation) {
  16587. var (
  16588. err error
  16589. once sync.Once
  16590. value *MessageRecords
  16591. )
  16592. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  16593. once.Do(func() {
  16594. if m.done {
  16595. err = errors.New("querying old values post mutation is not allowed")
  16596. } else {
  16597. value, err = m.Client().MessageRecords.Get(ctx, id)
  16598. }
  16599. })
  16600. return value, err
  16601. }
  16602. m.id = &id
  16603. }
  16604. }
  16605. // withMessageRecords sets the old MessageRecords of the mutation.
  16606. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  16607. return func(m *MessageRecordsMutation) {
  16608. m.oldValue = func(context.Context) (*MessageRecords, error) {
  16609. return node, nil
  16610. }
  16611. m.id = &node.ID
  16612. }
  16613. }
  16614. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16615. // executed in a transaction (ent.Tx), a transactional client is returned.
  16616. func (m MessageRecordsMutation) Client() *Client {
  16617. client := &Client{config: m.config}
  16618. client.init()
  16619. return client
  16620. }
  16621. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16622. // it returns an error otherwise.
  16623. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  16624. if _, ok := m.driver.(*txDriver); !ok {
  16625. return nil, errors.New("ent: mutation is not running in a transaction")
  16626. }
  16627. tx := &Tx{config: m.config}
  16628. tx.init()
  16629. return tx, nil
  16630. }
  16631. // SetID sets the value of the id field. Note that this
  16632. // operation is only accepted on creation of MessageRecords entities.
  16633. func (m *MessageRecordsMutation) SetID(id uint64) {
  16634. m.id = &id
  16635. }
  16636. // ID returns the ID value in the mutation. Note that the ID is only available
  16637. // if it was provided to the builder or after it was returned from the database.
  16638. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  16639. if m.id == nil {
  16640. return
  16641. }
  16642. return *m.id, true
  16643. }
  16644. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16645. // That means, if the mutation is applied within a transaction with an isolation level such
  16646. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16647. // or updated by the mutation.
  16648. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  16649. switch {
  16650. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16651. id, exists := m.ID()
  16652. if exists {
  16653. return []uint64{id}, nil
  16654. }
  16655. fallthrough
  16656. case m.op.Is(OpUpdate | OpDelete):
  16657. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  16658. default:
  16659. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16660. }
  16661. }
  16662. // SetCreatedAt sets the "created_at" field.
  16663. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  16664. m.created_at = &t
  16665. }
  16666. // CreatedAt returns the value of the "created_at" field in the mutation.
  16667. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  16668. v := m.created_at
  16669. if v == nil {
  16670. return
  16671. }
  16672. return *v, true
  16673. }
  16674. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  16675. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16677. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16678. if !m.op.Is(OpUpdateOne) {
  16679. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16680. }
  16681. if m.id == nil || m.oldValue == nil {
  16682. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16683. }
  16684. oldValue, err := m.oldValue(ctx)
  16685. if err != nil {
  16686. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16687. }
  16688. return oldValue.CreatedAt, nil
  16689. }
  16690. // ResetCreatedAt resets all changes to the "created_at" field.
  16691. func (m *MessageRecordsMutation) ResetCreatedAt() {
  16692. m.created_at = nil
  16693. }
  16694. // SetUpdatedAt sets the "updated_at" field.
  16695. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  16696. m.updated_at = &t
  16697. }
  16698. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16699. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  16700. v := m.updated_at
  16701. if v == nil {
  16702. return
  16703. }
  16704. return *v, true
  16705. }
  16706. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  16707. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16709. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16710. if !m.op.Is(OpUpdateOne) {
  16711. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16712. }
  16713. if m.id == nil || m.oldValue == nil {
  16714. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16715. }
  16716. oldValue, err := m.oldValue(ctx)
  16717. if err != nil {
  16718. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16719. }
  16720. return oldValue.UpdatedAt, nil
  16721. }
  16722. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16723. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  16724. m.updated_at = nil
  16725. }
  16726. // SetStatus sets the "status" field.
  16727. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  16728. m.status = &u
  16729. m.addstatus = nil
  16730. }
  16731. // Status returns the value of the "status" field in the mutation.
  16732. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  16733. v := m.status
  16734. if v == nil {
  16735. return
  16736. }
  16737. return *v, true
  16738. }
  16739. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  16740. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16742. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16743. if !m.op.Is(OpUpdateOne) {
  16744. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16745. }
  16746. if m.id == nil || m.oldValue == nil {
  16747. return v, errors.New("OldStatus requires an ID field in the mutation")
  16748. }
  16749. oldValue, err := m.oldValue(ctx)
  16750. if err != nil {
  16751. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16752. }
  16753. return oldValue.Status, nil
  16754. }
  16755. // AddStatus adds u to the "status" field.
  16756. func (m *MessageRecordsMutation) AddStatus(u int8) {
  16757. if m.addstatus != nil {
  16758. *m.addstatus += u
  16759. } else {
  16760. m.addstatus = &u
  16761. }
  16762. }
  16763. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16764. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  16765. v := m.addstatus
  16766. if v == nil {
  16767. return
  16768. }
  16769. return *v, true
  16770. }
  16771. // ClearStatus clears the value of the "status" field.
  16772. func (m *MessageRecordsMutation) ClearStatus() {
  16773. m.status = nil
  16774. m.addstatus = nil
  16775. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  16776. }
  16777. // StatusCleared returns if the "status" field was cleared in this mutation.
  16778. func (m *MessageRecordsMutation) StatusCleared() bool {
  16779. _, ok := m.clearedFields[messagerecords.FieldStatus]
  16780. return ok
  16781. }
  16782. // ResetStatus resets all changes to the "status" field.
  16783. func (m *MessageRecordsMutation) ResetStatus() {
  16784. m.status = nil
  16785. m.addstatus = nil
  16786. delete(m.clearedFields, messagerecords.FieldStatus)
  16787. }
  16788. // SetBotWxid sets the "bot_wxid" field.
  16789. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  16790. m.bot_wxid = &s
  16791. }
  16792. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  16793. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  16794. v := m.bot_wxid
  16795. if v == nil {
  16796. return
  16797. }
  16798. return *v, true
  16799. }
  16800. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  16801. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16803. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  16804. if !m.op.Is(OpUpdateOne) {
  16805. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  16806. }
  16807. if m.id == nil || m.oldValue == nil {
  16808. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  16809. }
  16810. oldValue, err := m.oldValue(ctx)
  16811. if err != nil {
  16812. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  16813. }
  16814. return oldValue.BotWxid, nil
  16815. }
  16816. // ResetBotWxid resets all changes to the "bot_wxid" field.
  16817. func (m *MessageRecordsMutation) ResetBotWxid() {
  16818. m.bot_wxid = nil
  16819. }
  16820. // SetContactID sets the "contact_id" field.
  16821. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  16822. m.message_contact = &u
  16823. }
  16824. // ContactID returns the value of the "contact_id" field in the mutation.
  16825. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  16826. v := m.message_contact
  16827. if v == nil {
  16828. return
  16829. }
  16830. return *v, true
  16831. }
  16832. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  16833. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16834. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16835. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  16836. if !m.op.Is(OpUpdateOne) {
  16837. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  16838. }
  16839. if m.id == nil || m.oldValue == nil {
  16840. return v, errors.New("OldContactID requires an ID field in the mutation")
  16841. }
  16842. oldValue, err := m.oldValue(ctx)
  16843. if err != nil {
  16844. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  16845. }
  16846. return oldValue.ContactID, nil
  16847. }
  16848. // ClearContactID clears the value of the "contact_id" field.
  16849. func (m *MessageRecordsMutation) ClearContactID() {
  16850. m.message_contact = nil
  16851. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  16852. }
  16853. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  16854. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  16855. _, ok := m.clearedFields[messagerecords.FieldContactID]
  16856. return ok
  16857. }
  16858. // ResetContactID resets all changes to the "contact_id" field.
  16859. func (m *MessageRecordsMutation) ResetContactID() {
  16860. m.message_contact = nil
  16861. delete(m.clearedFields, messagerecords.FieldContactID)
  16862. }
  16863. // SetContactType sets the "contact_type" field.
  16864. func (m *MessageRecordsMutation) SetContactType(i int) {
  16865. m.contact_type = &i
  16866. m.addcontact_type = nil
  16867. }
  16868. // ContactType returns the value of the "contact_type" field in the mutation.
  16869. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  16870. v := m.contact_type
  16871. if v == nil {
  16872. return
  16873. }
  16874. return *v, true
  16875. }
  16876. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  16877. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16879. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  16880. if !m.op.Is(OpUpdateOne) {
  16881. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  16882. }
  16883. if m.id == nil || m.oldValue == nil {
  16884. return v, errors.New("OldContactType requires an ID field in the mutation")
  16885. }
  16886. oldValue, err := m.oldValue(ctx)
  16887. if err != nil {
  16888. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  16889. }
  16890. return oldValue.ContactType, nil
  16891. }
  16892. // AddContactType adds i to the "contact_type" field.
  16893. func (m *MessageRecordsMutation) AddContactType(i int) {
  16894. if m.addcontact_type != nil {
  16895. *m.addcontact_type += i
  16896. } else {
  16897. m.addcontact_type = &i
  16898. }
  16899. }
  16900. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  16901. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  16902. v := m.addcontact_type
  16903. if v == nil {
  16904. return
  16905. }
  16906. return *v, true
  16907. }
  16908. // ResetContactType resets all changes to the "contact_type" field.
  16909. func (m *MessageRecordsMutation) ResetContactType() {
  16910. m.contact_type = nil
  16911. m.addcontact_type = nil
  16912. }
  16913. // SetContactWxid sets the "contact_wxid" field.
  16914. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  16915. m.contact_wxid = &s
  16916. }
  16917. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  16918. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  16919. v := m.contact_wxid
  16920. if v == nil {
  16921. return
  16922. }
  16923. return *v, true
  16924. }
  16925. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  16926. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16927. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16928. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  16929. if !m.op.Is(OpUpdateOne) {
  16930. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  16931. }
  16932. if m.id == nil || m.oldValue == nil {
  16933. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  16934. }
  16935. oldValue, err := m.oldValue(ctx)
  16936. if err != nil {
  16937. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  16938. }
  16939. return oldValue.ContactWxid, nil
  16940. }
  16941. // ResetContactWxid resets all changes to the "contact_wxid" field.
  16942. func (m *MessageRecordsMutation) ResetContactWxid() {
  16943. m.contact_wxid = nil
  16944. }
  16945. // SetContentType sets the "content_type" field.
  16946. func (m *MessageRecordsMutation) SetContentType(i int) {
  16947. m.content_type = &i
  16948. m.addcontent_type = nil
  16949. }
  16950. // ContentType returns the value of the "content_type" field in the mutation.
  16951. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  16952. v := m.content_type
  16953. if v == nil {
  16954. return
  16955. }
  16956. return *v, true
  16957. }
  16958. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  16959. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16960. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16961. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  16962. if !m.op.Is(OpUpdateOne) {
  16963. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  16964. }
  16965. if m.id == nil || m.oldValue == nil {
  16966. return v, errors.New("OldContentType requires an ID field in the mutation")
  16967. }
  16968. oldValue, err := m.oldValue(ctx)
  16969. if err != nil {
  16970. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  16971. }
  16972. return oldValue.ContentType, nil
  16973. }
  16974. // AddContentType adds i to the "content_type" field.
  16975. func (m *MessageRecordsMutation) AddContentType(i int) {
  16976. if m.addcontent_type != nil {
  16977. *m.addcontent_type += i
  16978. } else {
  16979. m.addcontent_type = &i
  16980. }
  16981. }
  16982. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  16983. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  16984. v := m.addcontent_type
  16985. if v == nil {
  16986. return
  16987. }
  16988. return *v, true
  16989. }
  16990. // ResetContentType resets all changes to the "content_type" field.
  16991. func (m *MessageRecordsMutation) ResetContentType() {
  16992. m.content_type = nil
  16993. m.addcontent_type = nil
  16994. }
  16995. // SetContent sets the "content" field.
  16996. func (m *MessageRecordsMutation) SetContent(s string) {
  16997. m.content = &s
  16998. }
  16999. // Content returns the value of the "content" field in the mutation.
  17000. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  17001. v := m.content
  17002. if v == nil {
  17003. return
  17004. }
  17005. return *v, true
  17006. }
  17007. // OldContent returns the old "content" field's value of the MessageRecords entity.
  17008. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17010. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  17011. if !m.op.Is(OpUpdateOne) {
  17012. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  17013. }
  17014. if m.id == nil || m.oldValue == nil {
  17015. return v, errors.New("OldContent requires an ID field in the mutation")
  17016. }
  17017. oldValue, err := m.oldValue(ctx)
  17018. if err != nil {
  17019. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  17020. }
  17021. return oldValue.Content, nil
  17022. }
  17023. // ResetContent resets all changes to the "content" field.
  17024. func (m *MessageRecordsMutation) ResetContent() {
  17025. m.content = nil
  17026. }
  17027. // SetMeta sets the "meta" field.
  17028. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  17029. m.meta = &ct
  17030. }
  17031. // Meta returns the value of the "meta" field in the mutation.
  17032. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  17033. v := m.meta
  17034. if v == nil {
  17035. return
  17036. }
  17037. return *v, true
  17038. }
  17039. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  17040. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17042. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  17043. if !m.op.Is(OpUpdateOne) {
  17044. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  17045. }
  17046. if m.id == nil || m.oldValue == nil {
  17047. return v, errors.New("OldMeta requires an ID field in the mutation")
  17048. }
  17049. oldValue, err := m.oldValue(ctx)
  17050. if err != nil {
  17051. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  17052. }
  17053. return oldValue.Meta, nil
  17054. }
  17055. // ClearMeta clears the value of the "meta" field.
  17056. func (m *MessageRecordsMutation) ClearMeta() {
  17057. m.meta = nil
  17058. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  17059. }
  17060. // MetaCleared returns if the "meta" field was cleared in this mutation.
  17061. func (m *MessageRecordsMutation) MetaCleared() bool {
  17062. _, ok := m.clearedFields[messagerecords.FieldMeta]
  17063. return ok
  17064. }
  17065. // ResetMeta resets all changes to the "meta" field.
  17066. func (m *MessageRecordsMutation) ResetMeta() {
  17067. m.meta = nil
  17068. delete(m.clearedFields, messagerecords.FieldMeta)
  17069. }
  17070. // SetErrorDetail sets the "error_detail" field.
  17071. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  17072. m.error_detail = &s
  17073. }
  17074. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  17075. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  17076. v := m.error_detail
  17077. if v == nil {
  17078. return
  17079. }
  17080. return *v, true
  17081. }
  17082. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  17083. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17084. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17085. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  17086. if !m.op.Is(OpUpdateOne) {
  17087. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  17088. }
  17089. if m.id == nil || m.oldValue == nil {
  17090. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  17091. }
  17092. oldValue, err := m.oldValue(ctx)
  17093. if err != nil {
  17094. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  17095. }
  17096. return oldValue.ErrorDetail, nil
  17097. }
  17098. // ResetErrorDetail resets all changes to the "error_detail" field.
  17099. func (m *MessageRecordsMutation) ResetErrorDetail() {
  17100. m.error_detail = nil
  17101. }
  17102. // SetSendTime sets the "send_time" field.
  17103. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  17104. m.send_time = &t
  17105. }
  17106. // SendTime returns the value of the "send_time" field in the mutation.
  17107. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  17108. v := m.send_time
  17109. if v == nil {
  17110. return
  17111. }
  17112. return *v, true
  17113. }
  17114. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  17115. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17116. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17117. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  17118. if !m.op.Is(OpUpdateOne) {
  17119. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  17120. }
  17121. if m.id == nil || m.oldValue == nil {
  17122. return v, errors.New("OldSendTime requires an ID field in the mutation")
  17123. }
  17124. oldValue, err := m.oldValue(ctx)
  17125. if err != nil {
  17126. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  17127. }
  17128. return oldValue.SendTime, nil
  17129. }
  17130. // ClearSendTime clears the value of the "send_time" field.
  17131. func (m *MessageRecordsMutation) ClearSendTime() {
  17132. m.send_time = nil
  17133. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  17134. }
  17135. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  17136. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  17137. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  17138. return ok
  17139. }
  17140. // ResetSendTime resets all changes to the "send_time" field.
  17141. func (m *MessageRecordsMutation) ResetSendTime() {
  17142. m.send_time = nil
  17143. delete(m.clearedFields, messagerecords.FieldSendTime)
  17144. }
  17145. // SetSourceType sets the "source_type" field.
  17146. func (m *MessageRecordsMutation) SetSourceType(i int) {
  17147. m.source_type = &i
  17148. m.addsource_type = nil
  17149. }
  17150. // SourceType returns the value of the "source_type" field in the mutation.
  17151. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  17152. v := m.source_type
  17153. if v == nil {
  17154. return
  17155. }
  17156. return *v, true
  17157. }
  17158. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  17159. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17160. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17161. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  17162. if !m.op.Is(OpUpdateOne) {
  17163. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  17164. }
  17165. if m.id == nil || m.oldValue == nil {
  17166. return v, errors.New("OldSourceType requires an ID field in the mutation")
  17167. }
  17168. oldValue, err := m.oldValue(ctx)
  17169. if err != nil {
  17170. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  17171. }
  17172. return oldValue.SourceType, nil
  17173. }
  17174. // AddSourceType adds i to the "source_type" field.
  17175. func (m *MessageRecordsMutation) AddSourceType(i int) {
  17176. if m.addsource_type != nil {
  17177. *m.addsource_type += i
  17178. } else {
  17179. m.addsource_type = &i
  17180. }
  17181. }
  17182. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  17183. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  17184. v := m.addsource_type
  17185. if v == nil {
  17186. return
  17187. }
  17188. return *v, true
  17189. }
  17190. // ResetSourceType resets all changes to the "source_type" field.
  17191. func (m *MessageRecordsMutation) ResetSourceType() {
  17192. m.source_type = nil
  17193. m.addsource_type = nil
  17194. }
  17195. // SetSourceID sets the "source_id" field.
  17196. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  17197. m.sop_stage = &u
  17198. }
  17199. // SourceID returns the value of the "source_id" field in the mutation.
  17200. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  17201. v := m.sop_stage
  17202. if v == nil {
  17203. return
  17204. }
  17205. return *v, true
  17206. }
  17207. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  17208. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17210. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  17211. if !m.op.Is(OpUpdateOne) {
  17212. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  17213. }
  17214. if m.id == nil || m.oldValue == nil {
  17215. return v, errors.New("OldSourceID requires an ID field in the mutation")
  17216. }
  17217. oldValue, err := m.oldValue(ctx)
  17218. if err != nil {
  17219. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  17220. }
  17221. return oldValue.SourceID, nil
  17222. }
  17223. // ClearSourceID clears the value of the "source_id" field.
  17224. func (m *MessageRecordsMutation) ClearSourceID() {
  17225. m.sop_stage = nil
  17226. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  17227. }
  17228. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  17229. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  17230. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  17231. return ok
  17232. }
  17233. // ResetSourceID resets all changes to the "source_id" field.
  17234. func (m *MessageRecordsMutation) ResetSourceID() {
  17235. m.sop_stage = nil
  17236. delete(m.clearedFields, messagerecords.FieldSourceID)
  17237. }
  17238. // SetSubSourceID sets the "sub_source_id" field.
  17239. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  17240. m.sop_node = &u
  17241. }
  17242. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  17243. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  17244. v := m.sop_node
  17245. if v == nil {
  17246. return
  17247. }
  17248. return *v, true
  17249. }
  17250. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  17251. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17253. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  17254. if !m.op.Is(OpUpdateOne) {
  17255. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  17256. }
  17257. if m.id == nil || m.oldValue == nil {
  17258. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  17259. }
  17260. oldValue, err := m.oldValue(ctx)
  17261. if err != nil {
  17262. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  17263. }
  17264. return oldValue.SubSourceID, nil
  17265. }
  17266. // ClearSubSourceID clears the value of the "sub_source_id" field.
  17267. func (m *MessageRecordsMutation) ClearSubSourceID() {
  17268. m.sop_node = nil
  17269. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  17270. }
  17271. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  17272. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  17273. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  17274. return ok
  17275. }
  17276. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  17277. func (m *MessageRecordsMutation) ResetSubSourceID() {
  17278. m.sop_node = nil
  17279. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  17280. }
  17281. // SetOrganizationID sets the "organization_id" field.
  17282. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  17283. m.organization_id = &u
  17284. m.addorganization_id = nil
  17285. }
  17286. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17287. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  17288. v := m.organization_id
  17289. if v == nil {
  17290. return
  17291. }
  17292. return *v, true
  17293. }
  17294. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  17295. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17296. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17297. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17298. if !m.op.Is(OpUpdateOne) {
  17299. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17300. }
  17301. if m.id == nil || m.oldValue == nil {
  17302. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17303. }
  17304. oldValue, err := m.oldValue(ctx)
  17305. if err != nil {
  17306. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17307. }
  17308. return oldValue.OrganizationID, nil
  17309. }
  17310. // AddOrganizationID adds u to the "organization_id" field.
  17311. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  17312. if m.addorganization_id != nil {
  17313. *m.addorganization_id += u
  17314. } else {
  17315. m.addorganization_id = &u
  17316. }
  17317. }
  17318. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17319. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  17320. v := m.addorganization_id
  17321. if v == nil {
  17322. return
  17323. }
  17324. return *v, true
  17325. }
  17326. // ClearOrganizationID clears the value of the "organization_id" field.
  17327. func (m *MessageRecordsMutation) ClearOrganizationID() {
  17328. m.organization_id = nil
  17329. m.addorganization_id = nil
  17330. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  17331. }
  17332. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17333. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  17334. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  17335. return ok
  17336. }
  17337. // ResetOrganizationID resets all changes to the "organization_id" field.
  17338. func (m *MessageRecordsMutation) ResetOrganizationID() {
  17339. m.organization_id = nil
  17340. m.addorganization_id = nil
  17341. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  17342. }
  17343. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  17344. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  17345. m.sop_stage = &id
  17346. }
  17347. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  17348. func (m *MessageRecordsMutation) ClearSopStage() {
  17349. m.clearedsop_stage = true
  17350. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  17351. }
  17352. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  17353. func (m *MessageRecordsMutation) SopStageCleared() bool {
  17354. return m.SourceIDCleared() || m.clearedsop_stage
  17355. }
  17356. // SopStageID returns the "sop_stage" edge ID in the mutation.
  17357. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  17358. if m.sop_stage != nil {
  17359. return *m.sop_stage, true
  17360. }
  17361. return
  17362. }
  17363. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  17364. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17365. // SopStageID instead. It exists only for internal usage by the builders.
  17366. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  17367. if id := m.sop_stage; id != nil {
  17368. ids = append(ids, *id)
  17369. }
  17370. return
  17371. }
  17372. // ResetSopStage resets all changes to the "sop_stage" edge.
  17373. func (m *MessageRecordsMutation) ResetSopStage() {
  17374. m.sop_stage = nil
  17375. m.clearedsop_stage = false
  17376. }
  17377. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  17378. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  17379. m.sop_node = &id
  17380. }
  17381. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  17382. func (m *MessageRecordsMutation) ClearSopNode() {
  17383. m.clearedsop_node = true
  17384. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  17385. }
  17386. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  17387. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  17388. return m.SubSourceIDCleared() || m.clearedsop_node
  17389. }
  17390. // SopNodeID returns the "sop_node" edge ID in the mutation.
  17391. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  17392. if m.sop_node != nil {
  17393. return *m.sop_node, true
  17394. }
  17395. return
  17396. }
  17397. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  17398. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17399. // SopNodeID instead. It exists only for internal usage by the builders.
  17400. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  17401. if id := m.sop_node; id != nil {
  17402. ids = append(ids, *id)
  17403. }
  17404. return
  17405. }
  17406. // ResetSopNode resets all changes to the "sop_node" edge.
  17407. func (m *MessageRecordsMutation) ResetSopNode() {
  17408. m.sop_node = nil
  17409. m.clearedsop_node = false
  17410. }
  17411. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  17412. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  17413. m.message_contact = &id
  17414. }
  17415. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  17416. func (m *MessageRecordsMutation) ClearMessageContact() {
  17417. m.clearedmessage_contact = true
  17418. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  17419. }
  17420. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  17421. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  17422. return m.ContactIDCleared() || m.clearedmessage_contact
  17423. }
  17424. // MessageContactID returns the "message_contact" edge ID in the mutation.
  17425. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  17426. if m.message_contact != nil {
  17427. return *m.message_contact, true
  17428. }
  17429. return
  17430. }
  17431. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  17432. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17433. // MessageContactID instead. It exists only for internal usage by the builders.
  17434. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  17435. if id := m.message_contact; id != nil {
  17436. ids = append(ids, *id)
  17437. }
  17438. return
  17439. }
  17440. // ResetMessageContact resets all changes to the "message_contact" edge.
  17441. func (m *MessageRecordsMutation) ResetMessageContact() {
  17442. m.message_contact = nil
  17443. m.clearedmessage_contact = false
  17444. }
  17445. // Where appends a list predicates to the MessageRecordsMutation builder.
  17446. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  17447. m.predicates = append(m.predicates, ps...)
  17448. }
  17449. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  17450. // users can use type-assertion to append predicates that do not depend on any generated package.
  17451. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  17452. p := make([]predicate.MessageRecords, len(ps))
  17453. for i := range ps {
  17454. p[i] = ps[i]
  17455. }
  17456. m.Where(p...)
  17457. }
  17458. // Op returns the operation name.
  17459. func (m *MessageRecordsMutation) Op() Op {
  17460. return m.op
  17461. }
  17462. // SetOp allows setting the mutation operation.
  17463. func (m *MessageRecordsMutation) SetOp(op Op) {
  17464. m.op = op
  17465. }
  17466. // Type returns the node type of this mutation (MessageRecords).
  17467. func (m *MessageRecordsMutation) Type() string {
  17468. return m.typ
  17469. }
  17470. // Fields returns all fields that were changed during this mutation. Note that in
  17471. // order to get all numeric fields that were incremented/decremented, call
  17472. // AddedFields().
  17473. func (m *MessageRecordsMutation) Fields() []string {
  17474. fields := make([]string, 0, 16)
  17475. if m.created_at != nil {
  17476. fields = append(fields, messagerecords.FieldCreatedAt)
  17477. }
  17478. if m.updated_at != nil {
  17479. fields = append(fields, messagerecords.FieldUpdatedAt)
  17480. }
  17481. if m.status != nil {
  17482. fields = append(fields, messagerecords.FieldStatus)
  17483. }
  17484. if m.bot_wxid != nil {
  17485. fields = append(fields, messagerecords.FieldBotWxid)
  17486. }
  17487. if m.message_contact != nil {
  17488. fields = append(fields, messagerecords.FieldContactID)
  17489. }
  17490. if m.contact_type != nil {
  17491. fields = append(fields, messagerecords.FieldContactType)
  17492. }
  17493. if m.contact_wxid != nil {
  17494. fields = append(fields, messagerecords.FieldContactWxid)
  17495. }
  17496. if m.content_type != nil {
  17497. fields = append(fields, messagerecords.FieldContentType)
  17498. }
  17499. if m.content != nil {
  17500. fields = append(fields, messagerecords.FieldContent)
  17501. }
  17502. if m.meta != nil {
  17503. fields = append(fields, messagerecords.FieldMeta)
  17504. }
  17505. if m.error_detail != nil {
  17506. fields = append(fields, messagerecords.FieldErrorDetail)
  17507. }
  17508. if m.send_time != nil {
  17509. fields = append(fields, messagerecords.FieldSendTime)
  17510. }
  17511. if m.source_type != nil {
  17512. fields = append(fields, messagerecords.FieldSourceType)
  17513. }
  17514. if m.sop_stage != nil {
  17515. fields = append(fields, messagerecords.FieldSourceID)
  17516. }
  17517. if m.sop_node != nil {
  17518. fields = append(fields, messagerecords.FieldSubSourceID)
  17519. }
  17520. if m.organization_id != nil {
  17521. fields = append(fields, messagerecords.FieldOrganizationID)
  17522. }
  17523. return fields
  17524. }
  17525. // Field returns the value of a field with the given name. The second boolean
  17526. // return value indicates that this field was not set, or was not defined in the
  17527. // schema.
  17528. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  17529. switch name {
  17530. case messagerecords.FieldCreatedAt:
  17531. return m.CreatedAt()
  17532. case messagerecords.FieldUpdatedAt:
  17533. return m.UpdatedAt()
  17534. case messagerecords.FieldStatus:
  17535. return m.Status()
  17536. case messagerecords.FieldBotWxid:
  17537. return m.BotWxid()
  17538. case messagerecords.FieldContactID:
  17539. return m.ContactID()
  17540. case messagerecords.FieldContactType:
  17541. return m.ContactType()
  17542. case messagerecords.FieldContactWxid:
  17543. return m.ContactWxid()
  17544. case messagerecords.FieldContentType:
  17545. return m.ContentType()
  17546. case messagerecords.FieldContent:
  17547. return m.Content()
  17548. case messagerecords.FieldMeta:
  17549. return m.Meta()
  17550. case messagerecords.FieldErrorDetail:
  17551. return m.ErrorDetail()
  17552. case messagerecords.FieldSendTime:
  17553. return m.SendTime()
  17554. case messagerecords.FieldSourceType:
  17555. return m.SourceType()
  17556. case messagerecords.FieldSourceID:
  17557. return m.SourceID()
  17558. case messagerecords.FieldSubSourceID:
  17559. return m.SubSourceID()
  17560. case messagerecords.FieldOrganizationID:
  17561. return m.OrganizationID()
  17562. }
  17563. return nil, false
  17564. }
  17565. // OldField returns the old value of the field from the database. An error is
  17566. // returned if the mutation operation is not UpdateOne, or the query to the
  17567. // database failed.
  17568. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17569. switch name {
  17570. case messagerecords.FieldCreatedAt:
  17571. return m.OldCreatedAt(ctx)
  17572. case messagerecords.FieldUpdatedAt:
  17573. return m.OldUpdatedAt(ctx)
  17574. case messagerecords.FieldStatus:
  17575. return m.OldStatus(ctx)
  17576. case messagerecords.FieldBotWxid:
  17577. return m.OldBotWxid(ctx)
  17578. case messagerecords.FieldContactID:
  17579. return m.OldContactID(ctx)
  17580. case messagerecords.FieldContactType:
  17581. return m.OldContactType(ctx)
  17582. case messagerecords.FieldContactWxid:
  17583. return m.OldContactWxid(ctx)
  17584. case messagerecords.FieldContentType:
  17585. return m.OldContentType(ctx)
  17586. case messagerecords.FieldContent:
  17587. return m.OldContent(ctx)
  17588. case messagerecords.FieldMeta:
  17589. return m.OldMeta(ctx)
  17590. case messagerecords.FieldErrorDetail:
  17591. return m.OldErrorDetail(ctx)
  17592. case messagerecords.FieldSendTime:
  17593. return m.OldSendTime(ctx)
  17594. case messagerecords.FieldSourceType:
  17595. return m.OldSourceType(ctx)
  17596. case messagerecords.FieldSourceID:
  17597. return m.OldSourceID(ctx)
  17598. case messagerecords.FieldSubSourceID:
  17599. return m.OldSubSourceID(ctx)
  17600. case messagerecords.FieldOrganizationID:
  17601. return m.OldOrganizationID(ctx)
  17602. }
  17603. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  17604. }
  17605. // SetField sets the value of a field with the given name. It returns an error if
  17606. // the field is not defined in the schema, or if the type mismatched the field
  17607. // type.
  17608. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  17609. switch name {
  17610. case messagerecords.FieldCreatedAt:
  17611. v, ok := value.(time.Time)
  17612. if !ok {
  17613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17614. }
  17615. m.SetCreatedAt(v)
  17616. return nil
  17617. case messagerecords.FieldUpdatedAt:
  17618. v, ok := value.(time.Time)
  17619. if !ok {
  17620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17621. }
  17622. m.SetUpdatedAt(v)
  17623. return nil
  17624. case messagerecords.FieldStatus:
  17625. v, ok := value.(uint8)
  17626. if !ok {
  17627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17628. }
  17629. m.SetStatus(v)
  17630. return nil
  17631. case messagerecords.FieldBotWxid:
  17632. v, ok := value.(string)
  17633. if !ok {
  17634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17635. }
  17636. m.SetBotWxid(v)
  17637. return nil
  17638. case messagerecords.FieldContactID:
  17639. v, ok := value.(uint64)
  17640. if !ok {
  17641. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17642. }
  17643. m.SetContactID(v)
  17644. return nil
  17645. case messagerecords.FieldContactType:
  17646. v, ok := value.(int)
  17647. if !ok {
  17648. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17649. }
  17650. m.SetContactType(v)
  17651. return nil
  17652. case messagerecords.FieldContactWxid:
  17653. v, ok := value.(string)
  17654. if !ok {
  17655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17656. }
  17657. m.SetContactWxid(v)
  17658. return nil
  17659. case messagerecords.FieldContentType:
  17660. v, ok := value.(int)
  17661. if !ok {
  17662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17663. }
  17664. m.SetContentType(v)
  17665. return nil
  17666. case messagerecords.FieldContent:
  17667. v, ok := value.(string)
  17668. if !ok {
  17669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17670. }
  17671. m.SetContent(v)
  17672. return nil
  17673. case messagerecords.FieldMeta:
  17674. v, ok := value.(custom_types.Meta)
  17675. if !ok {
  17676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17677. }
  17678. m.SetMeta(v)
  17679. return nil
  17680. case messagerecords.FieldErrorDetail:
  17681. v, ok := value.(string)
  17682. if !ok {
  17683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17684. }
  17685. m.SetErrorDetail(v)
  17686. return nil
  17687. case messagerecords.FieldSendTime:
  17688. v, ok := value.(time.Time)
  17689. if !ok {
  17690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17691. }
  17692. m.SetSendTime(v)
  17693. return nil
  17694. case messagerecords.FieldSourceType:
  17695. v, ok := value.(int)
  17696. if !ok {
  17697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17698. }
  17699. m.SetSourceType(v)
  17700. return nil
  17701. case messagerecords.FieldSourceID:
  17702. v, ok := value.(uint64)
  17703. if !ok {
  17704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17705. }
  17706. m.SetSourceID(v)
  17707. return nil
  17708. case messagerecords.FieldSubSourceID:
  17709. v, ok := value.(uint64)
  17710. if !ok {
  17711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17712. }
  17713. m.SetSubSourceID(v)
  17714. return nil
  17715. case messagerecords.FieldOrganizationID:
  17716. v, ok := value.(uint64)
  17717. if !ok {
  17718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17719. }
  17720. m.SetOrganizationID(v)
  17721. return nil
  17722. }
  17723. return fmt.Errorf("unknown MessageRecords field %s", name)
  17724. }
  17725. // AddedFields returns all numeric fields that were incremented/decremented during
  17726. // this mutation.
  17727. func (m *MessageRecordsMutation) AddedFields() []string {
  17728. var fields []string
  17729. if m.addstatus != nil {
  17730. fields = append(fields, messagerecords.FieldStatus)
  17731. }
  17732. if m.addcontact_type != nil {
  17733. fields = append(fields, messagerecords.FieldContactType)
  17734. }
  17735. if m.addcontent_type != nil {
  17736. fields = append(fields, messagerecords.FieldContentType)
  17737. }
  17738. if m.addsource_type != nil {
  17739. fields = append(fields, messagerecords.FieldSourceType)
  17740. }
  17741. if m.addorganization_id != nil {
  17742. fields = append(fields, messagerecords.FieldOrganizationID)
  17743. }
  17744. return fields
  17745. }
  17746. // AddedField returns the numeric value that was incremented/decremented on a field
  17747. // with the given name. The second boolean return value indicates that this field
  17748. // was not set, or was not defined in the schema.
  17749. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  17750. switch name {
  17751. case messagerecords.FieldStatus:
  17752. return m.AddedStatus()
  17753. case messagerecords.FieldContactType:
  17754. return m.AddedContactType()
  17755. case messagerecords.FieldContentType:
  17756. return m.AddedContentType()
  17757. case messagerecords.FieldSourceType:
  17758. return m.AddedSourceType()
  17759. case messagerecords.FieldOrganizationID:
  17760. return m.AddedOrganizationID()
  17761. }
  17762. return nil, false
  17763. }
  17764. // AddField adds the value to the field with the given name. It returns an error if
  17765. // the field is not defined in the schema, or if the type mismatched the field
  17766. // type.
  17767. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  17768. switch name {
  17769. case messagerecords.FieldStatus:
  17770. v, ok := value.(int8)
  17771. if !ok {
  17772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17773. }
  17774. m.AddStatus(v)
  17775. return nil
  17776. case messagerecords.FieldContactType:
  17777. v, ok := value.(int)
  17778. if !ok {
  17779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17780. }
  17781. m.AddContactType(v)
  17782. return nil
  17783. case messagerecords.FieldContentType:
  17784. v, ok := value.(int)
  17785. if !ok {
  17786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17787. }
  17788. m.AddContentType(v)
  17789. return nil
  17790. case messagerecords.FieldSourceType:
  17791. v, ok := value.(int)
  17792. if !ok {
  17793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17794. }
  17795. m.AddSourceType(v)
  17796. return nil
  17797. case messagerecords.FieldOrganizationID:
  17798. v, ok := value.(int64)
  17799. if !ok {
  17800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17801. }
  17802. m.AddOrganizationID(v)
  17803. return nil
  17804. }
  17805. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  17806. }
  17807. // ClearedFields returns all nullable fields that were cleared during this
  17808. // mutation.
  17809. func (m *MessageRecordsMutation) ClearedFields() []string {
  17810. var fields []string
  17811. if m.FieldCleared(messagerecords.FieldStatus) {
  17812. fields = append(fields, messagerecords.FieldStatus)
  17813. }
  17814. if m.FieldCleared(messagerecords.FieldContactID) {
  17815. fields = append(fields, messagerecords.FieldContactID)
  17816. }
  17817. if m.FieldCleared(messagerecords.FieldMeta) {
  17818. fields = append(fields, messagerecords.FieldMeta)
  17819. }
  17820. if m.FieldCleared(messagerecords.FieldSendTime) {
  17821. fields = append(fields, messagerecords.FieldSendTime)
  17822. }
  17823. if m.FieldCleared(messagerecords.FieldSourceID) {
  17824. fields = append(fields, messagerecords.FieldSourceID)
  17825. }
  17826. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  17827. fields = append(fields, messagerecords.FieldSubSourceID)
  17828. }
  17829. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  17830. fields = append(fields, messagerecords.FieldOrganizationID)
  17831. }
  17832. return fields
  17833. }
  17834. // FieldCleared returns a boolean indicating if a field with the given name was
  17835. // cleared in this mutation.
  17836. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  17837. _, ok := m.clearedFields[name]
  17838. return ok
  17839. }
  17840. // ClearField clears the value of the field with the given name. It returns an
  17841. // error if the field is not defined in the schema.
  17842. func (m *MessageRecordsMutation) ClearField(name string) error {
  17843. switch name {
  17844. case messagerecords.FieldStatus:
  17845. m.ClearStatus()
  17846. return nil
  17847. case messagerecords.FieldContactID:
  17848. m.ClearContactID()
  17849. return nil
  17850. case messagerecords.FieldMeta:
  17851. m.ClearMeta()
  17852. return nil
  17853. case messagerecords.FieldSendTime:
  17854. m.ClearSendTime()
  17855. return nil
  17856. case messagerecords.FieldSourceID:
  17857. m.ClearSourceID()
  17858. return nil
  17859. case messagerecords.FieldSubSourceID:
  17860. m.ClearSubSourceID()
  17861. return nil
  17862. case messagerecords.FieldOrganizationID:
  17863. m.ClearOrganizationID()
  17864. return nil
  17865. }
  17866. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  17867. }
  17868. // ResetField resets all changes in the mutation for the field with the given name.
  17869. // It returns an error if the field is not defined in the schema.
  17870. func (m *MessageRecordsMutation) ResetField(name string) error {
  17871. switch name {
  17872. case messagerecords.FieldCreatedAt:
  17873. m.ResetCreatedAt()
  17874. return nil
  17875. case messagerecords.FieldUpdatedAt:
  17876. m.ResetUpdatedAt()
  17877. return nil
  17878. case messagerecords.FieldStatus:
  17879. m.ResetStatus()
  17880. return nil
  17881. case messagerecords.FieldBotWxid:
  17882. m.ResetBotWxid()
  17883. return nil
  17884. case messagerecords.FieldContactID:
  17885. m.ResetContactID()
  17886. return nil
  17887. case messagerecords.FieldContactType:
  17888. m.ResetContactType()
  17889. return nil
  17890. case messagerecords.FieldContactWxid:
  17891. m.ResetContactWxid()
  17892. return nil
  17893. case messagerecords.FieldContentType:
  17894. m.ResetContentType()
  17895. return nil
  17896. case messagerecords.FieldContent:
  17897. m.ResetContent()
  17898. return nil
  17899. case messagerecords.FieldMeta:
  17900. m.ResetMeta()
  17901. return nil
  17902. case messagerecords.FieldErrorDetail:
  17903. m.ResetErrorDetail()
  17904. return nil
  17905. case messagerecords.FieldSendTime:
  17906. m.ResetSendTime()
  17907. return nil
  17908. case messagerecords.FieldSourceType:
  17909. m.ResetSourceType()
  17910. return nil
  17911. case messagerecords.FieldSourceID:
  17912. m.ResetSourceID()
  17913. return nil
  17914. case messagerecords.FieldSubSourceID:
  17915. m.ResetSubSourceID()
  17916. return nil
  17917. case messagerecords.FieldOrganizationID:
  17918. m.ResetOrganizationID()
  17919. return nil
  17920. }
  17921. return fmt.Errorf("unknown MessageRecords field %s", name)
  17922. }
  17923. // AddedEdges returns all edge names that were set/added in this mutation.
  17924. func (m *MessageRecordsMutation) AddedEdges() []string {
  17925. edges := make([]string, 0, 3)
  17926. if m.sop_stage != nil {
  17927. edges = append(edges, messagerecords.EdgeSopStage)
  17928. }
  17929. if m.sop_node != nil {
  17930. edges = append(edges, messagerecords.EdgeSopNode)
  17931. }
  17932. if m.message_contact != nil {
  17933. edges = append(edges, messagerecords.EdgeMessageContact)
  17934. }
  17935. return edges
  17936. }
  17937. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17938. // name in this mutation.
  17939. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  17940. switch name {
  17941. case messagerecords.EdgeSopStage:
  17942. if id := m.sop_stage; id != nil {
  17943. return []ent.Value{*id}
  17944. }
  17945. case messagerecords.EdgeSopNode:
  17946. if id := m.sop_node; id != nil {
  17947. return []ent.Value{*id}
  17948. }
  17949. case messagerecords.EdgeMessageContact:
  17950. if id := m.message_contact; id != nil {
  17951. return []ent.Value{*id}
  17952. }
  17953. }
  17954. return nil
  17955. }
  17956. // RemovedEdges returns all edge names that were removed in this mutation.
  17957. func (m *MessageRecordsMutation) RemovedEdges() []string {
  17958. edges := make([]string, 0, 3)
  17959. return edges
  17960. }
  17961. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17962. // the given name in this mutation.
  17963. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  17964. return nil
  17965. }
  17966. // ClearedEdges returns all edge names that were cleared in this mutation.
  17967. func (m *MessageRecordsMutation) ClearedEdges() []string {
  17968. edges := make([]string, 0, 3)
  17969. if m.clearedsop_stage {
  17970. edges = append(edges, messagerecords.EdgeSopStage)
  17971. }
  17972. if m.clearedsop_node {
  17973. edges = append(edges, messagerecords.EdgeSopNode)
  17974. }
  17975. if m.clearedmessage_contact {
  17976. edges = append(edges, messagerecords.EdgeMessageContact)
  17977. }
  17978. return edges
  17979. }
  17980. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17981. // was cleared in this mutation.
  17982. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  17983. switch name {
  17984. case messagerecords.EdgeSopStage:
  17985. return m.clearedsop_stage
  17986. case messagerecords.EdgeSopNode:
  17987. return m.clearedsop_node
  17988. case messagerecords.EdgeMessageContact:
  17989. return m.clearedmessage_contact
  17990. }
  17991. return false
  17992. }
  17993. // ClearEdge clears the value of the edge with the given name. It returns an error
  17994. // if that edge is not defined in the schema.
  17995. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  17996. switch name {
  17997. case messagerecords.EdgeSopStage:
  17998. m.ClearSopStage()
  17999. return nil
  18000. case messagerecords.EdgeSopNode:
  18001. m.ClearSopNode()
  18002. return nil
  18003. case messagerecords.EdgeMessageContact:
  18004. m.ClearMessageContact()
  18005. return nil
  18006. }
  18007. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  18008. }
  18009. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18010. // It returns an error if the edge is not defined in the schema.
  18011. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  18012. switch name {
  18013. case messagerecords.EdgeSopStage:
  18014. m.ResetSopStage()
  18015. return nil
  18016. case messagerecords.EdgeSopNode:
  18017. m.ResetSopNode()
  18018. return nil
  18019. case messagerecords.EdgeMessageContact:
  18020. m.ResetMessageContact()
  18021. return nil
  18022. }
  18023. return fmt.Errorf("unknown MessageRecords edge %s", name)
  18024. }
  18025. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  18026. type MsgMutation struct {
  18027. config
  18028. op Op
  18029. typ string
  18030. id *uint64
  18031. created_at *time.Time
  18032. updated_at *time.Time
  18033. deleted_at *time.Time
  18034. status *uint8
  18035. addstatus *int8
  18036. fromwxid *string
  18037. toid *string
  18038. msgtype *int32
  18039. addmsgtype *int32
  18040. msg *string
  18041. batch_no *string
  18042. clearedFields map[string]struct{}
  18043. done bool
  18044. oldValue func(context.Context) (*Msg, error)
  18045. predicates []predicate.Msg
  18046. }
  18047. var _ ent.Mutation = (*MsgMutation)(nil)
  18048. // msgOption allows management of the mutation configuration using functional options.
  18049. type msgOption func(*MsgMutation)
  18050. // newMsgMutation creates new mutation for the Msg entity.
  18051. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  18052. m := &MsgMutation{
  18053. config: c,
  18054. op: op,
  18055. typ: TypeMsg,
  18056. clearedFields: make(map[string]struct{}),
  18057. }
  18058. for _, opt := range opts {
  18059. opt(m)
  18060. }
  18061. return m
  18062. }
  18063. // withMsgID sets the ID field of the mutation.
  18064. func withMsgID(id uint64) msgOption {
  18065. return func(m *MsgMutation) {
  18066. var (
  18067. err error
  18068. once sync.Once
  18069. value *Msg
  18070. )
  18071. m.oldValue = func(ctx context.Context) (*Msg, error) {
  18072. once.Do(func() {
  18073. if m.done {
  18074. err = errors.New("querying old values post mutation is not allowed")
  18075. } else {
  18076. value, err = m.Client().Msg.Get(ctx, id)
  18077. }
  18078. })
  18079. return value, err
  18080. }
  18081. m.id = &id
  18082. }
  18083. }
  18084. // withMsg sets the old Msg of the mutation.
  18085. func withMsg(node *Msg) msgOption {
  18086. return func(m *MsgMutation) {
  18087. m.oldValue = func(context.Context) (*Msg, error) {
  18088. return node, nil
  18089. }
  18090. m.id = &node.ID
  18091. }
  18092. }
  18093. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18094. // executed in a transaction (ent.Tx), a transactional client is returned.
  18095. func (m MsgMutation) Client() *Client {
  18096. client := &Client{config: m.config}
  18097. client.init()
  18098. return client
  18099. }
  18100. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18101. // it returns an error otherwise.
  18102. func (m MsgMutation) Tx() (*Tx, error) {
  18103. if _, ok := m.driver.(*txDriver); !ok {
  18104. return nil, errors.New("ent: mutation is not running in a transaction")
  18105. }
  18106. tx := &Tx{config: m.config}
  18107. tx.init()
  18108. return tx, nil
  18109. }
  18110. // SetID sets the value of the id field. Note that this
  18111. // operation is only accepted on creation of Msg entities.
  18112. func (m *MsgMutation) SetID(id uint64) {
  18113. m.id = &id
  18114. }
  18115. // ID returns the ID value in the mutation. Note that the ID is only available
  18116. // if it was provided to the builder or after it was returned from the database.
  18117. func (m *MsgMutation) ID() (id uint64, exists bool) {
  18118. if m.id == nil {
  18119. return
  18120. }
  18121. return *m.id, true
  18122. }
  18123. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18124. // That means, if the mutation is applied within a transaction with an isolation level such
  18125. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18126. // or updated by the mutation.
  18127. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  18128. switch {
  18129. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18130. id, exists := m.ID()
  18131. if exists {
  18132. return []uint64{id}, nil
  18133. }
  18134. fallthrough
  18135. case m.op.Is(OpUpdate | OpDelete):
  18136. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  18137. default:
  18138. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18139. }
  18140. }
  18141. // SetCreatedAt sets the "created_at" field.
  18142. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  18143. m.created_at = &t
  18144. }
  18145. // CreatedAt returns the value of the "created_at" field in the mutation.
  18146. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  18147. v := m.created_at
  18148. if v == nil {
  18149. return
  18150. }
  18151. return *v, true
  18152. }
  18153. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  18154. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18155. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18156. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18157. if !m.op.Is(OpUpdateOne) {
  18158. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18159. }
  18160. if m.id == nil || m.oldValue == nil {
  18161. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18162. }
  18163. oldValue, err := m.oldValue(ctx)
  18164. if err != nil {
  18165. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18166. }
  18167. return oldValue.CreatedAt, nil
  18168. }
  18169. // ResetCreatedAt resets all changes to the "created_at" field.
  18170. func (m *MsgMutation) ResetCreatedAt() {
  18171. m.created_at = nil
  18172. }
  18173. // SetUpdatedAt sets the "updated_at" field.
  18174. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  18175. m.updated_at = &t
  18176. }
  18177. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18178. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  18179. v := m.updated_at
  18180. if v == nil {
  18181. return
  18182. }
  18183. return *v, true
  18184. }
  18185. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  18186. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18188. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18189. if !m.op.Is(OpUpdateOne) {
  18190. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18191. }
  18192. if m.id == nil || m.oldValue == nil {
  18193. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18194. }
  18195. oldValue, err := m.oldValue(ctx)
  18196. if err != nil {
  18197. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18198. }
  18199. return oldValue.UpdatedAt, nil
  18200. }
  18201. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18202. func (m *MsgMutation) ResetUpdatedAt() {
  18203. m.updated_at = nil
  18204. }
  18205. // SetDeletedAt sets the "deleted_at" field.
  18206. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  18207. m.deleted_at = &t
  18208. }
  18209. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18210. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  18211. v := m.deleted_at
  18212. if v == nil {
  18213. return
  18214. }
  18215. return *v, true
  18216. }
  18217. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  18218. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18220. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18221. if !m.op.Is(OpUpdateOne) {
  18222. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18223. }
  18224. if m.id == nil || m.oldValue == nil {
  18225. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18226. }
  18227. oldValue, err := m.oldValue(ctx)
  18228. if err != nil {
  18229. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18230. }
  18231. return oldValue.DeletedAt, nil
  18232. }
  18233. // ClearDeletedAt clears the value of the "deleted_at" field.
  18234. func (m *MsgMutation) ClearDeletedAt() {
  18235. m.deleted_at = nil
  18236. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  18237. }
  18238. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18239. func (m *MsgMutation) DeletedAtCleared() bool {
  18240. _, ok := m.clearedFields[msg.FieldDeletedAt]
  18241. return ok
  18242. }
  18243. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18244. func (m *MsgMutation) ResetDeletedAt() {
  18245. m.deleted_at = nil
  18246. delete(m.clearedFields, msg.FieldDeletedAt)
  18247. }
  18248. // SetStatus sets the "status" field.
  18249. func (m *MsgMutation) SetStatus(u uint8) {
  18250. m.status = &u
  18251. m.addstatus = nil
  18252. }
  18253. // Status returns the value of the "status" field in the mutation.
  18254. func (m *MsgMutation) Status() (r uint8, exists bool) {
  18255. v := m.status
  18256. if v == nil {
  18257. return
  18258. }
  18259. return *v, true
  18260. }
  18261. // OldStatus returns the old "status" field's value of the Msg entity.
  18262. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18264. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18265. if !m.op.Is(OpUpdateOne) {
  18266. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18267. }
  18268. if m.id == nil || m.oldValue == nil {
  18269. return v, errors.New("OldStatus requires an ID field in the mutation")
  18270. }
  18271. oldValue, err := m.oldValue(ctx)
  18272. if err != nil {
  18273. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18274. }
  18275. return oldValue.Status, nil
  18276. }
  18277. // AddStatus adds u to the "status" field.
  18278. func (m *MsgMutation) AddStatus(u int8) {
  18279. if m.addstatus != nil {
  18280. *m.addstatus += u
  18281. } else {
  18282. m.addstatus = &u
  18283. }
  18284. }
  18285. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18286. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  18287. v := m.addstatus
  18288. if v == nil {
  18289. return
  18290. }
  18291. return *v, true
  18292. }
  18293. // ClearStatus clears the value of the "status" field.
  18294. func (m *MsgMutation) ClearStatus() {
  18295. m.status = nil
  18296. m.addstatus = nil
  18297. m.clearedFields[msg.FieldStatus] = struct{}{}
  18298. }
  18299. // StatusCleared returns if the "status" field was cleared in this mutation.
  18300. func (m *MsgMutation) StatusCleared() bool {
  18301. _, ok := m.clearedFields[msg.FieldStatus]
  18302. return ok
  18303. }
  18304. // ResetStatus resets all changes to the "status" field.
  18305. func (m *MsgMutation) ResetStatus() {
  18306. m.status = nil
  18307. m.addstatus = nil
  18308. delete(m.clearedFields, msg.FieldStatus)
  18309. }
  18310. // SetFromwxid sets the "fromwxid" field.
  18311. func (m *MsgMutation) SetFromwxid(s string) {
  18312. m.fromwxid = &s
  18313. }
  18314. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  18315. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  18316. v := m.fromwxid
  18317. if v == nil {
  18318. return
  18319. }
  18320. return *v, true
  18321. }
  18322. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  18323. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18325. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  18326. if !m.op.Is(OpUpdateOne) {
  18327. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  18328. }
  18329. if m.id == nil || m.oldValue == nil {
  18330. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  18331. }
  18332. oldValue, err := m.oldValue(ctx)
  18333. if err != nil {
  18334. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  18335. }
  18336. return oldValue.Fromwxid, nil
  18337. }
  18338. // ClearFromwxid clears the value of the "fromwxid" field.
  18339. func (m *MsgMutation) ClearFromwxid() {
  18340. m.fromwxid = nil
  18341. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  18342. }
  18343. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  18344. func (m *MsgMutation) FromwxidCleared() bool {
  18345. _, ok := m.clearedFields[msg.FieldFromwxid]
  18346. return ok
  18347. }
  18348. // ResetFromwxid resets all changes to the "fromwxid" field.
  18349. func (m *MsgMutation) ResetFromwxid() {
  18350. m.fromwxid = nil
  18351. delete(m.clearedFields, msg.FieldFromwxid)
  18352. }
  18353. // SetToid sets the "toid" field.
  18354. func (m *MsgMutation) SetToid(s string) {
  18355. m.toid = &s
  18356. }
  18357. // Toid returns the value of the "toid" field in the mutation.
  18358. func (m *MsgMutation) Toid() (r string, exists bool) {
  18359. v := m.toid
  18360. if v == nil {
  18361. return
  18362. }
  18363. return *v, true
  18364. }
  18365. // OldToid returns the old "toid" field's value of the Msg entity.
  18366. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18368. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  18369. if !m.op.Is(OpUpdateOne) {
  18370. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  18371. }
  18372. if m.id == nil || m.oldValue == nil {
  18373. return v, errors.New("OldToid requires an ID field in the mutation")
  18374. }
  18375. oldValue, err := m.oldValue(ctx)
  18376. if err != nil {
  18377. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  18378. }
  18379. return oldValue.Toid, nil
  18380. }
  18381. // ClearToid clears the value of the "toid" field.
  18382. func (m *MsgMutation) ClearToid() {
  18383. m.toid = nil
  18384. m.clearedFields[msg.FieldToid] = struct{}{}
  18385. }
  18386. // ToidCleared returns if the "toid" field was cleared in this mutation.
  18387. func (m *MsgMutation) ToidCleared() bool {
  18388. _, ok := m.clearedFields[msg.FieldToid]
  18389. return ok
  18390. }
  18391. // ResetToid resets all changes to the "toid" field.
  18392. func (m *MsgMutation) ResetToid() {
  18393. m.toid = nil
  18394. delete(m.clearedFields, msg.FieldToid)
  18395. }
  18396. // SetMsgtype sets the "msgtype" field.
  18397. func (m *MsgMutation) SetMsgtype(i int32) {
  18398. m.msgtype = &i
  18399. m.addmsgtype = nil
  18400. }
  18401. // Msgtype returns the value of the "msgtype" field in the mutation.
  18402. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  18403. v := m.msgtype
  18404. if v == nil {
  18405. return
  18406. }
  18407. return *v, true
  18408. }
  18409. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  18410. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18412. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  18413. if !m.op.Is(OpUpdateOne) {
  18414. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  18415. }
  18416. if m.id == nil || m.oldValue == nil {
  18417. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  18418. }
  18419. oldValue, err := m.oldValue(ctx)
  18420. if err != nil {
  18421. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  18422. }
  18423. return oldValue.Msgtype, nil
  18424. }
  18425. // AddMsgtype adds i to the "msgtype" field.
  18426. func (m *MsgMutation) AddMsgtype(i int32) {
  18427. if m.addmsgtype != nil {
  18428. *m.addmsgtype += i
  18429. } else {
  18430. m.addmsgtype = &i
  18431. }
  18432. }
  18433. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  18434. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  18435. v := m.addmsgtype
  18436. if v == nil {
  18437. return
  18438. }
  18439. return *v, true
  18440. }
  18441. // ClearMsgtype clears the value of the "msgtype" field.
  18442. func (m *MsgMutation) ClearMsgtype() {
  18443. m.msgtype = nil
  18444. m.addmsgtype = nil
  18445. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  18446. }
  18447. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  18448. func (m *MsgMutation) MsgtypeCleared() bool {
  18449. _, ok := m.clearedFields[msg.FieldMsgtype]
  18450. return ok
  18451. }
  18452. // ResetMsgtype resets all changes to the "msgtype" field.
  18453. func (m *MsgMutation) ResetMsgtype() {
  18454. m.msgtype = nil
  18455. m.addmsgtype = nil
  18456. delete(m.clearedFields, msg.FieldMsgtype)
  18457. }
  18458. // SetMsg sets the "msg" field.
  18459. func (m *MsgMutation) SetMsg(s string) {
  18460. m.msg = &s
  18461. }
  18462. // Msg returns the value of the "msg" field in the mutation.
  18463. func (m *MsgMutation) Msg() (r string, exists bool) {
  18464. v := m.msg
  18465. if v == nil {
  18466. return
  18467. }
  18468. return *v, true
  18469. }
  18470. // OldMsg returns the old "msg" field's value of the Msg entity.
  18471. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18473. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  18474. if !m.op.Is(OpUpdateOne) {
  18475. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  18476. }
  18477. if m.id == nil || m.oldValue == nil {
  18478. return v, errors.New("OldMsg requires an ID field in the mutation")
  18479. }
  18480. oldValue, err := m.oldValue(ctx)
  18481. if err != nil {
  18482. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  18483. }
  18484. return oldValue.Msg, nil
  18485. }
  18486. // ClearMsg clears the value of the "msg" field.
  18487. func (m *MsgMutation) ClearMsg() {
  18488. m.msg = nil
  18489. m.clearedFields[msg.FieldMsg] = struct{}{}
  18490. }
  18491. // MsgCleared returns if the "msg" field was cleared in this mutation.
  18492. func (m *MsgMutation) MsgCleared() bool {
  18493. _, ok := m.clearedFields[msg.FieldMsg]
  18494. return ok
  18495. }
  18496. // ResetMsg resets all changes to the "msg" field.
  18497. func (m *MsgMutation) ResetMsg() {
  18498. m.msg = nil
  18499. delete(m.clearedFields, msg.FieldMsg)
  18500. }
  18501. // SetBatchNo sets the "batch_no" field.
  18502. func (m *MsgMutation) SetBatchNo(s string) {
  18503. m.batch_no = &s
  18504. }
  18505. // BatchNo returns the value of the "batch_no" field in the mutation.
  18506. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  18507. v := m.batch_no
  18508. if v == nil {
  18509. return
  18510. }
  18511. return *v, true
  18512. }
  18513. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  18514. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18515. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18516. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  18517. if !m.op.Is(OpUpdateOne) {
  18518. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  18519. }
  18520. if m.id == nil || m.oldValue == nil {
  18521. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  18522. }
  18523. oldValue, err := m.oldValue(ctx)
  18524. if err != nil {
  18525. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  18526. }
  18527. return oldValue.BatchNo, nil
  18528. }
  18529. // ClearBatchNo clears the value of the "batch_no" field.
  18530. func (m *MsgMutation) ClearBatchNo() {
  18531. m.batch_no = nil
  18532. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  18533. }
  18534. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  18535. func (m *MsgMutation) BatchNoCleared() bool {
  18536. _, ok := m.clearedFields[msg.FieldBatchNo]
  18537. return ok
  18538. }
  18539. // ResetBatchNo resets all changes to the "batch_no" field.
  18540. func (m *MsgMutation) ResetBatchNo() {
  18541. m.batch_no = nil
  18542. delete(m.clearedFields, msg.FieldBatchNo)
  18543. }
  18544. // Where appends a list predicates to the MsgMutation builder.
  18545. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  18546. m.predicates = append(m.predicates, ps...)
  18547. }
  18548. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  18549. // users can use type-assertion to append predicates that do not depend on any generated package.
  18550. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  18551. p := make([]predicate.Msg, len(ps))
  18552. for i := range ps {
  18553. p[i] = ps[i]
  18554. }
  18555. m.Where(p...)
  18556. }
  18557. // Op returns the operation name.
  18558. func (m *MsgMutation) Op() Op {
  18559. return m.op
  18560. }
  18561. // SetOp allows setting the mutation operation.
  18562. func (m *MsgMutation) SetOp(op Op) {
  18563. m.op = op
  18564. }
  18565. // Type returns the node type of this mutation (Msg).
  18566. func (m *MsgMutation) Type() string {
  18567. return m.typ
  18568. }
  18569. // Fields returns all fields that were changed during this mutation. Note that in
  18570. // order to get all numeric fields that were incremented/decremented, call
  18571. // AddedFields().
  18572. func (m *MsgMutation) Fields() []string {
  18573. fields := make([]string, 0, 9)
  18574. if m.created_at != nil {
  18575. fields = append(fields, msg.FieldCreatedAt)
  18576. }
  18577. if m.updated_at != nil {
  18578. fields = append(fields, msg.FieldUpdatedAt)
  18579. }
  18580. if m.deleted_at != nil {
  18581. fields = append(fields, msg.FieldDeletedAt)
  18582. }
  18583. if m.status != nil {
  18584. fields = append(fields, msg.FieldStatus)
  18585. }
  18586. if m.fromwxid != nil {
  18587. fields = append(fields, msg.FieldFromwxid)
  18588. }
  18589. if m.toid != nil {
  18590. fields = append(fields, msg.FieldToid)
  18591. }
  18592. if m.msgtype != nil {
  18593. fields = append(fields, msg.FieldMsgtype)
  18594. }
  18595. if m.msg != nil {
  18596. fields = append(fields, msg.FieldMsg)
  18597. }
  18598. if m.batch_no != nil {
  18599. fields = append(fields, msg.FieldBatchNo)
  18600. }
  18601. return fields
  18602. }
  18603. // Field returns the value of a field with the given name. The second boolean
  18604. // return value indicates that this field was not set, or was not defined in the
  18605. // schema.
  18606. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  18607. switch name {
  18608. case msg.FieldCreatedAt:
  18609. return m.CreatedAt()
  18610. case msg.FieldUpdatedAt:
  18611. return m.UpdatedAt()
  18612. case msg.FieldDeletedAt:
  18613. return m.DeletedAt()
  18614. case msg.FieldStatus:
  18615. return m.Status()
  18616. case msg.FieldFromwxid:
  18617. return m.Fromwxid()
  18618. case msg.FieldToid:
  18619. return m.Toid()
  18620. case msg.FieldMsgtype:
  18621. return m.Msgtype()
  18622. case msg.FieldMsg:
  18623. return m.Msg()
  18624. case msg.FieldBatchNo:
  18625. return m.BatchNo()
  18626. }
  18627. return nil, false
  18628. }
  18629. // OldField returns the old value of the field from the database. An error is
  18630. // returned if the mutation operation is not UpdateOne, or the query to the
  18631. // database failed.
  18632. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18633. switch name {
  18634. case msg.FieldCreatedAt:
  18635. return m.OldCreatedAt(ctx)
  18636. case msg.FieldUpdatedAt:
  18637. return m.OldUpdatedAt(ctx)
  18638. case msg.FieldDeletedAt:
  18639. return m.OldDeletedAt(ctx)
  18640. case msg.FieldStatus:
  18641. return m.OldStatus(ctx)
  18642. case msg.FieldFromwxid:
  18643. return m.OldFromwxid(ctx)
  18644. case msg.FieldToid:
  18645. return m.OldToid(ctx)
  18646. case msg.FieldMsgtype:
  18647. return m.OldMsgtype(ctx)
  18648. case msg.FieldMsg:
  18649. return m.OldMsg(ctx)
  18650. case msg.FieldBatchNo:
  18651. return m.OldBatchNo(ctx)
  18652. }
  18653. return nil, fmt.Errorf("unknown Msg field %s", name)
  18654. }
  18655. // SetField sets the value of a field with the given name. It returns an error if
  18656. // the field is not defined in the schema, or if the type mismatched the field
  18657. // type.
  18658. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  18659. switch name {
  18660. case msg.FieldCreatedAt:
  18661. v, ok := value.(time.Time)
  18662. if !ok {
  18663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18664. }
  18665. m.SetCreatedAt(v)
  18666. return nil
  18667. case msg.FieldUpdatedAt:
  18668. v, ok := value.(time.Time)
  18669. if !ok {
  18670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18671. }
  18672. m.SetUpdatedAt(v)
  18673. return nil
  18674. case msg.FieldDeletedAt:
  18675. v, ok := value.(time.Time)
  18676. if !ok {
  18677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18678. }
  18679. m.SetDeletedAt(v)
  18680. return nil
  18681. case msg.FieldStatus:
  18682. v, ok := value.(uint8)
  18683. if !ok {
  18684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18685. }
  18686. m.SetStatus(v)
  18687. return nil
  18688. case msg.FieldFromwxid:
  18689. v, ok := value.(string)
  18690. if !ok {
  18691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18692. }
  18693. m.SetFromwxid(v)
  18694. return nil
  18695. case msg.FieldToid:
  18696. v, ok := value.(string)
  18697. if !ok {
  18698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18699. }
  18700. m.SetToid(v)
  18701. return nil
  18702. case msg.FieldMsgtype:
  18703. v, ok := value.(int32)
  18704. if !ok {
  18705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18706. }
  18707. m.SetMsgtype(v)
  18708. return nil
  18709. case msg.FieldMsg:
  18710. v, ok := value.(string)
  18711. if !ok {
  18712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18713. }
  18714. m.SetMsg(v)
  18715. return nil
  18716. case msg.FieldBatchNo:
  18717. v, ok := value.(string)
  18718. if !ok {
  18719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18720. }
  18721. m.SetBatchNo(v)
  18722. return nil
  18723. }
  18724. return fmt.Errorf("unknown Msg field %s", name)
  18725. }
  18726. // AddedFields returns all numeric fields that were incremented/decremented during
  18727. // this mutation.
  18728. func (m *MsgMutation) AddedFields() []string {
  18729. var fields []string
  18730. if m.addstatus != nil {
  18731. fields = append(fields, msg.FieldStatus)
  18732. }
  18733. if m.addmsgtype != nil {
  18734. fields = append(fields, msg.FieldMsgtype)
  18735. }
  18736. return fields
  18737. }
  18738. // AddedField returns the numeric value that was incremented/decremented on a field
  18739. // with the given name. The second boolean return value indicates that this field
  18740. // was not set, or was not defined in the schema.
  18741. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  18742. switch name {
  18743. case msg.FieldStatus:
  18744. return m.AddedStatus()
  18745. case msg.FieldMsgtype:
  18746. return m.AddedMsgtype()
  18747. }
  18748. return nil, false
  18749. }
  18750. // AddField adds the value to the field with the given name. It returns an error if
  18751. // the field is not defined in the schema, or if the type mismatched the field
  18752. // type.
  18753. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  18754. switch name {
  18755. case msg.FieldStatus:
  18756. v, ok := value.(int8)
  18757. if !ok {
  18758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18759. }
  18760. m.AddStatus(v)
  18761. return nil
  18762. case msg.FieldMsgtype:
  18763. v, ok := value.(int32)
  18764. if !ok {
  18765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18766. }
  18767. m.AddMsgtype(v)
  18768. return nil
  18769. }
  18770. return fmt.Errorf("unknown Msg numeric field %s", name)
  18771. }
  18772. // ClearedFields returns all nullable fields that were cleared during this
  18773. // mutation.
  18774. func (m *MsgMutation) ClearedFields() []string {
  18775. var fields []string
  18776. if m.FieldCleared(msg.FieldDeletedAt) {
  18777. fields = append(fields, msg.FieldDeletedAt)
  18778. }
  18779. if m.FieldCleared(msg.FieldStatus) {
  18780. fields = append(fields, msg.FieldStatus)
  18781. }
  18782. if m.FieldCleared(msg.FieldFromwxid) {
  18783. fields = append(fields, msg.FieldFromwxid)
  18784. }
  18785. if m.FieldCleared(msg.FieldToid) {
  18786. fields = append(fields, msg.FieldToid)
  18787. }
  18788. if m.FieldCleared(msg.FieldMsgtype) {
  18789. fields = append(fields, msg.FieldMsgtype)
  18790. }
  18791. if m.FieldCleared(msg.FieldMsg) {
  18792. fields = append(fields, msg.FieldMsg)
  18793. }
  18794. if m.FieldCleared(msg.FieldBatchNo) {
  18795. fields = append(fields, msg.FieldBatchNo)
  18796. }
  18797. return fields
  18798. }
  18799. // FieldCleared returns a boolean indicating if a field with the given name was
  18800. // cleared in this mutation.
  18801. func (m *MsgMutation) FieldCleared(name string) bool {
  18802. _, ok := m.clearedFields[name]
  18803. return ok
  18804. }
  18805. // ClearField clears the value of the field with the given name. It returns an
  18806. // error if the field is not defined in the schema.
  18807. func (m *MsgMutation) ClearField(name string) error {
  18808. switch name {
  18809. case msg.FieldDeletedAt:
  18810. m.ClearDeletedAt()
  18811. return nil
  18812. case msg.FieldStatus:
  18813. m.ClearStatus()
  18814. return nil
  18815. case msg.FieldFromwxid:
  18816. m.ClearFromwxid()
  18817. return nil
  18818. case msg.FieldToid:
  18819. m.ClearToid()
  18820. return nil
  18821. case msg.FieldMsgtype:
  18822. m.ClearMsgtype()
  18823. return nil
  18824. case msg.FieldMsg:
  18825. m.ClearMsg()
  18826. return nil
  18827. case msg.FieldBatchNo:
  18828. m.ClearBatchNo()
  18829. return nil
  18830. }
  18831. return fmt.Errorf("unknown Msg nullable field %s", name)
  18832. }
  18833. // ResetField resets all changes in the mutation for the field with the given name.
  18834. // It returns an error if the field is not defined in the schema.
  18835. func (m *MsgMutation) ResetField(name string) error {
  18836. switch name {
  18837. case msg.FieldCreatedAt:
  18838. m.ResetCreatedAt()
  18839. return nil
  18840. case msg.FieldUpdatedAt:
  18841. m.ResetUpdatedAt()
  18842. return nil
  18843. case msg.FieldDeletedAt:
  18844. m.ResetDeletedAt()
  18845. return nil
  18846. case msg.FieldStatus:
  18847. m.ResetStatus()
  18848. return nil
  18849. case msg.FieldFromwxid:
  18850. m.ResetFromwxid()
  18851. return nil
  18852. case msg.FieldToid:
  18853. m.ResetToid()
  18854. return nil
  18855. case msg.FieldMsgtype:
  18856. m.ResetMsgtype()
  18857. return nil
  18858. case msg.FieldMsg:
  18859. m.ResetMsg()
  18860. return nil
  18861. case msg.FieldBatchNo:
  18862. m.ResetBatchNo()
  18863. return nil
  18864. }
  18865. return fmt.Errorf("unknown Msg field %s", name)
  18866. }
  18867. // AddedEdges returns all edge names that were set/added in this mutation.
  18868. func (m *MsgMutation) AddedEdges() []string {
  18869. edges := make([]string, 0, 0)
  18870. return edges
  18871. }
  18872. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18873. // name in this mutation.
  18874. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  18875. return nil
  18876. }
  18877. // RemovedEdges returns all edge names that were removed in this mutation.
  18878. func (m *MsgMutation) RemovedEdges() []string {
  18879. edges := make([]string, 0, 0)
  18880. return edges
  18881. }
  18882. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18883. // the given name in this mutation.
  18884. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  18885. return nil
  18886. }
  18887. // ClearedEdges returns all edge names that were cleared in this mutation.
  18888. func (m *MsgMutation) ClearedEdges() []string {
  18889. edges := make([]string, 0, 0)
  18890. return edges
  18891. }
  18892. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18893. // was cleared in this mutation.
  18894. func (m *MsgMutation) EdgeCleared(name string) bool {
  18895. return false
  18896. }
  18897. // ClearEdge clears the value of the edge with the given name. It returns an error
  18898. // if that edge is not defined in the schema.
  18899. func (m *MsgMutation) ClearEdge(name string) error {
  18900. return fmt.Errorf("unknown Msg unique edge %s", name)
  18901. }
  18902. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18903. // It returns an error if the edge is not defined in the schema.
  18904. func (m *MsgMutation) ResetEdge(name string) error {
  18905. return fmt.Errorf("unknown Msg edge %s", name)
  18906. }
  18907. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  18908. type PayRechargeMutation struct {
  18909. config
  18910. op Op
  18911. typ string
  18912. id *uint64
  18913. created_at *time.Time
  18914. updated_at *time.Time
  18915. deleted_at *time.Time
  18916. user_id *string
  18917. number *float32
  18918. addnumber *float32
  18919. status *int
  18920. addstatus *int
  18921. money *float32
  18922. addmoney *float32
  18923. out_trade_no *string
  18924. organization_id *uint64
  18925. addorganization_id *int64
  18926. clearedFields map[string]struct{}
  18927. done bool
  18928. oldValue func(context.Context) (*PayRecharge, error)
  18929. predicates []predicate.PayRecharge
  18930. }
  18931. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  18932. // payrechargeOption allows management of the mutation configuration using functional options.
  18933. type payrechargeOption func(*PayRechargeMutation)
  18934. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  18935. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  18936. m := &PayRechargeMutation{
  18937. config: c,
  18938. op: op,
  18939. typ: TypePayRecharge,
  18940. clearedFields: make(map[string]struct{}),
  18941. }
  18942. for _, opt := range opts {
  18943. opt(m)
  18944. }
  18945. return m
  18946. }
  18947. // withPayRechargeID sets the ID field of the mutation.
  18948. func withPayRechargeID(id uint64) payrechargeOption {
  18949. return func(m *PayRechargeMutation) {
  18950. var (
  18951. err error
  18952. once sync.Once
  18953. value *PayRecharge
  18954. )
  18955. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  18956. once.Do(func() {
  18957. if m.done {
  18958. err = errors.New("querying old values post mutation is not allowed")
  18959. } else {
  18960. value, err = m.Client().PayRecharge.Get(ctx, id)
  18961. }
  18962. })
  18963. return value, err
  18964. }
  18965. m.id = &id
  18966. }
  18967. }
  18968. // withPayRecharge sets the old PayRecharge of the mutation.
  18969. func withPayRecharge(node *PayRecharge) payrechargeOption {
  18970. return func(m *PayRechargeMutation) {
  18971. m.oldValue = func(context.Context) (*PayRecharge, error) {
  18972. return node, nil
  18973. }
  18974. m.id = &node.ID
  18975. }
  18976. }
  18977. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18978. // executed in a transaction (ent.Tx), a transactional client is returned.
  18979. func (m PayRechargeMutation) Client() *Client {
  18980. client := &Client{config: m.config}
  18981. client.init()
  18982. return client
  18983. }
  18984. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18985. // it returns an error otherwise.
  18986. func (m PayRechargeMutation) Tx() (*Tx, error) {
  18987. if _, ok := m.driver.(*txDriver); !ok {
  18988. return nil, errors.New("ent: mutation is not running in a transaction")
  18989. }
  18990. tx := &Tx{config: m.config}
  18991. tx.init()
  18992. return tx, nil
  18993. }
  18994. // SetID sets the value of the id field. Note that this
  18995. // operation is only accepted on creation of PayRecharge entities.
  18996. func (m *PayRechargeMutation) SetID(id uint64) {
  18997. m.id = &id
  18998. }
  18999. // ID returns the ID value in the mutation. Note that the ID is only available
  19000. // if it was provided to the builder or after it was returned from the database.
  19001. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  19002. if m.id == nil {
  19003. return
  19004. }
  19005. return *m.id, true
  19006. }
  19007. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19008. // That means, if the mutation is applied within a transaction with an isolation level such
  19009. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19010. // or updated by the mutation.
  19011. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  19012. switch {
  19013. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19014. id, exists := m.ID()
  19015. if exists {
  19016. return []uint64{id}, nil
  19017. }
  19018. fallthrough
  19019. case m.op.Is(OpUpdate | OpDelete):
  19020. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  19021. default:
  19022. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19023. }
  19024. }
  19025. // SetCreatedAt sets the "created_at" field.
  19026. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  19027. m.created_at = &t
  19028. }
  19029. // CreatedAt returns the value of the "created_at" field in the mutation.
  19030. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  19031. v := m.created_at
  19032. if v == nil {
  19033. return
  19034. }
  19035. return *v, true
  19036. }
  19037. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  19038. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19040. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19041. if !m.op.Is(OpUpdateOne) {
  19042. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19043. }
  19044. if m.id == nil || m.oldValue == nil {
  19045. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19046. }
  19047. oldValue, err := m.oldValue(ctx)
  19048. if err != nil {
  19049. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19050. }
  19051. return oldValue.CreatedAt, nil
  19052. }
  19053. // ResetCreatedAt resets all changes to the "created_at" field.
  19054. func (m *PayRechargeMutation) ResetCreatedAt() {
  19055. m.created_at = nil
  19056. }
  19057. // SetUpdatedAt sets the "updated_at" field.
  19058. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  19059. m.updated_at = &t
  19060. }
  19061. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19062. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  19063. v := m.updated_at
  19064. if v == nil {
  19065. return
  19066. }
  19067. return *v, true
  19068. }
  19069. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  19070. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19072. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19073. if !m.op.Is(OpUpdateOne) {
  19074. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19075. }
  19076. if m.id == nil || m.oldValue == nil {
  19077. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19078. }
  19079. oldValue, err := m.oldValue(ctx)
  19080. if err != nil {
  19081. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19082. }
  19083. return oldValue.UpdatedAt, nil
  19084. }
  19085. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19086. func (m *PayRechargeMutation) ResetUpdatedAt() {
  19087. m.updated_at = nil
  19088. }
  19089. // SetDeletedAt sets the "deleted_at" field.
  19090. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  19091. m.deleted_at = &t
  19092. }
  19093. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19094. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  19095. v := m.deleted_at
  19096. if v == nil {
  19097. return
  19098. }
  19099. return *v, true
  19100. }
  19101. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  19102. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19104. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19105. if !m.op.Is(OpUpdateOne) {
  19106. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19107. }
  19108. if m.id == nil || m.oldValue == nil {
  19109. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19110. }
  19111. oldValue, err := m.oldValue(ctx)
  19112. if err != nil {
  19113. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19114. }
  19115. return oldValue.DeletedAt, nil
  19116. }
  19117. // ClearDeletedAt clears the value of the "deleted_at" field.
  19118. func (m *PayRechargeMutation) ClearDeletedAt() {
  19119. m.deleted_at = nil
  19120. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  19121. }
  19122. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19123. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  19124. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  19125. return ok
  19126. }
  19127. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19128. func (m *PayRechargeMutation) ResetDeletedAt() {
  19129. m.deleted_at = nil
  19130. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  19131. }
  19132. // SetUserID sets the "user_id" field.
  19133. func (m *PayRechargeMutation) SetUserID(s string) {
  19134. m.user_id = &s
  19135. }
  19136. // UserID returns the value of the "user_id" field in the mutation.
  19137. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  19138. v := m.user_id
  19139. if v == nil {
  19140. return
  19141. }
  19142. return *v, true
  19143. }
  19144. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  19145. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19146. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19147. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  19148. if !m.op.Is(OpUpdateOne) {
  19149. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  19150. }
  19151. if m.id == nil || m.oldValue == nil {
  19152. return v, errors.New("OldUserID requires an ID field in the mutation")
  19153. }
  19154. oldValue, err := m.oldValue(ctx)
  19155. if err != nil {
  19156. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  19157. }
  19158. return oldValue.UserID, nil
  19159. }
  19160. // ResetUserID resets all changes to the "user_id" field.
  19161. func (m *PayRechargeMutation) ResetUserID() {
  19162. m.user_id = nil
  19163. }
  19164. // SetNumber sets the "number" field.
  19165. func (m *PayRechargeMutation) SetNumber(f float32) {
  19166. m.number = &f
  19167. m.addnumber = nil
  19168. }
  19169. // Number returns the value of the "number" field in the mutation.
  19170. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  19171. v := m.number
  19172. if v == nil {
  19173. return
  19174. }
  19175. return *v, true
  19176. }
  19177. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  19178. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19180. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  19181. if !m.op.Is(OpUpdateOne) {
  19182. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  19183. }
  19184. if m.id == nil || m.oldValue == nil {
  19185. return v, errors.New("OldNumber requires an ID field in the mutation")
  19186. }
  19187. oldValue, err := m.oldValue(ctx)
  19188. if err != nil {
  19189. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  19190. }
  19191. return oldValue.Number, nil
  19192. }
  19193. // AddNumber adds f to the "number" field.
  19194. func (m *PayRechargeMutation) AddNumber(f float32) {
  19195. if m.addnumber != nil {
  19196. *m.addnumber += f
  19197. } else {
  19198. m.addnumber = &f
  19199. }
  19200. }
  19201. // AddedNumber returns the value that was added to the "number" field in this mutation.
  19202. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  19203. v := m.addnumber
  19204. if v == nil {
  19205. return
  19206. }
  19207. return *v, true
  19208. }
  19209. // ResetNumber resets all changes to the "number" field.
  19210. func (m *PayRechargeMutation) ResetNumber() {
  19211. m.number = nil
  19212. m.addnumber = nil
  19213. }
  19214. // SetStatus sets the "status" field.
  19215. func (m *PayRechargeMutation) SetStatus(i int) {
  19216. m.status = &i
  19217. m.addstatus = nil
  19218. }
  19219. // Status returns the value of the "status" field in the mutation.
  19220. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  19221. v := m.status
  19222. if v == nil {
  19223. return
  19224. }
  19225. return *v, true
  19226. }
  19227. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  19228. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19230. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  19231. if !m.op.Is(OpUpdateOne) {
  19232. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19233. }
  19234. if m.id == nil || m.oldValue == nil {
  19235. return v, errors.New("OldStatus requires an ID field in the mutation")
  19236. }
  19237. oldValue, err := m.oldValue(ctx)
  19238. if err != nil {
  19239. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19240. }
  19241. return oldValue.Status, nil
  19242. }
  19243. // AddStatus adds i to the "status" field.
  19244. func (m *PayRechargeMutation) AddStatus(i int) {
  19245. if m.addstatus != nil {
  19246. *m.addstatus += i
  19247. } else {
  19248. m.addstatus = &i
  19249. }
  19250. }
  19251. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19252. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  19253. v := m.addstatus
  19254. if v == nil {
  19255. return
  19256. }
  19257. return *v, true
  19258. }
  19259. // ClearStatus clears the value of the "status" field.
  19260. func (m *PayRechargeMutation) ClearStatus() {
  19261. m.status = nil
  19262. m.addstatus = nil
  19263. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  19264. }
  19265. // StatusCleared returns if the "status" field was cleared in this mutation.
  19266. func (m *PayRechargeMutation) StatusCleared() bool {
  19267. _, ok := m.clearedFields[payrecharge.FieldStatus]
  19268. return ok
  19269. }
  19270. // ResetStatus resets all changes to the "status" field.
  19271. func (m *PayRechargeMutation) ResetStatus() {
  19272. m.status = nil
  19273. m.addstatus = nil
  19274. delete(m.clearedFields, payrecharge.FieldStatus)
  19275. }
  19276. // SetMoney sets the "money" field.
  19277. func (m *PayRechargeMutation) SetMoney(f float32) {
  19278. m.money = &f
  19279. m.addmoney = nil
  19280. }
  19281. // Money returns the value of the "money" field in the mutation.
  19282. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  19283. v := m.money
  19284. if v == nil {
  19285. return
  19286. }
  19287. return *v, true
  19288. }
  19289. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  19290. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19292. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  19293. if !m.op.Is(OpUpdateOne) {
  19294. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  19295. }
  19296. if m.id == nil || m.oldValue == nil {
  19297. return v, errors.New("OldMoney requires an ID field in the mutation")
  19298. }
  19299. oldValue, err := m.oldValue(ctx)
  19300. if err != nil {
  19301. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  19302. }
  19303. return oldValue.Money, nil
  19304. }
  19305. // AddMoney adds f to the "money" field.
  19306. func (m *PayRechargeMutation) AddMoney(f float32) {
  19307. if m.addmoney != nil {
  19308. *m.addmoney += f
  19309. } else {
  19310. m.addmoney = &f
  19311. }
  19312. }
  19313. // AddedMoney returns the value that was added to the "money" field in this mutation.
  19314. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  19315. v := m.addmoney
  19316. if v == nil {
  19317. return
  19318. }
  19319. return *v, true
  19320. }
  19321. // ClearMoney clears the value of the "money" field.
  19322. func (m *PayRechargeMutation) ClearMoney() {
  19323. m.money = nil
  19324. m.addmoney = nil
  19325. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  19326. }
  19327. // MoneyCleared returns if the "money" field was cleared in this mutation.
  19328. func (m *PayRechargeMutation) MoneyCleared() bool {
  19329. _, ok := m.clearedFields[payrecharge.FieldMoney]
  19330. return ok
  19331. }
  19332. // ResetMoney resets all changes to the "money" field.
  19333. func (m *PayRechargeMutation) ResetMoney() {
  19334. m.money = nil
  19335. m.addmoney = nil
  19336. delete(m.clearedFields, payrecharge.FieldMoney)
  19337. }
  19338. // SetOutTradeNo sets the "out_trade_no" field.
  19339. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  19340. m.out_trade_no = &s
  19341. }
  19342. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  19343. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  19344. v := m.out_trade_no
  19345. if v == nil {
  19346. return
  19347. }
  19348. return *v, true
  19349. }
  19350. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  19351. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19353. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  19354. if !m.op.Is(OpUpdateOne) {
  19355. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  19356. }
  19357. if m.id == nil || m.oldValue == nil {
  19358. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  19359. }
  19360. oldValue, err := m.oldValue(ctx)
  19361. if err != nil {
  19362. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  19363. }
  19364. return oldValue.OutTradeNo, nil
  19365. }
  19366. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  19367. func (m *PayRechargeMutation) ClearOutTradeNo() {
  19368. m.out_trade_no = nil
  19369. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  19370. }
  19371. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  19372. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  19373. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  19374. return ok
  19375. }
  19376. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  19377. func (m *PayRechargeMutation) ResetOutTradeNo() {
  19378. m.out_trade_no = nil
  19379. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  19380. }
  19381. // SetOrganizationID sets the "organization_id" field.
  19382. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  19383. m.organization_id = &u
  19384. m.addorganization_id = nil
  19385. }
  19386. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19387. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  19388. v := m.organization_id
  19389. if v == nil {
  19390. return
  19391. }
  19392. return *v, true
  19393. }
  19394. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  19395. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19396. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19397. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19398. if !m.op.Is(OpUpdateOne) {
  19399. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19400. }
  19401. if m.id == nil || m.oldValue == nil {
  19402. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19403. }
  19404. oldValue, err := m.oldValue(ctx)
  19405. if err != nil {
  19406. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19407. }
  19408. return oldValue.OrganizationID, nil
  19409. }
  19410. // AddOrganizationID adds u to the "organization_id" field.
  19411. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  19412. if m.addorganization_id != nil {
  19413. *m.addorganization_id += u
  19414. } else {
  19415. m.addorganization_id = &u
  19416. }
  19417. }
  19418. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19419. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  19420. v := m.addorganization_id
  19421. if v == nil {
  19422. return
  19423. }
  19424. return *v, true
  19425. }
  19426. // ResetOrganizationID resets all changes to the "organization_id" field.
  19427. func (m *PayRechargeMutation) ResetOrganizationID() {
  19428. m.organization_id = nil
  19429. m.addorganization_id = nil
  19430. }
  19431. // Where appends a list predicates to the PayRechargeMutation builder.
  19432. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  19433. m.predicates = append(m.predicates, ps...)
  19434. }
  19435. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  19436. // users can use type-assertion to append predicates that do not depend on any generated package.
  19437. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  19438. p := make([]predicate.PayRecharge, len(ps))
  19439. for i := range ps {
  19440. p[i] = ps[i]
  19441. }
  19442. m.Where(p...)
  19443. }
  19444. // Op returns the operation name.
  19445. func (m *PayRechargeMutation) Op() Op {
  19446. return m.op
  19447. }
  19448. // SetOp allows setting the mutation operation.
  19449. func (m *PayRechargeMutation) SetOp(op Op) {
  19450. m.op = op
  19451. }
  19452. // Type returns the node type of this mutation (PayRecharge).
  19453. func (m *PayRechargeMutation) Type() string {
  19454. return m.typ
  19455. }
  19456. // Fields returns all fields that were changed during this mutation. Note that in
  19457. // order to get all numeric fields that were incremented/decremented, call
  19458. // AddedFields().
  19459. func (m *PayRechargeMutation) Fields() []string {
  19460. fields := make([]string, 0, 9)
  19461. if m.created_at != nil {
  19462. fields = append(fields, payrecharge.FieldCreatedAt)
  19463. }
  19464. if m.updated_at != nil {
  19465. fields = append(fields, payrecharge.FieldUpdatedAt)
  19466. }
  19467. if m.deleted_at != nil {
  19468. fields = append(fields, payrecharge.FieldDeletedAt)
  19469. }
  19470. if m.user_id != nil {
  19471. fields = append(fields, payrecharge.FieldUserID)
  19472. }
  19473. if m.number != nil {
  19474. fields = append(fields, payrecharge.FieldNumber)
  19475. }
  19476. if m.status != nil {
  19477. fields = append(fields, payrecharge.FieldStatus)
  19478. }
  19479. if m.money != nil {
  19480. fields = append(fields, payrecharge.FieldMoney)
  19481. }
  19482. if m.out_trade_no != nil {
  19483. fields = append(fields, payrecharge.FieldOutTradeNo)
  19484. }
  19485. if m.organization_id != nil {
  19486. fields = append(fields, payrecharge.FieldOrganizationID)
  19487. }
  19488. return fields
  19489. }
  19490. // Field returns the value of a field with the given name. The second boolean
  19491. // return value indicates that this field was not set, or was not defined in the
  19492. // schema.
  19493. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  19494. switch name {
  19495. case payrecharge.FieldCreatedAt:
  19496. return m.CreatedAt()
  19497. case payrecharge.FieldUpdatedAt:
  19498. return m.UpdatedAt()
  19499. case payrecharge.FieldDeletedAt:
  19500. return m.DeletedAt()
  19501. case payrecharge.FieldUserID:
  19502. return m.UserID()
  19503. case payrecharge.FieldNumber:
  19504. return m.Number()
  19505. case payrecharge.FieldStatus:
  19506. return m.Status()
  19507. case payrecharge.FieldMoney:
  19508. return m.Money()
  19509. case payrecharge.FieldOutTradeNo:
  19510. return m.OutTradeNo()
  19511. case payrecharge.FieldOrganizationID:
  19512. return m.OrganizationID()
  19513. }
  19514. return nil, false
  19515. }
  19516. // OldField returns the old value of the field from the database. An error is
  19517. // returned if the mutation operation is not UpdateOne, or the query to the
  19518. // database failed.
  19519. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19520. switch name {
  19521. case payrecharge.FieldCreatedAt:
  19522. return m.OldCreatedAt(ctx)
  19523. case payrecharge.FieldUpdatedAt:
  19524. return m.OldUpdatedAt(ctx)
  19525. case payrecharge.FieldDeletedAt:
  19526. return m.OldDeletedAt(ctx)
  19527. case payrecharge.FieldUserID:
  19528. return m.OldUserID(ctx)
  19529. case payrecharge.FieldNumber:
  19530. return m.OldNumber(ctx)
  19531. case payrecharge.FieldStatus:
  19532. return m.OldStatus(ctx)
  19533. case payrecharge.FieldMoney:
  19534. return m.OldMoney(ctx)
  19535. case payrecharge.FieldOutTradeNo:
  19536. return m.OldOutTradeNo(ctx)
  19537. case payrecharge.FieldOrganizationID:
  19538. return m.OldOrganizationID(ctx)
  19539. }
  19540. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  19541. }
  19542. // SetField sets the value of a field with the given name. It returns an error if
  19543. // the field is not defined in the schema, or if the type mismatched the field
  19544. // type.
  19545. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  19546. switch name {
  19547. case payrecharge.FieldCreatedAt:
  19548. v, ok := value.(time.Time)
  19549. if !ok {
  19550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19551. }
  19552. m.SetCreatedAt(v)
  19553. return nil
  19554. case payrecharge.FieldUpdatedAt:
  19555. v, ok := value.(time.Time)
  19556. if !ok {
  19557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19558. }
  19559. m.SetUpdatedAt(v)
  19560. return nil
  19561. case payrecharge.FieldDeletedAt:
  19562. v, ok := value.(time.Time)
  19563. if !ok {
  19564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19565. }
  19566. m.SetDeletedAt(v)
  19567. return nil
  19568. case payrecharge.FieldUserID:
  19569. v, ok := value.(string)
  19570. if !ok {
  19571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19572. }
  19573. m.SetUserID(v)
  19574. return nil
  19575. case payrecharge.FieldNumber:
  19576. v, ok := value.(float32)
  19577. if !ok {
  19578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19579. }
  19580. m.SetNumber(v)
  19581. return nil
  19582. case payrecharge.FieldStatus:
  19583. v, ok := value.(int)
  19584. if !ok {
  19585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19586. }
  19587. m.SetStatus(v)
  19588. return nil
  19589. case payrecharge.FieldMoney:
  19590. v, ok := value.(float32)
  19591. if !ok {
  19592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19593. }
  19594. m.SetMoney(v)
  19595. return nil
  19596. case payrecharge.FieldOutTradeNo:
  19597. v, ok := value.(string)
  19598. if !ok {
  19599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19600. }
  19601. m.SetOutTradeNo(v)
  19602. return nil
  19603. case payrecharge.FieldOrganizationID:
  19604. v, ok := value.(uint64)
  19605. if !ok {
  19606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19607. }
  19608. m.SetOrganizationID(v)
  19609. return nil
  19610. }
  19611. return fmt.Errorf("unknown PayRecharge field %s", name)
  19612. }
  19613. // AddedFields returns all numeric fields that were incremented/decremented during
  19614. // this mutation.
  19615. func (m *PayRechargeMutation) AddedFields() []string {
  19616. var fields []string
  19617. if m.addnumber != nil {
  19618. fields = append(fields, payrecharge.FieldNumber)
  19619. }
  19620. if m.addstatus != nil {
  19621. fields = append(fields, payrecharge.FieldStatus)
  19622. }
  19623. if m.addmoney != nil {
  19624. fields = append(fields, payrecharge.FieldMoney)
  19625. }
  19626. if m.addorganization_id != nil {
  19627. fields = append(fields, payrecharge.FieldOrganizationID)
  19628. }
  19629. return fields
  19630. }
  19631. // AddedField returns the numeric value that was incremented/decremented on a field
  19632. // with the given name. The second boolean return value indicates that this field
  19633. // was not set, or was not defined in the schema.
  19634. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  19635. switch name {
  19636. case payrecharge.FieldNumber:
  19637. return m.AddedNumber()
  19638. case payrecharge.FieldStatus:
  19639. return m.AddedStatus()
  19640. case payrecharge.FieldMoney:
  19641. return m.AddedMoney()
  19642. case payrecharge.FieldOrganizationID:
  19643. return m.AddedOrganizationID()
  19644. }
  19645. return nil, false
  19646. }
  19647. // AddField adds the value to the field with the given name. It returns an error if
  19648. // the field is not defined in the schema, or if the type mismatched the field
  19649. // type.
  19650. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  19651. switch name {
  19652. case payrecharge.FieldNumber:
  19653. v, ok := value.(float32)
  19654. if !ok {
  19655. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19656. }
  19657. m.AddNumber(v)
  19658. return nil
  19659. case payrecharge.FieldStatus:
  19660. v, ok := value.(int)
  19661. if !ok {
  19662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19663. }
  19664. m.AddStatus(v)
  19665. return nil
  19666. case payrecharge.FieldMoney:
  19667. v, ok := value.(float32)
  19668. if !ok {
  19669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19670. }
  19671. m.AddMoney(v)
  19672. return nil
  19673. case payrecharge.FieldOrganizationID:
  19674. v, ok := value.(int64)
  19675. if !ok {
  19676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19677. }
  19678. m.AddOrganizationID(v)
  19679. return nil
  19680. }
  19681. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  19682. }
  19683. // ClearedFields returns all nullable fields that were cleared during this
  19684. // mutation.
  19685. func (m *PayRechargeMutation) ClearedFields() []string {
  19686. var fields []string
  19687. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  19688. fields = append(fields, payrecharge.FieldDeletedAt)
  19689. }
  19690. if m.FieldCleared(payrecharge.FieldStatus) {
  19691. fields = append(fields, payrecharge.FieldStatus)
  19692. }
  19693. if m.FieldCleared(payrecharge.FieldMoney) {
  19694. fields = append(fields, payrecharge.FieldMoney)
  19695. }
  19696. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  19697. fields = append(fields, payrecharge.FieldOutTradeNo)
  19698. }
  19699. return fields
  19700. }
  19701. // FieldCleared returns a boolean indicating if a field with the given name was
  19702. // cleared in this mutation.
  19703. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  19704. _, ok := m.clearedFields[name]
  19705. return ok
  19706. }
  19707. // ClearField clears the value of the field with the given name. It returns an
  19708. // error if the field is not defined in the schema.
  19709. func (m *PayRechargeMutation) ClearField(name string) error {
  19710. switch name {
  19711. case payrecharge.FieldDeletedAt:
  19712. m.ClearDeletedAt()
  19713. return nil
  19714. case payrecharge.FieldStatus:
  19715. m.ClearStatus()
  19716. return nil
  19717. case payrecharge.FieldMoney:
  19718. m.ClearMoney()
  19719. return nil
  19720. case payrecharge.FieldOutTradeNo:
  19721. m.ClearOutTradeNo()
  19722. return nil
  19723. }
  19724. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  19725. }
  19726. // ResetField resets all changes in the mutation for the field with the given name.
  19727. // It returns an error if the field is not defined in the schema.
  19728. func (m *PayRechargeMutation) ResetField(name string) error {
  19729. switch name {
  19730. case payrecharge.FieldCreatedAt:
  19731. m.ResetCreatedAt()
  19732. return nil
  19733. case payrecharge.FieldUpdatedAt:
  19734. m.ResetUpdatedAt()
  19735. return nil
  19736. case payrecharge.FieldDeletedAt:
  19737. m.ResetDeletedAt()
  19738. return nil
  19739. case payrecharge.FieldUserID:
  19740. m.ResetUserID()
  19741. return nil
  19742. case payrecharge.FieldNumber:
  19743. m.ResetNumber()
  19744. return nil
  19745. case payrecharge.FieldStatus:
  19746. m.ResetStatus()
  19747. return nil
  19748. case payrecharge.FieldMoney:
  19749. m.ResetMoney()
  19750. return nil
  19751. case payrecharge.FieldOutTradeNo:
  19752. m.ResetOutTradeNo()
  19753. return nil
  19754. case payrecharge.FieldOrganizationID:
  19755. m.ResetOrganizationID()
  19756. return nil
  19757. }
  19758. return fmt.Errorf("unknown PayRecharge field %s", name)
  19759. }
  19760. // AddedEdges returns all edge names that were set/added in this mutation.
  19761. func (m *PayRechargeMutation) AddedEdges() []string {
  19762. edges := make([]string, 0, 0)
  19763. return edges
  19764. }
  19765. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19766. // name in this mutation.
  19767. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  19768. return nil
  19769. }
  19770. // RemovedEdges returns all edge names that were removed in this mutation.
  19771. func (m *PayRechargeMutation) RemovedEdges() []string {
  19772. edges := make([]string, 0, 0)
  19773. return edges
  19774. }
  19775. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19776. // the given name in this mutation.
  19777. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  19778. return nil
  19779. }
  19780. // ClearedEdges returns all edge names that were cleared in this mutation.
  19781. func (m *PayRechargeMutation) ClearedEdges() []string {
  19782. edges := make([]string, 0, 0)
  19783. return edges
  19784. }
  19785. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19786. // was cleared in this mutation.
  19787. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  19788. return false
  19789. }
  19790. // ClearEdge clears the value of the edge with the given name. It returns an error
  19791. // if that edge is not defined in the schema.
  19792. func (m *PayRechargeMutation) ClearEdge(name string) error {
  19793. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  19794. }
  19795. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19796. // It returns an error if the edge is not defined in the schema.
  19797. func (m *PayRechargeMutation) ResetEdge(name string) error {
  19798. return fmt.Errorf("unknown PayRecharge edge %s", name)
  19799. }
  19800. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  19801. type ServerMutation struct {
  19802. config
  19803. op Op
  19804. typ string
  19805. id *uint64
  19806. created_at *time.Time
  19807. updated_at *time.Time
  19808. status *uint8
  19809. addstatus *int8
  19810. deleted_at *time.Time
  19811. name *string
  19812. public_ip *string
  19813. private_ip *string
  19814. admin_port *string
  19815. clearedFields map[string]struct{}
  19816. wxs map[uint64]struct{}
  19817. removedwxs map[uint64]struct{}
  19818. clearedwxs bool
  19819. done bool
  19820. oldValue func(context.Context) (*Server, error)
  19821. predicates []predicate.Server
  19822. }
  19823. var _ ent.Mutation = (*ServerMutation)(nil)
  19824. // serverOption allows management of the mutation configuration using functional options.
  19825. type serverOption func(*ServerMutation)
  19826. // newServerMutation creates new mutation for the Server entity.
  19827. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  19828. m := &ServerMutation{
  19829. config: c,
  19830. op: op,
  19831. typ: TypeServer,
  19832. clearedFields: make(map[string]struct{}),
  19833. }
  19834. for _, opt := range opts {
  19835. opt(m)
  19836. }
  19837. return m
  19838. }
  19839. // withServerID sets the ID field of the mutation.
  19840. func withServerID(id uint64) serverOption {
  19841. return func(m *ServerMutation) {
  19842. var (
  19843. err error
  19844. once sync.Once
  19845. value *Server
  19846. )
  19847. m.oldValue = func(ctx context.Context) (*Server, error) {
  19848. once.Do(func() {
  19849. if m.done {
  19850. err = errors.New("querying old values post mutation is not allowed")
  19851. } else {
  19852. value, err = m.Client().Server.Get(ctx, id)
  19853. }
  19854. })
  19855. return value, err
  19856. }
  19857. m.id = &id
  19858. }
  19859. }
  19860. // withServer sets the old Server of the mutation.
  19861. func withServer(node *Server) serverOption {
  19862. return func(m *ServerMutation) {
  19863. m.oldValue = func(context.Context) (*Server, error) {
  19864. return node, nil
  19865. }
  19866. m.id = &node.ID
  19867. }
  19868. }
  19869. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19870. // executed in a transaction (ent.Tx), a transactional client is returned.
  19871. func (m ServerMutation) Client() *Client {
  19872. client := &Client{config: m.config}
  19873. client.init()
  19874. return client
  19875. }
  19876. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19877. // it returns an error otherwise.
  19878. func (m ServerMutation) Tx() (*Tx, error) {
  19879. if _, ok := m.driver.(*txDriver); !ok {
  19880. return nil, errors.New("ent: mutation is not running in a transaction")
  19881. }
  19882. tx := &Tx{config: m.config}
  19883. tx.init()
  19884. return tx, nil
  19885. }
  19886. // SetID sets the value of the id field. Note that this
  19887. // operation is only accepted on creation of Server entities.
  19888. func (m *ServerMutation) SetID(id uint64) {
  19889. m.id = &id
  19890. }
  19891. // ID returns the ID value in the mutation. Note that the ID is only available
  19892. // if it was provided to the builder or after it was returned from the database.
  19893. func (m *ServerMutation) ID() (id uint64, exists bool) {
  19894. if m.id == nil {
  19895. return
  19896. }
  19897. return *m.id, true
  19898. }
  19899. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19900. // That means, if the mutation is applied within a transaction with an isolation level such
  19901. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19902. // or updated by the mutation.
  19903. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  19904. switch {
  19905. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19906. id, exists := m.ID()
  19907. if exists {
  19908. return []uint64{id}, nil
  19909. }
  19910. fallthrough
  19911. case m.op.Is(OpUpdate | OpDelete):
  19912. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  19913. default:
  19914. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19915. }
  19916. }
  19917. // SetCreatedAt sets the "created_at" field.
  19918. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  19919. m.created_at = &t
  19920. }
  19921. // CreatedAt returns the value of the "created_at" field in the mutation.
  19922. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  19923. v := m.created_at
  19924. if v == nil {
  19925. return
  19926. }
  19927. return *v, true
  19928. }
  19929. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  19930. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  19931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19932. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19933. if !m.op.Is(OpUpdateOne) {
  19934. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19935. }
  19936. if m.id == nil || m.oldValue == nil {
  19937. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19938. }
  19939. oldValue, err := m.oldValue(ctx)
  19940. if err != nil {
  19941. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19942. }
  19943. return oldValue.CreatedAt, nil
  19944. }
  19945. // ResetCreatedAt resets all changes to the "created_at" field.
  19946. func (m *ServerMutation) ResetCreatedAt() {
  19947. m.created_at = nil
  19948. }
  19949. // SetUpdatedAt sets the "updated_at" field.
  19950. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  19951. m.updated_at = &t
  19952. }
  19953. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19954. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  19955. v := m.updated_at
  19956. if v == nil {
  19957. return
  19958. }
  19959. return *v, true
  19960. }
  19961. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  19962. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  19963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19964. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19965. if !m.op.Is(OpUpdateOne) {
  19966. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19967. }
  19968. if m.id == nil || m.oldValue == nil {
  19969. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19970. }
  19971. oldValue, err := m.oldValue(ctx)
  19972. if err != nil {
  19973. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19974. }
  19975. return oldValue.UpdatedAt, nil
  19976. }
  19977. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19978. func (m *ServerMutation) ResetUpdatedAt() {
  19979. m.updated_at = nil
  19980. }
  19981. // SetStatus sets the "status" field.
  19982. func (m *ServerMutation) SetStatus(u uint8) {
  19983. m.status = &u
  19984. m.addstatus = nil
  19985. }
  19986. // Status returns the value of the "status" field in the mutation.
  19987. func (m *ServerMutation) Status() (r uint8, exists bool) {
  19988. v := m.status
  19989. if v == nil {
  19990. return
  19991. }
  19992. return *v, true
  19993. }
  19994. // OldStatus returns the old "status" field's value of the Server entity.
  19995. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  19996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19997. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19998. if !m.op.Is(OpUpdateOne) {
  19999. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20000. }
  20001. if m.id == nil || m.oldValue == nil {
  20002. return v, errors.New("OldStatus requires an ID field in the mutation")
  20003. }
  20004. oldValue, err := m.oldValue(ctx)
  20005. if err != nil {
  20006. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20007. }
  20008. return oldValue.Status, nil
  20009. }
  20010. // AddStatus adds u to the "status" field.
  20011. func (m *ServerMutation) AddStatus(u int8) {
  20012. if m.addstatus != nil {
  20013. *m.addstatus += u
  20014. } else {
  20015. m.addstatus = &u
  20016. }
  20017. }
  20018. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20019. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  20020. v := m.addstatus
  20021. if v == nil {
  20022. return
  20023. }
  20024. return *v, true
  20025. }
  20026. // ClearStatus clears the value of the "status" field.
  20027. func (m *ServerMutation) ClearStatus() {
  20028. m.status = nil
  20029. m.addstatus = nil
  20030. m.clearedFields[server.FieldStatus] = struct{}{}
  20031. }
  20032. // StatusCleared returns if the "status" field was cleared in this mutation.
  20033. func (m *ServerMutation) StatusCleared() bool {
  20034. _, ok := m.clearedFields[server.FieldStatus]
  20035. return ok
  20036. }
  20037. // ResetStatus resets all changes to the "status" field.
  20038. func (m *ServerMutation) ResetStatus() {
  20039. m.status = nil
  20040. m.addstatus = nil
  20041. delete(m.clearedFields, server.FieldStatus)
  20042. }
  20043. // SetDeletedAt sets the "deleted_at" field.
  20044. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  20045. m.deleted_at = &t
  20046. }
  20047. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20048. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  20049. v := m.deleted_at
  20050. if v == nil {
  20051. return
  20052. }
  20053. return *v, true
  20054. }
  20055. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  20056. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20058. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20059. if !m.op.Is(OpUpdateOne) {
  20060. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20061. }
  20062. if m.id == nil || m.oldValue == nil {
  20063. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20064. }
  20065. oldValue, err := m.oldValue(ctx)
  20066. if err != nil {
  20067. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20068. }
  20069. return oldValue.DeletedAt, nil
  20070. }
  20071. // ClearDeletedAt clears the value of the "deleted_at" field.
  20072. func (m *ServerMutation) ClearDeletedAt() {
  20073. m.deleted_at = nil
  20074. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  20075. }
  20076. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20077. func (m *ServerMutation) DeletedAtCleared() bool {
  20078. _, ok := m.clearedFields[server.FieldDeletedAt]
  20079. return ok
  20080. }
  20081. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20082. func (m *ServerMutation) ResetDeletedAt() {
  20083. m.deleted_at = nil
  20084. delete(m.clearedFields, server.FieldDeletedAt)
  20085. }
  20086. // SetName sets the "name" field.
  20087. func (m *ServerMutation) SetName(s string) {
  20088. m.name = &s
  20089. }
  20090. // Name returns the value of the "name" field in the mutation.
  20091. func (m *ServerMutation) Name() (r string, exists bool) {
  20092. v := m.name
  20093. if v == nil {
  20094. return
  20095. }
  20096. return *v, true
  20097. }
  20098. // OldName returns the old "name" field's value of the Server entity.
  20099. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20101. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  20102. if !m.op.Is(OpUpdateOne) {
  20103. return v, errors.New("OldName is only allowed on UpdateOne operations")
  20104. }
  20105. if m.id == nil || m.oldValue == nil {
  20106. return v, errors.New("OldName requires an ID field in the mutation")
  20107. }
  20108. oldValue, err := m.oldValue(ctx)
  20109. if err != nil {
  20110. return v, fmt.Errorf("querying old value for OldName: %w", err)
  20111. }
  20112. return oldValue.Name, nil
  20113. }
  20114. // ResetName resets all changes to the "name" field.
  20115. func (m *ServerMutation) ResetName() {
  20116. m.name = nil
  20117. }
  20118. // SetPublicIP sets the "public_ip" field.
  20119. func (m *ServerMutation) SetPublicIP(s string) {
  20120. m.public_ip = &s
  20121. }
  20122. // PublicIP returns the value of the "public_ip" field in the mutation.
  20123. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  20124. v := m.public_ip
  20125. if v == nil {
  20126. return
  20127. }
  20128. return *v, true
  20129. }
  20130. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  20131. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20133. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  20134. if !m.op.Is(OpUpdateOne) {
  20135. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  20136. }
  20137. if m.id == nil || m.oldValue == nil {
  20138. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  20139. }
  20140. oldValue, err := m.oldValue(ctx)
  20141. if err != nil {
  20142. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  20143. }
  20144. return oldValue.PublicIP, nil
  20145. }
  20146. // ResetPublicIP resets all changes to the "public_ip" field.
  20147. func (m *ServerMutation) ResetPublicIP() {
  20148. m.public_ip = nil
  20149. }
  20150. // SetPrivateIP sets the "private_ip" field.
  20151. func (m *ServerMutation) SetPrivateIP(s string) {
  20152. m.private_ip = &s
  20153. }
  20154. // PrivateIP returns the value of the "private_ip" field in the mutation.
  20155. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  20156. v := m.private_ip
  20157. if v == nil {
  20158. return
  20159. }
  20160. return *v, true
  20161. }
  20162. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  20163. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20165. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  20166. if !m.op.Is(OpUpdateOne) {
  20167. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  20168. }
  20169. if m.id == nil || m.oldValue == nil {
  20170. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  20171. }
  20172. oldValue, err := m.oldValue(ctx)
  20173. if err != nil {
  20174. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  20175. }
  20176. return oldValue.PrivateIP, nil
  20177. }
  20178. // ResetPrivateIP resets all changes to the "private_ip" field.
  20179. func (m *ServerMutation) ResetPrivateIP() {
  20180. m.private_ip = nil
  20181. }
  20182. // SetAdminPort sets the "admin_port" field.
  20183. func (m *ServerMutation) SetAdminPort(s string) {
  20184. m.admin_port = &s
  20185. }
  20186. // AdminPort returns the value of the "admin_port" field in the mutation.
  20187. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  20188. v := m.admin_port
  20189. if v == nil {
  20190. return
  20191. }
  20192. return *v, true
  20193. }
  20194. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  20195. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20197. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  20198. if !m.op.Is(OpUpdateOne) {
  20199. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  20200. }
  20201. if m.id == nil || m.oldValue == nil {
  20202. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  20203. }
  20204. oldValue, err := m.oldValue(ctx)
  20205. if err != nil {
  20206. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  20207. }
  20208. return oldValue.AdminPort, nil
  20209. }
  20210. // ResetAdminPort resets all changes to the "admin_port" field.
  20211. func (m *ServerMutation) ResetAdminPort() {
  20212. m.admin_port = nil
  20213. }
  20214. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  20215. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  20216. if m.wxs == nil {
  20217. m.wxs = make(map[uint64]struct{})
  20218. }
  20219. for i := range ids {
  20220. m.wxs[ids[i]] = struct{}{}
  20221. }
  20222. }
  20223. // ClearWxs clears the "wxs" edge to the Wx entity.
  20224. func (m *ServerMutation) ClearWxs() {
  20225. m.clearedwxs = true
  20226. }
  20227. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  20228. func (m *ServerMutation) WxsCleared() bool {
  20229. return m.clearedwxs
  20230. }
  20231. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  20232. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  20233. if m.removedwxs == nil {
  20234. m.removedwxs = make(map[uint64]struct{})
  20235. }
  20236. for i := range ids {
  20237. delete(m.wxs, ids[i])
  20238. m.removedwxs[ids[i]] = struct{}{}
  20239. }
  20240. }
  20241. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  20242. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  20243. for id := range m.removedwxs {
  20244. ids = append(ids, id)
  20245. }
  20246. return
  20247. }
  20248. // WxsIDs returns the "wxs" edge IDs in the mutation.
  20249. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  20250. for id := range m.wxs {
  20251. ids = append(ids, id)
  20252. }
  20253. return
  20254. }
  20255. // ResetWxs resets all changes to the "wxs" edge.
  20256. func (m *ServerMutation) ResetWxs() {
  20257. m.wxs = nil
  20258. m.clearedwxs = false
  20259. m.removedwxs = nil
  20260. }
  20261. // Where appends a list predicates to the ServerMutation builder.
  20262. func (m *ServerMutation) Where(ps ...predicate.Server) {
  20263. m.predicates = append(m.predicates, ps...)
  20264. }
  20265. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  20266. // users can use type-assertion to append predicates that do not depend on any generated package.
  20267. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  20268. p := make([]predicate.Server, len(ps))
  20269. for i := range ps {
  20270. p[i] = ps[i]
  20271. }
  20272. m.Where(p...)
  20273. }
  20274. // Op returns the operation name.
  20275. func (m *ServerMutation) Op() Op {
  20276. return m.op
  20277. }
  20278. // SetOp allows setting the mutation operation.
  20279. func (m *ServerMutation) SetOp(op Op) {
  20280. m.op = op
  20281. }
  20282. // Type returns the node type of this mutation (Server).
  20283. func (m *ServerMutation) Type() string {
  20284. return m.typ
  20285. }
  20286. // Fields returns all fields that were changed during this mutation. Note that in
  20287. // order to get all numeric fields that were incremented/decremented, call
  20288. // AddedFields().
  20289. func (m *ServerMutation) Fields() []string {
  20290. fields := make([]string, 0, 8)
  20291. if m.created_at != nil {
  20292. fields = append(fields, server.FieldCreatedAt)
  20293. }
  20294. if m.updated_at != nil {
  20295. fields = append(fields, server.FieldUpdatedAt)
  20296. }
  20297. if m.status != nil {
  20298. fields = append(fields, server.FieldStatus)
  20299. }
  20300. if m.deleted_at != nil {
  20301. fields = append(fields, server.FieldDeletedAt)
  20302. }
  20303. if m.name != nil {
  20304. fields = append(fields, server.FieldName)
  20305. }
  20306. if m.public_ip != nil {
  20307. fields = append(fields, server.FieldPublicIP)
  20308. }
  20309. if m.private_ip != nil {
  20310. fields = append(fields, server.FieldPrivateIP)
  20311. }
  20312. if m.admin_port != nil {
  20313. fields = append(fields, server.FieldAdminPort)
  20314. }
  20315. return fields
  20316. }
  20317. // Field returns the value of a field with the given name. The second boolean
  20318. // return value indicates that this field was not set, or was not defined in the
  20319. // schema.
  20320. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  20321. switch name {
  20322. case server.FieldCreatedAt:
  20323. return m.CreatedAt()
  20324. case server.FieldUpdatedAt:
  20325. return m.UpdatedAt()
  20326. case server.FieldStatus:
  20327. return m.Status()
  20328. case server.FieldDeletedAt:
  20329. return m.DeletedAt()
  20330. case server.FieldName:
  20331. return m.Name()
  20332. case server.FieldPublicIP:
  20333. return m.PublicIP()
  20334. case server.FieldPrivateIP:
  20335. return m.PrivateIP()
  20336. case server.FieldAdminPort:
  20337. return m.AdminPort()
  20338. }
  20339. return nil, false
  20340. }
  20341. // OldField returns the old value of the field from the database. An error is
  20342. // returned if the mutation operation is not UpdateOne, or the query to the
  20343. // database failed.
  20344. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20345. switch name {
  20346. case server.FieldCreatedAt:
  20347. return m.OldCreatedAt(ctx)
  20348. case server.FieldUpdatedAt:
  20349. return m.OldUpdatedAt(ctx)
  20350. case server.FieldStatus:
  20351. return m.OldStatus(ctx)
  20352. case server.FieldDeletedAt:
  20353. return m.OldDeletedAt(ctx)
  20354. case server.FieldName:
  20355. return m.OldName(ctx)
  20356. case server.FieldPublicIP:
  20357. return m.OldPublicIP(ctx)
  20358. case server.FieldPrivateIP:
  20359. return m.OldPrivateIP(ctx)
  20360. case server.FieldAdminPort:
  20361. return m.OldAdminPort(ctx)
  20362. }
  20363. return nil, fmt.Errorf("unknown Server field %s", name)
  20364. }
  20365. // SetField sets the value of a field with the given name. It returns an error if
  20366. // the field is not defined in the schema, or if the type mismatched the field
  20367. // type.
  20368. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  20369. switch name {
  20370. case server.FieldCreatedAt:
  20371. v, ok := value.(time.Time)
  20372. if !ok {
  20373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20374. }
  20375. m.SetCreatedAt(v)
  20376. return nil
  20377. case server.FieldUpdatedAt:
  20378. v, ok := value.(time.Time)
  20379. if !ok {
  20380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20381. }
  20382. m.SetUpdatedAt(v)
  20383. return nil
  20384. case server.FieldStatus:
  20385. v, ok := value.(uint8)
  20386. if !ok {
  20387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20388. }
  20389. m.SetStatus(v)
  20390. return nil
  20391. case server.FieldDeletedAt:
  20392. v, ok := value.(time.Time)
  20393. if !ok {
  20394. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20395. }
  20396. m.SetDeletedAt(v)
  20397. return nil
  20398. case server.FieldName:
  20399. v, ok := value.(string)
  20400. if !ok {
  20401. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20402. }
  20403. m.SetName(v)
  20404. return nil
  20405. case server.FieldPublicIP:
  20406. v, ok := value.(string)
  20407. if !ok {
  20408. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20409. }
  20410. m.SetPublicIP(v)
  20411. return nil
  20412. case server.FieldPrivateIP:
  20413. v, ok := value.(string)
  20414. if !ok {
  20415. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20416. }
  20417. m.SetPrivateIP(v)
  20418. return nil
  20419. case server.FieldAdminPort:
  20420. v, ok := value.(string)
  20421. if !ok {
  20422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20423. }
  20424. m.SetAdminPort(v)
  20425. return nil
  20426. }
  20427. return fmt.Errorf("unknown Server field %s", name)
  20428. }
  20429. // AddedFields returns all numeric fields that were incremented/decremented during
  20430. // this mutation.
  20431. func (m *ServerMutation) AddedFields() []string {
  20432. var fields []string
  20433. if m.addstatus != nil {
  20434. fields = append(fields, server.FieldStatus)
  20435. }
  20436. return fields
  20437. }
  20438. // AddedField returns the numeric value that was incremented/decremented on a field
  20439. // with the given name. The second boolean return value indicates that this field
  20440. // was not set, or was not defined in the schema.
  20441. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  20442. switch name {
  20443. case server.FieldStatus:
  20444. return m.AddedStatus()
  20445. }
  20446. return nil, false
  20447. }
  20448. // AddField adds the value to the field with the given name. It returns an error if
  20449. // the field is not defined in the schema, or if the type mismatched the field
  20450. // type.
  20451. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  20452. switch name {
  20453. case server.FieldStatus:
  20454. v, ok := value.(int8)
  20455. if !ok {
  20456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20457. }
  20458. m.AddStatus(v)
  20459. return nil
  20460. }
  20461. return fmt.Errorf("unknown Server numeric field %s", name)
  20462. }
  20463. // ClearedFields returns all nullable fields that were cleared during this
  20464. // mutation.
  20465. func (m *ServerMutation) ClearedFields() []string {
  20466. var fields []string
  20467. if m.FieldCleared(server.FieldStatus) {
  20468. fields = append(fields, server.FieldStatus)
  20469. }
  20470. if m.FieldCleared(server.FieldDeletedAt) {
  20471. fields = append(fields, server.FieldDeletedAt)
  20472. }
  20473. return fields
  20474. }
  20475. // FieldCleared returns a boolean indicating if a field with the given name was
  20476. // cleared in this mutation.
  20477. func (m *ServerMutation) FieldCleared(name string) bool {
  20478. _, ok := m.clearedFields[name]
  20479. return ok
  20480. }
  20481. // ClearField clears the value of the field with the given name. It returns an
  20482. // error if the field is not defined in the schema.
  20483. func (m *ServerMutation) ClearField(name string) error {
  20484. switch name {
  20485. case server.FieldStatus:
  20486. m.ClearStatus()
  20487. return nil
  20488. case server.FieldDeletedAt:
  20489. m.ClearDeletedAt()
  20490. return nil
  20491. }
  20492. return fmt.Errorf("unknown Server nullable field %s", name)
  20493. }
  20494. // ResetField resets all changes in the mutation for the field with the given name.
  20495. // It returns an error if the field is not defined in the schema.
  20496. func (m *ServerMutation) ResetField(name string) error {
  20497. switch name {
  20498. case server.FieldCreatedAt:
  20499. m.ResetCreatedAt()
  20500. return nil
  20501. case server.FieldUpdatedAt:
  20502. m.ResetUpdatedAt()
  20503. return nil
  20504. case server.FieldStatus:
  20505. m.ResetStatus()
  20506. return nil
  20507. case server.FieldDeletedAt:
  20508. m.ResetDeletedAt()
  20509. return nil
  20510. case server.FieldName:
  20511. m.ResetName()
  20512. return nil
  20513. case server.FieldPublicIP:
  20514. m.ResetPublicIP()
  20515. return nil
  20516. case server.FieldPrivateIP:
  20517. m.ResetPrivateIP()
  20518. return nil
  20519. case server.FieldAdminPort:
  20520. m.ResetAdminPort()
  20521. return nil
  20522. }
  20523. return fmt.Errorf("unknown Server field %s", name)
  20524. }
  20525. // AddedEdges returns all edge names that were set/added in this mutation.
  20526. func (m *ServerMutation) AddedEdges() []string {
  20527. edges := make([]string, 0, 1)
  20528. if m.wxs != nil {
  20529. edges = append(edges, server.EdgeWxs)
  20530. }
  20531. return edges
  20532. }
  20533. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20534. // name in this mutation.
  20535. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  20536. switch name {
  20537. case server.EdgeWxs:
  20538. ids := make([]ent.Value, 0, len(m.wxs))
  20539. for id := range m.wxs {
  20540. ids = append(ids, id)
  20541. }
  20542. return ids
  20543. }
  20544. return nil
  20545. }
  20546. // RemovedEdges returns all edge names that were removed in this mutation.
  20547. func (m *ServerMutation) RemovedEdges() []string {
  20548. edges := make([]string, 0, 1)
  20549. if m.removedwxs != nil {
  20550. edges = append(edges, server.EdgeWxs)
  20551. }
  20552. return edges
  20553. }
  20554. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20555. // the given name in this mutation.
  20556. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  20557. switch name {
  20558. case server.EdgeWxs:
  20559. ids := make([]ent.Value, 0, len(m.removedwxs))
  20560. for id := range m.removedwxs {
  20561. ids = append(ids, id)
  20562. }
  20563. return ids
  20564. }
  20565. return nil
  20566. }
  20567. // ClearedEdges returns all edge names that were cleared in this mutation.
  20568. func (m *ServerMutation) ClearedEdges() []string {
  20569. edges := make([]string, 0, 1)
  20570. if m.clearedwxs {
  20571. edges = append(edges, server.EdgeWxs)
  20572. }
  20573. return edges
  20574. }
  20575. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20576. // was cleared in this mutation.
  20577. func (m *ServerMutation) EdgeCleared(name string) bool {
  20578. switch name {
  20579. case server.EdgeWxs:
  20580. return m.clearedwxs
  20581. }
  20582. return false
  20583. }
  20584. // ClearEdge clears the value of the edge with the given name. It returns an error
  20585. // if that edge is not defined in the schema.
  20586. func (m *ServerMutation) ClearEdge(name string) error {
  20587. switch name {
  20588. }
  20589. return fmt.Errorf("unknown Server unique edge %s", name)
  20590. }
  20591. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20592. // It returns an error if the edge is not defined in the schema.
  20593. func (m *ServerMutation) ResetEdge(name string) error {
  20594. switch name {
  20595. case server.EdgeWxs:
  20596. m.ResetWxs()
  20597. return nil
  20598. }
  20599. return fmt.Errorf("unknown Server edge %s", name)
  20600. }
  20601. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  20602. type SopNodeMutation struct {
  20603. config
  20604. op Op
  20605. typ string
  20606. id *uint64
  20607. created_at *time.Time
  20608. updated_at *time.Time
  20609. status *uint8
  20610. addstatus *int8
  20611. deleted_at *time.Time
  20612. parent_id *uint64
  20613. addparent_id *int64
  20614. name *string
  20615. condition_type *int
  20616. addcondition_type *int
  20617. condition_list *[]string
  20618. appendcondition_list []string
  20619. no_reply_condition *uint64
  20620. addno_reply_condition *int64
  20621. no_reply_unit *string
  20622. action_message *[]custom_types.Action
  20623. appendaction_message []custom_types.Action
  20624. action_label_add *[]uint64
  20625. appendaction_label_add []uint64
  20626. action_label_del *[]uint64
  20627. appendaction_label_del []uint64
  20628. action_forward **custom_types.ActionForward
  20629. clearedFields map[string]struct{}
  20630. sop_stage *uint64
  20631. clearedsop_stage bool
  20632. node_messages map[uint64]struct{}
  20633. removednode_messages map[uint64]struct{}
  20634. clearednode_messages bool
  20635. done bool
  20636. oldValue func(context.Context) (*SopNode, error)
  20637. predicates []predicate.SopNode
  20638. }
  20639. var _ ent.Mutation = (*SopNodeMutation)(nil)
  20640. // sopnodeOption allows management of the mutation configuration using functional options.
  20641. type sopnodeOption func(*SopNodeMutation)
  20642. // newSopNodeMutation creates new mutation for the SopNode entity.
  20643. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  20644. m := &SopNodeMutation{
  20645. config: c,
  20646. op: op,
  20647. typ: TypeSopNode,
  20648. clearedFields: make(map[string]struct{}),
  20649. }
  20650. for _, opt := range opts {
  20651. opt(m)
  20652. }
  20653. return m
  20654. }
  20655. // withSopNodeID sets the ID field of the mutation.
  20656. func withSopNodeID(id uint64) sopnodeOption {
  20657. return func(m *SopNodeMutation) {
  20658. var (
  20659. err error
  20660. once sync.Once
  20661. value *SopNode
  20662. )
  20663. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  20664. once.Do(func() {
  20665. if m.done {
  20666. err = errors.New("querying old values post mutation is not allowed")
  20667. } else {
  20668. value, err = m.Client().SopNode.Get(ctx, id)
  20669. }
  20670. })
  20671. return value, err
  20672. }
  20673. m.id = &id
  20674. }
  20675. }
  20676. // withSopNode sets the old SopNode of the mutation.
  20677. func withSopNode(node *SopNode) sopnodeOption {
  20678. return func(m *SopNodeMutation) {
  20679. m.oldValue = func(context.Context) (*SopNode, error) {
  20680. return node, nil
  20681. }
  20682. m.id = &node.ID
  20683. }
  20684. }
  20685. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20686. // executed in a transaction (ent.Tx), a transactional client is returned.
  20687. func (m SopNodeMutation) Client() *Client {
  20688. client := &Client{config: m.config}
  20689. client.init()
  20690. return client
  20691. }
  20692. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20693. // it returns an error otherwise.
  20694. func (m SopNodeMutation) Tx() (*Tx, error) {
  20695. if _, ok := m.driver.(*txDriver); !ok {
  20696. return nil, errors.New("ent: mutation is not running in a transaction")
  20697. }
  20698. tx := &Tx{config: m.config}
  20699. tx.init()
  20700. return tx, nil
  20701. }
  20702. // SetID sets the value of the id field. Note that this
  20703. // operation is only accepted on creation of SopNode entities.
  20704. func (m *SopNodeMutation) SetID(id uint64) {
  20705. m.id = &id
  20706. }
  20707. // ID returns the ID value in the mutation. Note that the ID is only available
  20708. // if it was provided to the builder or after it was returned from the database.
  20709. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  20710. if m.id == nil {
  20711. return
  20712. }
  20713. return *m.id, true
  20714. }
  20715. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20716. // That means, if the mutation is applied within a transaction with an isolation level such
  20717. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20718. // or updated by the mutation.
  20719. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  20720. switch {
  20721. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20722. id, exists := m.ID()
  20723. if exists {
  20724. return []uint64{id}, nil
  20725. }
  20726. fallthrough
  20727. case m.op.Is(OpUpdate | OpDelete):
  20728. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  20729. default:
  20730. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20731. }
  20732. }
  20733. // SetCreatedAt sets the "created_at" field.
  20734. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  20735. m.created_at = &t
  20736. }
  20737. // CreatedAt returns the value of the "created_at" field in the mutation.
  20738. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  20739. v := m.created_at
  20740. if v == nil {
  20741. return
  20742. }
  20743. return *v, true
  20744. }
  20745. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  20746. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20747. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20748. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20749. if !m.op.Is(OpUpdateOne) {
  20750. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20751. }
  20752. if m.id == nil || m.oldValue == nil {
  20753. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20754. }
  20755. oldValue, err := m.oldValue(ctx)
  20756. if err != nil {
  20757. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20758. }
  20759. return oldValue.CreatedAt, nil
  20760. }
  20761. // ResetCreatedAt resets all changes to the "created_at" field.
  20762. func (m *SopNodeMutation) ResetCreatedAt() {
  20763. m.created_at = nil
  20764. }
  20765. // SetUpdatedAt sets the "updated_at" field.
  20766. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  20767. m.updated_at = &t
  20768. }
  20769. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20770. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  20771. v := m.updated_at
  20772. if v == nil {
  20773. return
  20774. }
  20775. return *v, true
  20776. }
  20777. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  20778. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20780. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20781. if !m.op.Is(OpUpdateOne) {
  20782. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20783. }
  20784. if m.id == nil || m.oldValue == nil {
  20785. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20786. }
  20787. oldValue, err := m.oldValue(ctx)
  20788. if err != nil {
  20789. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20790. }
  20791. return oldValue.UpdatedAt, nil
  20792. }
  20793. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20794. func (m *SopNodeMutation) ResetUpdatedAt() {
  20795. m.updated_at = nil
  20796. }
  20797. // SetStatus sets the "status" field.
  20798. func (m *SopNodeMutation) SetStatus(u uint8) {
  20799. m.status = &u
  20800. m.addstatus = nil
  20801. }
  20802. // Status returns the value of the "status" field in the mutation.
  20803. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  20804. v := m.status
  20805. if v == nil {
  20806. return
  20807. }
  20808. return *v, true
  20809. }
  20810. // OldStatus returns the old "status" field's value of the SopNode entity.
  20811. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20812. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20813. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20814. if !m.op.Is(OpUpdateOne) {
  20815. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20816. }
  20817. if m.id == nil || m.oldValue == nil {
  20818. return v, errors.New("OldStatus requires an ID field in the mutation")
  20819. }
  20820. oldValue, err := m.oldValue(ctx)
  20821. if err != nil {
  20822. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20823. }
  20824. return oldValue.Status, nil
  20825. }
  20826. // AddStatus adds u to the "status" field.
  20827. func (m *SopNodeMutation) AddStatus(u int8) {
  20828. if m.addstatus != nil {
  20829. *m.addstatus += u
  20830. } else {
  20831. m.addstatus = &u
  20832. }
  20833. }
  20834. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20835. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  20836. v := m.addstatus
  20837. if v == nil {
  20838. return
  20839. }
  20840. return *v, true
  20841. }
  20842. // ClearStatus clears the value of the "status" field.
  20843. func (m *SopNodeMutation) ClearStatus() {
  20844. m.status = nil
  20845. m.addstatus = nil
  20846. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  20847. }
  20848. // StatusCleared returns if the "status" field was cleared in this mutation.
  20849. func (m *SopNodeMutation) StatusCleared() bool {
  20850. _, ok := m.clearedFields[sopnode.FieldStatus]
  20851. return ok
  20852. }
  20853. // ResetStatus resets all changes to the "status" field.
  20854. func (m *SopNodeMutation) ResetStatus() {
  20855. m.status = nil
  20856. m.addstatus = nil
  20857. delete(m.clearedFields, sopnode.FieldStatus)
  20858. }
  20859. // SetDeletedAt sets the "deleted_at" field.
  20860. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  20861. m.deleted_at = &t
  20862. }
  20863. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20864. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  20865. v := m.deleted_at
  20866. if v == nil {
  20867. return
  20868. }
  20869. return *v, true
  20870. }
  20871. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  20872. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20874. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20875. if !m.op.Is(OpUpdateOne) {
  20876. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20877. }
  20878. if m.id == nil || m.oldValue == nil {
  20879. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20880. }
  20881. oldValue, err := m.oldValue(ctx)
  20882. if err != nil {
  20883. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20884. }
  20885. return oldValue.DeletedAt, nil
  20886. }
  20887. // ClearDeletedAt clears the value of the "deleted_at" field.
  20888. func (m *SopNodeMutation) ClearDeletedAt() {
  20889. m.deleted_at = nil
  20890. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  20891. }
  20892. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20893. func (m *SopNodeMutation) DeletedAtCleared() bool {
  20894. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  20895. return ok
  20896. }
  20897. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20898. func (m *SopNodeMutation) ResetDeletedAt() {
  20899. m.deleted_at = nil
  20900. delete(m.clearedFields, sopnode.FieldDeletedAt)
  20901. }
  20902. // SetStageID sets the "stage_id" field.
  20903. func (m *SopNodeMutation) SetStageID(u uint64) {
  20904. m.sop_stage = &u
  20905. }
  20906. // StageID returns the value of the "stage_id" field in the mutation.
  20907. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  20908. v := m.sop_stage
  20909. if v == nil {
  20910. return
  20911. }
  20912. return *v, true
  20913. }
  20914. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  20915. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20917. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  20918. if !m.op.Is(OpUpdateOne) {
  20919. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  20920. }
  20921. if m.id == nil || m.oldValue == nil {
  20922. return v, errors.New("OldStageID requires an ID field in the mutation")
  20923. }
  20924. oldValue, err := m.oldValue(ctx)
  20925. if err != nil {
  20926. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  20927. }
  20928. return oldValue.StageID, nil
  20929. }
  20930. // ResetStageID resets all changes to the "stage_id" field.
  20931. func (m *SopNodeMutation) ResetStageID() {
  20932. m.sop_stage = nil
  20933. }
  20934. // SetParentID sets the "parent_id" field.
  20935. func (m *SopNodeMutation) SetParentID(u uint64) {
  20936. m.parent_id = &u
  20937. m.addparent_id = nil
  20938. }
  20939. // ParentID returns the value of the "parent_id" field in the mutation.
  20940. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  20941. v := m.parent_id
  20942. if v == nil {
  20943. return
  20944. }
  20945. return *v, true
  20946. }
  20947. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  20948. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20950. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  20951. if !m.op.Is(OpUpdateOne) {
  20952. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  20953. }
  20954. if m.id == nil || m.oldValue == nil {
  20955. return v, errors.New("OldParentID requires an ID field in the mutation")
  20956. }
  20957. oldValue, err := m.oldValue(ctx)
  20958. if err != nil {
  20959. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  20960. }
  20961. return oldValue.ParentID, nil
  20962. }
  20963. // AddParentID adds u to the "parent_id" field.
  20964. func (m *SopNodeMutation) AddParentID(u int64) {
  20965. if m.addparent_id != nil {
  20966. *m.addparent_id += u
  20967. } else {
  20968. m.addparent_id = &u
  20969. }
  20970. }
  20971. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  20972. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  20973. v := m.addparent_id
  20974. if v == nil {
  20975. return
  20976. }
  20977. return *v, true
  20978. }
  20979. // ResetParentID resets all changes to the "parent_id" field.
  20980. func (m *SopNodeMutation) ResetParentID() {
  20981. m.parent_id = nil
  20982. m.addparent_id = nil
  20983. }
  20984. // SetName sets the "name" field.
  20985. func (m *SopNodeMutation) SetName(s string) {
  20986. m.name = &s
  20987. }
  20988. // Name returns the value of the "name" field in the mutation.
  20989. func (m *SopNodeMutation) Name() (r string, exists bool) {
  20990. v := m.name
  20991. if v == nil {
  20992. return
  20993. }
  20994. return *v, true
  20995. }
  20996. // OldName returns the old "name" field's value of the SopNode entity.
  20997. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20999. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  21000. if !m.op.Is(OpUpdateOne) {
  21001. return v, errors.New("OldName is only allowed on UpdateOne operations")
  21002. }
  21003. if m.id == nil || m.oldValue == nil {
  21004. return v, errors.New("OldName requires an ID field in the mutation")
  21005. }
  21006. oldValue, err := m.oldValue(ctx)
  21007. if err != nil {
  21008. return v, fmt.Errorf("querying old value for OldName: %w", err)
  21009. }
  21010. return oldValue.Name, nil
  21011. }
  21012. // ResetName resets all changes to the "name" field.
  21013. func (m *SopNodeMutation) ResetName() {
  21014. m.name = nil
  21015. }
  21016. // SetConditionType sets the "condition_type" field.
  21017. func (m *SopNodeMutation) SetConditionType(i int) {
  21018. m.condition_type = &i
  21019. m.addcondition_type = nil
  21020. }
  21021. // ConditionType returns the value of the "condition_type" field in the mutation.
  21022. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  21023. v := m.condition_type
  21024. if v == nil {
  21025. return
  21026. }
  21027. return *v, true
  21028. }
  21029. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  21030. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21032. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  21033. if !m.op.Is(OpUpdateOne) {
  21034. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  21035. }
  21036. if m.id == nil || m.oldValue == nil {
  21037. return v, errors.New("OldConditionType requires an ID field in the mutation")
  21038. }
  21039. oldValue, err := m.oldValue(ctx)
  21040. if err != nil {
  21041. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  21042. }
  21043. return oldValue.ConditionType, nil
  21044. }
  21045. // AddConditionType adds i to the "condition_type" field.
  21046. func (m *SopNodeMutation) AddConditionType(i int) {
  21047. if m.addcondition_type != nil {
  21048. *m.addcondition_type += i
  21049. } else {
  21050. m.addcondition_type = &i
  21051. }
  21052. }
  21053. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  21054. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  21055. v := m.addcondition_type
  21056. if v == nil {
  21057. return
  21058. }
  21059. return *v, true
  21060. }
  21061. // ResetConditionType resets all changes to the "condition_type" field.
  21062. func (m *SopNodeMutation) ResetConditionType() {
  21063. m.condition_type = nil
  21064. m.addcondition_type = nil
  21065. }
  21066. // SetConditionList sets the "condition_list" field.
  21067. func (m *SopNodeMutation) SetConditionList(s []string) {
  21068. m.condition_list = &s
  21069. m.appendcondition_list = nil
  21070. }
  21071. // ConditionList returns the value of the "condition_list" field in the mutation.
  21072. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  21073. v := m.condition_list
  21074. if v == nil {
  21075. return
  21076. }
  21077. return *v, true
  21078. }
  21079. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  21080. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21082. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  21083. if !m.op.Is(OpUpdateOne) {
  21084. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  21085. }
  21086. if m.id == nil || m.oldValue == nil {
  21087. return v, errors.New("OldConditionList requires an ID field in the mutation")
  21088. }
  21089. oldValue, err := m.oldValue(ctx)
  21090. if err != nil {
  21091. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  21092. }
  21093. return oldValue.ConditionList, nil
  21094. }
  21095. // AppendConditionList adds s to the "condition_list" field.
  21096. func (m *SopNodeMutation) AppendConditionList(s []string) {
  21097. m.appendcondition_list = append(m.appendcondition_list, s...)
  21098. }
  21099. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  21100. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  21101. if len(m.appendcondition_list) == 0 {
  21102. return nil, false
  21103. }
  21104. return m.appendcondition_list, true
  21105. }
  21106. // ClearConditionList clears the value of the "condition_list" field.
  21107. func (m *SopNodeMutation) ClearConditionList() {
  21108. m.condition_list = nil
  21109. m.appendcondition_list = nil
  21110. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  21111. }
  21112. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  21113. func (m *SopNodeMutation) ConditionListCleared() bool {
  21114. _, ok := m.clearedFields[sopnode.FieldConditionList]
  21115. return ok
  21116. }
  21117. // ResetConditionList resets all changes to the "condition_list" field.
  21118. func (m *SopNodeMutation) ResetConditionList() {
  21119. m.condition_list = nil
  21120. m.appendcondition_list = nil
  21121. delete(m.clearedFields, sopnode.FieldConditionList)
  21122. }
  21123. // SetNoReplyCondition sets the "no_reply_condition" field.
  21124. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  21125. m.no_reply_condition = &u
  21126. m.addno_reply_condition = nil
  21127. }
  21128. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  21129. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  21130. v := m.no_reply_condition
  21131. if v == nil {
  21132. return
  21133. }
  21134. return *v, true
  21135. }
  21136. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  21137. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21139. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  21140. if !m.op.Is(OpUpdateOne) {
  21141. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  21142. }
  21143. if m.id == nil || m.oldValue == nil {
  21144. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  21145. }
  21146. oldValue, err := m.oldValue(ctx)
  21147. if err != nil {
  21148. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  21149. }
  21150. return oldValue.NoReplyCondition, nil
  21151. }
  21152. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  21153. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  21154. if m.addno_reply_condition != nil {
  21155. *m.addno_reply_condition += u
  21156. } else {
  21157. m.addno_reply_condition = &u
  21158. }
  21159. }
  21160. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  21161. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  21162. v := m.addno_reply_condition
  21163. if v == nil {
  21164. return
  21165. }
  21166. return *v, true
  21167. }
  21168. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  21169. func (m *SopNodeMutation) ResetNoReplyCondition() {
  21170. m.no_reply_condition = nil
  21171. m.addno_reply_condition = nil
  21172. }
  21173. // SetNoReplyUnit sets the "no_reply_unit" field.
  21174. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  21175. m.no_reply_unit = &s
  21176. }
  21177. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  21178. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  21179. v := m.no_reply_unit
  21180. if v == nil {
  21181. return
  21182. }
  21183. return *v, true
  21184. }
  21185. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  21186. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21188. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  21189. if !m.op.Is(OpUpdateOne) {
  21190. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  21191. }
  21192. if m.id == nil || m.oldValue == nil {
  21193. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  21194. }
  21195. oldValue, err := m.oldValue(ctx)
  21196. if err != nil {
  21197. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  21198. }
  21199. return oldValue.NoReplyUnit, nil
  21200. }
  21201. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  21202. func (m *SopNodeMutation) ResetNoReplyUnit() {
  21203. m.no_reply_unit = nil
  21204. }
  21205. // SetActionMessage sets the "action_message" field.
  21206. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  21207. m.action_message = &ct
  21208. m.appendaction_message = nil
  21209. }
  21210. // ActionMessage returns the value of the "action_message" field in the mutation.
  21211. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  21212. v := m.action_message
  21213. if v == nil {
  21214. return
  21215. }
  21216. return *v, true
  21217. }
  21218. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  21219. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21221. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  21222. if !m.op.Is(OpUpdateOne) {
  21223. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  21224. }
  21225. if m.id == nil || m.oldValue == nil {
  21226. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  21227. }
  21228. oldValue, err := m.oldValue(ctx)
  21229. if err != nil {
  21230. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  21231. }
  21232. return oldValue.ActionMessage, nil
  21233. }
  21234. // AppendActionMessage adds ct to the "action_message" field.
  21235. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  21236. m.appendaction_message = append(m.appendaction_message, ct...)
  21237. }
  21238. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  21239. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  21240. if len(m.appendaction_message) == 0 {
  21241. return nil, false
  21242. }
  21243. return m.appendaction_message, true
  21244. }
  21245. // ClearActionMessage clears the value of the "action_message" field.
  21246. func (m *SopNodeMutation) ClearActionMessage() {
  21247. m.action_message = nil
  21248. m.appendaction_message = nil
  21249. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  21250. }
  21251. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  21252. func (m *SopNodeMutation) ActionMessageCleared() bool {
  21253. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  21254. return ok
  21255. }
  21256. // ResetActionMessage resets all changes to the "action_message" field.
  21257. func (m *SopNodeMutation) ResetActionMessage() {
  21258. m.action_message = nil
  21259. m.appendaction_message = nil
  21260. delete(m.clearedFields, sopnode.FieldActionMessage)
  21261. }
  21262. // SetActionLabelAdd sets the "action_label_add" field.
  21263. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  21264. m.action_label_add = &u
  21265. m.appendaction_label_add = nil
  21266. }
  21267. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  21268. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  21269. v := m.action_label_add
  21270. if v == nil {
  21271. return
  21272. }
  21273. return *v, true
  21274. }
  21275. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  21276. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21278. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  21279. if !m.op.Is(OpUpdateOne) {
  21280. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  21281. }
  21282. if m.id == nil || m.oldValue == nil {
  21283. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  21284. }
  21285. oldValue, err := m.oldValue(ctx)
  21286. if err != nil {
  21287. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  21288. }
  21289. return oldValue.ActionLabelAdd, nil
  21290. }
  21291. // AppendActionLabelAdd adds u to the "action_label_add" field.
  21292. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  21293. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  21294. }
  21295. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  21296. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  21297. if len(m.appendaction_label_add) == 0 {
  21298. return nil, false
  21299. }
  21300. return m.appendaction_label_add, true
  21301. }
  21302. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  21303. func (m *SopNodeMutation) ClearActionLabelAdd() {
  21304. m.action_label_add = nil
  21305. m.appendaction_label_add = nil
  21306. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  21307. }
  21308. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  21309. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  21310. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  21311. return ok
  21312. }
  21313. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  21314. func (m *SopNodeMutation) ResetActionLabelAdd() {
  21315. m.action_label_add = nil
  21316. m.appendaction_label_add = nil
  21317. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  21318. }
  21319. // SetActionLabelDel sets the "action_label_del" field.
  21320. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  21321. m.action_label_del = &u
  21322. m.appendaction_label_del = nil
  21323. }
  21324. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  21325. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  21326. v := m.action_label_del
  21327. if v == nil {
  21328. return
  21329. }
  21330. return *v, true
  21331. }
  21332. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  21333. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21335. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  21336. if !m.op.Is(OpUpdateOne) {
  21337. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  21338. }
  21339. if m.id == nil || m.oldValue == nil {
  21340. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  21341. }
  21342. oldValue, err := m.oldValue(ctx)
  21343. if err != nil {
  21344. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  21345. }
  21346. return oldValue.ActionLabelDel, nil
  21347. }
  21348. // AppendActionLabelDel adds u to the "action_label_del" field.
  21349. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  21350. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  21351. }
  21352. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  21353. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  21354. if len(m.appendaction_label_del) == 0 {
  21355. return nil, false
  21356. }
  21357. return m.appendaction_label_del, true
  21358. }
  21359. // ClearActionLabelDel clears the value of the "action_label_del" field.
  21360. func (m *SopNodeMutation) ClearActionLabelDel() {
  21361. m.action_label_del = nil
  21362. m.appendaction_label_del = nil
  21363. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  21364. }
  21365. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  21366. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  21367. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  21368. return ok
  21369. }
  21370. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  21371. func (m *SopNodeMutation) ResetActionLabelDel() {
  21372. m.action_label_del = nil
  21373. m.appendaction_label_del = nil
  21374. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  21375. }
  21376. // SetActionForward sets the "action_forward" field.
  21377. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  21378. m.action_forward = &ctf
  21379. }
  21380. // ActionForward returns the value of the "action_forward" field in the mutation.
  21381. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  21382. v := m.action_forward
  21383. if v == nil {
  21384. return
  21385. }
  21386. return *v, true
  21387. }
  21388. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  21389. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21391. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  21392. if !m.op.Is(OpUpdateOne) {
  21393. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  21394. }
  21395. if m.id == nil || m.oldValue == nil {
  21396. return v, errors.New("OldActionForward requires an ID field in the mutation")
  21397. }
  21398. oldValue, err := m.oldValue(ctx)
  21399. if err != nil {
  21400. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  21401. }
  21402. return oldValue.ActionForward, nil
  21403. }
  21404. // ClearActionForward clears the value of the "action_forward" field.
  21405. func (m *SopNodeMutation) ClearActionForward() {
  21406. m.action_forward = nil
  21407. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  21408. }
  21409. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  21410. func (m *SopNodeMutation) ActionForwardCleared() bool {
  21411. _, ok := m.clearedFields[sopnode.FieldActionForward]
  21412. return ok
  21413. }
  21414. // ResetActionForward resets all changes to the "action_forward" field.
  21415. func (m *SopNodeMutation) ResetActionForward() {
  21416. m.action_forward = nil
  21417. delete(m.clearedFields, sopnode.FieldActionForward)
  21418. }
  21419. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  21420. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  21421. m.sop_stage = &id
  21422. }
  21423. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  21424. func (m *SopNodeMutation) ClearSopStage() {
  21425. m.clearedsop_stage = true
  21426. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  21427. }
  21428. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  21429. func (m *SopNodeMutation) SopStageCleared() bool {
  21430. return m.clearedsop_stage
  21431. }
  21432. // SopStageID returns the "sop_stage" edge ID in the mutation.
  21433. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  21434. if m.sop_stage != nil {
  21435. return *m.sop_stage, true
  21436. }
  21437. return
  21438. }
  21439. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  21440. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21441. // SopStageID instead. It exists only for internal usage by the builders.
  21442. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  21443. if id := m.sop_stage; id != nil {
  21444. ids = append(ids, *id)
  21445. }
  21446. return
  21447. }
  21448. // ResetSopStage resets all changes to the "sop_stage" edge.
  21449. func (m *SopNodeMutation) ResetSopStage() {
  21450. m.sop_stage = nil
  21451. m.clearedsop_stage = false
  21452. }
  21453. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  21454. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  21455. if m.node_messages == nil {
  21456. m.node_messages = make(map[uint64]struct{})
  21457. }
  21458. for i := range ids {
  21459. m.node_messages[ids[i]] = struct{}{}
  21460. }
  21461. }
  21462. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  21463. func (m *SopNodeMutation) ClearNodeMessages() {
  21464. m.clearednode_messages = true
  21465. }
  21466. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  21467. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  21468. return m.clearednode_messages
  21469. }
  21470. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  21471. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  21472. if m.removednode_messages == nil {
  21473. m.removednode_messages = make(map[uint64]struct{})
  21474. }
  21475. for i := range ids {
  21476. delete(m.node_messages, ids[i])
  21477. m.removednode_messages[ids[i]] = struct{}{}
  21478. }
  21479. }
  21480. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  21481. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  21482. for id := range m.removednode_messages {
  21483. ids = append(ids, id)
  21484. }
  21485. return
  21486. }
  21487. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  21488. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  21489. for id := range m.node_messages {
  21490. ids = append(ids, id)
  21491. }
  21492. return
  21493. }
  21494. // ResetNodeMessages resets all changes to the "node_messages" edge.
  21495. func (m *SopNodeMutation) ResetNodeMessages() {
  21496. m.node_messages = nil
  21497. m.clearednode_messages = false
  21498. m.removednode_messages = nil
  21499. }
  21500. // Where appends a list predicates to the SopNodeMutation builder.
  21501. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  21502. m.predicates = append(m.predicates, ps...)
  21503. }
  21504. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  21505. // users can use type-assertion to append predicates that do not depend on any generated package.
  21506. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  21507. p := make([]predicate.SopNode, len(ps))
  21508. for i := range ps {
  21509. p[i] = ps[i]
  21510. }
  21511. m.Where(p...)
  21512. }
  21513. // Op returns the operation name.
  21514. func (m *SopNodeMutation) Op() Op {
  21515. return m.op
  21516. }
  21517. // SetOp allows setting the mutation operation.
  21518. func (m *SopNodeMutation) SetOp(op Op) {
  21519. m.op = op
  21520. }
  21521. // Type returns the node type of this mutation (SopNode).
  21522. func (m *SopNodeMutation) Type() string {
  21523. return m.typ
  21524. }
  21525. // Fields returns all fields that were changed during this mutation. Note that in
  21526. // order to get all numeric fields that were incremented/decremented, call
  21527. // AddedFields().
  21528. func (m *SopNodeMutation) Fields() []string {
  21529. fields := make([]string, 0, 15)
  21530. if m.created_at != nil {
  21531. fields = append(fields, sopnode.FieldCreatedAt)
  21532. }
  21533. if m.updated_at != nil {
  21534. fields = append(fields, sopnode.FieldUpdatedAt)
  21535. }
  21536. if m.status != nil {
  21537. fields = append(fields, sopnode.FieldStatus)
  21538. }
  21539. if m.deleted_at != nil {
  21540. fields = append(fields, sopnode.FieldDeletedAt)
  21541. }
  21542. if m.sop_stage != nil {
  21543. fields = append(fields, sopnode.FieldStageID)
  21544. }
  21545. if m.parent_id != nil {
  21546. fields = append(fields, sopnode.FieldParentID)
  21547. }
  21548. if m.name != nil {
  21549. fields = append(fields, sopnode.FieldName)
  21550. }
  21551. if m.condition_type != nil {
  21552. fields = append(fields, sopnode.FieldConditionType)
  21553. }
  21554. if m.condition_list != nil {
  21555. fields = append(fields, sopnode.FieldConditionList)
  21556. }
  21557. if m.no_reply_condition != nil {
  21558. fields = append(fields, sopnode.FieldNoReplyCondition)
  21559. }
  21560. if m.no_reply_unit != nil {
  21561. fields = append(fields, sopnode.FieldNoReplyUnit)
  21562. }
  21563. if m.action_message != nil {
  21564. fields = append(fields, sopnode.FieldActionMessage)
  21565. }
  21566. if m.action_label_add != nil {
  21567. fields = append(fields, sopnode.FieldActionLabelAdd)
  21568. }
  21569. if m.action_label_del != nil {
  21570. fields = append(fields, sopnode.FieldActionLabelDel)
  21571. }
  21572. if m.action_forward != nil {
  21573. fields = append(fields, sopnode.FieldActionForward)
  21574. }
  21575. return fields
  21576. }
  21577. // Field returns the value of a field with the given name. The second boolean
  21578. // return value indicates that this field was not set, or was not defined in the
  21579. // schema.
  21580. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  21581. switch name {
  21582. case sopnode.FieldCreatedAt:
  21583. return m.CreatedAt()
  21584. case sopnode.FieldUpdatedAt:
  21585. return m.UpdatedAt()
  21586. case sopnode.FieldStatus:
  21587. return m.Status()
  21588. case sopnode.FieldDeletedAt:
  21589. return m.DeletedAt()
  21590. case sopnode.FieldStageID:
  21591. return m.StageID()
  21592. case sopnode.FieldParentID:
  21593. return m.ParentID()
  21594. case sopnode.FieldName:
  21595. return m.Name()
  21596. case sopnode.FieldConditionType:
  21597. return m.ConditionType()
  21598. case sopnode.FieldConditionList:
  21599. return m.ConditionList()
  21600. case sopnode.FieldNoReplyCondition:
  21601. return m.NoReplyCondition()
  21602. case sopnode.FieldNoReplyUnit:
  21603. return m.NoReplyUnit()
  21604. case sopnode.FieldActionMessage:
  21605. return m.ActionMessage()
  21606. case sopnode.FieldActionLabelAdd:
  21607. return m.ActionLabelAdd()
  21608. case sopnode.FieldActionLabelDel:
  21609. return m.ActionLabelDel()
  21610. case sopnode.FieldActionForward:
  21611. return m.ActionForward()
  21612. }
  21613. return nil, false
  21614. }
  21615. // OldField returns the old value of the field from the database. An error is
  21616. // returned if the mutation operation is not UpdateOne, or the query to the
  21617. // database failed.
  21618. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21619. switch name {
  21620. case sopnode.FieldCreatedAt:
  21621. return m.OldCreatedAt(ctx)
  21622. case sopnode.FieldUpdatedAt:
  21623. return m.OldUpdatedAt(ctx)
  21624. case sopnode.FieldStatus:
  21625. return m.OldStatus(ctx)
  21626. case sopnode.FieldDeletedAt:
  21627. return m.OldDeletedAt(ctx)
  21628. case sopnode.FieldStageID:
  21629. return m.OldStageID(ctx)
  21630. case sopnode.FieldParentID:
  21631. return m.OldParentID(ctx)
  21632. case sopnode.FieldName:
  21633. return m.OldName(ctx)
  21634. case sopnode.FieldConditionType:
  21635. return m.OldConditionType(ctx)
  21636. case sopnode.FieldConditionList:
  21637. return m.OldConditionList(ctx)
  21638. case sopnode.FieldNoReplyCondition:
  21639. return m.OldNoReplyCondition(ctx)
  21640. case sopnode.FieldNoReplyUnit:
  21641. return m.OldNoReplyUnit(ctx)
  21642. case sopnode.FieldActionMessage:
  21643. return m.OldActionMessage(ctx)
  21644. case sopnode.FieldActionLabelAdd:
  21645. return m.OldActionLabelAdd(ctx)
  21646. case sopnode.FieldActionLabelDel:
  21647. return m.OldActionLabelDel(ctx)
  21648. case sopnode.FieldActionForward:
  21649. return m.OldActionForward(ctx)
  21650. }
  21651. return nil, fmt.Errorf("unknown SopNode field %s", name)
  21652. }
  21653. // SetField sets the value of a field with the given name. It returns an error if
  21654. // the field is not defined in the schema, or if the type mismatched the field
  21655. // type.
  21656. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  21657. switch name {
  21658. case sopnode.FieldCreatedAt:
  21659. v, ok := value.(time.Time)
  21660. if !ok {
  21661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21662. }
  21663. m.SetCreatedAt(v)
  21664. return nil
  21665. case sopnode.FieldUpdatedAt:
  21666. v, ok := value.(time.Time)
  21667. if !ok {
  21668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21669. }
  21670. m.SetUpdatedAt(v)
  21671. return nil
  21672. case sopnode.FieldStatus:
  21673. v, ok := value.(uint8)
  21674. if !ok {
  21675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21676. }
  21677. m.SetStatus(v)
  21678. return nil
  21679. case sopnode.FieldDeletedAt:
  21680. v, ok := value.(time.Time)
  21681. if !ok {
  21682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21683. }
  21684. m.SetDeletedAt(v)
  21685. return nil
  21686. case sopnode.FieldStageID:
  21687. v, ok := value.(uint64)
  21688. if !ok {
  21689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21690. }
  21691. m.SetStageID(v)
  21692. return nil
  21693. case sopnode.FieldParentID:
  21694. v, ok := value.(uint64)
  21695. if !ok {
  21696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21697. }
  21698. m.SetParentID(v)
  21699. return nil
  21700. case sopnode.FieldName:
  21701. v, ok := value.(string)
  21702. if !ok {
  21703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21704. }
  21705. m.SetName(v)
  21706. return nil
  21707. case sopnode.FieldConditionType:
  21708. v, ok := value.(int)
  21709. if !ok {
  21710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21711. }
  21712. m.SetConditionType(v)
  21713. return nil
  21714. case sopnode.FieldConditionList:
  21715. v, ok := value.([]string)
  21716. if !ok {
  21717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21718. }
  21719. m.SetConditionList(v)
  21720. return nil
  21721. case sopnode.FieldNoReplyCondition:
  21722. v, ok := value.(uint64)
  21723. if !ok {
  21724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21725. }
  21726. m.SetNoReplyCondition(v)
  21727. return nil
  21728. case sopnode.FieldNoReplyUnit:
  21729. v, ok := value.(string)
  21730. if !ok {
  21731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21732. }
  21733. m.SetNoReplyUnit(v)
  21734. return nil
  21735. case sopnode.FieldActionMessage:
  21736. v, ok := value.([]custom_types.Action)
  21737. if !ok {
  21738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21739. }
  21740. m.SetActionMessage(v)
  21741. return nil
  21742. case sopnode.FieldActionLabelAdd:
  21743. v, ok := value.([]uint64)
  21744. if !ok {
  21745. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21746. }
  21747. m.SetActionLabelAdd(v)
  21748. return nil
  21749. case sopnode.FieldActionLabelDel:
  21750. v, ok := value.([]uint64)
  21751. if !ok {
  21752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21753. }
  21754. m.SetActionLabelDel(v)
  21755. return nil
  21756. case sopnode.FieldActionForward:
  21757. v, ok := value.(*custom_types.ActionForward)
  21758. if !ok {
  21759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21760. }
  21761. m.SetActionForward(v)
  21762. return nil
  21763. }
  21764. return fmt.Errorf("unknown SopNode field %s", name)
  21765. }
  21766. // AddedFields returns all numeric fields that were incremented/decremented during
  21767. // this mutation.
  21768. func (m *SopNodeMutation) AddedFields() []string {
  21769. var fields []string
  21770. if m.addstatus != nil {
  21771. fields = append(fields, sopnode.FieldStatus)
  21772. }
  21773. if m.addparent_id != nil {
  21774. fields = append(fields, sopnode.FieldParentID)
  21775. }
  21776. if m.addcondition_type != nil {
  21777. fields = append(fields, sopnode.FieldConditionType)
  21778. }
  21779. if m.addno_reply_condition != nil {
  21780. fields = append(fields, sopnode.FieldNoReplyCondition)
  21781. }
  21782. return fields
  21783. }
  21784. // AddedField returns the numeric value that was incremented/decremented on a field
  21785. // with the given name. The second boolean return value indicates that this field
  21786. // was not set, or was not defined in the schema.
  21787. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  21788. switch name {
  21789. case sopnode.FieldStatus:
  21790. return m.AddedStatus()
  21791. case sopnode.FieldParentID:
  21792. return m.AddedParentID()
  21793. case sopnode.FieldConditionType:
  21794. return m.AddedConditionType()
  21795. case sopnode.FieldNoReplyCondition:
  21796. return m.AddedNoReplyCondition()
  21797. }
  21798. return nil, false
  21799. }
  21800. // AddField adds the value to the field with the given name. It returns an error if
  21801. // the field is not defined in the schema, or if the type mismatched the field
  21802. // type.
  21803. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  21804. switch name {
  21805. case sopnode.FieldStatus:
  21806. v, ok := value.(int8)
  21807. if !ok {
  21808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21809. }
  21810. m.AddStatus(v)
  21811. return nil
  21812. case sopnode.FieldParentID:
  21813. v, ok := value.(int64)
  21814. if !ok {
  21815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21816. }
  21817. m.AddParentID(v)
  21818. return nil
  21819. case sopnode.FieldConditionType:
  21820. v, ok := value.(int)
  21821. if !ok {
  21822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21823. }
  21824. m.AddConditionType(v)
  21825. return nil
  21826. case sopnode.FieldNoReplyCondition:
  21827. v, ok := value.(int64)
  21828. if !ok {
  21829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21830. }
  21831. m.AddNoReplyCondition(v)
  21832. return nil
  21833. }
  21834. return fmt.Errorf("unknown SopNode numeric field %s", name)
  21835. }
  21836. // ClearedFields returns all nullable fields that were cleared during this
  21837. // mutation.
  21838. func (m *SopNodeMutation) ClearedFields() []string {
  21839. var fields []string
  21840. if m.FieldCleared(sopnode.FieldStatus) {
  21841. fields = append(fields, sopnode.FieldStatus)
  21842. }
  21843. if m.FieldCleared(sopnode.FieldDeletedAt) {
  21844. fields = append(fields, sopnode.FieldDeletedAt)
  21845. }
  21846. if m.FieldCleared(sopnode.FieldConditionList) {
  21847. fields = append(fields, sopnode.FieldConditionList)
  21848. }
  21849. if m.FieldCleared(sopnode.FieldActionMessage) {
  21850. fields = append(fields, sopnode.FieldActionMessage)
  21851. }
  21852. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  21853. fields = append(fields, sopnode.FieldActionLabelAdd)
  21854. }
  21855. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  21856. fields = append(fields, sopnode.FieldActionLabelDel)
  21857. }
  21858. if m.FieldCleared(sopnode.FieldActionForward) {
  21859. fields = append(fields, sopnode.FieldActionForward)
  21860. }
  21861. return fields
  21862. }
  21863. // FieldCleared returns a boolean indicating if a field with the given name was
  21864. // cleared in this mutation.
  21865. func (m *SopNodeMutation) FieldCleared(name string) bool {
  21866. _, ok := m.clearedFields[name]
  21867. return ok
  21868. }
  21869. // ClearField clears the value of the field with the given name. It returns an
  21870. // error if the field is not defined in the schema.
  21871. func (m *SopNodeMutation) ClearField(name string) error {
  21872. switch name {
  21873. case sopnode.FieldStatus:
  21874. m.ClearStatus()
  21875. return nil
  21876. case sopnode.FieldDeletedAt:
  21877. m.ClearDeletedAt()
  21878. return nil
  21879. case sopnode.FieldConditionList:
  21880. m.ClearConditionList()
  21881. return nil
  21882. case sopnode.FieldActionMessage:
  21883. m.ClearActionMessage()
  21884. return nil
  21885. case sopnode.FieldActionLabelAdd:
  21886. m.ClearActionLabelAdd()
  21887. return nil
  21888. case sopnode.FieldActionLabelDel:
  21889. m.ClearActionLabelDel()
  21890. return nil
  21891. case sopnode.FieldActionForward:
  21892. m.ClearActionForward()
  21893. return nil
  21894. }
  21895. return fmt.Errorf("unknown SopNode nullable field %s", name)
  21896. }
  21897. // ResetField resets all changes in the mutation for the field with the given name.
  21898. // It returns an error if the field is not defined in the schema.
  21899. func (m *SopNodeMutation) ResetField(name string) error {
  21900. switch name {
  21901. case sopnode.FieldCreatedAt:
  21902. m.ResetCreatedAt()
  21903. return nil
  21904. case sopnode.FieldUpdatedAt:
  21905. m.ResetUpdatedAt()
  21906. return nil
  21907. case sopnode.FieldStatus:
  21908. m.ResetStatus()
  21909. return nil
  21910. case sopnode.FieldDeletedAt:
  21911. m.ResetDeletedAt()
  21912. return nil
  21913. case sopnode.FieldStageID:
  21914. m.ResetStageID()
  21915. return nil
  21916. case sopnode.FieldParentID:
  21917. m.ResetParentID()
  21918. return nil
  21919. case sopnode.FieldName:
  21920. m.ResetName()
  21921. return nil
  21922. case sopnode.FieldConditionType:
  21923. m.ResetConditionType()
  21924. return nil
  21925. case sopnode.FieldConditionList:
  21926. m.ResetConditionList()
  21927. return nil
  21928. case sopnode.FieldNoReplyCondition:
  21929. m.ResetNoReplyCondition()
  21930. return nil
  21931. case sopnode.FieldNoReplyUnit:
  21932. m.ResetNoReplyUnit()
  21933. return nil
  21934. case sopnode.FieldActionMessage:
  21935. m.ResetActionMessage()
  21936. return nil
  21937. case sopnode.FieldActionLabelAdd:
  21938. m.ResetActionLabelAdd()
  21939. return nil
  21940. case sopnode.FieldActionLabelDel:
  21941. m.ResetActionLabelDel()
  21942. return nil
  21943. case sopnode.FieldActionForward:
  21944. m.ResetActionForward()
  21945. return nil
  21946. }
  21947. return fmt.Errorf("unknown SopNode field %s", name)
  21948. }
  21949. // AddedEdges returns all edge names that were set/added in this mutation.
  21950. func (m *SopNodeMutation) AddedEdges() []string {
  21951. edges := make([]string, 0, 2)
  21952. if m.sop_stage != nil {
  21953. edges = append(edges, sopnode.EdgeSopStage)
  21954. }
  21955. if m.node_messages != nil {
  21956. edges = append(edges, sopnode.EdgeNodeMessages)
  21957. }
  21958. return edges
  21959. }
  21960. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21961. // name in this mutation.
  21962. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  21963. switch name {
  21964. case sopnode.EdgeSopStage:
  21965. if id := m.sop_stage; id != nil {
  21966. return []ent.Value{*id}
  21967. }
  21968. case sopnode.EdgeNodeMessages:
  21969. ids := make([]ent.Value, 0, len(m.node_messages))
  21970. for id := range m.node_messages {
  21971. ids = append(ids, id)
  21972. }
  21973. return ids
  21974. }
  21975. return nil
  21976. }
  21977. // RemovedEdges returns all edge names that were removed in this mutation.
  21978. func (m *SopNodeMutation) RemovedEdges() []string {
  21979. edges := make([]string, 0, 2)
  21980. if m.removednode_messages != nil {
  21981. edges = append(edges, sopnode.EdgeNodeMessages)
  21982. }
  21983. return edges
  21984. }
  21985. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21986. // the given name in this mutation.
  21987. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  21988. switch name {
  21989. case sopnode.EdgeNodeMessages:
  21990. ids := make([]ent.Value, 0, len(m.removednode_messages))
  21991. for id := range m.removednode_messages {
  21992. ids = append(ids, id)
  21993. }
  21994. return ids
  21995. }
  21996. return nil
  21997. }
  21998. // ClearedEdges returns all edge names that were cleared in this mutation.
  21999. func (m *SopNodeMutation) ClearedEdges() []string {
  22000. edges := make([]string, 0, 2)
  22001. if m.clearedsop_stage {
  22002. edges = append(edges, sopnode.EdgeSopStage)
  22003. }
  22004. if m.clearednode_messages {
  22005. edges = append(edges, sopnode.EdgeNodeMessages)
  22006. }
  22007. return edges
  22008. }
  22009. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22010. // was cleared in this mutation.
  22011. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  22012. switch name {
  22013. case sopnode.EdgeSopStage:
  22014. return m.clearedsop_stage
  22015. case sopnode.EdgeNodeMessages:
  22016. return m.clearednode_messages
  22017. }
  22018. return false
  22019. }
  22020. // ClearEdge clears the value of the edge with the given name. It returns an error
  22021. // if that edge is not defined in the schema.
  22022. func (m *SopNodeMutation) ClearEdge(name string) error {
  22023. switch name {
  22024. case sopnode.EdgeSopStage:
  22025. m.ClearSopStage()
  22026. return nil
  22027. }
  22028. return fmt.Errorf("unknown SopNode unique edge %s", name)
  22029. }
  22030. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22031. // It returns an error if the edge is not defined in the schema.
  22032. func (m *SopNodeMutation) ResetEdge(name string) error {
  22033. switch name {
  22034. case sopnode.EdgeSopStage:
  22035. m.ResetSopStage()
  22036. return nil
  22037. case sopnode.EdgeNodeMessages:
  22038. m.ResetNodeMessages()
  22039. return nil
  22040. }
  22041. return fmt.Errorf("unknown SopNode edge %s", name)
  22042. }
  22043. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  22044. type SopStageMutation struct {
  22045. config
  22046. op Op
  22047. typ string
  22048. id *uint64
  22049. created_at *time.Time
  22050. updated_at *time.Time
  22051. status *uint8
  22052. addstatus *int8
  22053. deleted_at *time.Time
  22054. name *string
  22055. condition_type *int
  22056. addcondition_type *int
  22057. condition_operator *int
  22058. addcondition_operator *int
  22059. condition_list *[]custom_types.Condition
  22060. appendcondition_list []custom_types.Condition
  22061. action_message *[]custom_types.Action
  22062. appendaction_message []custom_types.Action
  22063. action_label_add *[]uint64
  22064. appendaction_label_add []uint64
  22065. action_label_del *[]uint64
  22066. appendaction_label_del []uint64
  22067. action_forward **custom_types.ActionForward
  22068. index_sort *int
  22069. addindex_sort *int
  22070. clearedFields map[string]struct{}
  22071. sop_task *uint64
  22072. clearedsop_task bool
  22073. stage_nodes map[uint64]struct{}
  22074. removedstage_nodes map[uint64]struct{}
  22075. clearedstage_nodes bool
  22076. stage_messages map[uint64]struct{}
  22077. removedstage_messages map[uint64]struct{}
  22078. clearedstage_messages bool
  22079. done bool
  22080. oldValue func(context.Context) (*SopStage, error)
  22081. predicates []predicate.SopStage
  22082. }
  22083. var _ ent.Mutation = (*SopStageMutation)(nil)
  22084. // sopstageOption allows management of the mutation configuration using functional options.
  22085. type sopstageOption func(*SopStageMutation)
  22086. // newSopStageMutation creates new mutation for the SopStage entity.
  22087. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  22088. m := &SopStageMutation{
  22089. config: c,
  22090. op: op,
  22091. typ: TypeSopStage,
  22092. clearedFields: make(map[string]struct{}),
  22093. }
  22094. for _, opt := range opts {
  22095. opt(m)
  22096. }
  22097. return m
  22098. }
  22099. // withSopStageID sets the ID field of the mutation.
  22100. func withSopStageID(id uint64) sopstageOption {
  22101. return func(m *SopStageMutation) {
  22102. var (
  22103. err error
  22104. once sync.Once
  22105. value *SopStage
  22106. )
  22107. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  22108. once.Do(func() {
  22109. if m.done {
  22110. err = errors.New("querying old values post mutation is not allowed")
  22111. } else {
  22112. value, err = m.Client().SopStage.Get(ctx, id)
  22113. }
  22114. })
  22115. return value, err
  22116. }
  22117. m.id = &id
  22118. }
  22119. }
  22120. // withSopStage sets the old SopStage of the mutation.
  22121. func withSopStage(node *SopStage) sopstageOption {
  22122. return func(m *SopStageMutation) {
  22123. m.oldValue = func(context.Context) (*SopStage, error) {
  22124. return node, nil
  22125. }
  22126. m.id = &node.ID
  22127. }
  22128. }
  22129. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22130. // executed in a transaction (ent.Tx), a transactional client is returned.
  22131. func (m SopStageMutation) Client() *Client {
  22132. client := &Client{config: m.config}
  22133. client.init()
  22134. return client
  22135. }
  22136. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22137. // it returns an error otherwise.
  22138. func (m SopStageMutation) Tx() (*Tx, error) {
  22139. if _, ok := m.driver.(*txDriver); !ok {
  22140. return nil, errors.New("ent: mutation is not running in a transaction")
  22141. }
  22142. tx := &Tx{config: m.config}
  22143. tx.init()
  22144. return tx, nil
  22145. }
  22146. // SetID sets the value of the id field. Note that this
  22147. // operation is only accepted on creation of SopStage entities.
  22148. func (m *SopStageMutation) SetID(id uint64) {
  22149. m.id = &id
  22150. }
  22151. // ID returns the ID value in the mutation. Note that the ID is only available
  22152. // if it was provided to the builder or after it was returned from the database.
  22153. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  22154. if m.id == nil {
  22155. return
  22156. }
  22157. return *m.id, true
  22158. }
  22159. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22160. // That means, if the mutation is applied within a transaction with an isolation level such
  22161. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22162. // or updated by the mutation.
  22163. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  22164. switch {
  22165. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22166. id, exists := m.ID()
  22167. if exists {
  22168. return []uint64{id}, nil
  22169. }
  22170. fallthrough
  22171. case m.op.Is(OpUpdate | OpDelete):
  22172. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  22173. default:
  22174. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22175. }
  22176. }
  22177. // SetCreatedAt sets the "created_at" field.
  22178. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  22179. m.created_at = &t
  22180. }
  22181. // CreatedAt returns the value of the "created_at" field in the mutation.
  22182. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  22183. v := m.created_at
  22184. if v == nil {
  22185. return
  22186. }
  22187. return *v, true
  22188. }
  22189. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  22190. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22192. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22193. if !m.op.Is(OpUpdateOne) {
  22194. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22195. }
  22196. if m.id == nil || m.oldValue == nil {
  22197. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22198. }
  22199. oldValue, err := m.oldValue(ctx)
  22200. if err != nil {
  22201. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22202. }
  22203. return oldValue.CreatedAt, nil
  22204. }
  22205. // ResetCreatedAt resets all changes to the "created_at" field.
  22206. func (m *SopStageMutation) ResetCreatedAt() {
  22207. m.created_at = nil
  22208. }
  22209. // SetUpdatedAt sets the "updated_at" field.
  22210. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  22211. m.updated_at = &t
  22212. }
  22213. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22214. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  22215. v := m.updated_at
  22216. if v == nil {
  22217. return
  22218. }
  22219. return *v, true
  22220. }
  22221. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  22222. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22224. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22225. if !m.op.Is(OpUpdateOne) {
  22226. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22227. }
  22228. if m.id == nil || m.oldValue == nil {
  22229. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22230. }
  22231. oldValue, err := m.oldValue(ctx)
  22232. if err != nil {
  22233. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22234. }
  22235. return oldValue.UpdatedAt, nil
  22236. }
  22237. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22238. func (m *SopStageMutation) ResetUpdatedAt() {
  22239. m.updated_at = nil
  22240. }
  22241. // SetStatus sets the "status" field.
  22242. func (m *SopStageMutation) SetStatus(u uint8) {
  22243. m.status = &u
  22244. m.addstatus = nil
  22245. }
  22246. // Status returns the value of the "status" field in the mutation.
  22247. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  22248. v := m.status
  22249. if v == nil {
  22250. return
  22251. }
  22252. return *v, true
  22253. }
  22254. // OldStatus returns the old "status" field's value of the SopStage entity.
  22255. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22257. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22258. if !m.op.Is(OpUpdateOne) {
  22259. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22260. }
  22261. if m.id == nil || m.oldValue == nil {
  22262. return v, errors.New("OldStatus requires an ID field in the mutation")
  22263. }
  22264. oldValue, err := m.oldValue(ctx)
  22265. if err != nil {
  22266. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22267. }
  22268. return oldValue.Status, nil
  22269. }
  22270. // AddStatus adds u to the "status" field.
  22271. func (m *SopStageMutation) AddStatus(u int8) {
  22272. if m.addstatus != nil {
  22273. *m.addstatus += u
  22274. } else {
  22275. m.addstatus = &u
  22276. }
  22277. }
  22278. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22279. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  22280. v := m.addstatus
  22281. if v == nil {
  22282. return
  22283. }
  22284. return *v, true
  22285. }
  22286. // ClearStatus clears the value of the "status" field.
  22287. func (m *SopStageMutation) ClearStatus() {
  22288. m.status = nil
  22289. m.addstatus = nil
  22290. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  22291. }
  22292. // StatusCleared returns if the "status" field was cleared in this mutation.
  22293. func (m *SopStageMutation) StatusCleared() bool {
  22294. _, ok := m.clearedFields[sopstage.FieldStatus]
  22295. return ok
  22296. }
  22297. // ResetStatus resets all changes to the "status" field.
  22298. func (m *SopStageMutation) ResetStatus() {
  22299. m.status = nil
  22300. m.addstatus = nil
  22301. delete(m.clearedFields, sopstage.FieldStatus)
  22302. }
  22303. // SetDeletedAt sets the "deleted_at" field.
  22304. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  22305. m.deleted_at = &t
  22306. }
  22307. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22308. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  22309. v := m.deleted_at
  22310. if v == nil {
  22311. return
  22312. }
  22313. return *v, true
  22314. }
  22315. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  22316. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22318. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22319. if !m.op.Is(OpUpdateOne) {
  22320. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22321. }
  22322. if m.id == nil || m.oldValue == nil {
  22323. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22324. }
  22325. oldValue, err := m.oldValue(ctx)
  22326. if err != nil {
  22327. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22328. }
  22329. return oldValue.DeletedAt, nil
  22330. }
  22331. // ClearDeletedAt clears the value of the "deleted_at" field.
  22332. func (m *SopStageMutation) ClearDeletedAt() {
  22333. m.deleted_at = nil
  22334. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  22335. }
  22336. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22337. func (m *SopStageMutation) DeletedAtCleared() bool {
  22338. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  22339. return ok
  22340. }
  22341. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22342. func (m *SopStageMutation) ResetDeletedAt() {
  22343. m.deleted_at = nil
  22344. delete(m.clearedFields, sopstage.FieldDeletedAt)
  22345. }
  22346. // SetTaskID sets the "task_id" field.
  22347. func (m *SopStageMutation) SetTaskID(u uint64) {
  22348. m.sop_task = &u
  22349. }
  22350. // TaskID returns the value of the "task_id" field in the mutation.
  22351. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  22352. v := m.sop_task
  22353. if v == nil {
  22354. return
  22355. }
  22356. return *v, true
  22357. }
  22358. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  22359. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22361. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  22362. if !m.op.Is(OpUpdateOne) {
  22363. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  22364. }
  22365. if m.id == nil || m.oldValue == nil {
  22366. return v, errors.New("OldTaskID requires an ID field in the mutation")
  22367. }
  22368. oldValue, err := m.oldValue(ctx)
  22369. if err != nil {
  22370. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  22371. }
  22372. return oldValue.TaskID, nil
  22373. }
  22374. // ResetTaskID resets all changes to the "task_id" field.
  22375. func (m *SopStageMutation) ResetTaskID() {
  22376. m.sop_task = nil
  22377. }
  22378. // SetName sets the "name" field.
  22379. func (m *SopStageMutation) SetName(s string) {
  22380. m.name = &s
  22381. }
  22382. // Name returns the value of the "name" field in the mutation.
  22383. func (m *SopStageMutation) Name() (r string, exists bool) {
  22384. v := m.name
  22385. if v == nil {
  22386. return
  22387. }
  22388. return *v, true
  22389. }
  22390. // OldName returns the old "name" field's value of the SopStage entity.
  22391. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22393. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  22394. if !m.op.Is(OpUpdateOne) {
  22395. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22396. }
  22397. if m.id == nil || m.oldValue == nil {
  22398. return v, errors.New("OldName requires an ID field in the mutation")
  22399. }
  22400. oldValue, err := m.oldValue(ctx)
  22401. if err != nil {
  22402. return v, fmt.Errorf("querying old value for OldName: %w", err)
  22403. }
  22404. return oldValue.Name, nil
  22405. }
  22406. // ResetName resets all changes to the "name" field.
  22407. func (m *SopStageMutation) ResetName() {
  22408. m.name = nil
  22409. }
  22410. // SetConditionType sets the "condition_type" field.
  22411. func (m *SopStageMutation) SetConditionType(i int) {
  22412. m.condition_type = &i
  22413. m.addcondition_type = nil
  22414. }
  22415. // ConditionType returns the value of the "condition_type" field in the mutation.
  22416. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  22417. v := m.condition_type
  22418. if v == nil {
  22419. return
  22420. }
  22421. return *v, true
  22422. }
  22423. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  22424. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22426. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  22427. if !m.op.Is(OpUpdateOne) {
  22428. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  22429. }
  22430. if m.id == nil || m.oldValue == nil {
  22431. return v, errors.New("OldConditionType requires an ID field in the mutation")
  22432. }
  22433. oldValue, err := m.oldValue(ctx)
  22434. if err != nil {
  22435. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  22436. }
  22437. return oldValue.ConditionType, nil
  22438. }
  22439. // AddConditionType adds i to the "condition_type" field.
  22440. func (m *SopStageMutation) AddConditionType(i int) {
  22441. if m.addcondition_type != nil {
  22442. *m.addcondition_type += i
  22443. } else {
  22444. m.addcondition_type = &i
  22445. }
  22446. }
  22447. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  22448. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  22449. v := m.addcondition_type
  22450. if v == nil {
  22451. return
  22452. }
  22453. return *v, true
  22454. }
  22455. // ResetConditionType resets all changes to the "condition_type" field.
  22456. func (m *SopStageMutation) ResetConditionType() {
  22457. m.condition_type = nil
  22458. m.addcondition_type = nil
  22459. }
  22460. // SetConditionOperator sets the "condition_operator" field.
  22461. func (m *SopStageMutation) SetConditionOperator(i int) {
  22462. m.condition_operator = &i
  22463. m.addcondition_operator = nil
  22464. }
  22465. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  22466. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  22467. v := m.condition_operator
  22468. if v == nil {
  22469. return
  22470. }
  22471. return *v, true
  22472. }
  22473. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  22474. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22476. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  22477. if !m.op.Is(OpUpdateOne) {
  22478. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  22479. }
  22480. if m.id == nil || m.oldValue == nil {
  22481. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  22482. }
  22483. oldValue, err := m.oldValue(ctx)
  22484. if err != nil {
  22485. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  22486. }
  22487. return oldValue.ConditionOperator, nil
  22488. }
  22489. // AddConditionOperator adds i to the "condition_operator" field.
  22490. func (m *SopStageMutation) AddConditionOperator(i int) {
  22491. if m.addcondition_operator != nil {
  22492. *m.addcondition_operator += i
  22493. } else {
  22494. m.addcondition_operator = &i
  22495. }
  22496. }
  22497. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  22498. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  22499. v := m.addcondition_operator
  22500. if v == nil {
  22501. return
  22502. }
  22503. return *v, true
  22504. }
  22505. // ResetConditionOperator resets all changes to the "condition_operator" field.
  22506. func (m *SopStageMutation) ResetConditionOperator() {
  22507. m.condition_operator = nil
  22508. m.addcondition_operator = nil
  22509. }
  22510. // SetConditionList sets the "condition_list" field.
  22511. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  22512. m.condition_list = &ct
  22513. m.appendcondition_list = nil
  22514. }
  22515. // ConditionList returns the value of the "condition_list" field in the mutation.
  22516. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  22517. v := m.condition_list
  22518. if v == nil {
  22519. return
  22520. }
  22521. return *v, true
  22522. }
  22523. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  22524. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22526. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  22527. if !m.op.Is(OpUpdateOne) {
  22528. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  22529. }
  22530. if m.id == nil || m.oldValue == nil {
  22531. return v, errors.New("OldConditionList requires an ID field in the mutation")
  22532. }
  22533. oldValue, err := m.oldValue(ctx)
  22534. if err != nil {
  22535. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  22536. }
  22537. return oldValue.ConditionList, nil
  22538. }
  22539. // AppendConditionList adds ct to the "condition_list" field.
  22540. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  22541. m.appendcondition_list = append(m.appendcondition_list, ct...)
  22542. }
  22543. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  22544. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  22545. if len(m.appendcondition_list) == 0 {
  22546. return nil, false
  22547. }
  22548. return m.appendcondition_list, true
  22549. }
  22550. // ResetConditionList resets all changes to the "condition_list" field.
  22551. func (m *SopStageMutation) ResetConditionList() {
  22552. m.condition_list = nil
  22553. m.appendcondition_list = nil
  22554. }
  22555. // SetActionMessage sets the "action_message" field.
  22556. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  22557. m.action_message = &ct
  22558. m.appendaction_message = nil
  22559. }
  22560. // ActionMessage returns the value of the "action_message" field in the mutation.
  22561. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  22562. v := m.action_message
  22563. if v == nil {
  22564. return
  22565. }
  22566. return *v, true
  22567. }
  22568. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  22569. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22571. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  22572. if !m.op.Is(OpUpdateOne) {
  22573. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  22574. }
  22575. if m.id == nil || m.oldValue == nil {
  22576. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  22577. }
  22578. oldValue, err := m.oldValue(ctx)
  22579. if err != nil {
  22580. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  22581. }
  22582. return oldValue.ActionMessage, nil
  22583. }
  22584. // AppendActionMessage adds ct to the "action_message" field.
  22585. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  22586. m.appendaction_message = append(m.appendaction_message, ct...)
  22587. }
  22588. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  22589. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  22590. if len(m.appendaction_message) == 0 {
  22591. return nil, false
  22592. }
  22593. return m.appendaction_message, true
  22594. }
  22595. // ClearActionMessage clears the value of the "action_message" field.
  22596. func (m *SopStageMutation) ClearActionMessage() {
  22597. m.action_message = nil
  22598. m.appendaction_message = nil
  22599. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  22600. }
  22601. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  22602. func (m *SopStageMutation) ActionMessageCleared() bool {
  22603. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  22604. return ok
  22605. }
  22606. // ResetActionMessage resets all changes to the "action_message" field.
  22607. func (m *SopStageMutation) ResetActionMessage() {
  22608. m.action_message = nil
  22609. m.appendaction_message = nil
  22610. delete(m.clearedFields, sopstage.FieldActionMessage)
  22611. }
  22612. // SetActionLabelAdd sets the "action_label_add" field.
  22613. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  22614. m.action_label_add = &u
  22615. m.appendaction_label_add = nil
  22616. }
  22617. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  22618. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  22619. v := m.action_label_add
  22620. if v == nil {
  22621. return
  22622. }
  22623. return *v, true
  22624. }
  22625. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  22626. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22628. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  22629. if !m.op.Is(OpUpdateOne) {
  22630. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  22631. }
  22632. if m.id == nil || m.oldValue == nil {
  22633. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  22634. }
  22635. oldValue, err := m.oldValue(ctx)
  22636. if err != nil {
  22637. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  22638. }
  22639. return oldValue.ActionLabelAdd, nil
  22640. }
  22641. // AppendActionLabelAdd adds u to the "action_label_add" field.
  22642. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  22643. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  22644. }
  22645. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  22646. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  22647. if len(m.appendaction_label_add) == 0 {
  22648. return nil, false
  22649. }
  22650. return m.appendaction_label_add, true
  22651. }
  22652. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  22653. func (m *SopStageMutation) ClearActionLabelAdd() {
  22654. m.action_label_add = nil
  22655. m.appendaction_label_add = nil
  22656. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  22657. }
  22658. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  22659. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  22660. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  22661. return ok
  22662. }
  22663. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  22664. func (m *SopStageMutation) ResetActionLabelAdd() {
  22665. m.action_label_add = nil
  22666. m.appendaction_label_add = nil
  22667. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  22668. }
  22669. // SetActionLabelDel sets the "action_label_del" field.
  22670. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  22671. m.action_label_del = &u
  22672. m.appendaction_label_del = nil
  22673. }
  22674. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  22675. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  22676. v := m.action_label_del
  22677. if v == nil {
  22678. return
  22679. }
  22680. return *v, true
  22681. }
  22682. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  22683. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22684. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22685. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  22686. if !m.op.Is(OpUpdateOne) {
  22687. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  22688. }
  22689. if m.id == nil || m.oldValue == nil {
  22690. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  22691. }
  22692. oldValue, err := m.oldValue(ctx)
  22693. if err != nil {
  22694. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  22695. }
  22696. return oldValue.ActionLabelDel, nil
  22697. }
  22698. // AppendActionLabelDel adds u to the "action_label_del" field.
  22699. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  22700. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  22701. }
  22702. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  22703. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  22704. if len(m.appendaction_label_del) == 0 {
  22705. return nil, false
  22706. }
  22707. return m.appendaction_label_del, true
  22708. }
  22709. // ClearActionLabelDel clears the value of the "action_label_del" field.
  22710. func (m *SopStageMutation) ClearActionLabelDel() {
  22711. m.action_label_del = nil
  22712. m.appendaction_label_del = nil
  22713. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  22714. }
  22715. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  22716. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  22717. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  22718. return ok
  22719. }
  22720. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  22721. func (m *SopStageMutation) ResetActionLabelDel() {
  22722. m.action_label_del = nil
  22723. m.appendaction_label_del = nil
  22724. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  22725. }
  22726. // SetActionForward sets the "action_forward" field.
  22727. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  22728. m.action_forward = &ctf
  22729. }
  22730. // ActionForward returns the value of the "action_forward" field in the mutation.
  22731. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  22732. v := m.action_forward
  22733. if v == nil {
  22734. return
  22735. }
  22736. return *v, true
  22737. }
  22738. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  22739. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22741. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  22742. if !m.op.Is(OpUpdateOne) {
  22743. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  22744. }
  22745. if m.id == nil || m.oldValue == nil {
  22746. return v, errors.New("OldActionForward requires an ID field in the mutation")
  22747. }
  22748. oldValue, err := m.oldValue(ctx)
  22749. if err != nil {
  22750. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  22751. }
  22752. return oldValue.ActionForward, nil
  22753. }
  22754. // ClearActionForward clears the value of the "action_forward" field.
  22755. func (m *SopStageMutation) ClearActionForward() {
  22756. m.action_forward = nil
  22757. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  22758. }
  22759. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  22760. func (m *SopStageMutation) ActionForwardCleared() bool {
  22761. _, ok := m.clearedFields[sopstage.FieldActionForward]
  22762. return ok
  22763. }
  22764. // ResetActionForward resets all changes to the "action_forward" field.
  22765. func (m *SopStageMutation) ResetActionForward() {
  22766. m.action_forward = nil
  22767. delete(m.clearedFields, sopstage.FieldActionForward)
  22768. }
  22769. // SetIndexSort sets the "index_sort" field.
  22770. func (m *SopStageMutation) SetIndexSort(i int) {
  22771. m.index_sort = &i
  22772. m.addindex_sort = nil
  22773. }
  22774. // IndexSort returns the value of the "index_sort" field in the mutation.
  22775. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  22776. v := m.index_sort
  22777. if v == nil {
  22778. return
  22779. }
  22780. return *v, true
  22781. }
  22782. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  22783. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22785. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  22786. if !m.op.Is(OpUpdateOne) {
  22787. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  22788. }
  22789. if m.id == nil || m.oldValue == nil {
  22790. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  22791. }
  22792. oldValue, err := m.oldValue(ctx)
  22793. if err != nil {
  22794. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  22795. }
  22796. return oldValue.IndexSort, nil
  22797. }
  22798. // AddIndexSort adds i to the "index_sort" field.
  22799. func (m *SopStageMutation) AddIndexSort(i int) {
  22800. if m.addindex_sort != nil {
  22801. *m.addindex_sort += i
  22802. } else {
  22803. m.addindex_sort = &i
  22804. }
  22805. }
  22806. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  22807. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  22808. v := m.addindex_sort
  22809. if v == nil {
  22810. return
  22811. }
  22812. return *v, true
  22813. }
  22814. // ClearIndexSort clears the value of the "index_sort" field.
  22815. func (m *SopStageMutation) ClearIndexSort() {
  22816. m.index_sort = nil
  22817. m.addindex_sort = nil
  22818. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  22819. }
  22820. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  22821. func (m *SopStageMutation) IndexSortCleared() bool {
  22822. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  22823. return ok
  22824. }
  22825. // ResetIndexSort resets all changes to the "index_sort" field.
  22826. func (m *SopStageMutation) ResetIndexSort() {
  22827. m.index_sort = nil
  22828. m.addindex_sort = nil
  22829. delete(m.clearedFields, sopstage.FieldIndexSort)
  22830. }
  22831. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  22832. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  22833. m.sop_task = &id
  22834. }
  22835. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  22836. func (m *SopStageMutation) ClearSopTask() {
  22837. m.clearedsop_task = true
  22838. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  22839. }
  22840. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  22841. func (m *SopStageMutation) SopTaskCleared() bool {
  22842. return m.clearedsop_task
  22843. }
  22844. // SopTaskID returns the "sop_task" edge ID in the mutation.
  22845. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  22846. if m.sop_task != nil {
  22847. return *m.sop_task, true
  22848. }
  22849. return
  22850. }
  22851. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  22852. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22853. // SopTaskID instead. It exists only for internal usage by the builders.
  22854. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  22855. if id := m.sop_task; id != nil {
  22856. ids = append(ids, *id)
  22857. }
  22858. return
  22859. }
  22860. // ResetSopTask resets all changes to the "sop_task" edge.
  22861. func (m *SopStageMutation) ResetSopTask() {
  22862. m.sop_task = nil
  22863. m.clearedsop_task = false
  22864. }
  22865. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  22866. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  22867. if m.stage_nodes == nil {
  22868. m.stage_nodes = make(map[uint64]struct{})
  22869. }
  22870. for i := range ids {
  22871. m.stage_nodes[ids[i]] = struct{}{}
  22872. }
  22873. }
  22874. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  22875. func (m *SopStageMutation) ClearStageNodes() {
  22876. m.clearedstage_nodes = true
  22877. }
  22878. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  22879. func (m *SopStageMutation) StageNodesCleared() bool {
  22880. return m.clearedstage_nodes
  22881. }
  22882. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  22883. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  22884. if m.removedstage_nodes == nil {
  22885. m.removedstage_nodes = make(map[uint64]struct{})
  22886. }
  22887. for i := range ids {
  22888. delete(m.stage_nodes, ids[i])
  22889. m.removedstage_nodes[ids[i]] = struct{}{}
  22890. }
  22891. }
  22892. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  22893. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  22894. for id := range m.removedstage_nodes {
  22895. ids = append(ids, id)
  22896. }
  22897. return
  22898. }
  22899. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  22900. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  22901. for id := range m.stage_nodes {
  22902. ids = append(ids, id)
  22903. }
  22904. return
  22905. }
  22906. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  22907. func (m *SopStageMutation) ResetStageNodes() {
  22908. m.stage_nodes = nil
  22909. m.clearedstage_nodes = false
  22910. m.removedstage_nodes = nil
  22911. }
  22912. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  22913. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  22914. if m.stage_messages == nil {
  22915. m.stage_messages = make(map[uint64]struct{})
  22916. }
  22917. for i := range ids {
  22918. m.stage_messages[ids[i]] = struct{}{}
  22919. }
  22920. }
  22921. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  22922. func (m *SopStageMutation) ClearStageMessages() {
  22923. m.clearedstage_messages = true
  22924. }
  22925. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  22926. func (m *SopStageMutation) StageMessagesCleared() bool {
  22927. return m.clearedstage_messages
  22928. }
  22929. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  22930. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  22931. if m.removedstage_messages == nil {
  22932. m.removedstage_messages = make(map[uint64]struct{})
  22933. }
  22934. for i := range ids {
  22935. delete(m.stage_messages, ids[i])
  22936. m.removedstage_messages[ids[i]] = struct{}{}
  22937. }
  22938. }
  22939. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  22940. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  22941. for id := range m.removedstage_messages {
  22942. ids = append(ids, id)
  22943. }
  22944. return
  22945. }
  22946. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  22947. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  22948. for id := range m.stage_messages {
  22949. ids = append(ids, id)
  22950. }
  22951. return
  22952. }
  22953. // ResetStageMessages resets all changes to the "stage_messages" edge.
  22954. func (m *SopStageMutation) ResetStageMessages() {
  22955. m.stage_messages = nil
  22956. m.clearedstage_messages = false
  22957. m.removedstage_messages = nil
  22958. }
  22959. // Where appends a list predicates to the SopStageMutation builder.
  22960. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  22961. m.predicates = append(m.predicates, ps...)
  22962. }
  22963. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  22964. // users can use type-assertion to append predicates that do not depend on any generated package.
  22965. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  22966. p := make([]predicate.SopStage, len(ps))
  22967. for i := range ps {
  22968. p[i] = ps[i]
  22969. }
  22970. m.Where(p...)
  22971. }
  22972. // Op returns the operation name.
  22973. func (m *SopStageMutation) Op() Op {
  22974. return m.op
  22975. }
  22976. // SetOp allows setting the mutation operation.
  22977. func (m *SopStageMutation) SetOp(op Op) {
  22978. m.op = op
  22979. }
  22980. // Type returns the node type of this mutation (SopStage).
  22981. func (m *SopStageMutation) Type() string {
  22982. return m.typ
  22983. }
  22984. // Fields returns all fields that were changed during this mutation. Note that in
  22985. // order to get all numeric fields that were incremented/decremented, call
  22986. // AddedFields().
  22987. func (m *SopStageMutation) Fields() []string {
  22988. fields := make([]string, 0, 14)
  22989. if m.created_at != nil {
  22990. fields = append(fields, sopstage.FieldCreatedAt)
  22991. }
  22992. if m.updated_at != nil {
  22993. fields = append(fields, sopstage.FieldUpdatedAt)
  22994. }
  22995. if m.status != nil {
  22996. fields = append(fields, sopstage.FieldStatus)
  22997. }
  22998. if m.deleted_at != nil {
  22999. fields = append(fields, sopstage.FieldDeletedAt)
  23000. }
  23001. if m.sop_task != nil {
  23002. fields = append(fields, sopstage.FieldTaskID)
  23003. }
  23004. if m.name != nil {
  23005. fields = append(fields, sopstage.FieldName)
  23006. }
  23007. if m.condition_type != nil {
  23008. fields = append(fields, sopstage.FieldConditionType)
  23009. }
  23010. if m.condition_operator != nil {
  23011. fields = append(fields, sopstage.FieldConditionOperator)
  23012. }
  23013. if m.condition_list != nil {
  23014. fields = append(fields, sopstage.FieldConditionList)
  23015. }
  23016. if m.action_message != nil {
  23017. fields = append(fields, sopstage.FieldActionMessage)
  23018. }
  23019. if m.action_label_add != nil {
  23020. fields = append(fields, sopstage.FieldActionLabelAdd)
  23021. }
  23022. if m.action_label_del != nil {
  23023. fields = append(fields, sopstage.FieldActionLabelDel)
  23024. }
  23025. if m.action_forward != nil {
  23026. fields = append(fields, sopstage.FieldActionForward)
  23027. }
  23028. if m.index_sort != nil {
  23029. fields = append(fields, sopstage.FieldIndexSort)
  23030. }
  23031. return fields
  23032. }
  23033. // Field returns the value of a field with the given name. The second boolean
  23034. // return value indicates that this field was not set, or was not defined in the
  23035. // schema.
  23036. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  23037. switch name {
  23038. case sopstage.FieldCreatedAt:
  23039. return m.CreatedAt()
  23040. case sopstage.FieldUpdatedAt:
  23041. return m.UpdatedAt()
  23042. case sopstage.FieldStatus:
  23043. return m.Status()
  23044. case sopstage.FieldDeletedAt:
  23045. return m.DeletedAt()
  23046. case sopstage.FieldTaskID:
  23047. return m.TaskID()
  23048. case sopstage.FieldName:
  23049. return m.Name()
  23050. case sopstage.FieldConditionType:
  23051. return m.ConditionType()
  23052. case sopstage.FieldConditionOperator:
  23053. return m.ConditionOperator()
  23054. case sopstage.FieldConditionList:
  23055. return m.ConditionList()
  23056. case sopstage.FieldActionMessage:
  23057. return m.ActionMessage()
  23058. case sopstage.FieldActionLabelAdd:
  23059. return m.ActionLabelAdd()
  23060. case sopstage.FieldActionLabelDel:
  23061. return m.ActionLabelDel()
  23062. case sopstage.FieldActionForward:
  23063. return m.ActionForward()
  23064. case sopstage.FieldIndexSort:
  23065. return m.IndexSort()
  23066. }
  23067. return nil, false
  23068. }
  23069. // OldField returns the old value of the field from the database. An error is
  23070. // returned if the mutation operation is not UpdateOne, or the query to the
  23071. // database failed.
  23072. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23073. switch name {
  23074. case sopstage.FieldCreatedAt:
  23075. return m.OldCreatedAt(ctx)
  23076. case sopstage.FieldUpdatedAt:
  23077. return m.OldUpdatedAt(ctx)
  23078. case sopstage.FieldStatus:
  23079. return m.OldStatus(ctx)
  23080. case sopstage.FieldDeletedAt:
  23081. return m.OldDeletedAt(ctx)
  23082. case sopstage.FieldTaskID:
  23083. return m.OldTaskID(ctx)
  23084. case sopstage.FieldName:
  23085. return m.OldName(ctx)
  23086. case sopstage.FieldConditionType:
  23087. return m.OldConditionType(ctx)
  23088. case sopstage.FieldConditionOperator:
  23089. return m.OldConditionOperator(ctx)
  23090. case sopstage.FieldConditionList:
  23091. return m.OldConditionList(ctx)
  23092. case sopstage.FieldActionMessage:
  23093. return m.OldActionMessage(ctx)
  23094. case sopstage.FieldActionLabelAdd:
  23095. return m.OldActionLabelAdd(ctx)
  23096. case sopstage.FieldActionLabelDel:
  23097. return m.OldActionLabelDel(ctx)
  23098. case sopstage.FieldActionForward:
  23099. return m.OldActionForward(ctx)
  23100. case sopstage.FieldIndexSort:
  23101. return m.OldIndexSort(ctx)
  23102. }
  23103. return nil, fmt.Errorf("unknown SopStage field %s", name)
  23104. }
  23105. // SetField sets the value of a field with the given name. It returns an error if
  23106. // the field is not defined in the schema, or if the type mismatched the field
  23107. // type.
  23108. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  23109. switch name {
  23110. case sopstage.FieldCreatedAt:
  23111. v, ok := value.(time.Time)
  23112. if !ok {
  23113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23114. }
  23115. m.SetCreatedAt(v)
  23116. return nil
  23117. case sopstage.FieldUpdatedAt:
  23118. v, ok := value.(time.Time)
  23119. if !ok {
  23120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23121. }
  23122. m.SetUpdatedAt(v)
  23123. return nil
  23124. case sopstage.FieldStatus:
  23125. v, ok := value.(uint8)
  23126. if !ok {
  23127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23128. }
  23129. m.SetStatus(v)
  23130. return nil
  23131. case sopstage.FieldDeletedAt:
  23132. v, ok := value.(time.Time)
  23133. if !ok {
  23134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23135. }
  23136. m.SetDeletedAt(v)
  23137. return nil
  23138. case sopstage.FieldTaskID:
  23139. v, ok := value.(uint64)
  23140. if !ok {
  23141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23142. }
  23143. m.SetTaskID(v)
  23144. return nil
  23145. case sopstage.FieldName:
  23146. v, ok := value.(string)
  23147. if !ok {
  23148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23149. }
  23150. m.SetName(v)
  23151. return nil
  23152. case sopstage.FieldConditionType:
  23153. v, ok := value.(int)
  23154. if !ok {
  23155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23156. }
  23157. m.SetConditionType(v)
  23158. return nil
  23159. case sopstage.FieldConditionOperator:
  23160. v, ok := value.(int)
  23161. if !ok {
  23162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23163. }
  23164. m.SetConditionOperator(v)
  23165. return nil
  23166. case sopstage.FieldConditionList:
  23167. v, ok := value.([]custom_types.Condition)
  23168. if !ok {
  23169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23170. }
  23171. m.SetConditionList(v)
  23172. return nil
  23173. case sopstage.FieldActionMessage:
  23174. v, ok := value.([]custom_types.Action)
  23175. if !ok {
  23176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23177. }
  23178. m.SetActionMessage(v)
  23179. return nil
  23180. case sopstage.FieldActionLabelAdd:
  23181. v, ok := value.([]uint64)
  23182. if !ok {
  23183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23184. }
  23185. m.SetActionLabelAdd(v)
  23186. return nil
  23187. case sopstage.FieldActionLabelDel:
  23188. v, ok := value.([]uint64)
  23189. if !ok {
  23190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23191. }
  23192. m.SetActionLabelDel(v)
  23193. return nil
  23194. case sopstage.FieldActionForward:
  23195. v, ok := value.(*custom_types.ActionForward)
  23196. if !ok {
  23197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23198. }
  23199. m.SetActionForward(v)
  23200. return nil
  23201. case sopstage.FieldIndexSort:
  23202. v, ok := value.(int)
  23203. if !ok {
  23204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23205. }
  23206. m.SetIndexSort(v)
  23207. return nil
  23208. }
  23209. return fmt.Errorf("unknown SopStage field %s", name)
  23210. }
  23211. // AddedFields returns all numeric fields that were incremented/decremented during
  23212. // this mutation.
  23213. func (m *SopStageMutation) AddedFields() []string {
  23214. var fields []string
  23215. if m.addstatus != nil {
  23216. fields = append(fields, sopstage.FieldStatus)
  23217. }
  23218. if m.addcondition_type != nil {
  23219. fields = append(fields, sopstage.FieldConditionType)
  23220. }
  23221. if m.addcondition_operator != nil {
  23222. fields = append(fields, sopstage.FieldConditionOperator)
  23223. }
  23224. if m.addindex_sort != nil {
  23225. fields = append(fields, sopstage.FieldIndexSort)
  23226. }
  23227. return fields
  23228. }
  23229. // AddedField returns the numeric value that was incremented/decremented on a field
  23230. // with the given name. The second boolean return value indicates that this field
  23231. // was not set, or was not defined in the schema.
  23232. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  23233. switch name {
  23234. case sopstage.FieldStatus:
  23235. return m.AddedStatus()
  23236. case sopstage.FieldConditionType:
  23237. return m.AddedConditionType()
  23238. case sopstage.FieldConditionOperator:
  23239. return m.AddedConditionOperator()
  23240. case sopstage.FieldIndexSort:
  23241. return m.AddedIndexSort()
  23242. }
  23243. return nil, false
  23244. }
  23245. // AddField adds the value to the field with the given name. It returns an error if
  23246. // the field is not defined in the schema, or if the type mismatched the field
  23247. // type.
  23248. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  23249. switch name {
  23250. case sopstage.FieldStatus:
  23251. v, ok := value.(int8)
  23252. if !ok {
  23253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23254. }
  23255. m.AddStatus(v)
  23256. return nil
  23257. case sopstage.FieldConditionType:
  23258. v, ok := value.(int)
  23259. if !ok {
  23260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23261. }
  23262. m.AddConditionType(v)
  23263. return nil
  23264. case sopstage.FieldConditionOperator:
  23265. v, ok := value.(int)
  23266. if !ok {
  23267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23268. }
  23269. m.AddConditionOperator(v)
  23270. return nil
  23271. case sopstage.FieldIndexSort:
  23272. v, ok := value.(int)
  23273. if !ok {
  23274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23275. }
  23276. m.AddIndexSort(v)
  23277. return nil
  23278. }
  23279. return fmt.Errorf("unknown SopStage numeric field %s", name)
  23280. }
  23281. // ClearedFields returns all nullable fields that were cleared during this
  23282. // mutation.
  23283. func (m *SopStageMutation) ClearedFields() []string {
  23284. var fields []string
  23285. if m.FieldCleared(sopstage.FieldStatus) {
  23286. fields = append(fields, sopstage.FieldStatus)
  23287. }
  23288. if m.FieldCleared(sopstage.FieldDeletedAt) {
  23289. fields = append(fields, sopstage.FieldDeletedAt)
  23290. }
  23291. if m.FieldCleared(sopstage.FieldActionMessage) {
  23292. fields = append(fields, sopstage.FieldActionMessage)
  23293. }
  23294. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  23295. fields = append(fields, sopstage.FieldActionLabelAdd)
  23296. }
  23297. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  23298. fields = append(fields, sopstage.FieldActionLabelDel)
  23299. }
  23300. if m.FieldCleared(sopstage.FieldActionForward) {
  23301. fields = append(fields, sopstage.FieldActionForward)
  23302. }
  23303. if m.FieldCleared(sopstage.FieldIndexSort) {
  23304. fields = append(fields, sopstage.FieldIndexSort)
  23305. }
  23306. return fields
  23307. }
  23308. // FieldCleared returns a boolean indicating if a field with the given name was
  23309. // cleared in this mutation.
  23310. func (m *SopStageMutation) FieldCleared(name string) bool {
  23311. _, ok := m.clearedFields[name]
  23312. return ok
  23313. }
  23314. // ClearField clears the value of the field with the given name. It returns an
  23315. // error if the field is not defined in the schema.
  23316. func (m *SopStageMutation) ClearField(name string) error {
  23317. switch name {
  23318. case sopstage.FieldStatus:
  23319. m.ClearStatus()
  23320. return nil
  23321. case sopstage.FieldDeletedAt:
  23322. m.ClearDeletedAt()
  23323. return nil
  23324. case sopstage.FieldActionMessage:
  23325. m.ClearActionMessage()
  23326. return nil
  23327. case sopstage.FieldActionLabelAdd:
  23328. m.ClearActionLabelAdd()
  23329. return nil
  23330. case sopstage.FieldActionLabelDel:
  23331. m.ClearActionLabelDel()
  23332. return nil
  23333. case sopstage.FieldActionForward:
  23334. m.ClearActionForward()
  23335. return nil
  23336. case sopstage.FieldIndexSort:
  23337. m.ClearIndexSort()
  23338. return nil
  23339. }
  23340. return fmt.Errorf("unknown SopStage nullable field %s", name)
  23341. }
  23342. // ResetField resets all changes in the mutation for the field with the given name.
  23343. // It returns an error if the field is not defined in the schema.
  23344. func (m *SopStageMutation) ResetField(name string) error {
  23345. switch name {
  23346. case sopstage.FieldCreatedAt:
  23347. m.ResetCreatedAt()
  23348. return nil
  23349. case sopstage.FieldUpdatedAt:
  23350. m.ResetUpdatedAt()
  23351. return nil
  23352. case sopstage.FieldStatus:
  23353. m.ResetStatus()
  23354. return nil
  23355. case sopstage.FieldDeletedAt:
  23356. m.ResetDeletedAt()
  23357. return nil
  23358. case sopstage.FieldTaskID:
  23359. m.ResetTaskID()
  23360. return nil
  23361. case sopstage.FieldName:
  23362. m.ResetName()
  23363. return nil
  23364. case sopstage.FieldConditionType:
  23365. m.ResetConditionType()
  23366. return nil
  23367. case sopstage.FieldConditionOperator:
  23368. m.ResetConditionOperator()
  23369. return nil
  23370. case sopstage.FieldConditionList:
  23371. m.ResetConditionList()
  23372. return nil
  23373. case sopstage.FieldActionMessage:
  23374. m.ResetActionMessage()
  23375. return nil
  23376. case sopstage.FieldActionLabelAdd:
  23377. m.ResetActionLabelAdd()
  23378. return nil
  23379. case sopstage.FieldActionLabelDel:
  23380. m.ResetActionLabelDel()
  23381. return nil
  23382. case sopstage.FieldActionForward:
  23383. m.ResetActionForward()
  23384. return nil
  23385. case sopstage.FieldIndexSort:
  23386. m.ResetIndexSort()
  23387. return nil
  23388. }
  23389. return fmt.Errorf("unknown SopStage field %s", name)
  23390. }
  23391. // AddedEdges returns all edge names that were set/added in this mutation.
  23392. func (m *SopStageMutation) AddedEdges() []string {
  23393. edges := make([]string, 0, 3)
  23394. if m.sop_task != nil {
  23395. edges = append(edges, sopstage.EdgeSopTask)
  23396. }
  23397. if m.stage_nodes != nil {
  23398. edges = append(edges, sopstage.EdgeStageNodes)
  23399. }
  23400. if m.stage_messages != nil {
  23401. edges = append(edges, sopstage.EdgeStageMessages)
  23402. }
  23403. return edges
  23404. }
  23405. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23406. // name in this mutation.
  23407. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  23408. switch name {
  23409. case sopstage.EdgeSopTask:
  23410. if id := m.sop_task; id != nil {
  23411. return []ent.Value{*id}
  23412. }
  23413. case sopstage.EdgeStageNodes:
  23414. ids := make([]ent.Value, 0, len(m.stage_nodes))
  23415. for id := range m.stage_nodes {
  23416. ids = append(ids, id)
  23417. }
  23418. return ids
  23419. case sopstage.EdgeStageMessages:
  23420. ids := make([]ent.Value, 0, len(m.stage_messages))
  23421. for id := range m.stage_messages {
  23422. ids = append(ids, id)
  23423. }
  23424. return ids
  23425. }
  23426. return nil
  23427. }
  23428. // RemovedEdges returns all edge names that were removed in this mutation.
  23429. func (m *SopStageMutation) RemovedEdges() []string {
  23430. edges := make([]string, 0, 3)
  23431. if m.removedstage_nodes != nil {
  23432. edges = append(edges, sopstage.EdgeStageNodes)
  23433. }
  23434. if m.removedstage_messages != nil {
  23435. edges = append(edges, sopstage.EdgeStageMessages)
  23436. }
  23437. return edges
  23438. }
  23439. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23440. // the given name in this mutation.
  23441. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  23442. switch name {
  23443. case sopstage.EdgeStageNodes:
  23444. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  23445. for id := range m.removedstage_nodes {
  23446. ids = append(ids, id)
  23447. }
  23448. return ids
  23449. case sopstage.EdgeStageMessages:
  23450. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  23451. for id := range m.removedstage_messages {
  23452. ids = append(ids, id)
  23453. }
  23454. return ids
  23455. }
  23456. return nil
  23457. }
  23458. // ClearedEdges returns all edge names that were cleared in this mutation.
  23459. func (m *SopStageMutation) ClearedEdges() []string {
  23460. edges := make([]string, 0, 3)
  23461. if m.clearedsop_task {
  23462. edges = append(edges, sopstage.EdgeSopTask)
  23463. }
  23464. if m.clearedstage_nodes {
  23465. edges = append(edges, sopstage.EdgeStageNodes)
  23466. }
  23467. if m.clearedstage_messages {
  23468. edges = append(edges, sopstage.EdgeStageMessages)
  23469. }
  23470. return edges
  23471. }
  23472. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23473. // was cleared in this mutation.
  23474. func (m *SopStageMutation) EdgeCleared(name string) bool {
  23475. switch name {
  23476. case sopstage.EdgeSopTask:
  23477. return m.clearedsop_task
  23478. case sopstage.EdgeStageNodes:
  23479. return m.clearedstage_nodes
  23480. case sopstage.EdgeStageMessages:
  23481. return m.clearedstage_messages
  23482. }
  23483. return false
  23484. }
  23485. // ClearEdge clears the value of the edge with the given name. It returns an error
  23486. // if that edge is not defined in the schema.
  23487. func (m *SopStageMutation) ClearEdge(name string) error {
  23488. switch name {
  23489. case sopstage.EdgeSopTask:
  23490. m.ClearSopTask()
  23491. return nil
  23492. }
  23493. return fmt.Errorf("unknown SopStage unique edge %s", name)
  23494. }
  23495. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23496. // It returns an error if the edge is not defined in the schema.
  23497. func (m *SopStageMutation) ResetEdge(name string) error {
  23498. switch name {
  23499. case sopstage.EdgeSopTask:
  23500. m.ResetSopTask()
  23501. return nil
  23502. case sopstage.EdgeStageNodes:
  23503. m.ResetStageNodes()
  23504. return nil
  23505. case sopstage.EdgeStageMessages:
  23506. m.ResetStageMessages()
  23507. return nil
  23508. }
  23509. return fmt.Errorf("unknown SopStage edge %s", name)
  23510. }
  23511. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  23512. type SopTaskMutation struct {
  23513. config
  23514. op Op
  23515. typ string
  23516. id *uint64
  23517. created_at *time.Time
  23518. updated_at *time.Time
  23519. status *uint8
  23520. addstatus *int8
  23521. deleted_at *time.Time
  23522. name *string
  23523. bot_wxid_list *[]string
  23524. appendbot_wxid_list []string
  23525. _type *int
  23526. add_type *int
  23527. plan_start_time *time.Time
  23528. plan_end_time *time.Time
  23529. creator_id *string
  23530. organization_id *uint64
  23531. addorganization_id *int64
  23532. token *[]string
  23533. appendtoken []string
  23534. clearedFields map[string]struct{}
  23535. task_stages map[uint64]struct{}
  23536. removedtask_stages map[uint64]struct{}
  23537. clearedtask_stages bool
  23538. done bool
  23539. oldValue func(context.Context) (*SopTask, error)
  23540. predicates []predicate.SopTask
  23541. }
  23542. var _ ent.Mutation = (*SopTaskMutation)(nil)
  23543. // soptaskOption allows management of the mutation configuration using functional options.
  23544. type soptaskOption func(*SopTaskMutation)
  23545. // newSopTaskMutation creates new mutation for the SopTask entity.
  23546. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  23547. m := &SopTaskMutation{
  23548. config: c,
  23549. op: op,
  23550. typ: TypeSopTask,
  23551. clearedFields: make(map[string]struct{}),
  23552. }
  23553. for _, opt := range opts {
  23554. opt(m)
  23555. }
  23556. return m
  23557. }
  23558. // withSopTaskID sets the ID field of the mutation.
  23559. func withSopTaskID(id uint64) soptaskOption {
  23560. return func(m *SopTaskMutation) {
  23561. var (
  23562. err error
  23563. once sync.Once
  23564. value *SopTask
  23565. )
  23566. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  23567. once.Do(func() {
  23568. if m.done {
  23569. err = errors.New("querying old values post mutation is not allowed")
  23570. } else {
  23571. value, err = m.Client().SopTask.Get(ctx, id)
  23572. }
  23573. })
  23574. return value, err
  23575. }
  23576. m.id = &id
  23577. }
  23578. }
  23579. // withSopTask sets the old SopTask of the mutation.
  23580. func withSopTask(node *SopTask) soptaskOption {
  23581. return func(m *SopTaskMutation) {
  23582. m.oldValue = func(context.Context) (*SopTask, error) {
  23583. return node, nil
  23584. }
  23585. m.id = &node.ID
  23586. }
  23587. }
  23588. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23589. // executed in a transaction (ent.Tx), a transactional client is returned.
  23590. func (m SopTaskMutation) Client() *Client {
  23591. client := &Client{config: m.config}
  23592. client.init()
  23593. return client
  23594. }
  23595. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23596. // it returns an error otherwise.
  23597. func (m SopTaskMutation) Tx() (*Tx, error) {
  23598. if _, ok := m.driver.(*txDriver); !ok {
  23599. return nil, errors.New("ent: mutation is not running in a transaction")
  23600. }
  23601. tx := &Tx{config: m.config}
  23602. tx.init()
  23603. return tx, nil
  23604. }
  23605. // SetID sets the value of the id field. Note that this
  23606. // operation is only accepted on creation of SopTask entities.
  23607. func (m *SopTaskMutation) SetID(id uint64) {
  23608. m.id = &id
  23609. }
  23610. // ID returns the ID value in the mutation. Note that the ID is only available
  23611. // if it was provided to the builder or after it was returned from the database.
  23612. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  23613. if m.id == nil {
  23614. return
  23615. }
  23616. return *m.id, true
  23617. }
  23618. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23619. // That means, if the mutation is applied within a transaction with an isolation level such
  23620. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23621. // or updated by the mutation.
  23622. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  23623. switch {
  23624. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23625. id, exists := m.ID()
  23626. if exists {
  23627. return []uint64{id}, nil
  23628. }
  23629. fallthrough
  23630. case m.op.Is(OpUpdate | OpDelete):
  23631. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  23632. default:
  23633. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23634. }
  23635. }
  23636. // SetCreatedAt sets the "created_at" field.
  23637. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  23638. m.created_at = &t
  23639. }
  23640. // CreatedAt returns the value of the "created_at" field in the mutation.
  23641. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  23642. v := m.created_at
  23643. if v == nil {
  23644. return
  23645. }
  23646. return *v, true
  23647. }
  23648. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  23649. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23651. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23652. if !m.op.Is(OpUpdateOne) {
  23653. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23654. }
  23655. if m.id == nil || m.oldValue == nil {
  23656. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23657. }
  23658. oldValue, err := m.oldValue(ctx)
  23659. if err != nil {
  23660. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23661. }
  23662. return oldValue.CreatedAt, nil
  23663. }
  23664. // ResetCreatedAt resets all changes to the "created_at" field.
  23665. func (m *SopTaskMutation) ResetCreatedAt() {
  23666. m.created_at = nil
  23667. }
  23668. // SetUpdatedAt sets the "updated_at" field.
  23669. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  23670. m.updated_at = &t
  23671. }
  23672. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23673. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  23674. v := m.updated_at
  23675. if v == nil {
  23676. return
  23677. }
  23678. return *v, true
  23679. }
  23680. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  23681. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23683. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23684. if !m.op.Is(OpUpdateOne) {
  23685. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23686. }
  23687. if m.id == nil || m.oldValue == nil {
  23688. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23689. }
  23690. oldValue, err := m.oldValue(ctx)
  23691. if err != nil {
  23692. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23693. }
  23694. return oldValue.UpdatedAt, nil
  23695. }
  23696. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23697. func (m *SopTaskMutation) ResetUpdatedAt() {
  23698. m.updated_at = nil
  23699. }
  23700. // SetStatus sets the "status" field.
  23701. func (m *SopTaskMutation) SetStatus(u uint8) {
  23702. m.status = &u
  23703. m.addstatus = nil
  23704. }
  23705. // Status returns the value of the "status" field in the mutation.
  23706. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  23707. v := m.status
  23708. if v == nil {
  23709. return
  23710. }
  23711. return *v, true
  23712. }
  23713. // OldStatus returns the old "status" field's value of the SopTask entity.
  23714. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23715. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23716. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23717. if !m.op.Is(OpUpdateOne) {
  23718. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23719. }
  23720. if m.id == nil || m.oldValue == nil {
  23721. return v, errors.New("OldStatus requires an ID field in the mutation")
  23722. }
  23723. oldValue, err := m.oldValue(ctx)
  23724. if err != nil {
  23725. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23726. }
  23727. return oldValue.Status, nil
  23728. }
  23729. // AddStatus adds u to the "status" field.
  23730. func (m *SopTaskMutation) AddStatus(u int8) {
  23731. if m.addstatus != nil {
  23732. *m.addstatus += u
  23733. } else {
  23734. m.addstatus = &u
  23735. }
  23736. }
  23737. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23738. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  23739. v := m.addstatus
  23740. if v == nil {
  23741. return
  23742. }
  23743. return *v, true
  23744. }
  23745. // ClearStatus clears the value of the "status" field.
  23746. func (m *SopTaskMutation) ClearStatus() {
  23747. m.status = nil
  23748. m.addstatus = nil
  23749. m.clearedFields[soptask.FieldStatus] = struct{}{}
  23750. }
  23751. // StatusCleared returns if the "status" field was cleared in this mutation.
  23752. func (m *SopTaskMutation) StatusCleared() bool {
  23753. _, ok := m.clearedFields[soptask.FieldStatus]
  23754. return ok
  23755. }
  23756. // ResetStatus resets all changes to the "status" field.
  23757. func (m *SopTaskMutation) ResetStatus() {
  23758. m.status = nil
  23759. m.addstatus = nil
  23760. delete(m.clearedFields, soptask.FieldStatus)
  23761. }
  23762. // SetDeletedAt sets the "deleted_at" field.
  23763. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  23764. m.deleted_at = &t
  23765. }
  23766. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23767. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  23768. v := m.deleted_at
  23769. if v == nil {
  23770. return
  23771. }
  23772. return *v, true
  23773. }
  23774. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  23775. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23776. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23777. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23778. if !m.op.Is(OpUpdateOne) {
  23779. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23780. }
  23781. if m.id == nil || m.oldValue == nil {
  23782. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23783. }
  23784. oldValue, err := m.oldValue(ctx)
  23785. if err != nil {
  23786. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23787. }
  23788. return oldValue.DeletedAt, nil
  23789. }
  23790. // ClearDeletedAt clears the value of the "deleted_at" field.
  23791. func (m *SopTaskMutation) ClearDeletedAt() {
  23792. m.deleted_at = nil
  23793. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  23794. }
  23795. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23796. func (m *SopTaskMutation) DeletedAtCleared() bool {
  23797. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  23798. return ok
  23799. }
  23800. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23801. func (m *SopTaskMutation) ResetDeletedAt() {
  23802. m.deleted_at = nil
  23803. delete(m.clearedFields, soptask.FieldDeletedAt)
  23804. }
  23805. // SetName sets the "name" field.
  23806. func (m *SopTaskMutation) SetName(s string) {
  23807. m.name = &s
  23808. }
  23809. // Name returns the value of the "name" field in the mutation.
  23810. func (m *SopTaskMutation) Name() (r string, exists bool) {
  23811. v := m.name
  23812. if v == nil {
  23813. return
  23814. }
  23815. return *v, true
  23816. }
  23817. // OldName returns the old "name" field's value of the SopTask entity.
  23818. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23819. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23820. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  23821. if !m.op.Is(OpUpdateOne) {
  23822. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23823. }
  23824. if m.id == nil || m.oldValue == nil {
  23825. return v, errors.New("OldName requires an ID field in the mutation")
  23826. }
  23827. oldValue, err := m.oldValue(ctx)
  23828. if err != nil {
  23829. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23830. }
  23831. return oldValue.Name, nil
  23832. }
  23833. // ResetName resets all changes to the "name" field.
  23834. func (m *SopTaskMutation) ResetName() {
  23835. m.name = nil
  23836. }
  23837. // SetBotWxidList sets the "bot_wxid_list" field.
  23838. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  23839. m.bot_wxid_list = &s
  23840. m.appendbot_wxid_list = nil
  23841. }
  23842. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  23843. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  23844. v := m.bot_wxid_list
  23845. if v == nil {
  23846. return
  23847. }
  23848. return *v, true
  23849. }
  23850. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  23851. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23853. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  23854. if !m.op.Is(OpUpdateOne) {
  23855. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  23856. }
  23857. if m.id == nil || m.oldValue == nil {
  23858. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  23859. }
  23860. oldValue, err := m.oldValue(ctx)
  23861. if err != nil {
  23862. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  23863. }
  23864. return oldValue.BotWxidList, nil
  23865. }
  23866. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  23867. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  23868. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  23869. }
  23870. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  23871. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  23872. if len(m.appendbot_wxid_list) == 0 {
  23873. return nil, false
  23874. }
  23875. return m.appendbot_wxid_list, true
  23876. }
  23877. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  23878. func (m *SopTaskMutation) ClearBotWxidList() {
  23879. m.bot_wxid_list = nil
  23880. m.appendbot_wxid_list = nil
  23881. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  23882. }
  23883. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  23884. func (m *SopTaskMutation) BotWxidListCleared() bool {
  23885. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  23886. return ok
  23887. }
  23888. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  23889. func (m *SopTaskMutation) ResetBotWxidList() {
  23890. m.bot_wxid_list = nil
  23891. m.appendbot_wxid_list = nil
  23892. delete(m.clearedFields, soptask.FieldBotWxidList)
  23893. }
  23894. // SetType sets the "type" field.
  23895. func (m *SopTaskMutation) SetType(i int) {
  23896. m._type = &i
  23897. m.add_type = nil
  23898. }
  23899. // GetType returns the value of the "type" field in the mutation.
  23900. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  23901. v := m._type
  23902. if v == nil {
  23903. return
  23904. }
  23905. return *v, true
  23906. }
  23907. // OldType returns the old "type" field's value of the SopTask entity.
  23908. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23910. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  23911. if !m.op.Is(OpUpdateOne) {
  23912. return v, errors.New("OldType is only allowed on UpdateOne operations")
  23913. }
  23914. if m.id == nil || m.oldValue == nil {
  23915. return v, errors.New("OldType requires an ID field in the mutation")
  23916. }
  23917. oldValue, err := m.oldValue(ctx)
  23918. if err != nil {
  23919. return v, fmt.Errorf("querying old value for OldType: %w", err)
  23920. }
  23921. return oldValue.Type, nil
  23922. }
  23923. // AddType adds i to the "type" field.
  23924. func (m *SopTaskMutation) AddType(i int) {
  23925. if m.add_type != nil {
  23926. *m.add_type += i
  23927. } else {
  23928. m.add_type = &i
  23929. }
  23930. }
  23931. // AddedType returns the value that was added to the "type" field in this mutation.
  23932. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  23933. v := m.add_type
  23934. if v == nil {
  23935. return
  23936. }
  23937. return *v, true
  23938. }
  23939. // ResetType resets all changes to the "type" field.
  23940. func (m *SopTaskMutation) ResetType() {
  23941. m._type = nil
  23942. m.add_type = nil
  23943. }
  23944. // SetPlanStartTime sets the "plan_start_time" field.
  23945. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  23946. m.plan_start_time = &t
  23947. }
  23948. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  23949. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  23950. v := m.plan_start_time
  23951. if v == nil {
  23952. return
  23953. }
  23954. return *v, true
  23955. }
  23956. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  23957. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23958. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23959. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  23960. if !m.op.Is(OpUpdateOne) {
  23961. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  23962. }
  23963. if m.id == nil || m.oldValue == nil {
  23964. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  23965. }
  23966. oldValue, err := m.oldValue(ctx)
  23967. if err != nil {
  23968. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  23969. }
  23970. return oldValue.PlanStartTime, nil
  23971. }
  23972. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  23973. func (m *SopTaskMutation) ClearPlanStartTime() {
  23974. m.plan_start_time = nil
  23975. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  23976. }
  23977. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  23978. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  23979. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  23980. return ok
  23981. }
  23982. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  23983. func (m *SopTaskMutation) ResetPlanStartTime() {
  23984. m.plan_start_time = nil
  23985. delete(m.clearedFields, soptask.FieldPlanStartTime)
  23986. }
  23987. // SetPlanEndTime sets the "plan_end_time" field.
  23988. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  23989. m.plan_end_time = &t
  23990. }
  23991. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  23992. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  23993. v := m.plan_end_time
  23994. if v == nil {
  23995. return
  23996. }
  23997. return *v, true
  23998. }
  23999. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  24000. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24002. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  24003. if !m.op.Is(OpUpdateOne) {
  24004. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  24005. }
  24006. if m.id == nil || m.oldValue == nil {
  24007. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  24008. }
  24009. oldValue, err := m.oldValue(ctx)
  24010. if err != nil {
  24011. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  24012. }
  24013. return oldValue.PlanEndTime, nil
  24014. }
  24015. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  24016. func (m *SopTaskMutation) ClearPlanEndTime() {
  24017. m.plan_end_time = nil
  24018. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  24019. }
  24020. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  24021. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  24022. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  24023. return ok
  24024. }
  24025. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  24026. func (m *SopTaskMutation) ResetPlanEndTime() {
  24027. m.plan_end_time = nil
  24028. delete(m.clearedFields, soptask.FieldPlanEndTime)
  24029. }
  24030. // SetCreatorID sets the "creator_id" field.
  24031. func (m *SopTaskMutation) SetCreatorID(s string) {
  24032. m.creator_id = &s
  24033. }
  24034. // CreatorID returns the value of the "creator_id" field in the mutation.
  24035. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  24036. v := m.creator_id
  24037. if v == nil {
  24038. return
  24039. }
  24040. return *v, true
  24041. }
  24042. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  24043. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24045. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  24046. if !m.op.Is(OpUpdateOne) {
  24047. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  24048. }
  24049. if m.id == nil || m.oldValue == nil {
  24050. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  24051. }
  24052. oldValue, err := m.oldValue(ctx)
  24053. if err != nil {
  24054. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  24055. }
  24056. return oldValue.CreatorID, nil
  24057. }
  24058. // ClearCreatorID clears the value of the "creator_id" field.
  24059. func (m *SopTaskMutation) ClearCreatorID() {
  24060. m.creator_id = nil
  24061. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  24062. }
  24063. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  24064. func (m *SopTaskMutation) CreatorIDCleared() bool {
  24065. _, ok := m.clearedFields[soptask.FieldCreatorID]
  24066. return ok
  24067. }
  24068. // ResetCreatorID resets all changes to the "creator_id" field.
  24069. func (m *SopTaskMutation) ResetCreatorID() {
  24070. m.creator_id = nil
  24071. delete(m.clearedFields, soptask.FieldCreatorID)
  24072. }
  24073. // SetOrganizationID sets the "organization_id" field.
  24074. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  24075. m.organization_id = &u
  24076. m.addorganization_id = nil
  24077. }
  24078. // OrganizationID returns the value of the "organization_id" field in the mutation.
  24079. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  24080. v := m.organization_id
  24081. if v == nil {
  24082. return
  24083. }
  24084. return *v, true
  24085. }
  24086. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  24087. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24089. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  24090. if !m.op.Is(OpUpdateOne) {
  24091. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  24092. }
  24093. if m.id == nil || m.oldValue == nil {
  24094. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  24095. }
  24096. oldValue, err := m.oldValue(ctx)
  24097. if err != nil {
  24098. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  24099. }
  24100. return oldValue.OrganizationID, nil
  24101. }
  24102. // AddOrganizationID adds u to the "organization_id" field.
  24103. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  24104. if m.addorganization_id != nil {
  24105. *m.addorganization_id += u
  24106. } else {
  24107. m.addorganization_id = &u
  24108. }
  24109. }
  24110. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  24111. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  24112. v := m.addorganization_id
  24113. if v == nil {
  24114. return
  24115. }
  24116. return *v, true
  24117. }
  24118. // ClearOrganizationID clears the value of the "organization_id" field.
  24119. func (m *SopTaskMutation) ClearOrganizationID() {
  24120. m.organization_id = nil
  24121. m.addorganization_id = nil
  24122. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  24123. }
  24124. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  24125. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  24126. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  24127. return ok
  24128. }
  24129. // ResetOrganizationID resets all changes to the "organization_id" field.
  24130. func (m *SopTaskMutation) ResetOrganizationID() {
  24131. m.organization_id = nil
  24132. m.addorganization_id = nil
  24133. delete(m.clearedFields, soptask.FieldOrganizationID)
  24134. }
  24135. // SetToken sets the "token" field.
  24136. func (m *SopTaskMutation) SetToken(s []string) {
  24137. m.token = &s
  24138. m.appendtoken = nil
  24139. }
  24140. // Token returns the value of the "token" field in the mutation.
  24141. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  24142. v := m.token
  24143. if v == nil {
  24144. return
  24145. }
  24146. return *v, true
  24147. }
  24148. // OldToken returns the old "token" field's value of the SopTask entity.
  24149. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24151. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  24152. if !m.op.Is(OpUpdateOne) {
  24153. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  24154. }
  24155. if m.id == nil || m.oldValue == nil {
  24156. return v, errors.New("OldToken requires an ID field in the mutation")
  24157. }
  24158. oldValue, err := m.oldValue(ctx)
  24159. if err != nil {
  24160. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  24161. }
  24162. return oldValue.Token, nil
  24163. }
  24164. // AppendToken adds s to the "token" field.
  24165. func (m *SopTaskMutation) AppendToken(s []string) {
  24166. m.appendtoken = append(m.appendtoken, s...)
  24167. }
  24168. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  24169. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  24170. if len(m.appendtoken) == 0 {
  24171. return nil, false
  24172. }
  24173. return m.appendtoken, true
  24174. }
  24175. // ClearToken clears the value of the "token" field.
  24176. func (m *SopTaskMutation) ClearToken() {
  24177. m.token = nil
  24178. m.appendtoken = nil
  24179. m.clearedFields[soptask.FieldToken] = struct{}{}
  24180. }
  24181. // TokenCleared returns if the "token" field was cleared in this mutation.
  24182. func (m *SopTaskMutation) TokenCleared() bool {
  24183. _, ok := m.clearedFields[soptask.FieldToken]
  24184. return ok
  24185. }
  24186. // ResetToken resets all changes to the "token" field.
  24187. func (m *SopTaskMutation) ResetToken() {
  24188. m.token = nil
  24189. m.appendtoken = nil
  24190. delete(m.clearedFields, soptask.FieldToken)
  24191. }
  24192. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  24193. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  24194. if m.task_stages == nil {
  24195. m.task_stages = make(map[uint64]struct{})
  24196. }
  24197. for i := range ids {
  24198. m.task_stages[ids[i]] = struct{}{}
  24199. }
  24200. }
  24201. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  24202. func (m *SopTaskMutation) ClearTaskStages() {
  24203. m.clearedtask_stages = true
  24204. }
  24205. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  24206. func (m *SopTaskMutation) TaskStagesCleared() bool {
  24207. return m.clearedtask_stages
  24208. }
  24209. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  24210. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  24211. if m.removedtask_stages == nil {
  24212. m.removedtask_stages = make(map[uint64]struct{})
  24213. }
  24214. for i := range ids {
  24215. delete(m.task_stages, ids[i])
  24216. m.removedtask_stages[ids[i]] = struct{}{}
  24217. }
  24218. }
  24219. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  24220. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  24221. for id := range m.removedtask_stages {
  24222. ids = append(ids, id)
  24223. }
  24224. return
  24225. }
  24226. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  24227. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  24228. for id := range m.task_stages {
  24229. ids = append(ids, id)
  24230. }
  24231. return
  24232. }
  24233. // ResetTaskStages resets all changes to the "task_stages" edge.
  24234. func (m *SopTaskMutation) ResetTaskStages() {
  24235. m.task_stages = nil
  24236. m.clearedtask_stages = false
  24237. m.removedtask_stages = nil
  24238. }
  24239. // Where appends a list predicates to the SopTaskMutation builder.
  24240. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  24241. m.predicates = append(m.predicates, ps...)
  24242. }
  24243. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  24244. // users can use type-assertion to append predicates that do not depend on any generated package.
  24245. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  24246. p := make([]predicate.SopTask, len(ps))
  24247. for i := range ps {
  24248. p[i] = ps[i]
  24249. }
  24250. m.Where(p...)
  24251. }
  24252. // Op returns the operation name.
  24253. func (m *SopTaskMutation) Op() Op {
  24254. return m.op
  24255. }
  24256. // SetOp allows setting the mutation operation.
  24257. func (m *SopTaskMutation) SetOp(op Op) {
  24258. m.op = op
  24259. }
  24260. // Type returns the node type of this mutation (SopTask).
  24261. func (m *SopTaskMutation) Type() string {
  24262. return m.typ
  24263. }
  24264. // Fields returns all fields that were changed during this mutation. Note that in
  24265. // order to get all numeric fields that were incremented/decremented, call
  24266. // AddedFields().
  24267. func (m *SopTaskMutation) Fields() []string {
  24268. fields := make([]string, 0, 12)
  24269. if m.created_at != nil {
  24270. fields = append(fields, soptask.FieldCreatedAt)
  24271. }
  24272. if m.updated_at != nil {
  24273. fields = append(fields, soptask.FieldUpdatedAt)
  24274. }
  24275. if m.status != nil {
  24276. fields = append(fields, soptask.FieldStatus)
  24277. }
  24278. if m.deleted_at != nil {
  24279. fields = append(fields, soptask.FieldDeletedAt)
  24280. }
  24281. if m.name != nil {
  24282. fields = append(fields, soptask.FieldName)
  24283. }
  24284. if m.bot_wxid_list != nil {
  24285. fields = append(fields, soptask.FieldBotWxidList)
  24286. }
  24287. if m._type != nil {
  24288. fields = append(fields, soptask.FieldType)
  24289. }
  24290. if m.plan_start_time != nil {
  24291. fields = append(fields, soptask.FieldPlanStartTime)
  24292. }
  24293. if m.plan_end_time != nil {
  24294. fields = append(fields, soptask.FieldPlanEndTime)
  24295. }
  24296. if m.creator_id != nil {
  24297. fields = append(fields, soptask.FieldCreatorID)
  24298. }
  24299. if m.organization_id != nil {
  24300. fields = append(fields, soptask.FieldOrganizationID)
  24301. }
  24302. if m.token != nil {
  24303. fields = append(fields, soptask.FieldToken)
  24304. }
  24305. return fields
  24306. }
  24307. // Field returns the value of a field with the given name. The second boolean
  24308. // return value indicates that this field was not set, or was not defined in the
  24309. // schema.
  24310. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  24311. switch name {
  24312. case soptask.FieldCreatedAt:
  24313. return m.CreatedAt()
  24314. case soptask.FieldUpdatedAt:
  24315. return m.UpdatedAt()
  24316. case soptask.FieldStatus:
  24317. return m.Status()
  24318. case soptask.FieldDeletedAt:
  24319. return m.DeletedAt()
  24320. case soptask.FieldName:
  24321. return m.Name()
  24322. case soptask.FieldBotWxidList:
  24323. return m.BotWxidList()
  24324. case soptask.FieldType:
  24325. return m.GetType()
  24326. case soptask.FieldPlanStartTime:
  24327. return m.PlanStartTime()
  24328. case soptask.FieldPlanEndTime:
  24329. return m.PlanEndTime()
  24330. case soptask.FieldCreatorID:
  24331. return m.CreatorID()
  24332. case soptask.FieldOrganizationID:
  24333. return m.OrganizationID()
  24334. case soptask.FieldToken:
  24335. return m.Token()
  24336. }
  24337. return nil, false
  24338. }
  24339. // OldField returns the old value of the field from the database. An error is
  24340. // returned if the mutation operation is not UpdateOne, or the query to the
  24341. // database failed.
  24342. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24343. switch name {
  24344. case soptask.FieldCreatedAt:
  24345. return m.OldCreatedAt(ctx)
  24346. case soptask.FieldUpdatedAt:
  24347. return m.OldUpdatedAt(ctx)
  24348. case soptask.FieldStatus:
  24349. return m.OldStatus(ctx)
  24350. case soptask.FieldDeletedAt:
  24351. return m.OldDeletedAt(ctx)
  24352. case soptask.FieldName:
  24353. return m.OldName(ctx)
  24354. case soptask.FieldBotWxidList:
  24355. return m.OldBotWxidList(ctx)
  24356. case soptask.FieldType:
  24357. return m.OldType(ctx)
  24358. case soptask.FieldPlanStartTime:
  24359. return m.OldPlanStartTime(ctx)
  24360. case soptask.FieldPlanEndTime:
  24361. return m.OldPlanEndTime(ctx)
  24362. case soptask.FieldCreatorID:
  24363. return m.OldCreatorID(ctx)
  24364. case soptask.FieldOrganizationID:
  24365. return m.OldOrganizationID(ctx)
  24366. case soptask.FieldToken:
  24367. return m.OldToken(ctx)
  24368. }
  24369. return nil, fmt.Errorf("unknown SopTask field %s", name)
  24370. }
  24371. // SetField sets the value of a field with the given name. It returns an error if
  24372. // the field is not defined in the schema, or if the type mismatched the field
  24373. // type.
  24374. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  24375. switch name {
  24376. case soptask.FieldCreatedAt:
  24377. v, ok := value.(time.Time)
  24378. if !ok {
  24379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24380. }
  24381. m.SetCreatedAt(v)
  24382. return nil
  24383. case soptask.FieldUpdatedAt:
  24384. v, ok := value.(time.Time)
  24385. if !ok {
  24386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24387. }
  24388. m.SetUpdatedAt(v)
  24389. return nil
  24390. case soptask.FieldStatus:
  24391. v, ok := value.(uint8)
  24392. if !ok {
  24393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24394. }
  24395. m.SetStatus(v)
  24396. return nil
  24397. case soptask.FieldDeletedAt:
  24398. v, ok := value.(time.Time)
  24399. if !ok {
  24400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24401. }
  24402. m.SetDeletedAt(v)
  24403. return nil
  24404. case soptask.FieldName:
  24405. v, ok := value.(string)
  24406. if !ok {
  24407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24408. }
  24409. m.SetName(v)
  24410. return nil
  24411. case soptask.FieldBotWxidList:
  24412. v, ok := value.([]string)
  24413. if !ok {
  24414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24415. }
  24416. m.SetBotWxidList(v)
  24417. return nil
  24418. case soptask.FieldType:
  24419. v, ok := value.(int)
  24420. if !ok {
  24421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24422. }
  24423. m.SetType(v)
  24424. return nil
  24425. case soptask.FieldPlanStartTime:
  24426. v, ok := value.(time.Time)
  24427. if !ok {
  24428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24429. }
  24430. m.SetPlanStartTime(v)
  24431. return nil
  24432. case soptask.FieldPlanEndTime:
  24433. v, ok := value.(time.Time)
  24434. if !ok {
  24435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24436. }
  24437. m.SetPlanEndTime(v)
  24438. return nil
  24439. case soptask.FieldCreatorID:
  24440. v, ok := value.(string)
  24441. if !ok {
  24442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24443. }
  24444. m.SetCreatorID(v)
  24445. return nil
  24446. case soptask.FieldOrganizationID:
  24447. v, ok := value.(uint64)
  24448. if !ok {
  24449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24450. }
  24451. m.SetOrganizationID(v)
  24452. return nil
  24453. case soptask.FieldToken:
  24454. v, ok := value.([]string)
  24455. if !ok {
  24456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24457. }
  24458. m.SetToken(v)
  24459. return nil
  24460. }
  24461. return fmt.Errorf("unknown SopTask field %s", name)
  24462. }
  24463. // AddedFields returns all numeric fields that were incremented/decremented during
  24464. // this mutation.
  24465. func (m *SopTaskMutation) AddedFields() []string {
  24466. var fields []string
  24467. if m.addstatus != nil {
  24468. fields = append(fields, soptask.FieldStatus)
  24469. }
  24470. if m.add_type != nil {
  24471. fields = append(fields, soptask.FieldType)
  24472. }
  24473. if m.addorganization_id != nil {
  24474. fields = append(fields, soptask.FieldOrganizationID)
  24475. }
  24476. return fields
  24477. }
  24478. // AddedField returns the numeric value that was incremented/decremented on a field
  24479. // with the given name. The second boolean return value indicates that this field
  24480. // was not set, or was not defined in the schema.
  24481. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  24482. switch name {
  24483. case soptask.FieldStatus:
  24484. return m.AddedStatus()
  24485. case soptask.FieldType:
  24486. return m.AddedType()
  24487. case soptask.FieldOrganizationID:
  24488. return m.AddedOrganizationID()
  24489. }
  24490. return nil, false
  24491. }
  24492. // AddField adds the value to the field with the given name. It returns an error if
  24493. // the field is not defined in the schema, or if the type mismatched the field
  24494. // type.
  24495. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  24496. switch name {
  24497. case soptask.FieldStatus:
  24498. v, ok := value.(int8)
  24499. if !ok {
  24500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24501. }
  24502. m.AddStatus(v)
  24503. return nil
  24504. case soptask.FieldType:
  24505. v, ok := value.(int)
  24506. if !ok {
  24507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24508. }
  24509. m.AddType(v)
  24510. return nil
  24511. case soptask.FieldOrganizationID:
  24512. v, ok := value.(int64)
  24513. if !ok {
  24514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24515. }
  24516. m.AddOrganizationID(v)
  24517. return nil
  24518. }
  24519. return fmt.Errorf("unknown SopTask numeric field %s", name)
  24520. }
  24521. // ClearedFields returns all nullable fields that were cleared during this
  24522. // mutation.
  24523. func (m *SopTaskMutation) ClearedFields() []string {
  24524. var fields []string
  24525. if m.FieldCleared(soptask.FieldStatus) {
  24526. fields = append(fields, soptask.FieldStatus)
  24527. }
  24528. if m.FieldCleared(soptask.FieldDeletedAt) {
  24529. fields = append(fields, soptask.FieldDeletedAt)
  24530. }
  24531. if m.FieldCleared(soptask.FieldBotWxidList) {
  24532. fields = append(fields, soptask.FieldBotWxidList)
  24533. }
  24534. if m.FieldCleared(soptask.FieldPlanStartTime) {
  24535. fields = append(fields, soptask.FieldPlanStartTime)
  24536. }
  24537. if m.FieldCleared(soptask.FieldPlanEndTime) {
  24538. fields = append(fields, soptask.FieldPlanEndTime)
  24539. }
  24540. if m.FieldCleared(soptask.FieldCreatorID) {
  24541. fields = append(fields, soptask.FieldCreatorID)
  24542. }
  24543. if m.FieldCleared(soptask.FieldOrganizationID) {
  24544. fields = append(fields, soptask.FieldOrganizationID)
  24545. }
  24546. if m.FieldCleared(soptask.FieldToken) {
  24547. fields = append(fields, soptask.FieldToken)
  24548. }
  24549. return fields
  24550. }
  24551. // FieldCleared returns a boolean indicating if a field with the given name was
  24552. // cleared in this mutation.
  24553. func (m *SopTaskMutation) FieldCleared(name string) bool {
  24554. _, ok := m.clearedFields[name]
  24555. return ok
  24556. }
  24557. // ClearField clears the value of the field with the given name. It returns an
  24558. // error if the field is not defined in the schema.
  24559. func (m *SopTaskMutation) ClearField(name string) error {
  24560. switch name {
  24561. case soptask.FieldStatus:
  24562. m.ClearStatus()
  24563. return nil
  24564. case soptask.FieldDeletedAt:
  24565. m.ClearDeletedAt()
  24566. return nil
  24567. case soptask.FieldBotWxidList:
  24568. m.ClearBotWxidList()
  24569. return nil
  24570. case soptask.FieldPlanStartTime:
  24571. m.ClearPlanStartTime()
  24572. return nil
  24573. case soptask.FieldPlanEndTime:
  24574. m.ClearPlanEndTime()
  24575. return nil
  24576. case soptask.FieldCreatorID:
  24577. m.ClearCreatorID()
  24578. return nil
  24579. case soptask.FieldOrganizationID:
  24580. m.ClearOrganizationID()
  24581. return nil
  24582. case soptask.FieldToken:
  24583. m.ClearToken()
  24584. return nil
  24585. }
  24586. return fmt.Errorf("unknown SopTask nullable field %s", name)
  24587. }
  24588. // ResetField resets all changes in the mutation for the field with the given name.
  24589. // It returns an error if the field is not defined in the schema.
  24590. func (m *SopTaskMutation) ResetField(name string) error {
  24591. switch name {
  24592. case soptask.FieldCreatedAt:
  24593. m.ResetCreatedAt()
  24594. return nil
  24595. case soptask.FieldUpdatedAt:
  24596. m.ResetUpdatedAt()
  24597. return nil
  24598. case soptask.FieldStatus:
  24599. m.ResetStatus()
  24600. return nil
  24601. case soptask.FieldDeletedAt:
  24602. m.ResetDeletedAt()
  24603. return nil
  24604. case soptask.FieldName:
  24605. m.ResetName()
  24606. return nil
  24607. case soptask.FieldBotWxidList:
  24608. m.ResetBotWxidList()
  24609. return nil
  24610. case soptask.FieldType:
  24611. m.ResetType()
  24612. return nil
  24613. case soptask.FieldPlanStartTime:
  24614. m.ResetPlanStartTime()
  24615. return nil
  24616. case soptask.FieldPlanEndTime:
  24617. m.ResetPlanEndTime()
  24618. return nil
  24619. case soptask.FieldCreatorID:
  24620. m.ResetCreatorID()
  24621. return nil
  24622. case soptask.FieldOrganizationID:
  24623. m.ResetOrganizationID()
  24624. return nil
  24625. case soptask.FieldToken:
  24626. m.ResetToken()
  24627. return nil
  24628. }
  24629. return fmt.Errorf("unknown SopTask field %s", name)
  24630. }
  24631. // AddedEdges returns all edge names that were set/added in this mutation.
  24632. func (m *SopTaskMutation) AddedEdges() []string {
  24633. edges := make([]string, 0, 1)
  24634. if m.task_stages != nil {
  24635. edges = append(edges, soptask.EdgeTaskStages)
  24636. }
  24637. return edges
  24638. }
  24639. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24640. // name in this mutation.
  24641. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  24642. switch name {
  24643. case soptask.EdgeTaskStages:
  24644. ids := make([]ent.Value, 0, len(m.task_stages))
  24645. for id := range m.task_stages {
  24646. ids = append(ids, id)
  24647. }
  24648. return ids
  24649. }
  24650. return nil
  24651. }
  24652. // RemovedEdges returns all edge names that were removed in this mutation.
  24653. func (m *SopTaskMutation) RemovedEdges() []string {
  24654. edges := make([]string, 0, 1)
  24655. if m.removedtask_stages != nil {
  24656. edges = append(edges, soptask.EdgeTaskStages)
  24657. }
  24658. return edges
  24659. }
  24660. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24661. // the given name in this mutation.
  24662. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  24663. switch name {
  24664. case soptask.EdgeTaskStages:
  24665. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  24666. for id := range m.removedtask_stages {
  24667. ids = append(ids, id)
  24668. }
  24669. return ids
  24670. }
  24671. return nil
  24672. }
  24673. // ClearedEdges returns all edge names that were cleared in this mutation.
  24674. func (m *SopTaskMutation) ClearedEdges() []string {
  24675. edges := make([]string, 0, 1)
  24676. if m.clearedtask_stages {
  24677. edges = append(edges, soptask.EdgeTaskStages)
  24678. }
  24679. return edges
  24680. }
  24681. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24682. // was cleared in this mutation.
  24683. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  24684. switch name {
  24685. case soptask.EdgeTaskStages:
  24686. return m.clearedtask_stages
  24687. }
  24688. return false
  24689. }
  24690. // ClearEdge clears the value of the edge with the given name. It returns an error
  24691. // if that edge is not defined in the schema.
  24692. func (m *SopTaskMutation) ClearEdge(name string) error {
  24693. switch name {
  24694. }
  24695. return fmt.Errorf("unknown SopTask unique edge %s", name)
  24696. }
  24697. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24698. // It returns an error if the edge is not defined in the schema.
  24699. func (m *SopTaskMutation) ResetEdge(name string) error {
  24700. switch name {
  24701. case soptask.EdgeTaskStages:
  24702. m.ResetTaskStages()
  24703. return nil
  24704. }
  24705. return fmt.Errorf("unknown SopTask edge %s", name)
  24706. }
  24707. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  24708. type TokenMutation struct {
  24709. config
  24710. op Op
  24711. typ string
  24712. id *uint64
  24713. created_at *time.Time
  24714. updated_at *time.Time
  24715. deleted_at *time.Time
  24716. expire_at *time.Time
  24717. token *string
  24718. mac *string
  24719. organization_id *uint64
  24720. addorganization_id *int64
  24721. custom_agent_base *string
  24722. custom_agent_key *string
  24723. openai_base *string
  24724. openai_key *string
  24725. clearedFields map[string]struct{}
  24726. agent *uint64
  24727. clearedagent bool
  24728. done bool
  24729. oldValue func(context.Context) (*Token, error)
  24730. predicates []predicate.Token
  24731. }
  24732. var _ ent.Mutation = (*TokenMutation)(nil)
  24733. // tokenOption allows management of the mutation configuration using functional options.
  24734. type tokenOption func(*TokenMutation)
  24735. // newTokenMutation creates new mutation for the Token entity.
  24736. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  24737. m := &TokenMutation{
  24738. config: c,
  24739. op: op,
  24740. typ: TypeToken,
  24741. clearedFields: make(map[string]struct{}),
  24742. }
  24743. for _, opt := range opts {
  24744. opt(m)
  24745. }
  24746. return m
  24747. }
  24748. // withTokenID sets the ID field of the mutation.
  24749. func withTokenID(id uint64) tokenOption {
  24750. return func(m *TokenMutation) {
  24751. var (
  24752. err error
  24753. once sync.Once
  24754. value *Token
  24755. )
  24756. m.oldValue = func(ctx context.Context) (*Token, error) {
  24757. once.Do(func() {
  24758. if m.done {
  24759. err = errors.New("querying old values post mutation is not allowed")
  24760. } else {
  24761. value, err = m.Client().Token.Get(ctx, id)
  24762. }
  24763. })
  24764. return value, err
  24765. }
  24766. m.id = &id
  24767. }
  24768. }
  24769. // withToken sets the old Token of the mutation.
  24770. func withToken(node *Token) tokenOption {
  24771. return func(m *TokenMutation) {
  24772. m.oldValue = func(context.Context) (*Token, error) {
  24773. return node, nil
  24774. }
  24775. m.id = &node.ID
  24776. }
  24777. }
  24778. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24779. // executed in a transaction (ent.Tx), a transactional client is returned.
  24780. func (m TokenMutation) Client() *Client {
  24781. client := &Client{config: m.config}
  24782. client.init()
  24783. return client
  24784. }
  24785. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24786. // it returns an error otherwise.
  24787. func (m TokenMutation) Tx() (*Tx, error) {
  24788. if _, ok := m.driver.(*txDriver); !ok {
  24789. return nil, errors.New("ent: mutation is not running in a transaction")
  24790. }
  24791. tx := &Tx{config: m.config}
  24792. tx.init()
  24793. return tx, nil
  24794. }
  24795. // SetID sets the value of the id field. Note that this
  24796. // operation is only accepted on creation of Token entities.
  24797. func (m *TokenMutation) SetID(id uint64) {
  24798. m.id = &id
  24799. }
  24800. // ID returns the ID value in the mutation. Note that the ID is only available
  24801. // if it was provided to the builder or after it was returned from the database.
  24802. func (m *TokenMutation) ID() (id uint64, exists bool) {
  24803. if m.id == nil {
  24804. return
  24805. }
  24806. return *m.id, true
  24807. }
  24808. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24809. // That means, if the mutation is applied within a transaction with an isolation level such
  24810. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24811. // or updated by the mutation.
  24812. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  24813. switch {
  24814. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24815. id, exists := m.ID()
  24816. if exists {
  24817. return []uint64{id}, nil
  24818. }
  24819. fallthrough
  24820. case m.op.Is(OpUpdate | OpDelete):
  24821. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  24822. default:
  24823. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24824. }
  24825. }
  24826. // SetCreatedAt sets the "created_at" field.
  24827. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  24828. m.created_at = &t
  24829. }
  24830. // CreatedAt returns the value of the "created_at" field in the mutation.
  24831. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  24832. v := m.created_at
  24833. if v == nil {
  24834. return
  24835. }
  24836. return *v, true
  24837. }
  24838. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  24839. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24841. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24842. if !m.op.Is(OpUpdateOne) {
  24843. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24844. }
  24845. if m.id == nil || m.oldValue == nil {
  24846. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24847. }
  24848. oldValue, err := m.oldValue(ctx)
  24849. if err != nil {
  24850. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24851. }
  24852. return oldValue.CreatedAt, nil
  24853. }
  24854. // ResetCreatedAt resets all changes to the "created_at" field.
  24855. func (m *TokenMutation) ResetCreatedAt() {
  24856. m.created_at = nil
  24857. }
  24858. // SetUpdatedAt sets the "updated_at" field.
  24859. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  24860. m.updated_at = &t
  24861. }
  24862. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24863. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  24864. v := m.updated_at
  24865. if v == nil {
  24866. return
  24867. }
  24868. return *v, true
  24869. }
  24870. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  24871. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24873. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24874. if !m.op.Is(OpUpdateOne) {
  24875. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24876. }
  24877. if m.id == nil || m.oldValue == nil {
  24878. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24879. }
  24880. oldValue, err := m.oldValue(ctx)
  24881. if err != nil {
  24882. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24883. }
  24884. return oldValue.UpdatedAt, nil
  24885. }
  24886. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24887. func (m *TokenMutation) ResetUpdatedAt() {
  24888. m.updated_at = nil
  24889. }
  24890. // SetDeletedAt sets the "deleted_at" field.
  24891. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  24892. m.deleted_at = &t
  24893. }
  24894. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24895. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  24896. v := m.deleted_at
  24897. if v == nil {
  24898. return
  24899. }
  24900. return *v, true
  24901. }
  24902. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  24903. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24905. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24906. if !m.op.Is(OpUpdateOne) {
  24907. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24908. }
  24909. if m.id == nil || m.oldValue == nil {
  24910. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24911. }
  24912. oldValue, err := m.oldValue(ctx)
  24913. if err != nil {
  24914. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24915. }
  24916. return oldValue.DeletedAt, nil
  24917. }
  24918. // ClearDeletedAt clears the value of the "deleted_at" field.
  24919. func (m *TokenMutation) ClearDeletedAt() {
  24920. m.deleted_at = nil
  24921. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  24922. }
  24923. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24924. func (m *TokenMutation) DeletedAtCleared() bool {
  24925. _, ok := m.clearedFields[token.FieldDeletedAt]
  24926. return ok
  24927. }
  24928. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24929. func (m *TokenMutation) ResetDeletedAt() {
  24930. m.deleted_at = nil
  24931. delete(m.clearedFields, token.FieldDeletedAt)
  24932. }
  24933. // SetExpireAt sets the "expire_at" field.
  24934. func (m *TokenMutation) SetExpireAt(t time.Time) {
  24935. m.expire_at = &t
  24936. }
  24937. // ExpireAt returns the value of the "expire_at" field in the mutation.
  24938. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  24939. v := m.expire_at
  24940. if v == nil {
  24941. return
  24942. }
  24943. return *v, true
  24944. }
  24945. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  24946. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24947. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24948. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  24949. if !m.op.Is(OpUpdateOne) {
  24950. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  24951. }
  24952. if m.id == nil || m.oldValue == nil {
  24953. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  24954. }
  24955. oldValue, err := m.oldValue(ctx)
  24956. if err != nil {
  24957. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  24958. }
  24959. return oldValue.ExpireAt, nil
  24960. }
  24961. // ClearExpireAt clears the value of the "expire_at" field.
  24962. func (m *TokenMutation) ClearExpireAt() {
  24963. m.expire_at = nil
  24964. m.clearedFields[token.FieldExpireAt] = struct{}{}
  24965. }
  24966. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  24967. func (m *TokenMutation) ExpireAtCleared() bool {
  24968. _, ok := m.clearedFields[token.FieldExpireAt]
  24969. return ok
  24970. }
  24971. // ResetExpireAt resets all changes to the "expire_at" field.
  24972. func (m *TokenMutation) ResetExpireAt() {
  24973. m.expire_at = nil
  24974. delete(m.clearedFields, token.FieldExpireAt)
  24975. }
  24976. // SetToken sets the "token" field.
  24977. func (m *TokenMutation) SetToken(s string) {
  24978. m.token = &s
  24979. }
  24980. // Token returns the value of the "token" field in the mutation.
  24981. func (m *TokenMutation) Token() (r string, exists bool) {
  24982. v := m.token
  24983. if v == nil {
  24984. return
  24985. }
  24986. return *v, true
  24987. }
  24988. // OldToken returns the old "token" field's value of the Token entity.
  24989. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24991. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  24992. if !m.op.Is(OpUpdateOne) {
  24993. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  24994. }
  24995. if m.id == nil || m.oldValue == nil {
  24996. return v, errors.New("OldToken requires an ID field in the mutation")
  24997. }
  24998. oldValue, err := m.oldValue(ctx)
  24999. if err != nil {
  25000. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  25001. }
  25002. return oldValue.Token, nil
  25003. }
  25004. // ClearToken clears the value of the "token" field.
  25005. func (m *TokenMutation) ClearToken() {
  25006. m.token = nil
  25007. m.clearedFields[token.FieldToken] = struct{}{}
  25008. }
  25009. // TokenCleared returns if the "token" field was cleared in this mutation.
  25010. func (m *TokenMutation) TokenCleared() bool {
  25011. _, ok := m.clearedFields[token.FieldToken]
  25012. return ok
  25013. }
  25014. // ResetToken resets all changes to the "token" field.
  25015. func (m *TokenMutation) ResetToken() {
  25016. m.token = nil
  25017. delete(m.clearedFields, token.FieldToken)
  25018. }
  25019. // SetMAC sets the "mac" field.
  25020. func (m *TokenMutation) SetMAC(s string) {
  25021. m.mac = &s
  25022. }
  25023. // MAC returns the value of the "mac" field in the mutation.
  25024. func (m *TokenMutation) MAC() (r string, exists bool) {
  25025. v := m.mac
  25026. if v == nil {
  25027. return
  25028. }
  25029. return *v, true
  25030. }
  25031. // OldMAC returns the old "mac" field's value of the Token entity.
  25032. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25034. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  25035. if !m.op.Is(OpUpdateOne) {
  25036. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  25037. }
  25038. if m.id == nil || m.oldValue == nil {
  25039. return v, errors.New("OldMAC requires an ID field in the mutation")
  25040. }
  25041. oldValue, err := m.oldValue(ctx)
  25042. if err != nil {
  25043. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  25044. }
  25045. return oldValue.MAC, nil
  25046. }
  25047. // ClearMAC clears the value of the "mac" field.
  25048. func (m *TokenMutation) ClearMAC() {
  25049. m.mac = nil
  25050. m.clearedFields[token.FieldMAC] = struct{}{}
  25051. }
  25052. // MACCleared returns if the "mac" field was cleared in this mutation.
  25053. func (m *TokenMutation) MACCleared() bool {
  25054. _, ok := m.clearedFields[token.FieldMAC]
  25055. return ok
  25056. }
  25057. // ResetMAC resets all changes to the "mac" field.
  25058. func (m *TokenMutation) ResetMAC() {
  25059. m.mac = nil
  25060. delete(m.clearedFields, token.FieldMAC)
  25061. }
  25062. // SetOrganizationID sets the "organization_id" field.
  25063. func (m *TokenMutation) SetOrganizationID(u uint64) {
  25064. m.organization_id = &u
  25065. m.addorganization_id = nil
  25066. }
  25067. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25068. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  25069. v := m.organization_id
  25070. if v == nil {
  25071. return
  25072. }
  25073. return *v, true
  25074. }
  25075. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  25076. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25078. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25079. if !m.op.Is(OpUpdateOne) {
  25080. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25081. }
  25082. if m.id == nil || m.oldValue == nil {
  25083. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25084. }
  25085. oldValue, err := m.oldValue(ctx)
  25086. if err != nil {
  25087. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25088. }
  25089. return oldValue.OrganizationID, nil
  25090. }
  25091. // AddOrganizationID adds u to the "organization_id" field.
  25092. func (m *TokenMutation) AddOrganizationID(u int64) {
  25093. if m.addorganization_id != nil {
  25094. *m.addorganization_id += u
  25095. } else {
  25096. m.addorganization_id = &u
  25097. }
  25098. }
  25099. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25100. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  25101. v := m.addorganization_id
  25102. if v == nil {
  25103. return
  25104. }
  25105. return *v, true
  25106. }
  25107. // ResetOrganizationID resets all changes to the "organization_id" field.
  25108. func (m *TokenMutation) ResetOrganizationID() {
  25109. m.organization_id = nil
  25110. m.addorganization_id = nil
  25111. }
  25112. // SetAgentID sets the "agent_id" field.
  25113. func (m *TokenMutation) SetAgentID(u uint64) {
  25114. m.agent = &u
  25115. }
  25116. // AgentID returns the value of the "agent_id" field in the mutation.
  25117. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  25118. v := m.agent
  25119. if v == nil {
  25120. return
  25121. }
  25122. return *v, true
  25123. }
  25124. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  25125. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25127. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  25128. if !m.op.Is(OpUpdateOne) {
  25129. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  25130. }
  25131. if m.id == nil || m.oldValue == nil {
  25132. return v, errors.New("OldAgentID requires an ID field in the mutation")
  25133. }
  25134. oldValue, err := m.oldValue(ctx)
  25135. if err != nil {
  25136. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  25137. }
  25138. return oldValue.AgentID, nil
  25139. }
  25140. // ResetAgentID resets all changes to the "agent_id" field.
  25141. func (m *TokenMutation) ResetAgentID() {
  25142. m.agent = nil
  25143. }
  25144. // SetCustomAgentBase sets the "custom_agent_base" field.
  25145. func (m *TokenMutation) SetCustomAgentBase(s string) {
  25146. m.custom_agent_base = &s
  25147. }
  25148. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  25149. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  25150. v := m.custom_agent_base
  25151. if v == nil {
  25152. return
  25153. }
  25154. return *v, true
  25155. }
  25156. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  25157. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25159. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  25160. if !m.op.Is(OpUpdateOne) {
  25161. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  25162. }
  25163. if m.id == nil || m.oldValue == nil {
  25164. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  25165. }
  25166. oldValue, err := m.oldValue(ctx)
  25167. if err != nil {
  25168. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  25169. }
  25170. return oldValue.CustomAgentBase, nil
  25171. }
  25172. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  25173. func (m *TokenMutation) ClearCustomAgentBase() {
  25174. m.custom_agent_base = nil
  25175. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  25176. }
  25177. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  25178. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  25179. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  25180. return ok
  25181. }
  25182. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  25183. func (m *TokenMutation) ResetCustomAgentBase() {
  25184. m.custom_agent_base = nil
  25185. delete(m.clearedFields, token.FieldCustomAgentBase)
  25186. }
  25187. // SetCustomAgentKey sets the "custom_agent_key" field.
  25188. func (m *TokenMutation) SetCustomAgentKey(s string) {
  25189. m.custom_agent_key = &s
  25190. }
  25191. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  25192. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  25193. v := m.custom_agent_key
  25194. if v == nil {
  25195. return
  25196. }
  25197. return *v, true
  25198. }
  25199. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  25200. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25202. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  25203. if !m.op.Is(OpUpdateOne) {
  25204. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  25205. }
  25206. if m.id == nil || m.oldValue == nil {
  25207. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  25208. }
  25209. oldValue, err := m.oldValue(ctx)
  25210. if err != nil {
  25211. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  25212. }
  25213. return oldValue.CustomAgentKey, nil
  25214. }
  25215. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  25216. func (m *TokenMutation) ClearCustomAgentKey() {
  25217. m.custom_agent_key = nil
  25218. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  25219. }
  25220. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  25221. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  25222. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  25223. return ok
  25224. }
  25225. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  25226. func (m *TokenMutation) ResetCustomAgentKey() {
  25227. m.custom_agent_key = nil
  25228. delete(m.clearedFields, token.FieldCustomAgentKey)
  25229. }
  25230. // SetOpenaiBase sets the "openai_base" field.
  25231. func (m *TokenMutation) SetOpenaiBase(s string) {
  25232. m.openai_base = &s
  25233. }
  25234. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  25235. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  25236. v := m.openai_base
  25237. if v == nil {
  25238. return
  25239. }
  25240. return *v, true
  25241. }
  25242. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  25243. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25245. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  25246. if !m.op.Is(OpUpdateOne) {
  25247. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  25248. }
  25249. if m.id == nil || m.oldValue == nil {
  25250. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  25251. }
  25252. oldValue, err := m.oldValue(ctx)
  25253. if err != nil {
  25254. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  25255. }
  25256. return oldValue.OpenaiBase, nil
  25257. }
  25258. // ClearOpenaiBase clears the value of the "openai_base" field.
  25259. func (m *TokenMutation) ClearOpenaiBase() {
  25260. m.openai_base = nil
  25261. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  25262. }
  25263. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  25264. func (m *TokenMutation) OpenaiBaseCleared() bool {
  25265. _, ok := m.clearedFields[token.FieldOpenaiBase]
  25266. return ok
  25267. }
  25268. // ResetOpenaiBase resets all changes to the "openai_base" field.
  25269. func (m *TokenMutation) ResetOpenaiBase() {
  25270. m.openai_base = nil
  25271. delete(m.clearedFields, token.FieldOpenaiBase)
  25272. }
  25273. // SetOpenaiKey sets the "openai_key" field.
  25274. func (m *TokenMutation) SetOpenaiKey(s string) {
  25275. m.openai_key = &s
  25276. }
  25277. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  25278. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  25279. v := m.openai_key
  25280. if v == nil {
  25281. return
  25282. }
  25283. return *v, true
  25284. }
  25285. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  25286. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25288. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  25289. if !m.op.Is(OpUpdateOne) {
  25290. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  25291. }
  25292. if m.id == nil || m.oldValue == nil {
  25293. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  25294. }
  25295. oldValue, err := m.oldValue(ctx)
  25296. if err != nil {
  25297. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  25298. }
  25299. return oldValue.OpenaiKey, nil
  25300. }
  25301. // ClearOpenaiKey clears the value of the "openai_key" field.
  25302. func (m *TokenMutation) ClearOpenaiKey() {
  25303. m.openai_key = nil
  25304. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  25305. }
  25306. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  25307. func (m *TokenMutation) OpenaiKeyCleared() bool {
  25308. _, ok := m.clearedFields[token.FieldOpenaiKey]
  25309. return ok
  25310. }
  25311. // ResetOpenaiKey resets all changes to the "openai_key" field.
  25312. func (m *TokenMutation) ResetOpenaiKey() {
  25313. m.openai_key = nil
  25314. delete(m.clearedFields, token.FieldOpenaiKey)
  25315. }
  25316. // ClearAgent clears the "agent" edge to the Agent entity.
  25317. func (m *TokenMutation) ClearAgent() {
  25318. m.clearedagent = true
  25319. m.clearedFields[token.FieldAgentID] = struct{}{}
  25320. }
  25321. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  25322. func (m *TokenMutation) AgentCleared() bool {
  25323. return m.clearedagent
  25324. }
  25325. // AgentIDs returns the "agent" edge IDs in the mutation.
  25326. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25327. // AgentID instead. It exists only for internal usage by the builders.
  25328. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  25329. if id := m.agent; id != nil {
  25330. ids = append(ids, *id)
  25331. }
  25332. return
  25333. }
  25334. // ResetAgent resets all changes to the "agent" edge.
  25335. func (m *TokenMutation) ResetAgent() {
  25336. m.agent = nil
  25337. m.clearedagent = false
  25338. }
  25339. // Where appends a list predicates to the TokenMutation builder.
  25340. func (m *TokenMutation) Where(ps ...predicate.Token) {
  25341. m.predicates = append(m.predicates, ps...)
  25342. }
  25343. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  25344. // users can use type-assertion to append predicates that do not depend on any generated package.
  25345. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  25346. p := make([]predicate.Token, len(ps))
  25347. for i := range ps {
  25348. p[i] = ps[i]
  25349. }
  25350. m.Where(p...)
  25351. }
  25352. // Op returns the operation name.
  25353. func (m *TokenMutation) Op() Op {
  25354. return m.op
  25355. }
  25356. // SetOp allows setting the mutation operation.
  25357. func (m *TokenMutation) SetOp(op Op) {
  25358. m.op = op
  25359. }
  25360. // Type returns the node type of this mutation (Token).
  25361. func (m *TokenMutation) Type() string {
  25362. return m.typ
  25363. }
  25364. // Fields returns all fields that were changed during this mutation. Note that in
  25365. // order to get all numeric fields that were incremented/decremented, call
  25366. // AddedFields().
  25367. func (m *TokenMutation) Fields() []string {
  25368. fields := make([]string, 0, 12)
  25369. if m.created_at != nil {
  25370. fields = append(fields, token.FieldCreatedAt)
  25371. }
  25372. if m.updated_at != nil {
  25373. fields = append(fields, token.FieldUpdatedAt)
  25374. }
  25375. if m.deleted_at != nil {
  25376. fields = append(fields, token.FieldDeletedAt)
  25377. }
  25378. if m.expire_at != nil {
  25379. fields = append(fields, token.FieldExpireAt)
  25380. }
  25381. if m.token != nil {
  25382. fields = append(fields, token.FieldToken)
  25383. }
  25384. if m.mac != nil {
  25385. fields = append(fields, token.FieldMAC)
  25386. }
  25387. if m.organization_id != nil {
  25388. fields = append(fields, token.FieldOrganizationID)
  25389. }
  25390. if m.agent != nil {
  25391. fields = append(fields, token.FieldAgentID)
  25392. }
  25393. if m.custom_agent_base != nil {
  25394. fields = append(fields, token.FieldCustomAgentBase)
  25395. }
  25396. if m.custom_agent_key != nil {
  25397. fields = append(fields, token.FieldCustomAgentKey)
  25398. }
  25399. if m.openai_base != nil {
  25400. fields = append(fields, token.FieldOpenaiBase)
  25401. }
  25402. if m.openai_key != nil {
  25403. fields = append(fields, token.FieldOpenaiKey)
  25404. }
  25405. return fields
  25406. }
  25407. // Field returns the value of a field with the given name. The second boolean
  25408. // return value indicates that this field was not set, or was not defined in the
  25409. // schema.
  25410. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  25411. switch name {
  25412. case token.FieldCreatedAt:
  25413. return m.CreatedAt()
  25414. case token.FieldUpdatedAt:
  25415. return m.UpdatedAt()
  25416. case token.FieldDeletedAt:
  25417. return m.DeletedAt()
  25418. case token.FieldExpireAt:
  25419. return m.ExpireAt()
  25420. case token.FieldToken:
  25421. return m.Token()
  25422. case token.FieldMAC:
  25423. return m.MAC()
  25424. case token.FieldOrganizationID:
  25425. return m.OrganizationID()
  25426. case token.FieldAgentID:
  25427. return m.AgentID()
  25428. case token.FieldCustomAgentBase:
  25429. return m.CustomAgentBase()
  25430. case token.FieldCustomAgentKey:
  25431. return m.CustomAgentKey()
  25432. case token.FieldOpenaiBase:
  25433. return m.OpenaiBase()
  25434. case token.FieldOpenaiKey:
  25435. return m.OpenaiKey()
  25436. }
  25437. return nil, false
  25438. }
  25439. // OldField returns the old value of the field from the database. An error is
  25440. // returned if the mutation operation is not UpdateOne, or the query to the
  25441. // database failed.
  25442. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25443. switch name {
  25444. case token.FieldCreatedAt:
  25445. return m.OldCreatedAt(ctx)
  25446. case token.FieldUpdatedAt:
  25447. return m.OldUpdatedAt(ctx)
  25448. case token.FieldDeletedAt:
  25449. return m.OldDeletedAt(ctx)
  25450. case token.FieldExpireAt:
  25451. return m.OldExpireAt(ctx)
  25452. case token.FieldToken:
  25453. return m.OldToken(ctx)
  25454. case token.FieldMAC:
  25455. return m.OldMAC(ctx)
  25456. case token.FieldOrganizationID:
  25457. return m.OldOrganizationID(ctx)
  25458. case token.FieldAgentID:
  25459. return m.OldAgentID(ctx)
  25460. case token.FieldCustomAgentBase:
  25461. return m.OldCustomAgentBase(ctx)
  25462. case token.FieldCustomAgentKey:
  25463. return m.OldCustomAgentKey(ctx)
  25464. case token.FieldOpenaiBase:
  25465. return m.OldOpenaiBase(ctx)
  25466. case token.FieldOpenaiKey:
  25467. return m.OldOpenaiKey(ctx)
  25468. }
  25469. return nil, fmt.Errorf("unknown Token field %s", name)
  25470. }
  25471. // SetField sets the value of a field with the given name. It returns an error if
  25472. // the field is not defined in the schema, or if the type mismatched the field
  25473. // type.
  25474. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  25475. switch name {
  25476. case token.FieldCreatedAt:
  25477. v, ok := value.(time.Time)
  25478. if !ok {
  25479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25480. }
  25481. m.SetCreatedAt(v)
  25482. return nil
  25483. case token.FieldUpdatedAt:
  25484. v, ok := value.(time.Time)
  25485. if !ok {
  25486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25487. }
  25488. m.SetUpdatedAt(v)
  25489. return nil
  25490. case token.FieldDeletedAt:
  25491. v, ok := value.(time.Time)
  25492. if !ok {
  25493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25494. }
  25495. m.SetDeletedAt(v)
  25496. return nil
  25497. case token.FieldExpireAt:
  25498. v, ok := value.(time.Time)
  25499. if !ok {
  25500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25501. }
  25502. m.SetExpireAt(v)
  25503. return nil
  25504. case token.FieldToken:
  25505. v, ok := value.(string)
  25506. if !ok {
  25507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25508. }
  25509. m.SetToken(v)
  25510. return nil
  25511. case token.FieldMAC:
  25512. v, ok := value.(string)
  25513. if !ok {
  25514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25515. }
  25516. m.SetMAC(v)
  25517. return nil
  25518. case token.FieldOrganizationID:
  25519. v, ok := value.(uint64)
  25520. if !ok {
  25521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25522. }
  25523. m.SetOrganizationID(v)
  25524. return nil
  25525. case token.FieldAgentID:
  25526. v, ok := value.(uint64)
  25527. if !ok {
  25528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25529. }
  25530. m.SetAgentID(v)
  25531. return nil
  25532. case token.FieldCustomAgentBase:
  25533. v, ok := value.(string)
  25534. if !ok {
  25535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25536. }
  25537. m.SetCustomAgentBase(v)
  25538. return nil
  25539. case token.FieldCustomAgentKey:
  25540. v, ok := value.(string)
  25541. if !ok {
  25542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25543. }
  25544. m.SetCustomAgentKey(v)
  25545. return nil
  25546. case token.FieldOpenaiBase:
  25547. v, ok := value.(string)
  25548. if !ok {
  25549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25550. }
  25551. m.SetOpenaiBase(v)
  25552. return nil
  25553. case token.FieldOpenaiKey:
  25554. v, ok := value.(string)
  25555. if !ok {
  25556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25557. }
  25558. m.SetOpenaiKey(v)
  25559. return nil
  25560. }
  25561. return fmt.Errorf("unknown Token field %s", name)
  25562. }
  25563. // AddedFields returns all numeric fields that were incremented/decremented during
  25564. // this mutation.
  25565. func (m *TokenMutation) AddedFields() []string {
  25566. var fields []string
  25567. if m.addorganization_id != nil {
  25568. fields = append(fields, token.FieldOrganizationID)
  25569. }
  25570. return fields
  25571. }
  25572. // AddedField returns the numeric value that was incremented/decremented on a field
  25573. // with the given name. The second boolean return value indicates that this field
  25574. // was not set, or was not defined in the schema.
  25575. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  25576. switch name {
  25577. case token.FieldOrganizationID:
  25578. return m.AddedOrganizationID()
  25579. }
  25580. return nil, false
  25581. }
  25582. // AddField adds the value to the field with the given name. It returns an error if
  25583. // the field is not defined in the schema, or if the type mismatched the field
  25584. // type.
  25585. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  25586. switch name {
  25587. case token.FieldOrganizationID:
  25588. v, ok := value.(int64)
  25589. if !ok {
  25590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25591. }
  25592. m.AddOrganizationID(v)
  25593. return nil
  25594. }
  25595. return fmt.Errorf("unknown Token numeric field %s", name)
  25596. }
  25597. // ClearedFields returns all nullable fields that were cleared during this
  25598. // mutation.
  25599. func (m *TokenMutation) ClearedFields() []string {
  25600. var fields []string
  25601. if m.FieldCleared(token.FieldDeletedAt) {
  25602. fields = append(fields, token.FieldDeletedAt)
  25603. }
  25604. if m.FieldCleared(token.FieldExpireAt) {
  25605. fields = append(fields, token.FieldExpireAt)
  25606. }
  25607. if m.FieldCleared(token.FieldToken) {
  25608. fields = append(fields, token.FieldToken)
  25609. }
  25610. if m.FieldCleared(token.FieldMAC) {
  25611. fields = append(fields, token.FieldMAC)
  25612. }
  25613. if m.FieldCleared(token.FieldCustomAgentBase) {
  25614. fields = append(fields, token.FieldCustomAgentBase)
  25615. }
  25616. if m.FieldCleared(token.FieldCustomAgentKey) {
  25617. fields = append(fields, token.FieldCustomAgentKey)
  25618. }
  25619. if m.FieldCleared(token.FieldOpenaiBase) {
  25620. fields = append(fields, token.FieldOpenaiBase)
  25621. }
  25622. if m.FieldCleared(token.FieldOpenaiKey) {
  25623. fields = append(fields, token.FieldOpenaiKey)
  25624. }
  25625. return fields
  25626. }
  25627. // FieldCleared returns a boolean indicating if a field with the given name was
  25628. // cleared in this mutation.
  25629. func (m *TokenMutation) FieldCleared(name string) bool {
  25630. _, ok := m.clearedFields[name]
  25631. return ok
  25632. }
  25633. // ClearField clears the value of the field with the given name. It returns an
  25634. // error if the field is not defined in the schema.
  25635. func (m *TokenMutation) ClearField(name string) error {
  25636. switch name {
  25637. case token.FieldDeletedAt:
  25638. m.ClearDeletedAt()
  25639. return nil
  25640. case token.FieldExpireAt:
  25641. m.ClearExpireAt()
  25642. return nil
  25643. case token.FieldToken:
  25644. m.ClearToken()
  25645. return nil
  25646. case token.FieldMAC:
  25647. m.ClearMAC()
  25648. return nil
  25649. case token.FieldCustomAgentBase:
  25650. m.ClearCustomAgentBase()
  25651. return nil
  25652. case token.FieldCustomAgentKey:
  25653. m.ClearCustomAgentKey()
  25654. return nil
  25655. case token.FieldOpenaiBase:
  25656. m.ClearOpenaiBase()
  25657. return nil
  25658. case token.FieldOpenaiKey:
  25659. m.ClearOpenaiKey()
  25660. return nil
  25661. }
  25662. return fmt.Errorf("unknown Token nullable field %s", name)
  25663. }
  25664. // ResetField resets all changes in the mutation for the field with the given name.
  25665. // It returns an error if the field is not defined in the schema.
  25666. func (m *TokenMutation) ResetField(name string) error {
  25667. switch name {
  25668. case token.FieldCreatedAt:
  25669. m.ResetCreatedAt()
  25670. return nil
  25671. case token.FieldUpdatedAt:
  25672. m.ResetUpdatedAt()
  25673. return nil
  25674. case token.FieldDeletedAt:
  25675. m.ResetDeletedAt()
  25676. return nil
  25677. case token.FieldExpireAt:
  25678. m.ResetExpireAt()
  25679. return nil
  25680. case token.FieldToken:
  25681. m.ResetToken()
  25682. return nil
  25683. case token.FieldMAC:
  25684. m.ResetMAC()
  25685. return nil
  25686. case token.FieldOrganizationID:
  25687. m.ResetOrganizationID()
  25688. return nil
  25689. case token.FieldAgentID:
  25690. m.ResetAgentID()
  25691. return nil
  25692. case token.FieldCustomAgentBase:
  25693. m.ResetCustomAgentBase()
  25694. return nil
  25695. case token.FieldCustomAgentKey:
  25696. m.ResetCustomAgentKey()
  25697. return nil
  25698. case token.FieldOpenaiBase:
  25699. m.ResetOpenaiBase()
  25700. return nil
  25701. case token.FieldOpenaiKey:
  25702. m.ResetOpenaiKey()
  25703. return nil
  25704. }
  25705. return fmt.Errorf("unknown Token field %s", name)
  25706. }
  25707. // AddedEdges returns all edge names that were set/added in this mutation.
  25708. func (m *TokenMutation) AddedEdges() []string {
  25709. edges := make([]string, 0, 1)
  25710. if m.agent != nil {
  25711. edges = append(edges, token.EdgeAgent)
  25712. }
  25713. return edges
  25714. }
  25715. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25716. // name in this mutation.
  25717. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  25718. switch name {
  25719. case token.EdgeAgent:
  25720. if id := m.agent; id != nil {
  25721. return []ent.Value{*id}
  25722. }
  25723. }
  25724. return nil
  25725. }
  25726. // RemovedEdges returns all edge names that were removed in this mutation.
  25727. func (m *TokenMutation) RemovedEdges() []string {
  25728. edges := make([]string, 0, 1)
  25729. return edges
  25730. }
  25731. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25732. // the given name in this mutation.
  25733. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  25734. return nil
  25735. }
  25736. // ClearedEdges returns all edge names that were cleared in this mutation.
  25737. func (m *TokenMutation) ClearedEdges() []string {
  25738. edges := make([]string, 0, 1)
  25739. if m.clearedagent {
  25740. edges = append(edges, token.EdgeAgent)
  25741. }
  25742. return edges
  25743. }
  25744. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25745. // was cleared in this mutation.
  25746. func (m *TokenMutation) EdgeCleared(name string) bool {
  25747. switch name {
  25748. case token.EdgeAgent:
  25749. return m.clearedagent
  25750. }
  25751. return false
  25752. }
  25753. // ClearEdge clears the value of the edge with the given name. It returns an error
  25754. // if that edge is not defined in the schema.
  25755. func (m *TokenMutation) ClearEdge(name string) error {
  25756. switch name {
  25757. case token.EdgeAgent:
  25758. m.ClearAgent()
  25759. return nil
  25760. }
  25761. return fmt.Errorf("unknown Token unique edge %s", name)
  25762. }
  25763. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25764. // It returns an error if the edge is not defined in the schema.
  25765. func (m *TokenMutation) ResetEdge(name string) error {
  25766. switch name {
  25767. case token.EdgeAgent:
  25768. m.ResetAgent()
  25769. return nil
  25770. }
  25771. return fmt.Errorf("unknown Token edge %s", name)
  25772. }
  25773. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  25774. type TutorialMutation struct {
  25775. config
  25776. op Op
  25777. typ string
  25778. id *uint64
  25779. created_at *time.Time
  25780. updated_at *time.Time
  25781. deleted_at *time.Time
  25782. index *int
  25783. addindex *int
  25784. title *string
  25785. content *string
  25786. organization_id *uint64
  25787. addorganization_id *int64
  25788. clearedFields map[string]struct{}
  25789. employee *uint64
  25790. clearedemployee bool
  25791. done bool
  25792. oldValue func(context.Context) (*Tutorial, error)
  25793. predicates []predicate.Tutorial
  25794. }
  25795. var _ ent.Mutation = (*TutorialMutation)(nil)
  25796. // tutorialOption allows management of the mutation configuration using functional options.
  25797. type tutorialOption func(*TutorialMutation)
  25798. // newTutorialMutation creates new mutation for the Tutorial entity.
  25799. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  25800. m := &TutorialMutation{
  25801. config: c,
  25802. op: op,
  25803. typ: TypeTutorial,
  25804. clearedFields: make(map[string]struct{}),
  25805. }
  25806. for _, opt := range opts {
  25807. opt(m)
  25808. }
  25809. return m
  25810. }
  25811. // withTutorialID sets the ID field of the mutation.
  25812. func withTutorialID(id uint64) tutorialOption {
  25813. return func(m *TutorialMutation) {
  25814. var (
  25815. err error
  25816. once sync.Once
  25817. value *Tutorial
  25818. )
  25819. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  25820. once.Do(func() {
  25821. if m.done {
  25822. err = errors.New("querying old values post mutation is not allowed")
  25823. } else {
  25824. value, err = m.Client().Tutorial.Get(ctx, id)
  25825. }
  25826. })
  25827. return value, err
  25828. }
  25829. m.id = &id
  25830. }
  25831. }
  25832. // withTutorial sets the old Tutorial of the mutation.
  25833. func withTutorial(node *Tutorial) tutorialOption {
  25834. return func(m *TutorialMutation) {
  25835. m.oldValue = func(context.Context) (*Tutorial, error) {
  25836. return node, nil
  25837. }
  25838. m.id = &node.ID
  25839. }
  25840. }
  25841. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25842. // executed in a transaction (ent.Tx), a transactional client is returned.
  25843. func (m TutorialMutation) Client() *Client {
  25844. client := &Client{config: m.config}
  25845. client.init()
  25846. return client
  25847. }
  25848. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25849. // it returns an error otherwise.
  25850. func (m TutorialMutation) Tx() (*Tx, error) {
  25851. if _, ok := m.driver.(*txDriver); !ok {
  25852. return nil, errors.New("ent: mutation is not running in a transaction")
  25853. }
  25854. tx := &Tx{config: m.config}
  25855. tx.init()
  25856. return tx, nil
  25857. }
  25858. // SetID sets the value of the id field. Note that this
  25859. // operation is only accepted on creation of Tutorial entities.
  25860. func (m *TutorialMutation) SetID(id uint64) {
  25861. m.id = &id
  25862. }
  25863. // ID returns the ID value in the mutation. Note that the ID is only available
  25864. // if it was provided to the builder or after it was returned from the database.
  25865. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  25866. if m.id == nil {
  25867. return
  25868. }
  25869. return *m.id, true
  25870. }
  25871. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25872. // That means, if the mutation is applied within a transaction with an isolation level such
  25873. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25874. // or updated by the mutation.
  25875. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  25876. switch {
  25877. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25878. id, exists := m.ID()
  25879. if exists {
  25880. return []uint64{id}, nil
  25881. }
  25882. fallthrough
  25883. case m.op.Is(OpUpdate | OpDelete):
  25884. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  25885. default:
  25886. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25887. }
  25888. }
  25889. // SetCreatedAt sets the "created_at" field.
  25890. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  25891. m.created_at = &t
  25892. }
  25893. // CreatedAt returns the value of the "created_at" field in the mutation.
  25894. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  25895. v := m.created_at
  25896. if v == nil {
  25897. return
  25898. }
  25899. return *v, true
  25900. }
  25901. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  25902. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  25903. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25904. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25905. if !m.op.Is(OpUpdateOne) {
  25906. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25907. }
  25908. if m.id == nil || m.oldValue == nil {
  25909. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25910. }
  25911. oldValue, err := m.oldValue(ctx)
  25912. if err != nil {
  25913. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25914. }
  25915. return oldValue.CreatedAt, nil
  25916. }
  25917. // ResetCreatedAt resets all changes to the "created_at" field.
  25918. func (m *TutorialMutation) ResetCreatedAt() {
  25919. m.created_at = nil
  25920. }
  25921. // SetUpdatedAt sets the "updated_at" field.
  25922. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  25923. m.updated_at = &t
  25924. }
  25925. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25926. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  25927. v := m.updated_at
  25928. if v == nil {
  25929. return
  25930. }
  25931. return *v, true
  25932. }
  25933. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  25934. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  25935. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25936. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25937. if !m.op.Is(OpUpdateOne) {
  25938. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25939. }
  25940. if m.id == nil || m.oldValue == nil {
  25941. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25942. }
  25943. oldValue, err := m.oldValue(ctx)
  25944. if err != nil {
  25945. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25946. }
  25947. return oldValue.UpdatedAt, nil
  25948. }
  25949. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25950. func (m *TutorialMutation) ResetUpdatedAt() {
  25951. m.updated_at = nil
  25952. }
  25953. // SetDeletedAt sets the "deleted_at" field.
  25954. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  25955. m.deleted_at = &t
  25956. }
  25957. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25958. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  25959. v := m.deleted_at
  25960. if v == nil {
  25961. return
  25962. }
  25963. return *v, true
  25964. }
  25965. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  25966. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  25967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25968. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25969. if !m.op.Is(OpUpdateOne) {
  25970. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25971. }
  25972. if m.id == nil || m.oldValue == nil {
  25973. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25974. }
  25975. oldValue, err := m.oldValue(ctx)
  25976. if err != nil {
  25977. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25978. }
  25979. return oldValue.DeletedAt, nil
  25980. }
  25981. // ClearDeletedAt clears the value of the "deleted_at" field.
  25982. func (m *TutorialMutation) ClearDeletedAt() {
  25983. m.deleted_at = nil
  25984. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  25985. }
  25986. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25987. func (m *TutorialMutation) DeletedAtCleared() bool {
  25988. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  25989. return ok
  25990. }
  25991. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25992. func (m *TutorialMutation) ResetDeletedAt() {
  25993. m.deleted_at = nil
  25994. delete(m.clearedFields, tutorial.FieldDeletedAt)
  25995. }
  25996. // SetEmployeeID sets the "employee_id" field.
  25997. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  25998. m.employee = &u
  25999. }
  26000. // EmployeeID returns the value of the "employee_id" field in the mutation.
  26001. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  26002. v := m.employee
  26003. if v == nil {
  26004. return
  26005. }
  26006. return *v, true
  26007. }
  26008. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  26009. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26010. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26011. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  26012. if !m.op.Is(OpUpdateOne) {
  26013. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  26014. }
  26015. if m.id == nil || m.oldValue == nil {
  26016. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  26017. }
  26018. oldValue, err := m.oldValue(ctx)
  26019. if err != nil {
  26020. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  26021. }
  26022. return oldValue.EmployeeID, nil
  26023. }
  26024. // ResetEmployeeID resets all changes to the "employee_id" field.
  26025. func (m *TutorialMutation) ResetEmployeeID() {
  26026. m.employee = nil
  26027. }
  26028. // SetIndex sets the "index" field.
  26029. func (m *TutorialMutation) SetIndex(i int) {
  26030. m.index = &i
  26031. m.addindex = nil
  26032. }
  26033. // Index returns the value of the "index" field in the mutation.
  26034. func (m *TutorialMutation) Index() (r int, exists bool) {
  26035. v := m.index
  26036. if v == nil {
  26037. return
  26038. }
  26039. return *v, true
  26040. }
  26041. // OldIndex returns the old "index" field's value of the Tutorial entity.
  26042. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26044. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  26045. if !m.op.Is(OpUpdateOne) {
  26046. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  26047. }
  26048. if m.id == nil || m.oldValue == nil {
  26049. return v, errors.New("OldIndex requires an ID field in the mutation")
  26050. }
  26051. oldValue, err := m.oldValue(ctx)
  26052. if err != nil {
  26053. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  26054. }
  26055. return oldValue.Index, nil
  26056. }
  26057. // AddIndex adds i to the "index" field.
  26058. func (m *TutorialMutation) AddIndex(i int) {
  26059. if m.addindex != nil {
  26060. *m.addindex += i
  26061. } else {
  26062. m.addindex = &i
  26063. }
  26064. }
  26065. // AddedIndex returns the value that was added to the "index" field in this mutation.
  26066. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  26067. v := m.addindex
  26068. if v == nil {
  26069. return
  26070. }
  26071. return *v, true
  26072. }
  26073. // ResetIndex resets all changes to the "index" field.
  26074. func (m *TutorialMutation) ResetIndex() {
  26075. m.index = nil
  26076. m.addindex = nil
  26077. }
  26078. // SetTitle sets the "title" field.
  26079. func (m *TutorialMutation) SetTitle(s string) {
  26080. m.title = &s
  26081. }
  26082. // Title returns the value of the "title" field in the mutation.
  26083. func (m *TutorialMutation) Title() (r string, exists bool) {
  26084. v := m.title
  26085. if v == nil {
  26086. return
  26087. }
  26088. return *v, true
  26089. }
  26090. // OldTitle returns the old "title" field's value of the Tutorial entity.
  26091. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26093. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  26094. if !m.op.Is(OpUpdateOne) {
  26095. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  26096. }
  26097. if m.id == nil || m.oldValue == nil {
  26098. return v, errors.New("OldTitle requires an ID field in the mutation")
  26099. }
  26100. oldValue, err := m.oldValue(ctx)
  26101. if err != nil {
  26102. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  26103. }
  26104. return oldValue.Title, nil
  26105. }
  26106. // ResetTitle resets all changes to the "title" field.
  26107. func (m *TutorialMutation) ResetTitle() {
  26108. m.title = nil
  26109. }
  26110. // SetContent sets the "content" field.
  26111. func (m *TutorialMutation) SetContent(s string) {
  26112. m.content = &s
  26113. }
  26114. // Content returns the value of the "content" field in the mutation.
  26115. func (m *TutorialMutation) Content() (r string, exists bool) {
  26116. v := m.content
  26117. if v == nil {
  26118. return
  26119. }
  26120. return *v, true
  26121. }
  26122. // OldContent returns the old "content" field's value of the Tutorial entity.
  26123. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26125. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  26126. if !m.op.Is(OpUpdateOne) {
  26127. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  26128. }
  26129. if m.id == nil || m.oldValue == nil {
  26130. return v, errors.New("OldContent requires an ID field in the mutation")
  26131. }
  26132. oldValue, err := m.oldValue(ctx)
  26133. if err != nil {
  26134. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  26135. }
  26136. return oldValue.Content, nil
  26137. }
  26138. // ResetContent resets all changes to the "content" field.
  26139. func (m *TutorialMutation) ResetContent() {
  26140. m.content = nil
  26141. }
  26142. // SetOrganizationID sets the "organization_id" field.
  26143. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  26144. m.organization_id = &u
  26145. m.addorganization_id = nil
  26146. }
  26147. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26148. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  26149. v := m.organization_id
  26150. if v == nil {
  26151. return
  26152. }
  26153. return *v, true
  26154. }
  26155. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  26156. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26158. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26159. if !m.op.Is(OpUpdateOne) {
  26160. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26161. }
  26162. if m.id == nil || m.oldValue == nil {
  26163. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26164. }
  26165. oldValue, err := m.oldValue(ctx)
  26166. if err != nil {
  26167. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26168. }
  26169. return oldValue.OrganizationID, nil
  26170. }
  26171. // AddOrganizationID adds u to the "organization_id" field.
  26172. func (m *TutorialMutation) AddOrganizationID(u int64) {
  26173. if m.addorganization_id != nil {
  26174. *m.addorganization_id += u
  26175. } else {
  26176. m.addorganization_id = &u
  26177. }
  26178. }
  26179. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26180. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  26181. v := m.addorganization_id
  26182. if v == nil {
  26183. return
  26184. }
  26185. return *v, true
  26186. }
  26187. // ResetOrganizationID resets all changes to the "organization_id" field.
  26188. func (m *TutorialMutation) ResetOrganizationID() {
  26189. m.organization_id = nil
  26190. m.addorganization_id = nil
  26191. }
  26192. // ClearEmployee clears the "employee" edge to the Employee entity.
  26193. func (m *TutorialMutation) ClearEmployee() {
  26194. m.clearedemployee = true
  26195. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  26196. }
  26197. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  26198. func (m *TutorialMutation) EmployeeCleared() bool {
  26199. return m.clearedemployee
  26200. }
  26201. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  26202. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  26203. // EmployeeID instead. It exists only for internal usage by the builders.
  26204. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  26205. if id := m.employee; id != nil {
  26206. ids = append(ids, *id)
  26207. }
  26208. return
  26209. }
  26210. // ResetEmployee resets all changes to the "employee" edge.
  26211. func (m *TutorialMutation) ResetEmployee() {
  26212. m.employee = nil
  26213. m.clearedemployee = false
  26214. }
  26215. // Where appends a list predicates to the TutorialMutation builder.
  26216. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  26217. m.predicates = append(m.predicates, ps...)
  26218. }
  26219. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  26220. // users can use type-assertion to append predicates that do not depend on any generated package.
  26221. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  26222. p := make([]predicate.Tutorial, len(ps))
  26223. for i := range ps {
  26224. p[i] = ps[i]
  26225. }
  26226. m.Where(p...)
  26227. }
  26228. // Op returns the operation name.
  26229. func (m *TutorialMutation) Op() Op {
  26230. return m.op
  26231. }
  26232. // SetOp allows setting the mutation operation.
  26233. func (m *TutorialMutation) SetOp(op Op) {
  26234. m.op = op
  26235. }
  26236. // Type returns the node type of this mutation (Tutorial).
  26237. func (m *TutorialMutation) Type() string {
  26238. return m.typ
  26239. }
  26240. // Fields returns all fields that were changed during this mutation. Note that in
  26241. // order to get all numeric fields that were incremented/decremented, call
  26242. // AddedFields().
  26243. func (m *TutorialMutation) Fields() []string {
  26244. fields := make([]string, 0, 8)
  26245. if m.created_at != nil {
  26246. fields = append(fields, tutorial.FieldCreatedAt)
  26247. }
  26248. if m.updated_at != nil {
  26249. fields = append(fields, tutorial.FieldUpdatedAt)
  26250. }
  26251. if m.deleted_at != nil {
  26252. fields = append(fields, tutorial.FieldDeletedAt)
  26253. }
  26254. if m.employee != nil {
  26255. fields = append(fields, tutorial.FieldEmployeeID)
  26256. }
  26257. if m.index != nil {
  26258. fields = append(fields, tutorial.FieldIndex)
  26259. }
  26260. if m.title != nil {
  26261. fields = append(fields, tutorial.FieldTitle)
  26262. }
  26263. if m.content != nil {
  26264. fields = append(fields, tutorial.FieldContent)
  26265. }
  26266. if m.organization_id != nil {
  26267. fields = append(fields, tutorial.FieldOrganizationID)
  26268. }
  26269. return fields
  26270. }
  26271. // Field returns the value of a field with the given name. The second boolean
  26272. // return value indicates that this field was not set, or was not defined in the
  26273. // schema.
  26274. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  26275. switch name {
  26276. case tutorial.FieldCreatedAt:
  26277. return m.CreatedAt()
  26278. case tutorial.FieldUpdatedAt:
  26279. return m.UpdatedAt()
  26280. case tutorial.FieldDeletedAt:
  26281. return m.DeletedAt()
  26282. case tutorial.FieldEmployeeID:
  26283. return m.EmployeeID()
  26284. case tutorial.FieldIndex:
  26285. return m.Index()
  26286. case tutorial.FieldTitle:
  26287. return m.Title()
  26288. case tutorial.FieldContent:
  26289. return m.Content()
  26290. case tutorial.FieldOrganizationID:
  26291. return m.OrganizationID()
  26292. }
  26293. return nil, false
  26294. }
  26295. // OldField returns the old value of the field from the database. An error is
  26296. // returned if the mutation operation is not UpdateOne, or the query to the
  26297. // database failed.
  26298. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26299. switch name {
  26300. case tutorial.FieldCreatedAt:
  26301. return m.OldCreatedAt(ctx)
  26302. case tutorial.FieldUpdatedAt:
  26303. return m.OldUpdatedAt(ctx)
  26304. case tutorial.FieldDeletedAt:
  26305. return m.OldDeletedAt(ctx)
  26306. case tutorial.FieldEmployeeID:
  26307. return m.OldEmployeeID(ctx)
  26308. case tutorial.FieldIndex:
  26309. return m.OldIndex(ctx)
  26310. case tutorial.FieldTitle:
  26311. return m.OldTitle(ctx)
  26312. case tutorial.FieldContent:
  26313. return m.OldContent(ctx)
  26314. case tutorial.FieldOrganizationID:
  26315. return m.OldOrganizationID(ctx)
  26316. }
  26317. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  26318. }
  26319. // SetField sets the value of a field with the given name. It returns an error if
  26320. // the field is not defined in the schema, or if the type mismatched the field
  26321. // type.
  26322. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  26323. switch name {
  26324. case tutorial.FieldCreatedAt:
  26325. v, ok := value.(time.Time)
  26326. if !ok {
  26327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26328. }
  26329. m.SetCreatedAt(v)
  26330. return nil
  26331. case tutorial.FieldUpdatedAt:
  26332. v, ok := value.(time.Time)
  26333. if !ok {
  26334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26335. }
  26336. m.SetUpdatedAt(v)
  26337. return nil
  26338. case tutorial.FieldDeletedAt:
  26339. v, ok := value.(time.Time)
  26340. if !ok {
  26341. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26342. }
  26343. m.SetDeletedAt(v)
  26344. return nil
  26345. case tutorial.FieldEmployeeID:
  26346. v, ok := value.(uint64)
  26347. if !ok {
  26348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26349. }
  26350. m.SetEmployeeID(v)
  26351. return nil
  26352. case tutorial.FieldIndex:
  26353. v, ok := value.(int)
  26354. if !ok {
  26355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26356. }
  26357. m.SetIndex(v)
  26358. return nil
  26359. case tutorial.FieldTitle:
  26360. v, ok := value.(string)
  26361. if !ok {
  26362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26363. }
  26364. m.SetTitle(v)
  26365. return nil
  26366. case tutorial.FieldContent:
  26367. v, ok := value.(string)
  26368. if !ok {
  26369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26370. }
  26371. m.SetContent(v)
  26372. return nil
  26373. case tutorial.FieldOrganizationID:
  26374. v, ok := value.(uint64)
  26375. if !ok {
  26376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26377. }
  26378. m.SetOrganizationID(v)
  26379. return nil
  26380. }
  26381. return fmt.Errorf("unknown Tutorial field %s", name)
  26382. }
  26383. // AddedFields returns all numeric fields that were incremented/decremented during
  26384. // this mutation.
  26385. func (m *TutorialMutation) AddedFields() []string {
  26386. var fields []string
  26387. if m.addindex != nil {
  26388. fields = append(fields, tutorial.FieldIndex)
  26389. }
  26390. if m.addorganization_id != nil {
  26391. fields = append(fields, tutorial.FieldOrganizationID)
  26392. }
  26393. return fields
  26394. }
  26395. // AddedField returns the numeric value that was incremented/decremented on a field
  26396. // with the given name. The second boolean return value indicates that this field
  26397. // was not set, or was not defined in the schema.
  26398. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  26399. switch name {
  26400. case tutorial.FieldIndex:
  26401. return m.AddedIndex()
  26402. case tutorial.FieldOrganizationID:
  26403. return m.AddedOrganizationID()
  26404. }
  26405. return nil, false
  26406. }
  26407. // AddField adds the value to the field with the given name. It returns an error if
  26408. // the field is not defined in the schema, or if the type mismatched the field
  26409. // type.
  26410. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  26411. switch name {
  26412. case tutorial.FieldIndex:
  26413. v, ok := value.(int)
  26414. if !ok {
  26415. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26416. }
  26417. m.AddIndex(v)
  26418. return nil
  26419. case tutorial.FieldOrganizationID:
  26420. v, ok := value.(int64)
  26421. if !ok {
  26422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26423. }
  26424. m.AddOrganizationID(v)
  26425. return nil
  26426. }
  26427. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  26428. }
  26429. // ClearedFields returns all nullable fields that were cleared during this
  26430. // mutation.
  26431. func (m *TutorialMutation) ClearedFields() []string {
  26432. var fields []string
  26433. if m.FieldCleared(tutorial.FieldDeletedAt) {
  26434. fields = append(fields, tutorial.FieldDeletedAt)
  26435. }
  26436. return fields
  26437. }
  26438. // FieldCleared returns a boolean indicating if a field with the given name was
  26439. // cleared in this mutation.
  26440. func (m *TutorialMutation) FieldCleared(name string) bool {
  26441. _, ok := m.clearedFields[name]
  26442. return ok
  26443. }
  26444. // ClearField clears the value of the field with the given name. It returns an
  26445. // error if the field is not defined in the schema.
  26446. func (m *TutorialMutation) ClearField(name string) error {
  26447. switch name {
  26448. case tutorial.FieldDeletedAt:
  26449. m.ClearDeletedAt()
  26450. return nil
  26451. }
  26452. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  26453. }
  26454. // ResetField resets all changes in the mutation for the field with the given name.
  26455. // It returns an error if the field is not defined in the schema.
  26456. func (m *TutorialMutation) ResetField(name string) error {
  26457. switch name {
  26458. case tutorial.FieldCreatedAt:
  26459. m.ResetCreatedAt()
  26460. return nil
  26461. case tutorial.FieldUpdatedAt:
  26462. m.ResetUpdatedAt()
  26463. return nil
  26464. case tutorial.FieldDeletedAt:
  26465. m.ResetDeletedAt()
  26466. return nil
  26467. case tutorial.FieldEmployeeID:
  26468. m.ResetEmployeeID()
  26469. return nil
  26470. case tutorial.FieldIndex:
  26471. m.ResetIndex()
  26472. return nil
  26473. case tutorial.FieldTitle:
  26474. m.ResetTitle()
  26475. return nil
  26476. case tutorial.FieldContent:
  26477. m.ResetContent()
  26478. return nil
  26479. case tutorial.FieldOrganizationID:
  26480. m.ResetOrganizationID()
  26481. return nil
  26482. }
  26483. return fmt.Errorf("unknown Tutorial field %s", name)
  26484. }
  26485. // AddedEdges returns all edge names that were set/added in this mutation.
  26486. func (m *TutorialMutation) AddedEdges() []string {
  26487. edges := make([]string, 0, 1)
  26488. if m.employee != nil {
  26489. edges = append(edges, tutorial.EdgeEmployee)
  26490. }
  26491. return edges
  26492. }
  26493. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26494. // name in this mutation.
  26495. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  26496. switch name {
  26497. case tutorial.EdgeEmployee:
  26498. if id := m.employee; id != nil {
  26499. return []ent.Value{*id}
  26500. }
  26501. }
  26502. return nil
  26503. }
  26504. // RemovedEdges returns all edge names that were removed in this mutation.
  26505. func (m *TutorialMutation) RemovedEdges() []string {
  26506. edges := make([]string, 0, 1)
  26507. return edges
  26508. }
  26509. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26510. // the given name in this mutation.
  26511. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  26512. return nil
  26513. }
  26514. // ClearedEdges returns all edge names that were cleared in this mutation.
  26515. func (m *TutorialMutation) ClearedEdges() []string {
  26516. edges := make([]string, 0, 1)
  26517. if m.clearedemployee {
  26518. edges = append(edges, tutorial.EdgeEmployee)
  26519. }
  26520. return edges
  26521. }
  26522. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26523. // was cleared in this mutation.
  26524. func (m *TutorialMutation) EdgeCleared(name string) bool {
  26525. switch name {
  26526. case tutorial.EdgeEmployee:
  26527. return m.clearedemployee
  26528. }
  26529. return false
  26530. }
  26531. // ClearEdge clears the value of the edge with the given name. It returns an error
  26532. // if that edge is not defined in the schema.
  26533. func (m *TutorialMutation) ClearEdge(name string) error {
  26534. switch name {
  26535. case tutorial.EdgeEmployee:
  26536. m.ClearEmployee()
  26537. return nil
  26538. }
  26539. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  26540. }
  26541. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26542. // It returns an error if the edge is not defined in the schema.
  26543. func (m *TutorialMutation) ResetEdge(name string) error {
  26544. switch name {
  26545. case tutorial.EdgeEmployee:
  26546. m.ResetEmployee()
  26547. return nil
  26548. }
  26549. return fmt.Errorf("unknown Tutorial edge %s", name)
  26550. }
  26551. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  26552. type UsageDetailMutation struct {
  26553. config
  26554. op Op
  26555. typ string
  26556. id *uint64
  26557. created_at *time.Time
  26558. updated_at *time.Time
  26559. status *uint8
  26560. addstatus *int8
  26561. _type *int
  26562. add_type *int
  26563. bot_id *string
  26564. receiver_id *string
  26565. app *int
  26566. addapp *int
  26567. session_id *uint64
  26568. addsession_id *int64
  26569. request *string
  26570. response *string
  26571. original_data *custom_types.OriginalData
  26572. total_tokens *uint64
  26573. addtotal_tokens *int64
  26574. prompt_tokens *uint64
  26575. addprompt_tokens *int64
  26576. completion_tokens *uint64
  26577. addcompletion_tokens *int64
  26578. organization_id *uint64
  26579. addorganization_id *int64
  26580. clearedFields map[string]struct{}
  26581. done bool
  26582. oldValue func(context.Context) (*UsageDetail, error)
  26583. predicates []predicate.UsageDetail
  26584. }
  26585. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  26586. // usagedetailOption allows management of the mutation configuration using functional options.
  26587. type usagedetailOption func(*UsageDetailMutation)
  26588. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  26589. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  26590. m := &UsageDetailMutation{
  26591. config: c,
  26592. op: op,
  26593. typ: TypeUsageDetail,
  26594. clearedFields: make(map[string]struct{}),
  26595. }
  26596. for _, opt := range opts {
  26597. opt(m)
  26598. }
  26599. return m
  26600. }
  26601. // withUsageDetailID sets the ID field of the mutation.
  26602. func withUsageDetailID(id uint64) usagedetailOption {
  26603. return func(m *UsageDetailMutation) {
  26604. var (
  26605. err error
  26606. once sync.Once
  26607. value *UsageDetail
  26608. )
  26609. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  26610. once.Do(func() {
  26611. if m.done {
  26612. err = errors.New("querying old values post mutation is not allowed")
  26613. } else {
  26614. value, err = m.Client().UsageDetail.Get(ctx, id)
  26615. }
  26616. })
  26617. return value, err
  26618. }
  26619. m.id = &id
  26620. }
  26621. }
  26622. // withUsageDetail sets the old UsageDetail of the mutation.
  26623. func withUsageDetail(node *UsageDetail) usagedetailOption {
  26624. return func(m *UsageDetailMutation) {
  26625. m.oldValue = func(context.Context) (*UsageDetail, error) {
  26626. return node, nil
  26627. }
  26628. m.id = &node.ID
  26629. }
  26630. }
  26631. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26632. // executed in a transaction (ent.Tx), a transactional client is returned.
  26633. func (m UsageDetailMutation) Client() *Client {
  26634. client := &Client{config: m.config}
  26635. client.init()
  26636. return client
  26637. }
  26638. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26639. // it returns an error otherwise.
  26640. func (m UsageDetailMutation) Tx() (*Tx, error) {
  26641. if _, ok := m.driver.(*txDriver); !ok {
  26642. return nil, errors.New("ent: mutation is not running in a transaction")
  26643. }
  26644. tx := &Tx{config: m.config}
  26645. tx.init()
  26646. return tx, nil
  26647. }
  26648. // SetID sets the value of the id field. Note that this
  26649. // operation is only accepted on creation of UsageDetail entities.
  26650. func (m *UsageDetailMutation) SetID(id uint64) {
  26651. m.id = &id
  26652. }
  26653. // ID returns the ID value in the mutation. Note that the ID is only available
  26654. // if it was provided to the builder or after it was returned from the database.
  26655. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  26656. if m.id == nil {
  26657. return
  26658. }
  26659. return *m.id, true
  26660. }
  26661. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26662. // That means, if the mutation is applied within a transaction with an isolation level such
  26663. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26664. // or updated by the mutation.
  26665. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  26666. switch {
  26667. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26668. id, exists := m.ID()
  26669. if exists {
  26670. return []uint64{id}, nil
  26671. }
  26672. fallthrough
  26673. case m.op.Is(OpUpdate | OpDelete):
  26674. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  26675. default:
  26676. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26677. }
  26678. }
  26679. // SetCreatedAt sets the "created_at" field.
  26680. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  26681. m.created_at = &t
  26682. }
  26683. // CreatedAt returns the value of the "created_at" field in the mutation.
  26684. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  26685. v := m.created_at
  26686. if v == nil {
  26687. return
  26688. }
  26689. return *v, true
  26690. }
  26691. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  26692. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26693. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26694. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26695. if !m.op.Is(OpUpdateOne) {
  26696. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26697. }
  26698. if m.id == nil || m.oldValue == nil {
  26699. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26700. }
  26701. oldValue, err := m.oldValue(ctx)
  26702. if err != nil {
  26703. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26704. }
  26705. return oldValue.CreatedAt, nil
  26706. }
  26707. // ResetCreatedAt resets all changes to the "created_at" field.
  26708. func (m *UsageDetailMutation) ResetCreatedAt() {
  26709. m.created_at = nil
  26710. }
  26711. // SetUpdatedAt sets the "updated_at" field.
  26712. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  26713. m.updated_at = &t
  26714. }
  26715. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26716. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  26717. v := m.updated_at
  26718. if v == nil {
  26719. return
  26720. }
  26721. return *v, true
  26722. }
  26723. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  26724. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26725. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26726. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26727. if !m.op.Is(OpUpdateOne) {
  26728. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26729. }
  26730. if m.id == nil || m.oldValue == nil {
  26731. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26732. }
  26733. oldValue, err := m.oldValue(ctx)
  26734. if err != nil {
  26735. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26736. }
  26737. return oldValue.UpdatedAt, nil
  26738. }
  26739. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26740. func (m *UsageDetailMutation) ResetUpdatedAt() {
  26741. m.updated_at = nil
  26742. }
  26743. // SetStatus sets the "status" field.
  26744. func (m *UsageDetailMutation) SetStatus(u uint8) {
  26745. m.status = &u
  26746. m.addstatus = nil
  26747. }
  26748. // Status returns the value of the "status" field in the mutation.
  26749. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  26750. v := m.status
  26751. if v == nil {
  26752. return
  26753. }
  26754. return *v, true
  26755. }
  26756. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  26757. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26758. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26759. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26760. if !m.op.Is(OpUpdateOne) {
  26761. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26762. }
  26763. if m.id == nil || m.oldValue == nil {
  26764. return v, errors.New("OldStatus requires an ID field in the mutation")
  26765. }
  26766. oldValue, err := m.oldValue(ctx)
  26767. if err != nil {
  26768. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26769. }
  26770. return oldValue.Status, nil
  26771. }
  26772. // AddStatus adds u to the "status" field.
  26773. func (m *UsageDetailMutation) AddStatus(u int8) {
  26774. if m.addstatus != nil {
  26775. *m.addstatus += u
  26776. } else {
  26777. m.addstatus = &u
  26778. }
  26779. }
  26780. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26781. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  26782. v := m.addstatus
  26783. if v == nil {
  26784. return
  26785. }
  26786. return *v, true
  26787. }
  26788. // ClearStatus clears the value of the "status" field.
  26789. func (m *UsageDetailMutation) ClearStatus() {
  26790. m.status = nil
  26791. m.addstatus = nil
  26792. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  26793. }
  26794. // StatusCleared returns if the "status" field was cleared in this mutation.
  26795. func (m *UsageDetailMutation) StatusCleared() bool {
  26796. _, ok := m.clearedFields[usagedetail.FieldStatus]
  26797. return ok
  26798. }
  26799. // ResetStatus resets all changes to the "status" field.
  26800. func (m *UsageDetailMutation) ResetStatus() {
  26801. m.status = nil
  26802. m.addstatus = nil
  26803. delete(m.clearedFields, usagedetail.FieldStatus)
  26804. }
  26805. // SetType sets the "type" field.
  26806. func (m *UsageDetailMutation) SetType(i int) {
  26807. m._type = &i
  26808. m.add_type = nil
  26809. }
  26810. // GetType returns the value of the "type" field in the mutation.
  26811. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  26812. v := m._type
  26813. if v == nil {
  26814. return
  26815. }
  26816. return *v, true
  26817. }
  26818. // OldType returns the old "type" field's value of the UsageDetail entity.
  26819. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26821. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  26822. if !m.op.Is(OpUpdateOne) {
  26823. return v, errors.New("OldType is only allowed on UpdateOne operations")
  26824. }
  26825. if m.id == nil || m.oldValue == nil {
  26826. return v, errors.New("OldType requires an ID field in the mutation")
  26827. }
  26828. oldValue, err := m.oldValue(ctx)
  26829. if err != nil {
  26830. return v, fmt.Errorf("querying old value for OldType: %w", err)
  26831. }
  26832. return oldValue.Type, nil
  26833. }
  26834. // AddType adds i to the "type" field.
  26835. func (m *UsageDetailMutation) AddType(i int) {
  26836. if m.add_type != nil {
  26837. *m.add_type += i
  26838. } else {
  26839. m.add_type = &i
  26840. }
  26841. }
  26842. // AddedType returns the value that was added to the "type" field in this mutation.
  26843. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  26844. v := m.add_type
  26845. if v == nil {
  26846. return
  26847. }
  26848. return *v, true
  26849. }
  26850. // ClearType clears the value of the "type" field.
  26851. func (m *UsageDetailMutation) ClearType() {
  26852. m._type = nil
  26853. m.add_type = nil
  26854. m.clearedFields[usagedetail.FieldType] = struct{}{}
  26855. }
  26856. // TypeCleared returns if the "type" field was cleared in this mutation.
  26857. func (m *UsageDetailMutation) TypeCleared() bool {
  26858. _, ok := m.clearedFields[usagedetail.FieldType]
  26859. return ok
  26860. }
  26861. // ResetType resets all changes to the "type" field.
  26862. func (m *UsageDetailMutation) ResetType() {
  26863. m._type = nil
  26864. m.add_type = nil
  26865. delete(m.clearedFields, usagedetail.FieldType)
  26866. }
  26867. // SetBotID sets the "bot_id" field.
  26868. func (m *UsageDetailMutation) SetBotID(s string) {
  26869. m.bot_id = &s
  26870. }
  26871. // BotID returns the value of the "bot_id" field in the mutation.
  26872. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  26873. v := m.bot_id
  26874. if v == nil {
  26875. return
  26876. }
  26877. return *v, true
  26878. }
  26879. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  26880. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26881. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26882. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  26883. if !m.op.Is(OpUpdateOne) {
  26884. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  26885. }
  26886. if m.id == nil || m.oldValue == nil {
  26887. return v, errors.New("OldBotID requires an ID field in the mutation")
  26888. }
  26889. oldValue, err := m.oldValue(ctx)
  26890. if err != nil {
  26891. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  26892. }
  26893. return oldValue.BotID, nil
  26894. }
  26895. // ResetBotID resets all changes to the "bot_id" field.
  26896. func (m *UsageDetailMutation) ResetBotID() {
  26897. m.bot_id = nil
  26898. }
  26899. // SetReceiverID sets the "receiver_id" field.
  26900. func (m *UsageDetailMutation) SetReceiverID(s string) {
  26901. m.receiver_id = &s
  26902. }
  26903. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  26904. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  26905. v := m.receiver_id
  26906. if v == nil {
  26907. return
  26908. }
  26909. return *v, true
  26910. }
  26911. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  26912. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26914. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  26915. if !m.op.Is(OpUpdateOne) {
  26916. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  26917. }
  26918. if m.id == nil || m.oldValue == nil {
  26919. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  26920. }
  26921. oldValue, err := m.oldValue(ctx)
  26922. if err != nil {
  26923. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  26924. }
  26925. return oldValue.ReceiverID, nil
  26926. }
  26927. // ResetReceiverID resets all changes to the "receiver_id" field.
  26928. func (m *UsageDetailMutation) ResetReceiverID() {
  26929. m.receiver_id = nil
  26930. }
  26931. // SetApp sets the "app" field.
  26932. func (m *UsageDetailMutation) SetApp(i int) {
  26933. m.app = &i
  26934. m.addapp = nil
  26935. }
  26936. // App returns the value of the "app" field in the mutation.
  26937. func (m *UsageDetailMutation) App() (r int, exists bool) {
  26938. v := m.app
  26939. if v == nil {
  26940. return
  26941. }
  26942. return *v, true
  26943. }
  26944. // OldApp returns the old "app" field's value of the UsageDetail entity.
  26945. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26947. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  26948. if !m.op.Is(OpUpdateOne) {
  26949. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  26950. }
  26951. if m.id == nil || m.oldValue == nil {
  26952. return v, errors.New("OldApp requires an ID field in the mutation")
  26953. }
  26954. oldValue, err := m.oldValue(ctx)
  26955. if err != nil {
  26956. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  26957. }
  26958. return oldValue.App, nil
  26959. }
  26960. // AddApp adds i to the "app" field.
  26961. func (m *UsageDetailMutation) AddApp(i int) {
  26962. if m.addapp != nil {
  26963. *m.addapp += i
  26964. } else {
  26965. m.addapp = &i
  26966. }
  26967. }
  26968. // AddedApp returns the value that was added to the "app" field in this mutation.
  26969. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  26970. v := m.addapp
  26971. if v == nil {
  26972. return
  26973. }
  26974. return *v, true
  26975. }
  26976. // ClearApp clears the value of the "app" field.
  26977. func (m *UsageDetailMutation) ClearApp() {
  26978. m.app = nil
  26979. m.addapp = nil
  26980. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  26981. }
  26982. // AppCleared returns if the "app" field was cleared in this mutation.
  26983. func (m *UsageDetailMutation) AppCleared() bool {
  26984. _, ok := m.clearedFields[usagedetail.FieldApp]
  26985. return ok
  26986. }
  26987. // ResetApp resets all changes to the "app" field.
  26988. func (m *UsageDetailMutation) ResetApp() {
  26989. m.app = nil
  26990. m.addapp = nil
  26991. delete(m.clearedFields, usagedetail.FieldApp)
  26992. }
  26993. // SetSessionID sets the "session_id" field.
  26994. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  26995. m.session_id = &u
  26996. m.addsession_id = nil
  26997. }
  26998. // SessionID returns the value of the "session_id" field in the mutation.
  26999. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  27000. v := m.session_id
  27001. if v == nil {
  27002. return
  27003. }
  27004. return *v, true
  27005. }
  27006. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  27007. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27009. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  27010. if !m.op.Is(OpUpdateOne) {
  27011. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  27012. }
  27013. if m.id == nil || m.oldValue == nil {
  27014. return v, errors.New("OldSessionID requires an ID field in the mutation")
  27015. }
  27016. oldValue, err := m.oldValue(ctx)
  27017. if err != nil {
  27018. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  27019. }
  27020. return oldValue.SessionID, nil
  27021. }
  27022. // AddSessionID adds u to the "session_id" field.
  27023. func (m *UsageDetailMutation) AddSessionID(u int64) {
  27024. if m.addsession_id != nil {
  27025. *m.addsession_id += u
  27026. } else {
  27027. m.addsession_id = &u
  27028. }
  27029. }
  27030. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  27031. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  27032. v := m.addsession_id
  27033. if v == nil {
  27034. return
  27035. }
  27036. return *v, true
  27037. }
  27038. // ClearSessionID clears the value of the "session_id" field.
  27039. func (m *UsageDetailMutation) ClearSessionID() {
  27040. m.session_id = nil
  27041. m.addsession_id = nil
  27042. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  27043. }
  27044. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  27045. func (m *UsageDetailMutation) SessionIDCleared() bool {
  27046. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  27047. return ok
  27048. }
  27049. // ResetSessionID resets all changes to the "session_id" field.
  27050. func (m *UsageDetailMutation) ResetSessionID() {
  27051. m.session_id = nil
  27052. m.addsession_id = nil
  27053. delete(m.clearedFields, usagedetail.FieldSessionID)
  27054. }
  27055. // SetRequest sets the "request" field.
  27056. func (m *UsageDetailMutation) SetRequest(s string) {
  27057. m.request = &s
  27058. }
  27059. // Request returns the value of the "request" field in the mutation.
  27060. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  27061. v := m.request
  27062. if v == nil {
  27063. return
  27064. }
  27065. return *v, true
  27066. }
  27067. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  27068. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27069. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27070. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  27071. if !m.op.Is(OpUpdateOne) {
  27072. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  27073. }
  27074. if m.id == nil || m.oldValue == nil {
  27075. return v, errors.New("OldRequest requires an ID field in the mutation")
  27076. }
  27077. oldValue, err := m.oldValue(ctx)
  27078. if err != nil {
  27079. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  27080. }
  27081. return oldValue.Request, nil
  27082. }
  27083. // ResetRequest resets all changes to the "request" field.
  27084. func (m *UsageDetailMutation) ResetRequest() {
  27085. m.request = nil
  27086. }
  27087. // SetResponse sets the "response" field.
  27088. func (m *UsageDetailMutation) SetResponse(s string) {
  27089. m.response = &s
  27090. }
  27091. // Response returns the value of the "response" field in the mutation.
  27092. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  27093. v := m.response
  27094. if v == nil {
  27095. return
  27096. }
  27097. return *v, true
  27098. }
  27099. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  27100. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27102. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  27103. if !m.op.Is(OpUpdateOne) {
  27104. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  27105. }
  27106. if m.id == nil || m.oldValue == nil {
  27107. return v, errors.New("OldResponse requires an ID field in the mutation")
  27108. }
  27109. oldValue, err := m.oldValue(ctx)
  27110. if err != nil {
  27111. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  27112. }
  27113. return oldValue.Response, nil
  27114. }
  27115. // ResetResponse resets all changes to the "response" field.
  27116. func (m *UsageDetailMutation) ResetResponse() {
  27117. m.response = nil
  27118. }
  27119. // SetOriginalData sets the "original_data" field.
  27120. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  27121. m.original_data = &ctd
  27122. }
  27123. // OriginalData returns the value of the "original_data" field in the mutation.
  27124. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  27125. v := m.original_data
  27126. if v == nil {
  27127. return
  27128. }
  27129. return *v, true
  27130. }
  27131. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  27132. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27134. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  27135. if !m.op.Is(OpUpdateOne) {
  27136. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  27137. }
  27138. if m.id == nil || m.oldValue == nil {
  27139. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  27140. }
  27141. oldValue, err := m.oldValue(ctx)
  27142. if err != nil {
  27143. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  27144. }
  27145. return oldValue.OriginalData, nil
  27146. }
  27147. // ResetOriginalData resets all changes to the "original_data" field.
  27148. func (m *UsageDetailMutation) ResetOriginalData() {
  27149. m.original_data = nil
  27150. }
  27151. // SetTotalTokens sets the "total_tokens" field.
  27152. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  27153. m.total_tokens = &u
  27154. m.addtotal_tokens = nil
  27155. }
  27156. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  27157. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  27158. v := m.total_tokens
  27159. if v == nil {
  27160. return
  27161. }
  27162. return *v, true
  27163. }
  27164. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  27165. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27167. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  27168. if !m.op.Is(OpUpdateOne) {
  27169. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  27170. }
  27171. if m.id == nil || m.oldValue == nil {
  27172. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  27173. }
  27174. oldValue, err := m.oldValue(ctx)
  27175. if err != nil {
  27176. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  27177. }
  27178. return oldValue.TotalTokens, nil
  27179. }
  27180. // AddTotalTokens adds u to the "total_tokens" field.
  27181. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  27182. if m.addtotal_tokens != nil {
  27183. *m.addtotal_tokens += u
  27184. } else {
  27185. m.addtotal_tokens = &u
  27186. }
  27187. }
  27188. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  27189. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  27190. v := m.addtotal_tokens
  27191. if v == nil {
  27192. return
  27193. }
  27194. return *v, true
  27195. }
  27196. // ClearTotalTokens clears the value of the "total_tokens" field.
  27197. func (m *UsageDetailMutation) ClearTotalTokens() {
  27198. m.total_tokens = nil
  27199. m.addtotal_tokens = nil
  27200. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  27201. }
  27202. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  27203. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  27204. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  27205. return ok
  27206. }
  27207. // ResetTotalTokens resets all changes to the "total_tokens" field.
  27208. func (m *UsageDetailMutation) ResetTotalTokens() {
  27209. m.total_tokens = nil
  27210. m.addtotal_tokens = nil
  27211. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  27212. }
  27213. // SetPromptTokens sets the "prompt_tokens" field.
  27214. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  27215. m.prompt_tokens = &u
  27216. m.addprompt_tokens = nil
  27217. }
  27218. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  27219. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  27220. v := m.prompt_tokens
  27221. if v == nil {
  27222. return
  27223. }
  27224. return *v, true
  27225. }
  27226. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  27227. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27228. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27229. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  27230. if !m.op.Is(OpUpdateOne) {
  27231. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  27232. }
  27233. if m.id == nil || m.oldValue == nil {
  27234. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  27235. }
  27236. oldValue, err := m.oldValue(ctx)
  27237. if err != nil {
  27238. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  27239. }
  27240. return oldValue.PromptTokens, nil
  27241. }
  27242. // AddPromptTokens adds u to the "prompt_tokens" field.
  27243. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  27244. if m.addprompt_tokens != nil {
  27245. *m.addprompt_tokens += u
  27246. } else {
  27247. m.addprompt_tokens = &u
  27248. }
  27249. }
  27250. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  27251. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  27252. v := m.addprompt_tokens
  27253. if v == nil {
  27254. return
  27255. }
  27256. return *v, true
  27257. }
  27258. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  27259. func (m *UsageDetailMutation) ClearPromptTokens() {
  27260. m.prompt_tokens = nil
  27261. m.addprompt_tokens = nil
  27262. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  27263. }
  27264. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  27265. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  27266. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  27267. return ok
  27268. }
  27269. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  27270. func (m *UsageDetailMutation) ResetPromptTokens() {
  27271. m.prompt_tokens = nil
  27272. m.addprompt_tokens = nil
  27273. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  27274. }
  27275. // SetCompletionTokens sets the "completion_tokens" field.
  27276. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  27277. m.completion_tokens = &u
  27278. m.addcompletion_tokens = nil
  27279. }
  27280. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  27281. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  27282. v := m.completion_tokens
  27283. if v == nil {
  27284. return
  27285. }
  27286. return *v, true
  27287. }
  27288. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  27289. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27291. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  27292. if !m.op.Is(OpUpdateOne) {
  27293. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  27294. }
  27295. if m.id == nil || m.oldValue == nil {
  27296. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  27297. }
  27298. oldValue, err := m.oldValue(ctx)
  27299. if err != nil {
  27300. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  27301. }
  27302. return oldValue.CompletionTokens, nil
  27303. }
  27304. // AddCompletionTokens adds u to the "completion_tokens" field.
  27305. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  27306. if m.addcompletion_tokens != nil {
  27307. *m.addcompletion_tokens += u
  27308. } else {
  27309. m.addcompletion_tokens = &u
  27310. }
  27311. }
  27312. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  27313. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  27314. v := m.addcompletion_tokens
  27315. if v == nil {
  27316. return
  27317. }
  27318. return *v, true
  27319. }
  27320. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  27321. func (m *UsageDetailMutation) ClearCompletionTokens() {
  27322. m.completion_tokens = nil
  27323. m.addcompletion_tokens = nil
  27324. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  27325. }
  27326. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  27327. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  27328. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  27329. return ok
  27330. }
  27331. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  27332. func (m *UsageDetailMutation) ResetCompletionTokens() {
  27333. m.completion_tokens = nil
  27334. m.addcompletion_tokens = nil
  27335. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  27336. }
  27337. // SetOrganizationID sets the "organization_id" field.
  27338. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  27339. m.organization_id = &u
  27340. m.addorganization_id = nil
  27341. }
  27342. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27343. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  27344. v := m.organization_id
  27345. if v == nil {
  27346. return
  27347. }
  27348. return *v, true
  27349. }
  27350. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  27351. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27353. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27354. if !m.op.Is(OpUpdateOne) {
  27355. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27356. }
  27357. if m.id == nil || m.oldValue == nil {
  27358. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27359. }
  27360. oldValue, err := m.oldValue(ctx)
  27361. if err != nil {
  27362. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27363. }
  27364. return oldValue.OrganizationID, nil
  27365. }
  27366. // AddOrganizationID adds u to the "organization_id" field.
  27367. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  27368. if m.addorganization_id != nil {
  27369. *m.addorganization_id += u
  27370. } else {
  27371. m.addorganization_id = &u
  27372. }
  27373. }
  27374. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27375. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  27376. v := m.addorganization_id
  27377. if v == nil {
  27378. return
  27379. }
  27380. return *v, true
  27381. }
  27382. // ClearOrganizationID clears the value of the "organization_id" field.
  27383. func (m *UsageDetailMutation) ClearOrganizationID() {
  27384. m.organization_id = nil
  27385. m.addorganization_id = nil
  27386. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  27387. }
  27388. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  27389. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  27390. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  27391. return ok
  27392. }
  27393. // ResetOrganizationID resets all changes to the "organization_id" field.
  27394. func (m *UsageDetailMutation) ResetOrganizationID() {
  27395. m.organization_id = nil
  27396. m.addorganization_id = nil
  27397. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  27398. }
  27399. // Where appends a list predicates to the UsageDetailMutation builder.
  27400. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  27401. m.predicates = append(m.predicates, ps...)
  27402. }
  27403. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  27404. // users can use type-assertion to append predicates that do not depend on any generated package.
  27405. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  27406. p := make([]predicate.UsageDetail, len(ps))
  27407. for i := range ps {
  27408. p[i] = ps[i]
  27409. }
  27410. m.Where(p...)
  27411. }
  27412. // Op returns the operation name.
  27413. func (m *UsageDetailMutation) Op() Op {
  27414. return m.op
  27415. }
  27416. // SetOp allows setting the mutation operation.
  27417. func (m *UsageDetailMutation) SetOp(op Op) {
  27418. m.op = op
  27419. }
  27420. // Type returns the node type of this mutation (UsageDetail).
  27421. func (m *UsageDetailMutation) Type() string {
  27422. return m.typ
  27423. }
  27424. // Fields returns all fields that were changed during this mutation. Note that in
  27425. // order to get all numeric fields that were incremented/decremented, call
  27426. // AddedFields().
  27427. func (m *UsageDetailMutation) Fields() []string {
  27428. fields := make([]string, 0, 15)
  27429. if m.created_at != nil {
  27430. fields = append(fields, usagedetail.FieldCreatedAt)
  27431. }
  27432. if m.updated_at != nil {
  27433. fields = append(fields, usagedetail.FieldUpdatedAt)
  27434. }
  27435. if m.status != nil {
  27436. fields = append(fields, usagedetail.FieldStatus)
  27437. }
  27438. if m._type != nil {
  27439. fields = append(fields, usagedetail.FieldType)
  27440. }
  27441. if m.bot_id != nil {
  27442. fields = append(fields, usagedetail.FieldBotID)
  27443. }
  27444. if m.receiver_id != nil {
  27445. fields = append(fields, usagedetail.FieldReceiverID)
  27446. }
  27447. if m.app != nil {
  27448. fields = append(fields, usagedetail.FieldApp)
  27449. }
  27450. if m.session_id != nil {
  27451. fields = append(fields, usagedetail.FieldSessionID)
  27452. }
  27453. if m.request != nil {
  27454. fields = append(fields, usagedetail.FieldRequest)
  27455. }
  27456. if m.response != nil {
  27457. fields = append(fields, usagedetail.FieldResponse)
  27458. }
  27459. if m.original_data != nil {
  27460. fields = append(fields, usagedetail.FieldOriginalData)
  27461. }
  27462. if m.total_tokens != nil {
  27463. fields = append(fields, usagedetail.FieldTotalTokens)
  27464. }
  27465. if m.prompt_tokens != nil {
  27466. fields = append(fields, usagedetail.FieldPromptTokens)
  27467. }
  27468. if m.completion_tokens != nil {
  27469. fields = append(fields, usagedetail.FieldCompletionTokens)
  27470. }
  27471. if m.organization_id != nil {
  27472. fields = append(fields, usagedetail.FieldOrganizationID)
  27473. }
  27474. return fields
  27475. }
  27476. // Field returns the value of a field with the given name. The second boolean
  27477. // return value indicates that this field was not set, or was not defined in the
  27478. // schema.
  27479. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  27480. switch name {
  27481. case usagedetail.FieldCreatedAt:
  27482. return m.CreatedAt()
  27483. case usagedetail.FieldUpdatedAt:
  27484. return m.UpdatedAt()
  27485. case usagedetail.FieldStatus:
  27486. return m.Status()
  27487. case usagedetail.FieldType:
  27488. return m.GetType()
  27489. case usagedetail.FieldBotID:
  27490. return m.BotID()
  27491. case usagedetail.FieldReceiverID:
  27492. return m.ReceiverID()
  27493. case usagedetail.FieldApp:
  27494. return m.App()
  27495. case usagedetail.FieldSessionID:
  27496. return m.SessionID()
  27497. case usagedetail.FieldRequest:
  27498. return m.Request()
  27499. case usagedetail.FieldResponse:
  27500. return m.Response()
  27501. case usagedetail.FieldOriginalData:
  27502. return m.OriginalData()
  27503. case usagedetail.FieldTotalTokens:
  27504. return m.TotalTokens()
  27505. case usagedetail.FieldPromptTokens:
  27506. return m.PromptTokens()
  27507. case usagedetail.FieldCompletionTokens:
  27508. return m.CompletionTokens()
  27509. case usagedetail.FieldOrganizationID:
  27510. return m.OrganizationID()
  27511. }
  27512. return nil, false
  27513. }
  27514. // OldField returns the old value of the field from the database. An error is
  27515. // returned if the mutation operation is not UpdateOne, or the query to the
  27516. // database failed.
  27517. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27518. switch name {
  27519. case usagedetail.FieldCreatedAt:
  27520. return m.OldCreatedAt(ctx)
  27521. case usagedetail.FieldUpdatedAt:
  27522. return m.OldUpdatedAt(ctx)
  27523. case usagedetail.FieldStatus:
  27524. return m.OldStatus(ctx)
  27525. case usagedetail.FieldType:
  27526. return m.OldType(ctx)
  27527. case usagedetail.FieldBotID:
  27528. return m.OldBotID(ctx)
  27529. case usagedetail.FieldReceiverID:
  27530. return m.OldReceiverID(ctx)
  27531. case usagedetail.FieldApp:
  27532. return m.OldApp(ctx)
  27533. case usagedetail.FieldSessionID:
  27534. return m.OldSessionID(ctx)
  27535. case usagedetail.FieldRequest:
  27536. return m.OldRequest(ctx)
  27537. case usagedetail.FieldResponse:
  27538. return m.OldResponse(ctx)
  27539. case usagedetail.FieldOriginalData:
  27540. return m.OldOriginalData(ctx)
  27541. case usagedetail.FieldTotalTokens:
  27542. return m.OldTotalTokens(ctx)
  27543. case usagedetail.FieldPromptTokens:
  27544. return m.OldPromptTokens(ctx)
  27545. case usagedetail.FieldCompletionTokens:
  27546. return m.OldCompletionTokens(ctx)
  27547. case usagedetail.FieldOrganizationID:
  27548. return m.OldOrganizationID(ctx)
  27549. }
  27550. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  27551. }
  27552. // SetField sets the value of a field with the given name. It returns an error if
  27553. // the field is not defined in the schema, or if the type mismatched the field
  27554. // type.
  27555. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  27556. switch name {
  27557. case usagedetail.FieldCreatedAt:
  27558. v, ok := value.(time.Time)
  27559. if !ok {
  27560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27561. }
  27562. m.SetCreatedAt(v)
  27563. return nil
  27564. case usagedetail.FieldUpdatedAt:
  27565. v, ok := value.(time.Time)
  27566. if !ok {
  27567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27568. }
  27569. m.SetUpdatedAt(v)
  27570. return nil
  27571. case usagedetail.FieldStatus:
  27572. v, ok := value.(uint8)
  27573. if !ok {
  27574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27575. }
  27576. m.SetStatus(v)
  27577. return nil
  27578. case usagedetail.FieldType:
  27579. v, ok := value.(int)
  27580. if !ok {
  27581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27582. }
  27583. m.SetType(v)
  27584. return nil
  27585. case usagedetail.FieldBotID:
  27586. v, ok := value.(string)
  27587. if !ok {
  27588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27589. }
  27590. m.SetBotID(v)
  27591. return nil
  27592. case usagedetail.FieldReceiverID:
  27593. v, ok := value.(string)
  27594. if !ok {
  27595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27596. }
  27597. m.SetReceiverID(v)
  27598. return nil
  27599. case usagedetail.FieldApp:
  27600. v, ok := value.(int)
  27601. if !ok {
  27602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27603. }
  27604. m.SetApp(v)
  27605. return nil
  27606. case usagedetail.FieldSessionID:
  27607. v, ok := value.(uint64)
  27608. if !ok {
  27609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27610. }
  27611. m.SetSessionID(v)
  27612. return nil
  27613. case usagedetail.FieldRequest:
  27614. v, ok := value.(string)
  27615. if !ok {
  27616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27617. }
  27618. m.SetRequest(v)
  27619. return nil
  27620. case usagedetail.FieldResponse:
  27621. v, ok := value.(string)
  27622. if !ok {
  27623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27624. }
  27625. m.SetResponse(v)
  27626. return nil
  27627. case usagedetail.FieldOriginalData:
  27628. v, ok := value.(custom_types.OriginalData)
  27629. if !ok {
  27630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27631. }
  27632. m.SetOriginalData(v)
  27633. return nil
  27634. case usagedetail.FieldTotalTokens:
  27635. v, ok := value.(uint64)
  27636. if !ok {
  27637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27638. }
  27639. m.SetTotalTokens(v)
  27640. return nil
  27641. case usagedetail.FieldPromptTokens:
  27642. v, ok := value.(uint64)
  27643. if !ok {
  27644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27645. }
  27646. m.SetPromptTokens(v)
  27647. return nil
  27648. case usagedetail.FieldCompletionTokens:
  27649. v, ok := value.(uint64)
  27650. if !ok {
  27651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27652. }
  27653. m.SetCompletionTokens(v)
  27654. return nil
  27655. case usagedetail.FieldOrganizationID:
  27656. v, ok := value.(uint64)
  27657. if !ok {
  27658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27659. }
  27660. m.SetOrganizationID(v)
  27661. return nil
  27662. }
  27663. return fmt.Errorf("unknown UsageDetail field %s", name)
  27664. }
  27665. // AddedFields returns all numeric fields that were incremented/decremented during
  27666. // this mutation.
  27667. func (m *UsageDetailMutation) AddedFields() []string {
  27668. var fields []string
  27669. if m.addstatus != nil {
  27670. fields = append(fields, usagedetail.FieldStatus)
  27671. }
  27672. if m.add_type != nil {
  27673. fields = append(fields, usagedetail.FieldType)
  27674. }
  27675. if m.addapp != nil {
  27676. fields = append(fields, usagedetail.FieldApp)
  27677. }
  27678. if m.addsession_id != nil {
  27679. fields = append(fields, usagedetail.FieldSessionID)
  27680. }
  27681. if m.addtotal_tokens != nil {
  27682. fields = append(fields, usagedetail.FieldTotalTokens)
  27683. }
  27684. if m.addprompt_tokens != nil {
  27685. fields = append(fields, usagedetail.FieldPromptTokens)
  27686. }
  27687. if m.addcompletion_tokens != nil {
  27688. fields = append(fields, usagedetail.FieldCompletionTokens)
  27689. }
  27690. if m.addorganization_id != nil {
  27691. fields = append(fields, usagedetail.FieldOrganizationID)
  27692. }
  27693. return fields
  27694. }
  27695. // AddedField returns the numeric value that was incremented/decremented on a field
  27696. // with the given name. The second boolean return value indicates that this field
  27697. // was not set, or was not defined in the schema.
  27698. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  27699. switch name {
  27700. case usagedetail.FieldStatus:
  27701. return m.AddedStatus()
  27702. case usagedetail.FieldType:
  27703. return m.AddedType()
  27704. case usagedetail.FieldApp:
  27705. return m.AddedApp()
  27706. case usagedetail.FieldSessionID:
  27707. return m.AddedSessionID()
  27708. case usagedetail.FieldTotalTokens:
  27709. return m.AddedTotalTokens()
  27710. case usagedetail.FieldPromptTokens:
  27711. return m.AddedPromptTokens()
  27712. case usagedetail.FieldCompletionTokens:
  27713. return m.AddedCompletionTokens()
  27714. case usagedetail.FieldOrganizationID:
  27715. return m.AddedOrganizationID()
  27716. }
  27717. return nil, false
  27718. }
  27719. // AddField adds the value to the field with the given name. It returns an error if
  27720. // the field is not defined in the schema, or if the type mismatched the field
  27721. // type.
  27722. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  27723. switch name {
  27724. case usagedetail.FieldStatus:
  27725. v, ok := value.(int8)
  27726. if !ok {
  27727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27728. }
  27729. m.AddStatus(v)
  27730. return nil
  27731. case usagedetail.FieldType:
  27732. v, ok := value.(int)
  27733. if !ok {
  27734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27735. }
  27736. m.AddType(v)
  27737. return nil
  27738. case usagedetail.FieldApp:
  27739. v, ok := value.(int)
  27740. if !ok {
  27741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27742. }
  27743. m.AddApp(v)
  27744. return nil
  27745. case usagedetail.FieldSessionID:
  27746. v, ok := value.(int64)
  27747. if !ok {
  27748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27749. }
  27750. m.AddSessionID(v)
  27751. return nil
  27752. case usagedetail.FieldTotalTokens:
  27753. v, ok := value.(int64)
  27754. if !ok {
  27755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27756. }
  27757. m.AddTotalTokens(v)
  27758. return nil
  27759. case usagedetail.FieldPromptTokens:
  27760. v, ok := value.(int64)
  27761. if !ok {
  27762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27763. }
  27764. m.AddPromptTokens(v)
  27765. return nil
  27766. case usagedetail.FieldCompletionTokens:
  27767. v, ok := value.(int64)
  27768. if !ok {
  27769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27770. }
  27771. m.AddCompletionTokens(v)
  27772. return nil
  27773. case usagedetail.FieldOrganizationID:
  27774. v, ok := value.(int64)
  27775. if !ok {
  27776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27777. }
  27778. m.AddOrganizationID(v)
  27779. return nil
  27780. }
  27781. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  27782. }
  27783. // ClearedFields returns all nullable fields that were cleared during this
  27784. // mutation.
  27785. func (m *UsageDetailMutation) ClearedFields() []string {
  27786. var fields []string
  27787. if m.FieldCleared(usagedetail.FieldStatus) {
  27788. fields = append(fields, usagedetail.FieldStatus)
  27789. }
  27790. if m.FieldCleared(usagedetail.FieldType) {
  27791. fields = append(fields, usagedetail.FieldType)
  27792. }
  27793. if m.FieldCleared(usagedetail.FieldApp) {
  27794. fields = append(fields, usagedetail.FieldApp)
  27795. }
  27796. if m.FieldCleared(usagedetail.FieldSessionID) {
  27797. fields = append(fields, usagedetail.FieldSessionID)
  27798. }
  27799. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  27800. fields = append(fields, usagedetail.FieldTotalTokens)
  27801. }
  27802. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  27803. fields = append(fields, usagedetail.FieldPromptTokens)
  27804. }
  27805. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  27806. fields = append(fields, usagedetail.FieldCompletionTokens)
  27807. }
  27808. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  27809. fields = append(fields, usagedetail.FieldOrganizationID)
  27810. }
  27811. return fields
  27812. }
  27813. // FieldCleared returns a boolean indicating if a field with the given name was
  27814. // cleared in this mutation.
  27815. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  27816. _, ok := m.clearedFields[name]
  27817. return ok
  27818. }
  27819. // ClearField clears the value of the field with the given name. It returns an
  27820. // error if the field is not defined in the schema.
  27821. func (m *UsageDetailMutation) ClearField(name string) error {
  27822. switch name {
  27823. case usagedetail.FieldStatus:
  27824. m.ClearStatus()
  27825. return nil
  27826. case usagedetail.FieldType:
  27827. m.ClearType()
  27828. return nil
  27829. case usagedetail.FieldApp:
  27830. m.ClearApp()
  27831. return nil
  27832. case usagedetail.FieldSessionID:
  27833. m.ClearSessionID()
  27834. return nil
  27835. case usagedetail.FieldTotalTokens:
  27836. m.ClearTotalTokens()
  27837. return nil
  27838. case usagedetail.FieldPromptTokens:
  27839. m.ClearPromptTokens()
  27840. return nil
  27841. case usagedetail.FieldCompletionTokens:
  27842. m.ClearCompletionTokens()
  27843. return nil
  27844. case usagedetail.FieldOrganizationID:
  27845. m.ClearOrganizationID()
  27846. return nil
  27847. }
  27848. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  27849. }
  27850. // ResetField resets all changes in the mutation for the field with the given name.
  27851. // It returns an error if the field is not defined in the schema.
  27852. func (m *UsageDetailMutation) ResetField(name string) error {
  27853. switch name {
  27854. case usagedetail.FieldCreatedAt:
  27855. m.ResetCreatedAt()
  27856. return nil
  27857. case usagedetail.FieldUpdatedAt:
  27858. m.ResetUpdatedAt()
  27859. return nil
  27860. case usagedetail.FieldStatus:
  27861. m.ResetStatus()
  27862. return nil
  27863. case usagedetail.FieldType:
  27864. m.ResetType()
  27865. return nil
  27866. case usagedetail.FieldBotID:
  27867. m.ResetBotID()
  27868. return nil
  27869. case usagedetail.FieldReceiverID:
  27870. m.ResetReceiverID()
  27871. return nil
  27872. case usagedetail.FieldApp:
  27873. m.ResetApp()
  27874. return nil
  27875. case usagedetail.FieldSessionID:
  27876. m.ResetSessionID()
  27877. return nil
  27878. case usagedetail.FieldRequest:
  27879. m.ResetRequest()
  27880. return nil
  27881. case usagedetail.FieldResponse:
  27882. m.ResetResponse()
  27883. return nil
  27884. case usagedetail.FieldOriginalData:
  27885. m.ResetOriginalData()
  27886. return nil
  27887. case usagedetail.FieldTotalTokens:
  27888. m.ResetTotalTokens()
  27889. return nil
  27890. case usagedetail.FieldPromptTokens:
  27891. m.ResetPromptTokens()
  27892. return nil
  27893. case usagedetail.FieldCompletionTokens:
  27894. m.ResetCompletionTokens()
  27895. return nil
  27896. case usagedetail.FieldOrganizationID:
  27897. m.ResetOrganizationID()
  27898. return nil
  27899. }
  27900. return fmt.Errorf("unknown UsageDetail field %s", name)
  27901. }
  27902. // AddedEdges returns all edge names that were set/added in this mutation.
  27903. func (m *UsageDetailMutation) AddedEdges() []string {
  27904. edges := make([]string, 0, 0)
  27905. return edges
  27906. }
  27907. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27908. // name in this mutation.
  27909. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  27910. return nil
  27911. }
  27912. // RemovedEdges returns all edge names that were removed in this mutation.
  27913. func (m *UsageDetailMutation) RemovedEdges() []string {
  27914. edges := make([]string, 0, 0)
  27915. return edges
  27916. }
  27917. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27918. // the given name in this mutation.
  27919. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  27920. return nil
  27921. }
  27922. // ClearedEdges returns all edge names that were cleared in this mutation.
  27923. func (m *UsageDetailMutation) ClearedEdges() []string {
  27924. edges := make([]string, 0, 0)
  27925. return edges
  27926. }
  27927. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27928. // was cleared in this mutation.
  27929. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  27930. return false
  27931. }
  27932. // ClearEdge clears the value of the edge with the given name. It returns an error
  27933. // if that edge is not defined in the schema.
  27934. func (m *UsageDetailMutation) ClearEdge(name string) error {
  27935. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  27936. }
  27937. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27938. // It returns an error if the edge is not defined in the schema.
  27939. func (m *UsageDetailMutation) ResetEdge(name string) error {
  27940. return fmt.Errorf("unknown UsageDetail edge %s", name)
  27941. }
  27942. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  27943. type UsageStatisticDayMutation struct {
  27944. config
  27945. op Op
  27946. typ string
  27947. id *uint64
  27948. created_at *time.Time
  27949. updated_at *time.Time
  27950. status *uint8
  27951. addstatus *int8
  27952. deleted_at *time.Time
  27953. addtime *uint64
  27954. addaddtime *int64
  27955. _type *int
  27956. add_type *int
  27957. bot_id *string
  27958. organization_id *uint64
  27959. addorganization_id *int64
  27960. ai_response *uint64
  27961. addai_response *int64
  27962. sop_run *uint64
  27963. addsop_run *int64
  27964. total_friend *uint64
  27965. addtotal_friend *int64
  27966. total_group *uint64
  27967. addtotal_group *int64
  27968. account_balance *uint64
  27969. addaccount_balance *int64
  27970. consume_token *uint64
  27971. addconsume_token *int64
  27972. active_user *uint64
  27973. addactive_user *int64
  27974. new_user *int64
  27975. addnew_user *int64
  27976. label_dist *[]custom_types.LabelDist
  27977. appendlabel_dist []custom_types.LabelDist
  27978. clearedFields map[string]struct{}
  27979. done bool
  27980. oldValue func(context.Context) (*UsageStatisticDay, error)
  27981. predicates []predicate.UsageStatisticDay
  27982. }
  27983. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  27984. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  27985. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  27986. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  27987. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  27988. m := &UsageStatisticDayMutation{
  27989. config: c,
  27990. op: op,
  27991. typ: TypeUsageStatisticDay,
  27992. clearedFields: make(map[string]struct{}),
  27993. }
  27994. for _, opt := range opts {
  27995. opt(m)
  27996. }
  27997. return m
  27998. }
  27999. // withUsageStatisticDayID sets the ID field of the mutation.
  28000. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  28001. return func(m *UsageStatisticDayMutation) {
  28002. var (
  28003. err error
  28004. once sync.Once
  28005. value *UsageStatisticDay
  28006. )
  28007. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  28008. once.Do(func() {
  28009. if m.done {
  28010. err = errors.New("querying old values post mutation is not allowed")
  28011. } else {
  28012. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  28013. }
  28014. })
  28015. return value, err
  28016. }
  28017. m.id = &id
  28018. }
  28019. }
  28020. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  28021. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  28022. return func(m *UsageStatisticDayMutation) {
  28023. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  28024. return node, nil
  28025. }
  28026. m.id = &node.ID
  28027. }
  28028. }
  28029. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28030. // executed in a transaction (ent.Tx), a transactional client is returned.
  28031. func (m UsageStatisticDayMutation) Client() *Client {
  28032. client := &Client{config: m.config}
  28033. client.init()
  28034. return client
  28035. }
  28036. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28037. // it returns an error otherwise.
  28038. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  28039. if _, ok := m.driver.(*txDriver); !ok {
  28040. return nil, errors.New("ent: mutation is not running in a transaction")
  28041. }
  28042. tx := &Tx{config: m.config}
  28043. tx.init()
  28044. return tx, nil
  28045. }
  28046. // SetID sets the value of the id field. Note that this
  28047. // operation is only accepted on creation of UsageStatisticDay entities.
  28048. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  28049. m.id = &id
  28050. }
  28051. // ID returns the ID value in the mutation. Note that the ID is only available
  28052. // if it was provided to the builder or after it was returned from the database.
  28053. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  28054. if m.id == nil {
  28055. return
  28056. }
  28057. return *m.id, true
  28058. }
  28059. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28060. // That means, if the mutation is applied within a transaction with an isolation level such
  28061. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28062. // or updated by the mutation.
  28063. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  28064. switch {
  28065. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28066. id, exists := m.ID()
  28067. if exists {
  28068. return []uint64{id}, nil
  28069. }
  28070. fallthrough
  28071. case m.op.Is(OpUpdate | OpDelete):
  28072. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  28073. default:
  28074. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28075. }
  28076. }
  28077. // SetCreatedAt sets the "created_at" field.
  28078. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  28079. m.created_at = &t
  28080. }
  28081. // CreatedAt returns the value of the "created_at" field in the mutation.
  28082. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  28083. v := m.created_at
  28084. if v == nil {
  28085. return
  28086. }
  28087. return *v, true
  28088. }
  28089. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  28090. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28091. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28092. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28093. if !m.op.Is(OpUpdateOne) {
  28094. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28095. }
  28096. if m.id == nil || m.oldValue == nil {
  28097. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28098. }
  28099. oldValue, err := m.oldValue(ctx)
  28100. if err != nil {
  28101. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28102. }
  28103. return oldValue.CreatedAt, nil
  28104. }
  28105. // ResetCreatedAt resets all changes to the "created_at" field.
  28106. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  28107. m.created_at = nil
  28108. }
  28109. // SetUpdatedAt sets the "updated_at" field.
  28110. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  28111. m.updated_at = &t
  28112. }
  28113. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28114. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  28115. v := m.updated_at
  28116. if v == nil {
  28117. return
  28118. }
  28119. return *v, true
  28120. }
  28121. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  28122. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28124. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28125. if !m.op.Is(OpUpdateOne) {
  28126. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28127. }
  28128. if m.id == nil || m.oldValue == nil {
  28129. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28130. }
  28131. oldValue, err := m.oldValue(ctx)
  28132. if err != nil {
  28133. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28134. }
  28135. return oldValue.UpdatedAt, nil
  28136. }
  28137. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28138. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  28139. m.updated_at = nil
  28140. }
  28141. // SetStatus sets the "status" field.
  28142. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  28143. m.status = &u
  28144. m.addstatus = nil
  28145. }
  28146. // Status returns the value of the "status" field in the mutation.
  28147. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  28148. v := m.status
  28149. if v == nil {
  28150. return
  28151. }
  28152. return *v, true
  28153. }
  28154. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  28155. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28157. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28158. if !m.op.Is(OpUpdateOne) {
  28159. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28160. }
  28161. if m.id == nil || m.oldValue == nil {
  28162. return v, errors.New("OldStatus requires an ID field in the mutation")
  28163. }
  28164. oldValue, err := m.oldValue(ctx)
  28165. if err != nil {
  28166. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28167. }
  28168. return oldValue.Status, nil
  28169. }
  28170. // AddStatus adds u to the "status" field.
  28171. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  28172. if m.addstatus != nil {
  28173. *m.addstatus += u
  28174. } else {
  28175. m.addstatus = &u
  28176. }
  28177. }
  28178. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28179. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  28180. v := m.addstatus
  28181. if v == nil {
  28182. return
  28183. }
  28184. return *v, true
  28185. }
  28186. // ClearStatus clears the value of the "status" field.
  28187. func (m *UsageStatisticDayMutation) ClearStatus() {
  28188. m.status = nil
  28189. m.addstatus = nil
  28190. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  28191. }
  28192. // StatusCleared returns if the "status" field was cleared in this mutation.
  28193. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  28194. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  28195. return ok
  28196. }
  28197. // ResetStatus resets all changes to the "status" field.
  28198. func (m *UsageStatisticDayMutation) ResetStatus() {
  28199. m.status = nil
  28200. m.addstatus = nil
  28201. delete(m.clearedFields, usagestatisticday.FieldStatus)
  28202. }
  28203. // SetDeletedAt sets the "deleted_at" field.
  28204. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  28205. m.deleted_at = &t
  28206. }
  28207. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28208. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  28209. v := m.deleted_at
  28210. if v == nil {
  28211. return
  28212. }
  28213. return *v, true
  28214. }
  28215. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  28216. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28218. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28219. if !m.op.Is(OpUpdateOne) {
  28220. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28221. }
  28222. if m.id == nil || m.oldValue == nil {
  28223. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28224. }
  28225. oldValue, err := m.oldValue(ctx)
  28226. if err != nil {
  28227. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28228. }
  28229. return oldValue.DeletedAt, nil
  28230. }
  28231. // ClearDeletedAt clears the value of the "deleted_at" field.
  28232. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  28233. m.deleted_at = nil
  28234. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  28235. }
  28236. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28237. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  28238. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  28239. return ok
  28240. }
  28241. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28242. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  28243. m.deleted_at = nil
  28244. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  28245. }
  28246. // SetAddtime sets the "addtime" field.
  28247. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  28248. m.addtime = &u
  28249. m.addaddtime = nil
  28250. }
  28251. // Addtime returns the value of the "addtime" field in the mutation.
  28252. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  28253. v := m.addtime
  28254. if v == nil {
  28255. return
  28256. }
  28257. return *v, true
  28258. }
  28259. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  28260. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28262. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  28263. if !m.op.Is(OpUpdateOne) {
  28264. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  28265. }
  28266. if m.id == nil || m.oldValue == nil {
  28267. return v, errors.New("OldAddtime requires an ID field in the mutation")
  28268. }
  28269. oldValue, err := m.oldValue(ctx)
  28270. if err != nil {
  28271. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  28272. }
  28273. return oldValue.Addtime, nil
  28274. }
  28275. // AddAddtime adds u to the "addtime" field.
  28276. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  28277. if m.addaddtime != nil {
  28278. *m.addaddtime += u
  28279. } else {
  28280. m.addaddtime = &u
  28281. }
  28282. }
  28283. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  28284. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  28285. v := m.addaddtime
  28286. if v == nil {
  28287. return
  28288. }
  28289. return *v, true
  28290. }
  28291. // ResetAddtime resets all changes to the "addtime" field.
  28292. func (m *UsageStatisticDayMutation) ResetAddtime() {
  28293. m.addtime = nil
  28294. m.addaddtime = nil
  28295. }
  28296. // SetType sets the "type" field.
  28297. func (m *UsageStatisticDayMutation) SetType(i int) {
  28298. m._type = &i
  28299. m.add_type = nil
  28300. }
  28301. // GetType returns the value of the "type" field in the mutation.
  28302. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  28303. v := m._type
  28304. if v == nil {
  28305. return
  28306. }
  28307. return *v, true
  28308. }
  28309. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  28310. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28312. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  28313. if !m.op.Is(OpUpdateOne) {
  28314. return v, errors.New("OldType is only allowed on UpdateOne operations")
  28315. }
  28316. if m.id == nil || m.oldValue == nil {
  28317. return v, errors.New("OldType requires an ID field in the mutation")
  28318. }
  28319. oldValue, err := m.oldValue(ctx)
  28320. if err != nil {
  28321. return v, fmt.Errorf("querying old value for OldType: %w", err)
  28322. }
  28323. return oldValue.Type, nil
  28324. }
  28325. // AddType adds i to the "type" field.
  28326. func (m *UsageStatisticDayMutation) AddType(i int) {
  28327. if m.add_type != nil {
  28328. *m.add_type += i
  28329. } else {
  28330. m.add_type = &i
  28331. }
  28332. }
  28333. // AddedType returns the value that was added to the "type" field in this mutation.
  28334. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  28335. v := m.add_type
  28336. if v == nil {
  28337. return
  28338. }
  28339. return *v, true
  28340. }
  28341. // ResetType resets all changes to the "type" field.
  28342. func (m *UsageStatisticDayMutation) ResetType() {
  28343. m._type = nil
  28344. m.add_type = nil
  28345. }
  28346. // SetBotID sets the "bot_id" field.
  28347. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  28348. m.bot_id = &s
  28349. }
  28350. // BotID returns the value of the "bot_id" field in the mutation.
  28351. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  28352. v := m.bot_id
  28353. if v == nil {
  28354. return
  28355. }
  28356. return *v, true
  28357. }
  28358. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  28359. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28361. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  28362. if !m.op.Is(OpUpdateOne) {
  28363. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  28364. }
  28365. if m.id == nil || m.oldValue == nil {
  28366. return v, errors.New("OldBotID requires an ID field in the mutation")
  28367. }
  28368. oldValue, err := m.oldValue(ctx)
  28369. if err != nil {
  28370. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  28371. }
  28372. return oldValue.BotID, nil
  28373. }
  28374. // ClearBotID clears the value of the "bot_id" field.
  28375. func (m *UsageStatisticDayMutation) ClearBotID() {
  28376. m.bot_id = nil
  28377. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  28378. }
  28379. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  28380. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  28381. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  28382. return ok
  28383. }
  28384. // ResetBotID resets all changes to the "bot_id" field.
  28385. func (m *UsageStatisticDayMutation) ResetBotID() {
  28386. m.bot_id = nil
  28387. delete(m.clearedFields, usagestatisticday.FieldBotID)
  28388. }
  28389. // SetOrganizationID sets the "organization_id" field.
  28390. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  28391. m.organization_id = &u
  28392. m.addorganization_id = nil
  28393. }
  28394. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28395. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  28396. v := m.organization_id
  28397. if v == nil {
  28398. return
  28399. }
  28400. return *v, true
  28401. }
  28402. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  28403. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28405. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28406. if !m.op.Is(OpUpdateOne) {
  28407. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28408. }
  28409. if m.id == nil || m.oldValue == nil {
  28410. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28411. }
  28412. oldValue, err := m.oldValue(ctx)
  28413. if err != nil {
  28414. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28415. }
  28416. return oldValue.OrganizationID, nil
  28417. }
  28418. // AddOrganizationID adds u to the "organization_id" field.
  28419. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  28420. if m.addorganization_id != nil {
  28421. *m.addorganization_id += u
  28422. } else {
  28423. m.addorganization_id = &u
  28424. }
  28425. }
  28426. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28427. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  28428. v := m.addorganization_id
  28429. if v == nil {
  28430. return
  28431. }
  28432. return *v, true
  28433. }
  28434. // ClearOrganizationID clears the value of the "organization_id" field.
  28435. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  28436. m.organization_id = nil
  28437. m.addorganization_id = nil
  28438. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  28439. }
  28440. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28441. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  28442. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  28443. return ok
  28444. }
  28445. // ResetOrganizationID resets all changes to the "organization_id" field.
  28446. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  28447. m.organization_id = nil
  28448. m.addorganization_id = nil
  28449. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  28450. }
  28451. // SetAiResponse sets the "ai_response" field.
  28452. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  28453. m.ai_response = &u
  28454. m.addai_response = nil
  28455. }
  28456. // AiResponse returns the value of the "ai_response" field in the mutation.
  28457. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  28458. v := m.ai_response
  28459. if v == nil {
  28460. return
  28461. }
  28462. return *v, true
  28463. }
  28464. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  28465. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28466. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28467. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  28468. if !m.op.Is(OpUpdateOne) {
  28469. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  28470. }
  28471. if m.id == nil || m.oldValue == nil {
  28472. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  28473. }
  28474. oldValue, err := m.oldValue(ctx)
  28475. if err != nil {
  28476. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  28477. }
  28478. return oldValue.AiResponse, nil
  28479. }
  28480. // AddAiResponse adds u to the "ai_response" field.
  28481. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  28482. if m.addai_response != nil {
  28483. *m.addai_response += u
  28484. } else {
  28485. m.addai_response = &u
  28486. }
  28487. }
  28488. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  28489. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  28490. v := m.addai_response
  28491. if v == nil {
  28492. return
  28493. }
  28494. return *v, true
  28495. }
  28496. // ResetAiResponse resets all changes to the "ai_response" field.
  28497. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  28498. m.ai_response = nil
  28499. m.addai_response = nil
  28500. }
  28501. // SetSopRun sets the "sop_run" field.
  28502. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  28503. m.sop_run = &u
  28504. m.addsop_run = nil
  28505. }
  28506. // SopRun returns the value of the "sop_run" field in the mutation.
  28507. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  28508. v := m.sop_run
  28509. if v == nil {
  28510. return
  28511. }
  28512. return *v, true
  28513. }
  28514. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  28515. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28516. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28517. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  28518. if !m.op.Is(OpUpdateOne) {
  28519. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  28520. }
  28521. if m.id == nil || m.oldValue == nil {
  28522. return v, errors.New("OldSopRun requires an ID field in the mutation")
  28523. }
  28524. oldValue, err := m.oldValue(ctx)
  28525. if err != nil {
  28526. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  28527. }
  28528. return oldValue.SopRun, nil
  28529. }
  28530. // AddSopRun adds u to the "sop_run" field.
  28531. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  28532. if m.addsop_run != nil {
  28533. *m.addsop_run += u
  28534. } else {
  28535. m.addsop_run = &u
  28536. }
  28537. }
  28538. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  28539. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  28540. v := m.addsop_run
  28541. if v == nil {
  28542. return
  28543. }
  28544. return *v, true
  28545. }
  28546. // ResetSopRun resets all changes to the "sop_run" field.
  28547. func (m *UsageStatisticDayMutation) ResetSopRun() {
  28548. m.sop_run = nil
  28549. m.addsop_run = nil
  28550. }
  28551. // SetTotalFriend sets the "total_friend" field.
  28552. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  28553. m.total_friend = &u
  28554. m.addtotal_friend = nil
  28555. }
  28556. // TotalFriend returns the value of the "total_friend" field in the mutation.
  28557. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  28558. v := m.total_friend
  28559. if v == nil {
  28560. return
  28561. }
  28562. return *v, true
  28563. }
  28564. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  28565. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28567. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  28568. if !m.op.Is(OpUpdateOne) {
  28569. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  28570. }
  28571. if m.id == nil || m.oldValue == nil {
  28572. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  28573. }
  28574. oldValue, err := m.oldValue(ctx)
  28575. if err != nil {
  28576. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  28577. }
  28578. return oldValue.TotalFriend, nil
  28579. }
  28580. // AddTotalFriend adds u to the "total_friend" field.
  28581. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  28582. if m.addtotal_friend != nil {
  28583. *m.addtotal_friend += u
  28584. } else {
  28585. m.addtotal_friend = &u
  28586. }
  28587. }
  28588. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  28589. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  28590. v := m.addtotal_friend
  28591. if v == nil {
  28592. return
  28593. }
  28594. return *v, true
  28595. }
  28596. // ResetTotalFriend resets all changes to the "total_friend" field.
  28597. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  28598. m.total_friend = nil
  28599. m.addtotal_friend = nil
  28600. }
  28601. // SetTotalGroup sets the "total_group" field.
  28602. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  28603. m.total_group = &u
  28604. m.addtotal_group = nil
  28605. }
  28606. // TotalGroup returns the value of the "total_group" field in the mutation.
  28607. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  28608. v := m.total_group
  28609. if v == nil {
  28610. return
  28611. }
  28612. return *v, true
  28613. }
  28614. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  28615. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28617. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  28618. if !m.op.Is(OpUpdateOne) {
  28619. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  28620. }
  28621. if m.id == nil || m.oldValue == nil {
  28622. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  28623. }
  28624. oldValue, err := m.oldValue(ctx)
  28625. if err != nil {
  28626. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  28627. }
  28628. return oldValue.TotalGroup, nil
  28629. }
  28630. // AddTotalGroup adds u to the "total_group" field.
  28631. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  28632. if m.addtotal_group != nil {
  28633. *m.addtotal_group += u
  28634. } else {
  28635. m.addtotal_group = &u
  28636. }
  28637. }
  28638. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  28639. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  28640. v := m.addtotal_group
  28641. if v == nil {
  28642. return
  28643. }
  28644. return *v, true
  28645. }
  28646. // ResetTotalGroup resets all changes to the "total_group" field.
  28647. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  28648. m.total_group = nil
  28649. m.addtotal_group = nil
  28650. }
  28651. // SetAccountBalance sets the "account_balance" field.
  28652. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  28653. m.account_balance = &u
  28654. m.addaccount_balance = nil
  28655. }
  28656. // AccountBalance returns the value of the "account_balance" field in the mutation.
  28657. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  28658. v := m.account_balance
  28659. if v == nil {
  28660. return
  28661. }
  28662. return *v, true
  28663. }
  28664. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  28665. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28667. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  28668. if !m.op.Is(OpUpdateOne) {
  28669. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  28670. }
  28671. if m.id == nil || m.oldValue == nil {
  28672. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  28673. }
  28674. oldValue, err := m.oldValue(ctx)
  28675. if err != nil {
  28676. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  28677. }
  28678. return oldValue.AccountBalance, nil
  28679. }
  28680. // AddAccountBalance adds u to the "account_balance" field.
  28681. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  28682. if m.addaccount_balance != nil {
  28683. *m.addaccount_balance += u
  28684. } else {
  28685. m.addaccount_balance = &u
  28686. }
  28687. }
  28688. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  28689. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  28690. v := m.addaccount_balance
  28691. if v == nil {
  28692. return
  28693. }
  28694. return *v, true
  28695. }
  28696. // ResetAccountBalance resets all changes to the "account_balance" field.
  28697. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  28698. m.account_balance = nil
  28699. m.addaccount_balance = nil
  28700. }
  28701. // SetConsumeToken sets the "consume_token" field.
  28702. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  28703. m.consume_token = &u
  28704. m.addconsume_token = nil
  28705. }
  28706. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  28707. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  28708. v := m.consume_token
  28709. if v == nil {
  28710. return
  28711. }
  28712. return *v, true
  28713. }
  28714. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  28715. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28717. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  28718. if !m.op.Is(OpUpdateOne) {
  28719. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  28720. }
  28721. if m.id == nil || m.oldValue == nil {
  28722. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  28723. }
  28724. oldValue, err := m.oldValue(ctx)
  28725. if err != nil {
  28726. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  28727. }
  28728. return oldValue.ConsumeToken, nil
  28729. }
  28730. // AddConsumeToken adds u to the "consume_token" field.
  28731. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  28732. if m.addconsume_token != nil {
  28733. *m.addconsume_token += u
  28734. } else {
  28735. m.addconsume_token = &u
  28736. }
  28737. }
  28738. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  28739. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  28740. v := m.addconsume_token
  28741. if v == nil {
  28742. return
  28743. }
  28744. return *v, true
  28745. }
  28746. // ResetConsumeToken resets all changes to the "consume_token" field.
  28747. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  28748. m.consume_token = nil
  28749. m.addconsume_token = nil
  28750. }
  28751. // SetActiveUser sets the "active_user" field.
  28752. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  28753. m.active_user = &u
  28754. m.addactive_user = nil
  28755. }
  28756. // ActiveUser returns the value of the "active_user" field in the mutation.
  28757. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  28758. v := m.active_user
  28759. if v == nil {
  28760. return
  28761. }
  28762. return *v, true
  28763. }
  28764. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  28765. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28767. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  28768. if !m.op.Is(OpUpdateOne) {
  28769. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  28770. }
  28771. if m.id == nil || m.oldValue == nil {
  28772. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  28773. }
  28774. oldValue, err := m.oldValue(ctx)
  28775. if err != nil {
  28776. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  28777. }
  28778. return oldValue.ActiveUser, nil
  28779. }
  28780. // AddActiveUser adds u to the "active_user" field.
  28781. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  28782. if m.addactive_user != nil {
  28783. *m.addactive_user += u
  28784. } else {
  28785. m.addactive_user = &u
  28786. }
  28787. }
  28788. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  28789. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  28790. v := m.addactive_user
  28791. if v == nil {
  28792. return
  28793. }
  28794. return *v, true
  28795. }
  28796. // ResetActiveUser resets all changes to the "active_user" field.
  28797. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  28798. m.active_user = nil
  28799. m.addactive_user = nil
  28800. }
  28801. // SetNewUser sets the "new_user" field.
  28802. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  28803. m.new_user = &i
  28804. m.addnew_user = nil
  28805. }
  28806. // NewUser returns the value of the "new_user" field in the mutation.
  28807. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  28808. v := m.new_user
  28809. if v == nil {
  28810. return
  28811. }
  28812. return *v, true
  28813. }
  28814. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  28815. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28817. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  28818. if !m.op.Is(OpUpdateOne) {
  28819. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  28820. }
  28821. if m.id == nil || m.oldValue == nil {
  28822. return v, errors.New("OldNewUser requires an ID field in the mutation")
  28823. }
  28824. oldValue, err := m.oldValue(ctx)
  28825. if err != nil {
  28826. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  28827. }
  28828. return oldValue.NewUser, nil
  28829. }
  28830. // AddNewUser adds i to the "new_user" field.
  28831. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  28832. if m.addnew_user != nil {
  28833. *m.addnew_user += i
  28834. } else {
  28835. m.addnew_user = &i
  28836. }
  28837. }
  28838. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  28839. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  28840. v := m.addnew_user
  28841. if v == nil {
  28842. return
  28843. }
  28844. return *v, true
  28845. }
  28846. // ResetNewUser resets all changes to the "new_user" field.
  28847. func (m *UsageStatisticDayMutation) ResetNewUser() {
  28848. m.new_user = nil
  28849. m.addnew_user = nil
  28850. }
  28851. // SetLabelDist sets the "label_dist" field.
  28852. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  28853. m.label_dist = &ctd
  28854. m.appendlabel_dist = nil
  28855. }
  28856. // LabelDist returns the value of the "label_dist" field in the mutation.
  28857. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  28858. v := m.label_dist
  28859. if v == nil {
  28860. return
  28861. }
  28862. return *v, true
  28863. }
  28864. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  28865. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28867. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  28868. if !m.op.Is(OpUpdateOne) {
  28869. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  28870. }
  28871. if m.id == nil || m.oldValue == nil {
  28872. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  28873. }
  28874. oldValue, err := m.oldValue(ctx)
  28875. if err != nil {
  28876. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  28877. }
  28878. return oldValue.LabelDist, nil
  28879. }
  28880. // AppendLabelDist adds ctd to the "label_dist" field.
  28881. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  28882. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  28883. }
  28884. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  28885. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  28886. if len(m.appendlabel_dist) == 0 {
  28887. return nil, false
  28888. }
  28889. return m.appendlabel_dist, true
  28890. }
  28891. // ResetLabelDist resets all changes to the "label_dist" field.
  28892. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  28893. m.label_dist = nil
  28894. m.appendlabel_dist = nil
  28895. }
  28896. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  28897. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  28898. m.predicates = append(m.predicates, ps...)
  28899. }
  28900. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  28901. // users can use type-assertion to append predicates that do not depend on any generated package.
  28902. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  28903. p := make([]predicate.UsageStatisticDay, len(ps))
  28904. for i := range ps {
  28905. p[i] = ps[i]
  28906. }
  28907. m.Where(p...)
  28908. }
  28909. // Op returns the operation name.
  28910. func (m *UsageStatisticDayMutation) Op() Op {
  28911. return m.op
  28912. }
  28913. // SetOp allows setting the mutation operation.
  28914. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  28915. m.op = op
  28916. }
  28917. // Type returns the node type of this mutation (UsageStatisticDay).
  28918. func (m *UsageStatisticDayMutation) Type() string {
  28919. return m.typ
  28920. }
  28921. // Fields returns all fields that were changed during this mutation. Note that in
  28922. // order to get all numeric fields that were incremented/decremented, call
  28923. // AddedFields().
  28924. func (m *UsageStatisticDayMutation) Fields() []string {
  28925. fields := make([]string, 0, 17)
  28926. if m.created_at != nil {
  28927. fields = append(fields, usagestatisticday.FieldCreatedAt)
  28928. }
  28929. if m.updated_at != nil {
  28930. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  28931. }
  28932. if m.status != nil {
  28933. fields = append(fields, usagestatisticday.FieldStatus)
  28934. }
  28935. if m.deleted_at != nil {
  28936. fields = append(fields, usagestatisticday.FieldDeletedAt)
  28937. }
  28938. if m.addtime != nil {
  28939. fields = append(fields, usagestatisticday.FieldAddtime)
  28940. }
  28941. if m._type != nil {
  28942. fields = append(fields, usagestatisticday.FieldType)
  28943. }
  28944. if m.bot_id != nil {
  28945. fields = append(fields, usagestatisticday.FieldBotID)
  28946. }
  28947. if m.organization_id != nil {
  28948. fields = append(fields, usagestatisticday.FieldOrganizationID)
  28949. }
  28950. if m.ai_response != nil {
  28951. fields = append(fields, usagestatisticday.FieldAiResponse)
  28952. }
  28953. if m.sop_run != nil {
  28954. fields = append(fields, usagestatisticday.FieldSopRun)
  28955. }
  28956. if m.total_friend != nil {
  28957. fields = append(fields, usagestatisticday.FieldTotalFriend)
  28958. }
  28959. if m.total_group != nil {
  28960. fields = append(fields, usagestatisticday.FieldTotalGroup)
  28961. }
  28962. if m.account_balance != nil {
  28963. fields = append(fields, usagestatisticday.FieldAccountBalance)
  28964. }
  28965. if m.consume_token != nil {
  28966. fields = append(fields, usagestatisticday.FieldConsumeToken)
  28967. }
  28968. if m.active_user != nil {
  28969. fields = append(fields, usagestatisticday.FieldActiveUser)
  28970. }
  28971. if m.new_user != nil {
  28972. fields = append(fields, usagestatisticday.FieldNewUser)
  28973. }
  28974. if m.label_dist != nil {
  28975. fields = append(fields, usagestatisticday.FieldLabelDist)
  28976. }
  28977. return fields
  28978. }
  28979. // Field returns the value of a field with the given name. The second boolean
  28980. // return value indicates that this field was not set, or was not defined in the
  28981. // schema.
  28982. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  28983. switch name {
  28984. case usagestatisticday.FieldCreatedAt:
  28985. return m.CreatedAt()
  28986. case usagestatisticday.FieldUpdatedAt:
  28987. return m.UpdatedAt()
  28988. case usagestatisticday.FieldStatus:
  28989. return m.Status()
  28990. case usagestatisticday.FieldDeletedAt:
  28991. return m.DeletedAt()
  28992. case usagestatisticday.FieldAddtime:
  28993. return m.Addtime()
  28994. case usagestatisticday.FieldType:
  28995. return m.GetType()
  28996. case usagestatisticday.FieldBotID:
  28997. return m.BotID()
  28998. case usagestatisticday.FieldOrganizationID:
  28999. return m.OrganizationID()
  29000. case usagestatisticday.FieldAiResponse:
  29001. return m.AiResponse()
  29002. case usagestatisticday.FieldSopRun:
  29003. return m.SopRun()
  29004. case usagestatisticday.FieldTotalFriend:
  29005. return m.TotalFriend()
  29006. case usagestatisticday.FieldTotalGroup:
  29007. return m.TotalGroup()
  29008. case usagestatisticday.FieldAccountBalance:
  29009. return m.AccountBalance()
  29010. case usagestatisticday.FieldConsumeToken:
  29011. return m.ConsumeToken()
  29012. case usagestatisticday.FieldActiveUser:
  29013. return m.ActiveUser()
  29014. case usagestatisticday.FieldNewUser:
  29015. return m.NewUser()
  29016. case usagestatisticday.FieldLabelDist:
  29017. return m.LabelDist()
  29018. }
  29019. return nil, false
  29020. }
  29021. // OldField returns the old value of the field from the database. An error is
  29022. // returned if the mutation operation is not UpdateOne, or the query to the
  29023. // database failed.
  29024. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29025. switch name {
  29026. case usagestatisticday.FieldCreatedAt:
  29027. return m.OldCreatedAt(ctx)
  29028. case usagestatisticday.FieldUpdatedAt:
  29029. return m.OldUpdatedAt(ctx)
  29030. case usagestatisticday.FieldStatus:
  29031. return m.OldStatus(ctx)
  29032. case usagestatisticday.FieldDeletedAt:
  29033. return m.OldDeletedAt(ctx)
  29034. case usagestatisticday.FieldAddtime:
  29035. return m.OldAddtime(ctx)
  29036. case usagestatisticday.FieldType:
  29037. return m.OldType(ctx)
  29038. case usagestatisticday.FieldBotID:
  29039. return m.OldBotID(ctx)
  29040. case usagestatisticday.FieldOrganizationID:
  29041. return m.OldOrganizationID(ctx)
  29042. case usagestatisticday.FieldAiResponse:
  29043. return m.OldAiResponse(ctx)
  29044. case usagestatisticday.FieldSopRun:
  29045. return m.OldSopRun(ctx)
  29046. case usagestatisticday.FieldTotalFriend:
  29047. return m.OldTotalFriend(ctx)
  29048. case usagestatisticday.FieldTotalGroup:
  29049. return m.OldTotalGroup(ctx)
  29050. case usagestatisticday.FieldAccountBalance:
  29051. return m.OldAccountBalance(ctx)
  29052. case usagestatisticday.FieldConsumeToken:
  29053. return m.OldConsumeToken(ctx)
  29054. case usagestatisticday.FieldActiveUser:
  29055. return m.OldActiveUser(ctx)
  29056. case usagestatisticday.FieldNewUser:
  29057. return m.OldNewUser(ctx)
  29058. case usagestatisticday.FieldLabelDist:
  29059. return m.OldLabelDist(ctx)
  29060. }
  29061. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29062. }
  29063. // SetField sets the value of a field with the given name. It returns an error if
  29064. // the field is not defined in the schema, or if the type mismatched the field
  29065. // type.
  29066. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  29067. switch name {
  29068. case usagestatisticday.FieldCreatedAt:
  29069. v, ok := value.(time.Time)
  29070. if !ok {
  29071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29072. }
  29073. m.SetCreatedAt(v)
  29074. return nil
  29075. case usagestatisticday.FieldUpdatedAt:
  29076. v, ok := value.(time.Time)
  29077. if !ok {
  29078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29079. }
  29080. m.SetUpdatedAt(v)
  29081. return nil
  29082. case usagestatisticday.FieldStatus:
  29083. v, ok := value.(uint8)
  29084. if !ok {
  29085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29086. }
  29087. m.SetStatus(v)
  29088. return nil
  29089. case usagestatisticday.FieldDeletedAt:
  29090. v, ok := value.(time.Time)
  29091. if !ok {
  29092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29093. }
  29094. m.SetDeletedAt(v)
  29095. return nil
  29096. case usagestatisticday.FieldAddtime:
  29097. v, ok := value.(uint64)
  29098. if !ok {
  29099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29100. }
  29101. m.SetAddtime(v)
  29102. return nil
  29103. case usagestatisticday.FieldType:
  29104. v, ok := value.(int)
  29105. if !ok {
  29106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29107. }
  29108. m.SetType(v)
  29109. return nil
  29110. case usagestatisticday.FieldBotID:
  29111. v, ok := value.(string)
  29112. if !ok {
  29113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29114. }
  29115. m.SetBotID(v)
  29116. return nil
  29117. case usagestatisticday.FieldOrganizationID:
  29118. v, ok := value.(uint64)
  29119. if !ok {
  29120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29121. }
  29122. m.SetOrganizationID(v)
  29123. return nil
  29124. case usagestatisticday.FieldAiResponse:
  29125. v, ok := value.(uint64)
  29126. if !ok {
  29127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29128. }
  29129. m.SetAiResponse(v)
  29130. return nil
  29131. case usagestatisticday.FieldSopRun:
  29132. v, ok := value.(uint64)
  29133. if !ok {
  29134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29135. }
  29136. m.SetSopRun(v)
  29137. return nil
  29138. case usagestatisticday.FieldTotalFriend:
  29139. v, ok := value.(uint64)
  29140. if !ok {
  29141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29142. }
  29143. m.SetTotalFriend(v)
  29144. return nil
  29145. case usagestatisticday.FieldTotalGroup:
  29146. v, ok := value.(uint64)
  29147. if !ok {
  29148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29149. }
  29150. m.SetTotalGroup(v)
  29151. return nil
  29152. case usagestatisticday.FieldAccountBalance:
  29153. v, ok := value.(uint64)
  29154. if !ok {
  29155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29156. }
  29157. m.SetAccountBalance(v)
  29158. return nil
  29159. case usagestatisticday.FieldConsumeToken:
  29160. v, ok := value.(uint64)
  29161. if !ok {
  29162. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29163. }
  29164. m.SetConsumeToken(v)
  29165. return nil
  29166. case usagestatisticday.FieldActiveUser:
  29167. v, ok := value.(uint64)
  29168. if !ok {
  29169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29170. }
  29171. m.SetActiveUser(v)
  29172. return nil
  29173. case usagestatisticday.FieldNewUser:
  29174. v, ok := value.(int64)
  29175. if !ok {
  29176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29177. }
  29178. m.SetNewUser(v)
  29179. return nil
  29180. case usagestatisticday.FieldLabelDist:
  29181. v, ok := value.([]custom_types.LabelDist)
  29182. if !ok {
  29183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29184. }
  29185. m.SetLabelDist(v)
  29186. return nil
  29187. }
  29188. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29189. }
  29190. // AddedFields returns all numeric fields that were incremented/decremented during
  29191. // this mutation.
  29192. func (m *UsageStatisticDayMutation) AddedFields() []string {
  29193. var fields []string
  29194. if m.addstatus != nil {
  29195. fields = append(fields, usagestatisticday.FieldStatus)
  29196. }
  29197. if m.addaddtime != nil {
  29198. fields = append(fields, usagestatisticday.FieldAddtime)
  29199. }
  29200. if m.add_type != nil {
  29201. fields = append(fields, usagestatisticday.FieldType)
  29202. }
  29203. if m.addorganization_id != nil {
  29204. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29205. }
  29206. if m.addai_response != nil {
  29207. fields = append(fields, usagestatisticday.FieldAiResponse)
  29208. }
  29209. if m.addsop_run != nil {
  29210. fields = append(fields, usagestatisticday.FieldSopRun)
  29211. }
  29212. if m.addtotal_friend != nil {
  29213. fields = append(fields, usagestatisticday.FieldTotalFriend)
  29214. }
  29215. if m.addtotal_group != nil {
  29216. fields = append(fields, usagestatisticday.FieldTotalGroup)
  29217. }
  29218. if m.addaccount_balance != nil {
  29219. fields = append(fields, usagestatisticday.FieldAccountBalance)
  29220. }
  29221. if m.addconsume_token != nil {
  29222. fields = append(fields, usagestatisticday.FieldConsumeToken)
  29223. }
  29224. if m.addactive_user != nil {
  29225. fields = append(fields, usagestatisticday.FieldActiveUser)
  29226. }
  29227. if m.addnew_user != nil {
  29228. fields = append(fields, usagestatisticday.FieldNewUser)
  29229. }
  29230. return fields
  29231. }
  29232. // AddedField returns the numeric value that was incremented/decremented on a field
  29233. // with the given name. The second boolean return value indicates that this field
  29234. // was not set, or was not defined in the schema.
  29235. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  29236. switch name {
  29237. case usagestatisticday.FieldStatus:
  29238. return m.AddedStatus()
  29239. case usagestatisticday.FieldAddtime:
  29240. return m.AddedAddtime()
  29241. case usagestatisticday.FieldType:
  29242. return m.AddedType()
  29243. case usagestatisticday.FieldOrganizationID:
  29244. return m.AddedOrganizationID()
  29245. case usagestatisticday.FieldAiResponse:
  29246. return m.AddedAiResponse()
  29247. case usagestatisticday.FieldSopRun:
  29248. return m.AddedSopRun()
  29249. case usagestatisticday.FieldTotalFriend:
  29250. return m.AddedTotalFriend()
  29251. case usagestatisticday.FieldTotalGroup:
  29252. return m.AddedTotalGroup()
  29253. case usagestatisticday.FieldAccountBalance:
  29254. return m.AddedAccountBalance()
  29255. case usagestatisticday.FieldConsumeToken:
  29256. return m.AddedConsumeToken()
  29257. case usagestatisticday.FieldActiveUser:
  29258. return m.AddedActiveUser()
  29259. case usagestatisticday.FieldNewUser:
  29260. return m.AddedNewUser()
  29261. }
  29262. return nil, false
  29263. }
  29264. // AddField adds the value to the field with the given name. It returns an error if
  29265. // the field is not defined in the schema, or if the type mismatched the field
  29266. // type.
  29267. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  29268. switch name {
  29269. case usagestatisticday.FieldStatus:
  29270. v, ok := value.(int8)
  29271. if !ok {
  29272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29273. }
  29274. m.AddStatus(v)
  29275. return nil
  29276. case usagestatisticday.FieldAddtime:
  29277. v, ok := value.(int64)
  29278. if !ok {
  29279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29280. }
  29281. m.AddAddtime(v)
  29282. return nil
  29283. case usagestatisticday.FieldType:
  29284. v, ok := value.(int)
  29285. if !ok {
  29286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29287. }
  29288. m.AddType(v)
  29289. return nil
  29290. case usagestatisticday.FieldOrganizationID:
  29291. v, ok := value.(int64)
  29292. if !ok {
  29293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29294. }
  29295. m.AddOrganizationID(v)
  29296. return nil
  29297. case usagestatisticday.FieldAiResponse:
  29298. v, ok := value.(int64)
  29299. if !ok {
  29300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29301. }
  29302. m.AddAiResponse(v)
  29303. return nil
  29304. case usagestatisticday.FieldSopRun:
  29305. v, ok := value.(int64)
  29306. if !ok {
  29307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29308. }
  29309. m.AddSopRun(v)
  29310. return nil
  29311. case usagestatisticday.FieldTotalFriend:
  29312. v, ok := value.(int64)
  29313. if !ok {
  29314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29315. }
  29316. m.AddTotalFriend(v)
  29317. return nil
  29318. case usagestatisticday.FieldTotalGroup:
  29319. v, ok := value.(int64)
  29320. if !ok {
  29321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29322. }
  29323. m.AddTotalGroup(v)
  29324. return nil
  29325. case usagestatisticday.FieldAccountBalance:
  29326. v, ok := value.(int64)
  29327. if !ok {
  29328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29329. }
  29330. m.AddAccountBalance(v)
  29331. return nil
  29332. case usagestatisticday.FieldConsumeToken:
  29333. v, ok := value.(int64)
  29334. if !ok {
  29335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29336. }
  29337. m.AddConsumeToken(v)
  29338. return nil
  29339. case usagestatisticday.FieldActiveUser:
  29340. v, ok := value.(int64)
  29341. if !ok {
  29342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29343. }
  29344. m.AddActiveUser(v)
  29345. return nil
  29346. case usagestatisticday.FieldNewUser:
  29347. v, ok := value.(int64)
  29348. if !ok {
  29349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29350. }
  29351. m.AddNewUser(v)
  29352. return nil
  29353. }
  29354. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  29355. }
  29356. // ClearedFields returns all nullable fields that were cleared during this
  29357. // mutation.
  29358. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  29359. var fields []string
  29360. if m.FieldCleared(usagestatisticday.FieldStatus) {
  29361. fields = append(fields, usagestatisticday.FieldStatus)
  29362. }
  29363. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  29364. fields = append(fields, usagestatisticday.FieldDeletedAt)
  29365. }
  29366. if m.FieldCleared(usagestatisticday.FieldBotID) {
  29367. fields = append(fields, usagestatisticday.FieldBotID)
  29368. }
  29369. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  29370. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29371. }
  29372. return fields
  29373. }
  29374. // FieldCleared returns a boolean indicating if a field with the given name was
  29375. // cleared in this mutation.
  29376. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  29377. _, ok := m.clearedFields[name]
  29378. return ok
  29379. }
  29380. // ClearField clears the value of the field with the given name. It returns an
  29381. // error if the field is not defined in the schema.
  29382. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  29383. switch name {
  29384. case usagestatisticday.FieldStatus:
  29385. m.ClearStatus()
  29386. return nil
  29387. case usagestatisticday.FieldDeletedAt:
  29388. m.ClearDeletedAt()
  29389. return nil
  29390. case usagestatisticday.FieldBotID:
  29391. m.ClearBotID()
  29392. return nil
  29393. case usagestatisticday.FieldOrganizationID:
  29394. m.ClearOrganizationID()
  29395. return nil
  29396. }
  29397. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  29398. }
  29399. // ResetField resets all changes in the mutation for the field with the given name.
  29400. // It returns an error if the field is not defined in the schema.
  29401. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  29402. switch name {
  29403. case usagestatisticday.FieldCreatedAt:
  29404. m.ResetCreatedAt()
  29405. return nil
  29406. case usagestatisticday.FieldUpdatedAt:
  29407. m.ResetUpdatedAt()
  29408. return nil
  29409. case usagestatisticday.FieldStatus:
  29410. m.ResetStatus()
  29411. return nil
  29412. case usagestatisticday.FieldDeletedAt:
  29413. m.ResetDeletedAt()
  29414. return nil
  29415. case usagestatisticday.FieldAddtime:
  29416. m.ResetAddtime()
  29417. return nil
  29418. case usagestatisticday.FieldType:
  29419. m.ResetType()
  29420. return nil
  29421. case usagestatisticday.FieldBotID:
  29422. m.ResetBotID()
  29423. return nil
  29424. case usagestatisticday.FieldOrganizationID:
  29425. m.ResetOrganizationID()
  29426. return nil
  29427. case usagestatisticday.FieldAiResponse:
  29428. m.ResetAiResponse()
  29429. return nil
  29430. case usagestatisticday.FieldSopRun:
  29431. m.ResetSopRun()
  29432. return nil
  29433. case usagestatisticday.FieldTotalFriend:
  29434. m.ResetTotalFriend()
  29435. return nil
  29436. case usagestatisticday.FieldTotalGroup:
  29437. m.ResetTotalGroup()
  29438. return nil
  29439. case usagestatisticday.FieldAccountBalance:
  29440. m.ResetAccountBalance()
  29441. return nil
  29442. case usagestatisticday.FieldConsumeToken:
  29443. m.ResetConsumeToken()
  29444. return nil
  29445. case usagestatisticday.FieldActiveUser:
  29446. m.ResetActiveUser()
  29447. return nil
  29448. case usagestatisticday.FieldNewUser:
  29449. m.ResetNewUser()
  29450. return nil
  29451. case usagestatisticday.FieldLabelDist:
  29452. m.ResetLabelDist()
  29453. return nil
  29454. }
  29455. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29456. }
  29457. // AddedEdges returns all edge names that were set/added in this mutation.
  29458. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  29459. edges := make([]string, 0, 0)
  29460. return edges
  29461. }
  29462. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29463. // name in this mutation.
  29464. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  29465. return nil
  29466. }
  29467. // RemovedEdges returns all edge names that were removed in this mutation.
  29468. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  29469. edges := make([]string, 0, 0)
  29470. return edges
  29471. }
  29472. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29473. // the given name in this mutation.
  29474. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  29475. return nil
  29476. }
  29477. // ClearedEdges returns all edge names that were cleared in this mutation.
  29478. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  29479. edges := make([]string, 0, 0)
  29480. return edges
  29481. }
  29482. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29483. // was cleared in this mutation.
  29484. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  29485. return false
  29486. }
  29487. // ClearEdge clears the value of the edge with the given name. It returns an error
  29488. // if that edge is not defined in the schema.
  29489. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  29490. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  29491. }
  29492. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29493. // It returns an error if the edge is not defined in the schema.
  29494. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  29495. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  29496. }
  29497. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  29498. type UsageStatisticHourMutation struct {
  29499. config
  29500. op Op
  29501. typ string
  29502. id *uint64
  29503. created_at *time.Time
  29504. updated_at *time.Time
  29505. status *uint8
  29506. addstatus *int8
  29507. deleted_at *time.Time
  29508. addtime *uint64
  29509. addaddtime *int64
  29510. _type *int
  29511. add_type *int
  29512. bot_id *string
  29513. organization_id *uint64
  29514. addorganization_id *int64
  29515. ai_response *uint64
  29516. addai_response *int64
  29517. sop_run *uint64
  29518. addsop_run *int64
  29519. total_friend *uint64
  29520. addtotal_friend *int64
  29521. total_group *uint64
  29522. addtotal_group *int64
  29523. account_balance *uint64
  29524. addaccount_balance *int64
  29525. consume_token *uint64
  29526. addconsume_token *int64
  29527. active_user *uint64
  29528. addactive_user *int64
  29529. new_user *int64
  29530. addnew_user *int64
  29531. label_dist *[]custom_types.LabelDist
  29532. appendlabel_dist []custom_types.LabelDist
  29533. clearedFields map[string]struct{}
  29534. done bool
  29535. oldValue func(context.Context) (*UsageStatisticHour, error)
  29536. predicates []predicate.UsageStatisticHour
  29537. }
  29538. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  29539. // usagestatistichourOption allows management of the mutation configuration using functional options.
  29540. type usagestatistichourOption func(*UsageStatisticHourMutation)
  29541. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  29542. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  29543. m := &UsageStatisticHourMutation{
  29544. config: c,
  29545. op: op,
  29546. typ: TypeUsageStatisticHour,
  29547. clearedFields: make(map[string]struct{}),
  29548. }
  29549. for _, opt := range opts {
  29550. opt(m)
  29551. }
  29552. return m
  29553. }
  29554. // withUsageStatisticHourID sets the ID field of the mutation.
  29555. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  29556. return func(m *UsageStatisticHourMutation) {
  29557. var (
  29558. err error
  29559. once sync.Once
  29560. value *UsageStatisticHour
  29561. )
  29562. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  29563. once.Do(func() {
  29564. if m.done {
  29565. err = errors.New("querying old values post mutation is not allowed")
  29566. } else {
  29567. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  29568. }
  29569. })
  29570. return value, err
  29571. }
  29572. m.id = &id
  29573. }
  29574. }
  29575. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  29576. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  29577. return func(m *UsageStatisticHourMutation) {
  29578. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  29579. return node, nil
  29580. }
  29581. m.id = &node.ID
  29582. }
  29583. }
  29584. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29585. // executed in a transaction (ent.Tx), a transactional client is returned.
  29586. func (m UsageStatisticHourMutation) Client() *Client {
  29587. client := &Client{config: m.config}
  29588. client.init()
  29589. return client
  29590. }
  29591. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29592. // it returns an error otherwise.
  29593. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  29594. if _, ok := m.driver.(*txDriver); !ok {
  29595. return nil, errors.New("ent: mutation is not running in a transaction")
  29596. }
  29597. tx := &Tx{config: m.config}
  29598. tx.init()
  29599. return tx, nil
  29600. }
  29601. // SetID sets the value of the id field. Note that this
  29602. // operation is only accepted on creation of UsageStatisticHour entities.
  29603. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  29604. m.id = &id
  29605. }
  29606. // ID returns the ID value in the mutation. Note that the ID is only available
  29607. // if it was provided to the builder or after it was returned from the database.
  29608. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  29609. if m.id == nil {
  29610. return
  29611. }
  29612. return *m.id, true
  29613. }
  29614. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29615. // That means, if the mutation is applied within a transaction with an isolation level such
  29616. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29617. // or updated by the mutation.
  29618. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  29619. switch {
  29620. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29621. id, exists := m.ID()
  29622. if exists {
  29623. return []uint64{id}, nil
  29624. }
  29625. fallthrough
  29626. case m.op.Is(OpUpdate | OpDelete):
  29627. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  29628. default:
  29629. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29630. }
  29631. }
  29632. // SetCreatedAt sets the "created_at" field.
  29633. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  29634. m.created_at = &t
  29635. }
  29636. // CreatedAt returns the value of the "created_at" field in the mutation.
  29637. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  29638. v := m.created_at
  29639. if v == nil {
  29640. return
  29641. }
  29642. return *v, true
  29643. }
  29644. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  29645. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29647. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29648. if !m.op.Is(OpUpdateOne) {
  29649. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29650. }
  29651. if m.id == nil || m.oldValue == nil {
  29652. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29653. }
  29654. oldValue, err := m.oldValue(ctx)
  29655. if err != nil {
  29656. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29657. }
  29658. return oldValue.CreatedAt, nil
  29659. }
  29660. // ResetCreatedAt resets all changes to the "created_at" field.
  29661. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  29662. m.created_at = nil
  29663. }
  29664. // SetUpdatedAt sets the "updated_at" field.
  29665. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  29666. m.updated_at = &t
  29667. }
  29668. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29669. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  29670. v := m.updated_at
  29671. if v == nil {
  29672. return
  29673. }
  29674. return *v, true
  29675. }
  29676. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  29677. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29679. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29680. if !m.op.Is(OpUpdateOne) {
  29681. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29682. }
  29683. if m.id == nil || m.oldValue == nil {
  29684. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29685. }
  29686. oldValue, err := m.oldValue(ctx)
  29687. if err != nil {
  29688. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29689. }
  29690. return oldValue.UpdatedAt, nil
  29691. }
  29692. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29693. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  29694. m.updated_at = nil
  29695. }
  29696. // SetStatus sets the "status" field.
  29697. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  29698. m.status = &u
  29699. m.addstatus = nil
  29700. }
  29701. // Status returns the value of the "status" field in the mutation.
  29702. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  29703. v := m.status
  29704. if v == nil {
  29705. return
  29706. }
  29707. return *v, true
  29708. }
  29709. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  29710. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29712. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29713. if !m.op.Is(OpUpdateOne) {
  29714. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29715. }
  29716. if m.id == nil || m.oldValue == nil {
  29717. return v, errors.New("OldStatus requires an ID field in the mutation")
  29718. }
  29719. oldValue, err := m.oldValue(ctx)
  29720. if err != nil {
  29721. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29722. }
  29723. return oldValue.Status, nil
  29724. }
  29725. // AddStatus adds u to the "status" field.
  29726. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  29727. if m.addstatus != nil {
  29728. *m.addstatus += u
  29729. } else {
  29730. m.addstatus = &u
  29731. }
  29732. }
  29733. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29734. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  29735. v := m.addstatus
  29736. if v == nil {
  29737. return
  29738. }
  29739. return *v, true
  29740. }
  29741. // ClearStatus clears the value of the "status" field.
  29742. func (m *UsageStatisticHourMutation) ClearStatus() {
  29743. m.status = nil
  29744. m.addstatus = nil
  29745. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  29746. }
  29747. // StatusCleared returns if the "status" field was cleared in this mutation.
  29748. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  29749. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  29750. return ok
  29751. }
  29752. // ResetStatus resets all changes to the "status" field.
  29753. func (m *UsageStatisticHourMutation) ResetStatus() {
  29754. m.status = nil
  29755. m.addstatus = nil
  29756. delete(m.clearedFields, usagestatistichour.FieldStatus)
  29757. }
  29758. // SetDeletedAt sets the "deleted_at" field.
  29759. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  29760. m.deleted_at = &t
  29761. }
  29762. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29763. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  29764. v := m.deleted_at
  29765. if v == nil {
  29766. return
  29767. }
  29768. return *v, true
  29769. }
  29770. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  29771. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29772. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29773. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29774. if !m.op.Is(OpUpdateOne) {
  29775. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29776. }
  29777. if m.id == nil || m.oldValue == nil {
  29778. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29779. }
  29780. oldValue, err := m.oldValue(ctx)
  29781. if err != nil {
  29782. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29783. }
  29784. return oldValue.DeletedAt, nil
  29785. }
  29786. // ClearDeletedAt clears the value of the "deleted_at" field.
  29787. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  29788. m.deleted_at = nil
  29789. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  29790. }
  29791. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29792. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  29793. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  29794. return ok
  29795. }
  29796. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29797. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  29798. m.deleted_at = nil
  29799. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  29800. }
  29801. // SetAddtime sets the "addtime" field.
  29802. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  29803. m.addtime = &u
  29804. m.addaddtime = nil
  29805. }
  29806. // Addtime returns the value of the "addtime" field in the mutation.
  29807. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  29808. v := m.addtime
  29809. if v == nil {
  29810. return
  29811. }
  29812. return *v, true
  29813. }
  29814. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  29815. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29817. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  29818. if !m.op.Is(OpUpdateOne) {
  29819. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  29820. }
  29821. if m.id == nil || m.oldValue == nil {
  29822. return v, errors.New("OldAddtime requires an ID field in the mutation")
  29823. }
  29824. oldValue, err := m.oldValue(ctx)
  29825. if err != nil {
  29826. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  29827. }
  29828. return oldValue.Addtime, nil
  29829. }
  29830. // AddAddtime adds u to the "addtime" field.
  29831. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  29832. if m.addaddtime != nil {
  29833. *m.addaddtime += u
  29834. } else {
  29835. m.addaddtime = &u
  29836. }
  29837. }
  29838. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  29839. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  29840. v := m.addaddtime
  29841. if v == nil {
  29842. return
  29843. }
  29844. return *v, true
  29845. }
  29846. // ResetAddtime resets all changes to the "addtime" field.
  29847. func (m *UsageStatisticHourMutation) ResetAddtime() {
  29848. m.addtime = nil
  29849. m.addaddtime = nil
  29850. }
  29851. // SetType sets the "type" field.
  29852. func (m *UsageStatisticHourMutation) SetType(i int) {
  29853. m._type = &i
  29854. m.add_type = nil
  29855. }
  29856. // GetType returns the value of the "type" field in the mutation.
  29857. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  29858. v := m._type
  29859. if v == nil {
  29860. return
  29861. }
  29862. return *v, true
  29863. }
  29864. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  29865. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29866. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29867. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  29868. if !m.op.Is(OpUpdateOne) {
  29869. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29870. }
  29871. if m.id == nil || m.oldValue == nil {
  29872. return v, errors.New("OldType requires an ID field in the mutation")
  29873. }
  29874. oldValue, err := m.oldValue(ctx)
  29875. if err != nil {
  29876. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29877. }
  29878. return oldValue.Type, nil
  29879. }
  29880. // AddType adds i to the "type" field.
  29881. func (m *UsageStatisticHourMutation) AddType(i int) {
  29882. if m.add_type != nil {
  29883. *m.add_type += i
  29884. } else {
  29885. m.add_type = &i
  29886. }
  29887. }
  29888. // AddedType returns the value that was added to the "type" field in this mutation.
  29889. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  29890. v := m.add_type
  29891. if v == nil {
  29892. return
  29893. }
  29894. return *v, true
  29895. }
  29896. // ResetType resets all changes to the "type" field.
  29897. func (m *UsageStatisticHourMutation) ResetType() {
  29898. m._type = nil
  29899. m.add_type = nil
  29900. }
  29901. // SetBotID sets the "bot_id" field.
  29902. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  29903. m.bot_id = &s
  29904. }
  29905. // BotID returns the value of the "bot_id" field in the mutation.
  29906. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  29907. v := m.bot_id
  29908. if v == nil {
  29909. return
  29910. }
  29911. return *v, true
  29912. }
  29913. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  29914. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29915. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29916. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  29917. if !m.op.Is(OpUpdateOne) {
  29918. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  29919. }
  29920. if m.id == nil || m.oldValue == nil {
  29921. return v, errors.New("OldBotID requires an ID field in the mutation")
  29922. }
  29923. oldValue, err := m.oldValue(ctx)
  29924. if err != nil {
  29925. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  29926. }
  29927. return oldValue.BotID, nil
  29928. }
  29929. // ClearBotID clears the value of the "bot_id" field.
  29930. func (m *UsageStatisticHourMutation) ClearBotID() {
  29931. m.bot_id = nil
  29932. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  29933. }
  29934. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  29935. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  29936. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  29937. return ok
  29938. }
  29939. // ResetBotID resets all changes to the "bot_id" field.
  29940. func (m *UsageStatisticHourMutation) ResetBotID() {
  29941. m.bot_id = nil
  29942. delete(m.clearedFields, usagestatistichour.FieldBotID)
  29943. }
  29944. // SetOrganizationID sets the "organization_id" field.
  29945. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  29946. m.organization_id = &u
  29947. m.addorganization_id = nil
  29948. }
  29949. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29950. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  29951. v := m.organization_id
  29952. if v == nil {
  29953. return
  29954. }
  29955. return *v, true
  29956. }
  29957. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  29958. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29960. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29961. if !m.op.Is(OpUpdateOne) {
  29962. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29963. }
  29964. if m.id == nil || m.oldValue == nil {
  29965. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29966. }
  29967. oldValue, err := m.oldValue(ctx)
  29968. if err != nil {
  29969. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29970. }
  29971. return oldValue.OrganizationID, nil
  29972. }
  29973. // AddOrganizationID adds u to the "organization_id" field.
  29974. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  29975. if m.addorganization_id != nil {
  29976. *m.addorganization_id += u
  29977. } else {
  29978. m.addorganization_id = &u
  29979. }
  29980. }
  29981. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29982. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  29983. v := m.addorganization_id
  29984. if v == nil {
  29985. return
  29986. }
  29987. return *v, true
  29988. }
  29989. // ClearOrganizationID clears the value of the "organization_id" field.
  29990. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  29991. m.organization_id = nil
  29992. m.addorganization_id = nil
  29993. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  29994. }
  29995. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  29996. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  29997. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  29998. return ok
  29999. }
  30000. // ResetOrganizationID resets all changes to the "organization_id" field.
  30001. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  30002. m.organization_id = nil
  30003. m.addorganization_id = nil
  30004. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  30005. }
  30006. // SetAiResponse sets the "ai_response" field.
  30007. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  30008. m.ai_response = &u
  30009. m.addai_response = nil
  30010. }
  30011. // AiResponse returns the value of the "ai_response" field in the mutation.
  30012. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  30013. v := m.ai_response
  30014. if v == nil {
  30015. return
  30016. }
  30017. return *v, true
  30018. }
  30019. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  30020. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30021. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30022. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  30023. if !m.op.Is(OpUpdateOne) {
  30024. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  30025. }
  30026. if m.id == nil || m.oldValue == nil {
  30027. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  30028. }
  30029. oldValue, err := m.oldValue(ctx)
  30030. if err != nil {
  30031. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  30032. }
  30033. return oldValue.AiResponse, nil
  30034. }
  30035. // AddAiResponse adds u to the "ai_response" field.
  30036. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  30037. if m.addai_response != nil {
  30038. *m.addai_response += u
  30039. } else {
  30040. m.addai_response = &u
  30041. }
  30042. }
  30043. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  30044. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  30045. v := m.addai_response
  30046. if v == nil {
  30047. return
  30048. }
  30049. return *v, true
  30050. }
  30051. // ResetAiResponse resets all changes to the "ai_response" field.
  30052. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  30053. m.ai_response = nil
  30054. m.addai_response = nil
  30055. }
  30056. // SetSopRun sets the "sop_run" field.
  30057. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  30058. m.sop_run = &u
  30059. m.addsop_run = nil
  30060. }
  30061. // SopRun returns the value of the "sop_run" field in the mutation.
  30062. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  30063. v := m.sop_run
  30064. if v == nil {
  30065. return
  30066. }
  30067. return *v, true
  30068. }
  30069. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  30070. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30072. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  30073. if !m.op.Is(OpUpdateOne) {
  30074. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  30075. }
  30076. if m.id == nil || m.oldValue == nil {
  30077. return v, errors.New("OldSopRun requires an ID field in the mutation")
  30078. }
  30079. oldValue, err := m.oldValue(ctx)
  30080. if err != nil {
  30081. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  30082. }
  30083. return oldValue.SopRun, nil
  30084. }
  30085. // AddSopRun adds u to the "sop_run" field.
  30086. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  30087. if m.addsop_run != nil {
  30088. *m.addsop_run += u
  30089. } else {
  30090. m.addsop_run = &u
  30091. }
  30092. }
  30093. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  30094. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  30095. v := m.addsop_run
  30096. if v == nil {
  30097. return
  30098. }
  30099. return *v, true
  30100. }
  30101. // ResetSopRun resets all changes to the "sop_run" field.
  30102. func (m *UsageStatisticHourMutation) ResetSopRun() {
  30103. m.sop_run = nil
  30104. m.addsop_run = nil
  30105. }
  30106. // SetTotalFriend sets the "total_friend" field.
  30107. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  30108. m.total_friend = &u
  30109. m.addtotal_friend = nil
  30110. }
  30111. // TotalFriend returns the value of the "total_friend" field in the mutation.
  30112. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  30113. v := m.total_friend
  30114. if v == nil {
  30115. return
  30116. }
  30117. return *v, true
  30118. }
  30119. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  30120. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30122. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  30123. if !m.op.Is(OpUpdateOne) {
  30124. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  30125. }
  30126. if m.id == nil || m.oldValue == nil {
  30127. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  30128. }
  30129. oldValue, err := m.oldValue(ctx)
  30130. if err != nil {
  30131. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  30132. }
  30133. return oldValue.TotalFriend, nil
  30134. }
  30135. // AddTotalFriend adds u to the "total_friend" field.
  30136. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  30137. if m.addtotal_friend != nil {
  30138. *m.addtotal_friend += u
  30139. } else {
  30140. m.addtotal_friend = &u
  30141. }
  30142. }
  30143. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  30144. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  30145. v := m.addtotal_friend
  30146. if v == nil {
  30147. return
  30148. }
  30149. return *v, true
  30150. }
  30151. // ResetTotalFriend resets all changes to the "total_friend" field.
  30152. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  30153. m.total_friend = nil
  30154. m.addtotal_friend = nil
  30155. }
  30156. // SetTotalGroup sets the "total_group" field.
  30157. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  30158. m.total_group = &u
  30159. m.addtotal_group = nil
  30160. }
  30161. // TotalGroup returns the value of the "total_group" field in the mutation.
  30162. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  30163. v := m.total_group
  30164. if v == nil {
  30165. return
  30166. }
  30167. return *v, true
  30168. }
  30169. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  30170. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30172. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  30173. if !m.op.Is(OpUpdateOne) {
  30174. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  30175. }
  30176. if m.id == nil || m.oldValue == nil {
  30177. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  30178. }
  30179. oldValue, err := m.oldValue(ctx)
  30180. if err != nil {
  30181. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  30182. }
  30183. return oldValue.TotalGroup, nil
  30184. }
  30185. // AddTotalGroup adds u to the "total_group" field.
  30186. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  30187. if m.addtotal_group != nil {
  30188. *m.addtotal_group += u
  30189. } else {
  30190. m.addtotal_group = &u
  30191. }
  30192. }
  30193. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  30194. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  30195. v := m.addtotal_group
  30196. if v == nil {
  30197. return
  30198. }
  30199. return *v, true
  30200. }
  30201. // ResetTotalGroup resets all changes to the "total_group" field.
  30202. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  30203. m.total_group = nil
  30204. m.addtotal_group = nil
  30205. }
  30206. // SetAccountBalance sets the "account_balance" field.
  30207. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  30208. m.account_balance = &u
  30209. m.addaccount_balance = nil
  30210. }
  30211. // AccountBalance returns the value of the "account_balance" field in the mutation.
  30212. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  30213. v := m.account_balance
  30214. if v == nil {
  30215. return
  30216. }
  30217. return *v, true
  30218. }
  30219. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  30220. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30222. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  30223. if !m.op.Is(OpUpdateOne) {
  30224. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  30225. }
  30226. if m.id == nil || m.oldValue == nil {
  30227. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  30228. }
  30229. oldValue, err := m.oldValue(ctx)
  30230. if err != nil {
  30231. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  30232. }
  30233. return oldValue.AccountBalance, nil
  30234. }
  30235. // AddAccountBalance adds u to the "account_balance" field.
  30236. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  30237. if m.addaccount_balance != nil {
  30238. *m.addaccount_balance += u
  30239. } else {
  30240. m.addaccount_balance = &u
  30241. }
  30242. }
  30243. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  30244. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  30245. v := m.addaccount_balance
  30246. if v == nil {
  30247. return
  30248. }
  30249. return *v, true
  30250. }
  30251. // ResetAccountBalance resets all changes to the "account_balance" field.
  30252. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  30253. m.account_balance = nil
  30254. m.addaccount_balance = nil
  30255. }
  30256. // SetConsumeToken sets the "consume_token" field.
  30257. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  30258. m.consume_token = &u
  30259. m.addconsume_token = nil
  30260. }
  30261. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  30262. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  30263. v := m.consume_token
  30264. if v == nil {
  30265. return
  30266. }
  30267. return *v, true
  30268. }
  30269. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  30270. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30272. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  30273. if !m.op.Is(OpUpdateOne) {
  30274. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  30275. }
  30276. if m.id == nil || m.oldValue == nil {
  30277. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  30278. }
  30279. oldValue, err := m.oldValue(ctx)
  30280. if err != nil {
  30281. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  30282. }
  30283. return oldValue.ConsumeToken, nil
  30284. }
  30285. // AddConsumeToken adds u to the "consume_token" field.
  30286. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  30287. if m.addconsume_token != nil {
  30288. *m.addconsume_token += u
  30289. } else {
  30290. m.addconsume_token = &u
  30291. }
  30292. }
  30293. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  30294. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  30295. v := m.addconsume_token
  30296. if v == nil {
  30297. return
  30298. }
  30299. return *v, true
  30300. }
  30301. // ResetConsumeToken resets all changes to the "consume_token" field.
  30302. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  30303. m.consume_token = nil
  30304. m.addconsume_token = nil
  30305. }
  30306. // SetActiveUser sets the "active_user" field.
  30307. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  30308. m.active_user = &u
  30309. m.addactive_user = nil
  30310. }
  30311. // ActiveUser returns the value of the "active_user" field in the mutation.
  30312. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  30313. v := m.active_user
  30314. if v == nil {
  30315. return
  30316. }
  30317. return *v, true
  30318. }
  30319. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  30320. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30322. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  30323. if !m.op.Is(OpUpdateOne) {
  30324. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  30325. }
  30326. if m.id == nil || m.oldValue == nil {
  30327. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  30328. }
  30329. oldValue, err := m.oldValue(ctx)
  30330. if err != nil {
  30331. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  30332. }
  30333. return oldValue.ActiveUser, nil
  30334. }
  30335. // AddActiveUser adds u to the "active_user" field.
  30336. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  30337. if m.addactive_user != nil {
  30338. *m.addactive_user += u
  30339. } else {
  30340. m.addactive_user = &u
  30341. }
  30342. }
  30343. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  30344. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  30345. v := m.addactive_user
  30346. if v == nil {
  30347. return
  30348. }
  30349. return *v, true
  30350. }
  30351. // ResetActiveUser resets all changes to the "active_user" field.
  30352. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  30353. m.active_user = nil
  30354. m.addactive_user = nil
  30355. }
  30356. // SetNewUser sets the "new_user" field.
  30357. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  30358. m.new_user = &i
  30359. m.addnew_user = nil
  30360. }
  30361. // NewUser returns the value of the "new_user" field in the mutation.
  30362. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  30363. v := m.new_user
  30364. if v == nil {
  30365. return
  30366. }
  30367. return *v, true
  30368. }
  30369. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  30370. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30372. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  30373. if !m.op.Is(OpUpdateOne) {
  30374. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  30375. }
  30376. if m.id == nil || m.oldValue == nil {
  30377. return v, errors.New("OldNewUser requires an ID field in the mutation")
  30378. }
  30379. oldValue, err := m.oldValue(ctx)
  30380. if err != nil {
  30381. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  30382. }
  30383. return oldValue.NewUser, nil
  30384. }
  30385. // AddNewUser adds i to the "new_user" field.
  30386. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  30387. if m.addnew_user != nil {
  30388. *m.addnew_user += i
  30389. } else {
  30390. m.addnew_user = &i
  30391. }
  30392. }
  30393. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  30394. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  30395. v := m.addnew_user
  30396. if v == nil {
  30397. return
  30398. }
  30399. return *v, true
  30400. }
  30401. // ResetNewUser resets all changes to the "new_user" field.
  30402. func (m *UsageStatisticHourMutation) ResetNewUser() {
  30403. m.new_user = nil
  30404. m.addnew_user = nil
  30405. }
  30406. // SetLabelDist sets the "label_dist" field.
  30407. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  30408. m.label_dist = &ctd
  30409. m.appendlabel_dist = nil
  30410. }
  30411. // LabelDist returns the value of the "label_dist" field in the mutation.
  30412. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  30413. v := m.label_dist
  30414. if v == nil {
  30415. return
  30416. }
  30417. return *v, true
  30418. }
  30419. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  30420. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30422. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  30423. if !m.op.Is(OpUpdateOne) {
  30424. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  30425. }
  30426. if m.id == nil || m.oldValue == nil {
  30427. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  30428. }
  30429. oldValue, err := m.oldValue(ctx)
  30430. if err != nil {
  30431. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  30432. }
  30433. return oldValue.LabelDist, nil
  30434. }
  30435. // AppendLabelDist adds ctd to the "label_dist" field.
  30436. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  30437. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  30438. }
  30439. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  30440. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  30441. if len(m.appendlabel_dist) == 0 {
  30442. return nil, false
  30443. }
  30444. return m.appendlabel_dist, true
  30445. }
  30446. // ResetLabelDist resets all changes to the "label_dist" field.
  30447. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  30448. m.label_dist = nil
  30449. m.appendlabel_dist = nil
  30450. }
  30451. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  30452. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  30453. m.predicates = append(m.predicates, ps...)
  30454. }
  30455. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  30456. // users can use type-assertion to append predicates that do not depend on any generated package.
  30457. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  30458. p := make([]predicate.UsageStatisticHour, len(ps))
  30459. for i := range ps {
  30460. p[i] = ps[i]
  30461. }
  30462. m.Where(p...)
  30463. }
  30464. // Op returns the operation name.
  30465. func (m *UsageStatisticHourMutation) Op() Op {
  30466. return m.op
  30467. }
  30468. // SetOp allows setting the mutation operation.
  30469. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  30470. m.op = op
  30471. }
  30472. // Type returns the node type of this mutation (UsageStatisticHour).
  30473. func (m *UsageStatisticHourMutation) Type() string {
  30474. return m.typ
  30475. }
  30476. // Fields returns all fields that were changed during this mutation. Note that in
  30477. // order to get all numeric fields that were incremented/decremented, call
  30478. // AddedFields().
  30479. func (m *UsageStatisticHourMutation) Fields() []string {
  30480. fields := make([]string, 0, 17)
  30481. if m.created_at != nil {
  30482. fields = append(fields, usagestatistichour.FieldCreatedAt)
  30483. }
  30484. if m.updated_at != nil {
  30485. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  30486. }
  30487. if m.status != nil {
  30488. fields = append(fields, usagestatistichour.FieldStatus)
  30489. }
  30490. if m.deleted_at != nil {
  30491. fields = append(fields, usagestatistichour.FieldDeletedAt)
  30492. }
  30493. if m.addtime != nil {
  30494. fields = append(fields, usagestatistichour.FieldAddtime)
  30495. }
  30496. if m._type != nil {
  30497. fields = append(fields, usagestatistichour.FieldType)
  30498. }
  30499. if m.bot_id != nil {
  30500. fields = append(fields, usagestatistichour.FieldBotID)
  30501. }
  30502. if m.organization_id != nil {
  30503. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30504. }
  30505. if m.ai_response != nil {
  30506. fields = append(fields, usagestatistichour.FieldAiResponse)
  30507. }
  30508. if m.sop_run != nil {
  30509. fields = append(fields, usagestatistichour.FieldSopRun)
  30510. }
  30511. if m.total_friend != nil {
  30512. fields = append(fields, usagestatistichour.FieldTotalFriend)
  30513. }
  30514. if m.total_group != nil {
  30515. fields = append(fields, usagestatistichour.FieldTotalGroup)
  30516. }
  30517. if m.account_balance != nil {
  30518. fields = append(fields, usagestatistichour.FieldAccountBalance)
  30519. }
  30520. if m.consume_token != nil {
  30521. fields = append(fields, usagestatistichour.FieldConsumeToken)
  30522. }
  30523. if m.active_user != nil {
  30524. fields = append(fields, usagestatistichour.FieldActiveUser)
  30525. }
  30526. if m.new_user != nil {
  30527. fields = append(fields, usagestatistichour.FieldNewUser)
  30528. }
  30529. if m.label_dist != nil {
  30530. fields = append(fields, usagestatistichour.FieldLabelDist)
  30531. }
  30532. return fields
  30533. }
  30534. // Field returns the value of a field with the given name. The second boolean
  30535. // return value indicates that this field was not set, or was not defined in the
  30536. // schema.
  30537. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  30538. switch name {
  30539. case usagestatistichour.FieldCreatedAt:
  30540. return m.CreatedAt()
  30541. case usagestatistichour.FieldUpdatedAt:
  30542. return m.UpdatedAt()
  30543. case usagestatistichour.FieldStatus:
  30544. return m.Status()
  30545. case usagestatistichour.FieldDeletedAt:
  30546. return m.DeletedAt()
  30547. case usagestatistichour.FieldAddtime:
  30548. return m.Addtime()
  30549. case usagestatistichour.FieldType:
  30550. return m.GetType()
  30551. case usagestatistichour.FieldBotID:
  30552. return m.BotID()
  30553. case usagestatistichour.FieldOrganizationID:
  30554. return m.OrganizationID()
  30555. case usagestatistichour.FieldAiResponse:
  30556. return m.AiResponse()
  30557. case usagestatistichour.FieldSopRun:
  30558. return m.SopRun()
  30559. case usagestatistichour.FieldTotalFriend:
  30560. return m.TotalFriend()
  30561. case usagestatistichour.FieldTotalGroup:
  30562. return m.TotalGroup()
  30563. case usagestatistichour.FieldAccountBalance:
  30564. return m.AccountBalance()
  30565. case usagestatistichour.FieldConsumeToken:
  30566. return m.ConsumeToken()
  30567. case usagestatistichour.FieldActiveUser:
  30568. return m.ActiveUser()
  30569. case usagestatistichour.FieldNewUser:
  30570. return m.NewUser()
  30571. case usagestatistichour.FieldLabelDist:
  30572. return m.LabelDist()
  30573. }
  30574. return nil, false
  30575. }
  30576. // OldField returns the old value of the field from the database. An error is
  30577. // returned if the mutation operation is not UpdateOne, or the query to the
  30578. // database failed.
  30579. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30580. switch name {
  30581. case usagestatistichour.FieldCreatedAt:
  30582. return m.OldCreatedAt(ctx)
  30583. case usagestatistichour.FieldUpdatedAt:
  30584. return m.OldUpdatedAt(ctx)
  30585. case usagestatistichour.FieldStatus:
  30586. return m.OldStatus(ctx)
  30587. case usagestatistichour.FieldDeletedAt:
  30588. return m.OldDeletedAt(ctx)
  30589. case usagestatistichour.FieldAddtime:
  30590. return m.OldAddtime(ctx)
  30591. case usagestatistichour.FieldType:
  30592. return m.OldType(ctx)
  30593. case usagestatistichour.FieldBotID:
  30594. return m.OldBotID(ctx)
  30595. case usagestatistichour.FieldOrganizationID:
  30596. return m.OldOrganizationID(ctx)
  30597. case usagestatistichour.FieldAiResponse:
  30598. return m.OldAiResponse(ctx)
  30599. case usagestatistichour.FieldSopRun:
  30600. return m.OldSopRun(ctx)
  30601. case usagestatistichour.FieldTotalFriend:
  30602. return m.OldTotalFriend(ctx)
  30603. case usagestatistichour.FieldTotalGroup:
  30604. return m.OldTotalGroup(ctx)
  30605. case usagestatistichour.FieldAccountBalance:
  30606. return m.OldAccountBalance(ctx)
  30607. case usagestatistichour.FieldConsumeToken:
  30608. return m.OldConsumeToken(ctx)
  30609. case usagestatistichour.FieldActiveUser:
  30610. return m.OldActiveUser(ctx)
  30611. case usagestatistichour.FieldNewUser:
  30612. return m.OldNewUser(ctx)
  30613. case usagestatistichour.FieldLabelDist:
  30614. return m.OldLabelDist(ctx)
  30615. }
  30616. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  30617. }
  30618. // SetField sets the value of a field with the given name. It returns an error if
  30619. // the field is not defined in the schema, or if the type mismatched the field
  30620. // type.
  30621. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  30622. switch name {
  30623. case usagestatistichour.FieldCreatedAt:
  30624. v, ok := value.(time.Time)
  30625. if !ok {
  30626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30627. }
  30628. m.SetCreatedAt(v)
  30629. return nil
  30630. case usagestatistichour.FieldUpdatedAt:
  30631. v, ok := value.(time.Time)
  30632. if !ok {
  30633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30634. }
  30635. m.SetUpdatedAt(v)
  30636. return nil
  30637. case usagestatistichour.FieldStatus:
  30638. v, ok := value.(uint8)
  30639. if !ok {
  30640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30641. }
  30642. m.SetStatus(v)
  30643. return nil
  30644. case usagestatistichour.FieldDeletedAt:
  30645. v, ok := value.(time.Time)
  30646. if !ok {
  30647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30648. }
  30649. m.SetDeletedAt(v)
  30650. return nil
  30651. case usagestatistichour.FieldAddtime:
  30652. v, ok := value.(uint64)
  30653. if !ok {
  30654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30655. }
  30656. m.SetAddtime(v)
  30657. return nil
  30658. case usagestatistichour.FieldType:
  30659. v, ok := value.(int)
  30660. if !ok {
  30661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30662. }
  30663. m.SetType(v)
  30664. return nil
  30665. case usagestatistichour.FieldBotID:
  30666. v, ok := value.(string)
  30667. if !ok {
  30668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30669. }
  30670. m.SetBotID(v)
  30671. return nil
  30672. case usagestatistichour.FieldOrganizationID:
  30673. v, ok := value.(uint64)
  30674. if !ok {
  30675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30676. }
  30677. m.SetOrganizationID(v)
  30678. return nil
  30679. case usagestatistichour.FieldAiResponse:
  30680. v, ok := value.(uint64)
  30681. if !ok {
  30682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30683. }
  30684. m.SetAiResponse(v)
  30685. return nil
  30686. case usagestatistichour.FieldSopRun:
  30687. v, ok := value.(uint64)
  30688. if !ok {
  30689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30690. }
  30691. m.SetSopRun(v)
  30692. return nil
  30693. case usagestatistichour.FieldTotalFriend:
  30694. v, ok := value.(uint64)
  30695. if !ok {
  30696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30697. }
  30698. m.SetTotalFriend(v)
  30699. return nil
  30700. case usagestatistichour.FieldTotalGroup:
  30701. v, ok := value.(uint64)
  30702. if !ok {
  30703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30704. }
  30705. m.SetTotalGroup(v)
  30706. return nil
  30707. case usagestatistichour.FieldAccountBalance:
  30708. v, ok := value.(uint64)
  30709. if !ok {
  30710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30711. }
  30712. m.SetAccountBalance(v)
  30713. return nil
  30714. case usagestatistichour.FieldConsumeToken:
  30715. v, ok := value.(uint64)
  30716. if !ok {
  30717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30718. }
  30719. m.SetConsumeToken(v)
  30720. return nil
  30721. case usagestatistichour.FieldActiveUser:
  30722. v, ok := value.(uint64)
  30723. if !ok {
  30724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30725. }
  30726. m.SetActiveUser(v)
  30727. return nil
  30728. case usagestatistichour.FieldNewUser:
  30729. v, ok := value.(int64)
  30730. if !ok {
  30731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30732. }
  30733. m.SetNewUser(v)
  30734. return nil
  30735. case usagestatistichour.FieldLabelDist:
  30736. v, ok := value.([]custom_types.LabelDist)
  30737. if !ok {
  30738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30739. }
  30740. m.SetLabelDist(v)
  30741. return nil
  30742. }
  30743. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  30744. }
  30745. // AddedFields returns all numeric fields that were incremented/decremented during
  30746. // this mutation.
  30747. func (m *UsageStatisticHourMutation) AddedFields() []string {
  30748. var fields []string
  30749. if m.addstatus != nil {
  30750. fields = append(fields, usagestatistichour.FieldStatus)
  30751. }
  30752. if m.addaddtime != nil {
  30753. fields = append(fields, usagestatistichour.FieldAddtime)
  30754. }
  30755. if m.add_type != nil {
  30756. fields = append(fields, usagestatistichour.FieldType)
  30757. }
  30758. if m.addorganization_id != nil {
  30759. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30760. }
  30761. if m.addai_response != nil {
  30762. fields = append(fields, usagestatistichour.FieldAiResponse)
  30763. }
  30764. if m.addsop_run != nil {
  30765. fields = append(fields, usagestatistichour.FieldSopRun)
  30766. }
  30767. if m.addtotal_friend != nil {
  30768. fields = append(fields, usagestatistichour.FieldTotalFriend)
  30769. }
  30770. if m.addtotal_group != nil {
  30771. fields = append(fields, usagestatistichour.FieldTotalGroup)
  30772. }
  30773. if m.addaccount_balance != nil {
  30774. fields = append(fields, usagestatistichour.FieldAccountBalance)
  30775. }
  30776. if m.addconsume_token != nil {
  30777. fields = append(fields, usagestatistichour.FieldConsumeToken)
  30778. }
  30779. if m.addactive_user != nil {
  30780. fields = append(fields, usagestatistichour.FieldActiveUser)
  30781. }
  30782. if m.addnew_user != nil {
  30783. fields = append(fields, usagestatistichour.FieldNewUser)
  30784. }
  30785. return fields
  30786. }
  30787. // AddedField returns the numeric value that was incremented/decremented on a field
  30788. // with the given name. The second boolean return value indicates that this field
  30789. // was not set, or was not defined in the schema.
  30790. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  30791. switch name {
  30792. case usagestatistichour.FieldStatus:
  30793. return m.AddedStatus()
  30794. case usagestatistichour.FieldAddtime:
  30795. return m.AddedAddtime()
  30796. case usagestatistichour.FieldType:
  30797. return m.AddedType()
  30798. case usagestatistichour.FieldOrganizationID:
  30799. return m.AddedOrganizationID()
  30800. case usagestatistichour.FieldAiResponse:
  30801. return m.AddedAiResponse()
  30802. case usagestatistichour.FieldSopRun:
  30803. return m.AddedSopRun()
  30804. case usagestatistichour.FieldTotalFriend:
  30805. return m.AddedTotalFriend()
  30806. case usagestatistichour.FieldTotalGroup:
  30807. return m.AddedTotalGroup()
  30808. case usagestatistichour.FieldAccountBalance:
  30809. return m.AddedAccountBalance()
  30810. case usagestatistichour.FieldConsumeToken:
  30811. return m.AddedConsumeToken()
  30812. case usagestatistichour.FieldActiveUser:
  30813. return m.AddedActiveUser()
  30814. case usagestatistichour.FieldNewUser:
  30815. return m.AddedNewUser()
  30816. }
  30817. return nil, false
  30818. }
  30819. // AddField adds the value to the field with the given name. It returns an error if
  30820. // the field is not defined in the schema, or if the type mismatched the field
  30821. // type.
  30822. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  30823. switch name {
  30824. case usagestatistichour.FieldStatus:
  30825. v, ok := value.(int8)
  30826. if !ok {
  30827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30828. }
  30829. m.AddStatus(v)
  30830. return nil
  30831. case usagestatistichour.FieldAddtime:
  30832. v, ok := value.(int64)
  30833. if !ok {
  30834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30835. }
  30836. m.AddAddtime(v)
  30837. return nil
  30838. case usagestatistichour.FieldType:
  30839. v, ok := value.(int)
  30840. if !ok {
  30841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30842. }
  30843. m.AddType(v)
  30844. return nil
  30845. case usagestatistichour.FieldOrganizationID:
  30846. v, ok := value.(int64)
  30847. if !ok {
  30848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30849. }
  30850. m.AddOrganizationID(v)
  30851. return nil
  30852. case usagestatistichour.FieldAiResponse:
  30853. v, ok := value.(int64)
  30854. if !ok {
  30855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30856. }
  30857. m.AddAiResponse(v)
  30858. return nil
  30859. case usagestatistichour.FieldSopRun:
  30860. v, ok := value.(int64)
  30861. if !ok {
  30862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30863. }
  30864. m.AddSopRun(v)
  30865. return nil
  30866. case usagestatistichour.FieldTotalFriend:
  30867. v, ok := value.(int64)
  30868. if !ok {
  30869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30870. }
  30871. m.AddTotalFriend(v)
  30872. return nil
  30873. case usagestatistichour.FieldTotalGroup:
  30874. v, ok := value.(int64)
  30875. if !ok {
  30876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30877. }
  30878. m.AddTotalGroup(v)
  30879. return nil
  30880. case usagestatistichour.FieldAccountBalance:
  30881. v, ok := value.(int64)
  30882. if !ok {
  30883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30884. }
  30885. m.AddAccountBalance(v)
  30886. return nil
  30887. case usagestatistichour.FieldConsumeToken:
  30888. v, ok := value.(int64)
  30889. if !ok {
  30890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30891. }
  30892. m.AddConsumeToken(v)
  30893. return nil
  30894. case usagestatistichour.FieldActiveUser:
  30895. v, ok := value.(int64)
  30896. if !ok {
  30897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30898. }
  30899. m.AddActiveUser(v)
  30900. return nil
  30901. case usagestatistichour.FieldNewUser:
  30902. v, ok := value.(int64)
  30903. if !ok {
  30904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30905. }
  30906. m.AddNewUser(v)
  30907. return nil
  30908. }
  30909. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  30910. }
  30911. // ClearedFields returns all nullable fields that were cleared during this
  30912. // mutation.
  30913. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  30914. var fields []string
  30915. if m.FieldCleared(usagestatistichour.FieldStatus) {
  30916. fields = append(fields, usagestatistichour.FieldStatus)
  30917. }
  30918. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  30919. fields = append(fields, usagestatistichour.FieldDeletedAt)
  30920. }
  30921. if m.FieldCleared(usagestatistichour.FieldBotID) {
  30922. fields = append(fields, usagestatistichour.FieldBotID)
  30923. }
  30924. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  30925. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30926. }
  30927. return fields
  30928. }
  30929. // FieldCleared returns a boolean indicating if a field with the given name was
  30930. // cleared in this mutation.
  30931. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  30932. _, ok := m.clearedFields[name]
  30933. return ok
  30934. }
  30935. // ClearField clears the value of the field with the given name. It returns an
  30936. // error if the field is not defined in the schema.
  30937. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  30938. switch name {
  30939. case usagestatistichour.FieldStatus:
  30940. m.ClearStatus()
  30941. return nil
  30942. case usagestatistichour.FieldDeletedAt:
  30943. m.ClearDeletedAt()
  30944. return nil
  30945. case usagestatistichour.FieldBotID:
  30946. m.ClearBotID()
  30947. return nil
  30948. case usagestatistichour.FieldOrganizationID:
  30949. m.ClearOrganizationID()
  30950. return nil
  30951. }
  30952. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  30953. }
  30954. // ResetField resets all changes in the mutation for the field with the given name.
  30955. // It returns an error if the field is not defined in the schema.
  30956. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  30957. switch name {
  30958. case usagestatistichour.FieldCreatedAt:
  30959. m.ResetCreatedAt()
  30960. return nil
  30961. case usagestatistichour.FieldUpdatedAt:
  30962. m.ResetUpdatedAt()
  30963. return nil
  30964. case usagestatistichour.FieldStatus:
  30965. m.ResetStatus()
  30966. return nil
  30967. case usagestatistichour.FieldDeletedAt:
  30968. m.ResetDeletedAt()
  30969. return nil
  30970. case usagestatistichour.FieldAddtime:
  30971. m.ResetAddtime()
  30972. return nil
  30973. case usagestatistichour.FieldType:
  30974. m.ResetType()
  30975. return nil
  30976. case usagestatistichour.FieldBotID:
  30977. m.ResetBotID()
  30978. return nil
  30979. case usagestatistichour.FieldOrganizationID:
  30980. m.ResetOrganizationID()
  30981. return nil
  30982. case usagestatistichour.FieldAiResponse:
  30983. m.ResetAiResponse()
  30984. return nil
  30985. case usagestatistichour.FieldSopRun:
  30986. m.ResetSopRun()
  30987. return nil
  30988. case usagestatistichour.FieldTotalFriend:
  30989. m.ResetTotalFriend()
  30990. return nil
  30991. case usagestatistichour.FieldTotalGroup:
  30992. m.ResetTotalGroup()
  30993. return nil
  30994. case usagestatistichour.FieldAccountBalance:
  30995. m.ResetAccountBalance()
  30996. return nil
  30997. case usagestatistichour.FieldConsumeToken:
  30998. m.ResetConsumeToken()
  30999. return nil
  31000. case usagestatistichour.FieldActiveUser:
  31001. m.ResetActiveUser()
  31002. return nil
  31003. case usagestatistichour.FieldNewUser:
  31004. m.ResetNewUser()
  31005. return nil
  31006. case usagestatistichour.FieldLabelDist:
  31007. m.ResetLabelDist()
  31008. return nil
  31009. }
  31010. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  31011. }
  31012. // AddedEdges returns all edge names that were set/added in this mutation.
  31013. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  31014. edges := make([]string, 0, 0)
  31015. return edges
  31016. }
  31017. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31018. // name in this mutation.
  31019. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  31020. return nil
  31021. }
  31022. // RemovedEdges returns all edge names that were removed in this mutation.
  31023. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  31024. edges := make([]string, 0, 0)
  31025. return edges
  31026. }
  31027. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31028. // the given name in this mutation.
  31029. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  31030. return nil
  31031. }
  31032. // ClearedEdges returns all edge names that were cleared in this mutation.
  31033. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  31034. edges := make([]string, 0, 0)
  31035. return edges
  31036. }
  31037. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31038. // was cleared in this mutation.
  31039. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  31040. return false
  31041. }
  31042. // ClearEdge clears the value of the edge with the given name. It returns an error
  31043. // if that edge is not defined in the schema.
  31044. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  31045. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  31046. }
  31047. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31048. // It returns an error if the edge is not defined in the schema.
  31049. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  31050. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  31051. }
  31052. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  31053. type UsageStatisticMonthMutation struct {
  31054. config
  31055. op Op
  31056. typ string
  31057. id *uint64
  31058. created_at *time.Time
  31059. updated_at *time.Time
  31060. status *uint8
  31061. addstatus *int8
  31062. deleted_at *time.Time
  31063. addtime *uint64
  31064. addaddtime *int64
  31065. _type *int
  31066. add_type *int
  31067. bot_id *string
  31068. organization_id *uint64
  31069. addorganization_id *int64
  31070. ai_response *uint64
  31071. addai_response *int64
  31072. sop_run *uint64
  31073. addsop_run *int64
  31074. total_friend *uint64
  31075. addtotal_friend *int64
  31076. total_group *uint64
  31077. addtotal_group *int64
  31078. account_balance *uint64
  31079. addaccount_balance *int64
  31080. consume_token *uint64
  31081. addconsume_token *int64
  31082. active_user *uint64
  31083. addactive_user *int64
  31084. new_user *int64
  31085. addnew_user *int64
  31086. label_dist *[]custom_types.LabelDist
  31087. appendlabel_dist []custom_types.LabelDist
  31088. clearedFields map[string]struct{}
  31089. done bool
  31090. oldValue func(context.Context) (*UsageStatisticMonth, error)
  31091. predicates []predicate.UsageStatisticMonth
  31092. }
  31093. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  31094. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  31095. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  31096. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  31097. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  31098. m := &UsageStatisticMonthMutation{
  31099. config: c,
  31100. op: op,
  31101. typ: TypeUsageStatisticMonth,
  31102. clearedFields: make(map[string]struct{}),
  31103. }
  31104. for _, opt := range opts {
  31105. opt(m)
  31106. }
  31107. return m
  31108. }
  31109. // withUsageStatisticMonthID sets the ID field of the mutation.
  31110. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  31111. return func(m *UsageStatisticMonthMutation) {
  31112. var (
  31113. err error
  31114. once sync.Once
  31115. value *UsageStatisticMonth
  31116. )
  31117. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  31118. once.Do(func() {
  31119. if m.done {
  31120. err = errors.New("querying old values post mutation is not allowed")
  31121. } else {
  31122. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  31123. }
  31124. })
  31125. return value, err
  31126. }
  31127. m.id = &id
  31128. }
  31129. }
  31130. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  31131. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  31132. return func(m *UsageStatisticMonthMutation) {
  31133. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  31134. return node, nil
  31135. }
  31136. m.id = &node.ID
  31137. }
  31138. }
  31139. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31140. // executed in a transaction (ent.Tx), a transactional client is returned.
  31141. func (m UsageStatisticMonthMutation) Client() *Client {
  31142. client := &Client{config: m.config}
  31143. client.init()
  31144. return client
  31145. }
  31146. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31147. // it returns an error otherwise.
  31148. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  31149. if _, ok := m.driver.(*txDriver); !ok {
  31150. return nil, errors.New("ent: mutation is not running in a transaction")
  31151. }
  31152. tx := &Tx{config: m.config}
  31153. tx.init()
  31154. return tx, nil
  31155. }
  31156. // SetID sets the value of the id field. Note that this
  31157. // operation is only accepted on creation of UsageStatisticMonth entities.
  31158. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  31159. m.id = &id
  31160. }
  31161. // ID returns the ID value in the mutation. Note that the ID is only available
  31162. // if it was provided to the builder or after it was returned from the database.
  31163. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  31164. if m.id == nil {
  31165. return
  31166. }
  31167. return *m.id, true
  31168. }
  31169. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31170. // That means, if the mutation is applied within a transaction with an isolation level such
  31171. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31172. // or updated by the mutation.
  31173. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  31174. switch {
  31175. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31176. id, exists := m.ID()
  31177. if exists {
  31178. return []uint64{id}, nil
  31179. }
  31180. fallthrough
  31181. case m.op.Is(OpUpdate | OpDelete):
  31182. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  31183. default:
  31184. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31185. }
  31186. }
  31187. // SetCreatedAt sets the "created_at" field.
  31188. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  31189. m.created_at = &t
  31190. }
  31191. // CreatedAt returns the value of the "created_at" field in the mutation.
  31192. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  31193. v := m.created_at
  31194. if v == nil {
  31195. return
  31196. }
  31197. return *v, true
  31198. }
  31199. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  31200. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31202. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31203. if !m.op.Is(OpUpdateOne) {
  31204. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31205. }
  31206. if m.id == nil || m.oldValue == nil {
  31207. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31208. }
  31209. oldValue, err := m.oldValue(ctx)
  31210. if err != nil {
  31211. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31212. }
  31213. return oldValue.CreatedAt, nil
  31214. }
  31215. // ResetCreatedAt resets all changes to the "created_at" field.
  31216. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  31217. m.created_at = nil
  31218. }
  31219. // SetUpdatedAt sets the "updated_at" field.
  31220. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  31221. m.updated_at = &t
  31222. }
  31223. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31224. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  31225. v := m.updated_at
  31226. if v == nil {
  31227. return
  31228. }
  31229. return *v, true
  31230. }
  31231. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  31232. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31234. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31235. if !m.op.Is(OpUpdateOne) {
  31236. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31237. }
  31238. if m.id == nil || m.oldValue == nil {
  31239. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31240. }
  31241. oldValue, err := m.oldValue(ctx)
  31242. if err != nil {
  31243. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31244. }
  31245. return oldValue.UpdatedAt, nil
  31246. }
  31247. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31248. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  31249. m.updated_at = nil
  31250. }
  31251. // SetStatus sets the "status" field.
  31252. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  31253. m.status = &u
  31254. m.addstatus = nil
  31255. }
  31256. // Status returns the value of the "status" field in the mutation.
  31257. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  31258. v := m.status
  31259. if v == nil {
  31260. return
  31261. }
  31262. return *v, true
  31263. }
  31264. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  31265. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31267. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31268. if !m.op.Is(OpUpdateOne) {
  31269. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31270. }
  31271. if m.id == nil || m.oldValue == nil {
  31272. return v, errors.New("OldStatus requires an ID field in the mutation")
  31273. }
  31274. oldValue, err := m.oldValue(ctx)
  31275. if err != nil {
  31276. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31277. }
  31278. return oldValue.Status, nil
  31279. }
  31280. // AddStatus adds u to the "status" field.
  31281. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  31282. if m.addstatus != nil {
  31283. *m.addstatus += u
  31284. } else {
  31285. m.addstatus = &u
  31286. }
  31287. }
  31288. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31289. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  31290. v := m.addstatus
  31291. if v == nil {
  31292. return
  31293. }
  31294. return *v, true
  31295. }
  31296. // ClearStatus clears the value of the "status" field.
  31297. func (m *UsageStatisticMonthMutation) ClearStatus() {
  31298. m.status = nil
  31299. m.addstatus = nil
  31300. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  31301. }
  31302. // StatusCleared returns if the "status" field was cleared in this mutation.
  31303. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  31304. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  31305. return ok
  31306. }
  31307. // ResetStatus resets all changes to the "status" field.
  31308. func (m *UsageStatisticMonthMutation) ResetStatus() {
  31309. m.status = nil
  31310. m.addstatus = nil
  31311. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  31312. }
  31313. // SetDeletedAt sets the "deleted_at" field.
  31314. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  31315. m.deleted_at = &t
  31316. }
  31317. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31318. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  31319. v := m.deleted_at
  31320. if v == nil {
  31321. return
  31322. }
  31323. return *v, true
  31324. }
  31325. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  31326. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31328. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31329. if !m.op.Is(OpUpdateOne) {
  31330. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31331. }
  31332. if m.id == nil || m.oldValue == nil {
  31333. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31334. }
  31335. oldValue, err := m.oldValue(ctx)
  31336. if err != nil {
  31337. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31338. }
  31339. return oldValue.DeletedAt, nil
  31340. }
  31341. // ClearDeletedAt clears the value of the "deleted_at" field.
  31342. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  31343. m.deleted_at = nil
  31344. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  31345. }
  31346. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31347. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  31348. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  31349. return ok
  31350. }
  31351. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31352. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  31353. m.deleted_at = nil
  31354. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  31355. }
  31356. // SetAddtime sets the "addtime" field.
  31357. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  31358. m.addtime = &u
  31359. m.addaddtime = nil
  31360. }
  31361. // Addtime returns the value of the "addtime" field in the mutation.
  31362. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  31363. v := m.addtime
  31364. if v == nil {
  31365. return
  31366. }
  31367. return *v, true
  31368. }
  31369. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  31370. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31372. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  31373. if !m.op.Is(OpUpdateOne) {
  31374. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  31375. }
  31376. if m.id == nil || m.oldValue == nil {
  31377. return v, errors.New("OldAddtime requires an ID field in the mutation")
  31378. }
  31379. oldValue, err := m.oldValue(ctx)
  31380. if err != nil {
  31381. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  31382. }
  31383. return oldValue.Addtime, nil
  31384. }
  31385. // AddAddtime adds u to the "addtime" field.
  31386. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  31387. if m.addaddtime != nil {
  31388. *m.addaddtime += u
  31389. } else {
  31390. m.addaddtime = &u
  31391. }
  31392. }
  31393. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  31394. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  31395. v := m.addaddtime
  31396. if v == nil {
  31397. return
  31398. }
  31399. return *v, true
  31400. }
  31401. // ResetAddtime resets all changes to the "addtime" field.
  31402. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  31403. m.addtime = nil
  31404. m.addaddtime = nil
  31405. }
  31406. // SetType sets the "type" field.
  31407. func (m *UsageStatisticMonthMutation) SetType(i int) {
  31408. m._type = &i
  31409. m.add_type = nil
  31410. }
  31411. // GetType returns the value of the "type" field in the mutation.
  31412. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  31413. v := m._type
  31414. if v == nil {
  31415. return
  31416. }
  31417. return *v, true
  31418. }
  31419. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  31420. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31422. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  31423. if !m.op.Is(OpUpdateOne) {
  31424. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31425. }
  31426. if m.id == nil || m.oldValue == nil {
  31427. return v, errors.New("OldType requires an ID field in the mutation")
  31428. }
  31429. oldValue, err := m.oldValue(ctx)
  31430. if err != nil {
  31431. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31432. }
  31433. return oldValue.Type, nil
  31434. }
  31435. // AddType adds i to the "type" field.
  31436. func (m *UsageStatisticMonthMutation) AddType(i int) {
  31437. if m.add_type != nil {
  31438. *m.add_type += i
  31439. } else {
  31440. m.add_type = &i
  31441. }
  31442. }
  31443. // AddedType returns the value that was added to the "type" field in this mutation.
  31444. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  31445. v := m.add_type
  31446. if v == nil {
  31447. return
  31448. }
  31449. return *v, true
  31450. }
  31451. // ResetType resets all changes to the "type" field.
  31452. func (m *UsageStatisticMonthMutation) ResetType() {
  31453. m._type = nil
  31454. m.add_type = nil
  31455. }
  31456. // SetBotID sets the "bot_id" field.
  31457. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  31458. m.bot_id = &s
  31459. }
  31460. // BotID returns the value of the "bot_id" field in the mutation.
  31461. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  31462. v := m.bot_id
  31463. if v == nil {
  31464. return
  31465. }
  31466. return *v, true
  31467. }
  31468. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  31469. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31470. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31471. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  31472. if !m.op.Is(OpUpdateOne) {
  31473. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31474. }
  31475. if m.id == nil || m.oldValue == nil {
  31476. return v, errors.New("OldBotID requires an ID field in the mutation")
  31477. }
  31478. oldValue, err := m.oldValue(ctx)
  31479. if err != nil {
  31480. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31481. }
  31482. return oldValue.BotID, nil
  31483. }
  31484. // ClearBotID clears the value of the "bot_id" field.
  31485. func (m *UsageStatisticMonthMutation) ClearBotID() {
  31486. m.bot_id = nil
  31487. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  31488. }
  31489. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  31490. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  31491. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  31492. return ok
  31493. }
  31494. // ResetBotID resets all changes to the "bot_id" field.
  31495. func (m *UsageStatisticMonthMutation) ResetBotID() {
  31496. m.bot_id = nil
  31497. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  31498. }
  31499. // SetOrganizationID sets the "organization_id" field.
  31500. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  31501. m.organization_id = &u
  31502. m.addorganization_id = nil
  31503. }
  31504. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31505. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  31506. v := m.organization_id
  31507. if v == nil {
  31508. return
  31509. }
  31510. return *v, true
  31511. }
  31512. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  31513. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31515. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31516. if !m.op.Is(OpUpdateOne) {
  31517. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31518. }
  31519. if m.id == nil || m.oldValue == nil {
  31520. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31521. }
  31522. oldValue, err := m.oldValue(ctx)
  31523. if err != nil {
  31524. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31525. }
  31526. return oldValue.OrganizationID, nil
  31527. }
  31528. // AddOrganizationID adds u to the "organization_id" field.
  31529. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  31530. if m.addorganization_id != nil {
  31531. *m.addorganization_id += u
  31532. } else {
  31533. m.addorganization_id = &u
  31534. }
  31535. }
  31536. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31537. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  31538. v := m.addorganization_id
  31539. if v == nil {
  31540. return
  31541. }
  31542. return *v, true
  31543. }
  31544. // ClearOrganizationID clears the value of the "organization_id" field.
  31545. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  31546. m.organization_id = nil
  31547. m.addorganization_id = nil
  31548. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  31549. }
  31550. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31551. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  31552. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  31553. return ok
  31554. }
  31555. // ResetOrganizationID resets all changes to the "organization_id" field.
  31556. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  31557. m.organization_id = nil
  31558. m.addorganization_id = nil
  31559. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  31560. }
  31561. // SetAiResponse sets the "ai_response" field.
  31562. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  31563. m.ai_response = &u
  31564. m.addai_response = nil
  31565. }
  31566. // AiResponse returns the value of the "ai_response" field in the mutation.
  31567. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  31568. v := m.ai_response
  31569. if v == nil {
  31570. return
  31571. }
  31572. return *v, true
  31573. }
  31574. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  31575. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31577. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  31578. if !m.op.Is(OpUpdateOne) {
  31579. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  31580. }
  31581. if m.id == nil || m.oldValue == nil {
  31582. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  31583. }
  31584. oldValue, err := m.oldValue(ctx)
  31585. if err != nil {
  31586. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  31587. }
  31588. return oldValue.AiResponse, nil
  31589. }
  31590. // AddAiResponse adds u to the "ai_response" field.
  31591. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  31592. if m.addai_response != nil {
  31593. *m.addai_response += u
  31594. } else {
  31595. m.addai_response = &u
  31596. }
  31597. }
  31598. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  31599. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  31600. v := m.addai_response
  31601. if v == nil {
  31602. return
  31603. }
  31604. return *v, true
  31605. }
  31606. // ResetAiResponse resets all changes to the "ai_response" field.
  31607. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  31608. m.ai_response = nil
  31609. m.addai_response = nil
  31610. }
  31611. // SetSopRun sets the "sop_run" field.
  31612. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  31613. m.sop_run = &u
  31614. m.addsop_run = nil
  31615. }
  31616. // SopRun returns the value of the "sop_run" field in the mutation.
  31617. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  31618. v := m.sop_run
  31619. if v == nil {
  31620. return
  31621. }
  31622. return *v, true
  31623. }
  31624. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  31625. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31626. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31627. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  31628. if !m.op.Is(OpUpdateOne) {
  31629. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  31630. }
  31631. if m.id == nil || m.oldValue == nil {
  31632. return v, errors.New("OldSopRun requires an ID field in the mutation")
  31633. }
  31634. oldValue, err := m.oldValue(ctx)
  31635. if err != nil {
  31636. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  31637. }
  31638. return oldValue.SopRun, nil
  31639. }
  31640. // AddSopRun adds u to the "sop_run" field.
  31641. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  31642. if m.addsop_run != nil {
  31643. *m.addsop_run += u
  31644. } else {
  31645. m.addsop_run = &u
  31646. }
  31647. }
  31648. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  31649. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  31650. v := m.addsop_run
  31651. if v == nil {
  31652. return
  31653. }
  31654. return *v, true
  31655. }
  31656. // ResetSopRun resets all changes to the "sop_run" field.
  31657. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  31658. m.sop_run = nil
  31659. m.addsop_run = nil
  31660. }
  31661. // SetTotalFriend sets the "total_friend" field.
  31662. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  31663. m.total_friend = &u
  31664. m.addtotal_friend = nil
  31665. }
  31666. // TotalFriend returns the value of the "total_friend" field in the mutation.
  31667. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  31668. v := m.total_friend
  31669. if v == nil {
  31670. return
  31671. }
  31672. return *v, true
  31673. }
  31674. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  31675. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31677. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  31678. if !m.op.Is(OpUpdateOne) {
  31679. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  31680. }
  31681. if m.id == nil || m.oldValue == nil {
  31682. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  31683. }
  31684. oldValue, err := m.oldValue(ctx)
  31685. if err != nil {
  31686. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  31687. }
  31688. return oldValue.TotalFriend, nil
  31689. }
  31690. // AddTotalFriend adds u to the "total_friend" field.
  31691. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  31692. if m.addtotal_friend != nil {
  31693. *m.addtotal_friend += u
  31694. } else {
  31695. m.addtotal_friend = &u
  31696. }
  31697. }
  31698. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  31699. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  31700. v := m.addtotal_friend
  31701. if v == nil {
  31702. return
  31703. }
  31704. return *v, true
  31705. }
  31706. // ResetTotalFriend resets all changes to the "total_friend" field.
  31707. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  31708. m.total_friend = nil
  31709. m.addtotal_friend = nil
  31710. }
  31711. // SetTotalGroup sets the "total_group" field.
  31712. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  31713. m.total_group = &u
  31714. m.addtotal_group = nil
  31715. }
  31716. // TotalGroup returns the value of the "total_group" field in the mutation.
  31717. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  31718. v := m.total_group
  31719. if v == nil {
  31720. return
  31721. }
  31722. return *v, true
  31723. }
  31724. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  31725. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31727. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  31728. if !m.op.Is(OpUpdateOne) {
  31729. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  31730. }
  31731. if m.id == nil || m.oldValue == nil {
  31732. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  31733. }
  31734. oldValue, err := m.oldValue(ctx)
  31735. if err != nil {
  31736. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  31737. }
  31738. return oldValue.TotalGroup, nil
  31739. }
  31740. // AddTotalGroup adds u to the "total_group" field.
  31741. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  31742. if m.addtotal_group != nil {
  31743. *m.addtotal_group += u
  31744. } else {
  31745. m.addtotal_group = &u
  31746. }
  31747. }
  31748. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  31749. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  31750. v := m.addtotal_group
  31751. if v == nil {
  31752. return
  31753. }
  31754. return *v, true
  31755. }
  31756. // ResetTotalGroup resets all changes to the "total_group" field.
  31757. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  31758. m.total_group = nil
  31759. m.addtotal_group = nil
  31760. }
  31761. // SetAccountBalance sets the "account_balance" field.
  31762. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  31763. m.account_balance = &u
  31764. m.addaccount_balance = nil
  31765. }
  31766. // AccountBalance returns the value of the "account_balance" field in the mutation.
  31767. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  31768. v := m.account_balance
  31769. if v == nil {
  31770. return
  31771. }
  31772. return *v, true
  31773. }
  31774. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  31775. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31776. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31777. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  31778. if !m.op.Is(OpUpdateOne) {
  31779. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  31780. }
  31781. if m.id == nil || m.oldValue == nil {
  31782. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  31783. }
  31784. oldValue, err := m.oldValue(ctx)
  31785. if err != nil {
  31786. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  31787. }
  31788. return oldValue.AccountBalance, nil
  31789. }
  31790. // AddAccountBalance adds u to the "account_balance" field.
  31791. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  31792. if m.addaccount_balance != nil {
  31793. *m.addaccount_balance += u
  31794. } else {
  31795. m.addaccount_balance = &u
  31796. }
  31797. }
  31798. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  31799. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  31800. v := m.addaccount_balance
  31801. if v == nil {
  31802. return
  31803. }
  31804. return *v, true
  31805. }
  31806. // ResetAccountBalance resets all changes to the "account_balance" field.
  31807. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  31808. m.account_balance = nil
  31809. m.addaccount_balance = nil
  31810. }
  31811. // SetConsumeToken sets the "consume_token" field.
  31812. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  31813. m.consume_token = &u
  31814. m.addconsume_token = nil
  31815. }
  31816. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  31817. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  31818. v := m.consume_token
  31819. if v == nil {
  31820. return
  31821. }
  31822. return *v, true
  31823. }
  31824. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  31825. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31826. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31827. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31828. if !m.op.Is(OpUpdateOne) {
  31829. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31830. }
  31831. if m.id == nil || m.oldValue == nil {
  31832. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31833. }
  31834. oldValue, err := m.oldValue(ctx)
  31835. if err != nil {
  31836. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31837. }
  31838. return oldValue.ConsumeToken, nil
  31839. }
  31840. // AddConsumeToken adds u to the "consume_token" field.
  31841. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  31842. if m.addconsume_token != nil {
  31843. *m.addconsume_token += u
  31844. } else {
  31845. m.addconsume_token = &u
  31846. }
  31847. }
  31848. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31849. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  31850. v := m.addconsume_token
  31851. if v == nil {
  31852. return
  31853. }
  31854. return *v, true
  31855. }
  31856. // ResetConsumeToken resets all changes to the "consume_token" field.
  31857. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  31858. m.consume_token = nil
  31859. m.addconsume_token = nil
  31860. }
  31861. // SetActiveUser sets the "active_user" field.
  31862. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  31863. m.active_user = &u
  31864. m.addactive_user = nil
  31865. }
  31866. // ActiveUser returns the value of the "active_user" field in the mutation.
  31867. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  31868. v := m.active_user
  31869. if v == nil {
  31870. return
  31871. }
  31872. return *v, true
  31873. }
  31874. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  31875. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31877. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  31878. if !m.op.Is(OpUpdateOne) {
  31879. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  31880. }
  31881. if m.id == nil || m.oldValue == nil {
  31882. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  31883. }
  31884. oldValue, err := m.oldValue(ctx)
  31885. if err != nil {
  31886. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  31887. }
  31888. return oldValue.ActiveUser, nil
  31889. }
  31890. // AddActiveUser adds u to the "active_user" field.
  31891. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  31892. if m.addactive_user != nil {
  31893. *m.addactive_user += u
  31894. } else {
  31895. m.addactive_user = &u
  31896. }
  31897. }
  31898. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  31899. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  31900. v := m.addactive_user
  31901. if v == nil {
  31902. return
  31903. }
  31904. return *v, true
  31905. }
  31906. // ResetActiveUser resets all changes to the "active_user" field.
  31907. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  31908. m.active_user = nil
  31909. m.addactive_user = nil
  31910. }
  31911. // SetNewUser sets the "new_user" field.
  31912. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  31913. m.new_user = &i
  31914. m.addnew_user = nil
  31915. }
  31916. // NewUser returns the value of the "new_user" field in the mutation.
  31917. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  31918. v := m.new_user
  31919. if v == nil {
  31920. return
  31921. }
  31922. return *v, true
  31923. }
  31924. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  31925. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31927. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  31928. if !m.op.Is(OpUpdateOne) {
  31929. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  31930. }
  31931. if m.id == nil || m.oldValue == nil {
  31932. return v, errors.New("OldNewUser requires an ID field in the mutation")
  31933. }
  31934. oldValue, err := m.oldValue(ctx)
  31935. if err != nil {
  31936. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  31937. }
  31938. return oldValue.NewUser, nil
  31939. }
  31940. // AddNewUser adds i to the "new_user" field.
  31941. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  31942. if m.addnew_user != nil {
  31943. *m.addnew_user += i
  31944. } else {
  31945. m.addnew_user = &i
  31946. }
  31947. }
  31948. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  31949. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  31950. v := m.addnew_user
  31951. if v == nil {
  31952. return
  31953. }
  31954. return *v, true
  31955. }
  31956. // ResetNewUser resets all changes to the "new_user" field.
  31957. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  31958. m.new_user = nil
  31959. m.addnew_user = nil
  31960. }
  31961. // SetLabelDist sets the "label_dist" field.
  31962. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  31963. m.label_dist = &ctd
  31964. m.appendlabel_dist = nil
  31965. }
  31966. // LabelDist returns the value of the "label_dist" field in the mutation.
  31967. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  31968. v := m.label_dist
  31969. if v == nil {
  31970. return
  31971. }
  31972. return *v, true
  31973. }
  31974. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  31975. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31977. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  31978. if !m.op.Is(OpUpdateOne) {
  31979. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  31980. }
  31981. if m.id == nil || m.oldValue == nil {
  31982. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  31983. }
  31984. oldValue, err := m.oldValue(ctx)
  31985. if err != nil {
  31986. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  31987. }
  31988. return oldValue.LabelDist, nil
  31989. }
  31990. // AppendLabelDist adds ctd to the "label_dist" field.
  31991. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  31992. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  31993. }
  31994. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  31995. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  31996. if len(m.appendlabel_dist) == 0 {
  31997. return nil, false
  31998. }
  31999. return m.appendlabel_dist, true
  32000. }
  32001. // ResetLabelDist resets all changes to the "label_dist" field.
  32002. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  32003. m.label_dist = nil
  32004. m.appendlabel_dist = nil
  32005. }
  32006. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  32007. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  32008. m.predicates = append(m.predicates, ps...)
  32009. }
  32010. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  32011. // users can use type-assertion to append predicates that do not depend on any generated package.
  32012. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  32013. p := make([]predicate.UsageStatisticMonth, len(ps))
  32014. for i := range ps {
  32015. p[i] = ps[i]
  32016. }
  32017. m.Where(p...)
  32018. }
  32019. // Op returns the operation name.
  32020. func (m *UsageStatisticMonthMutation) Op() Op {
  32021. return m.op
  32022. }
  32023. // SetOp allows setting the mutation operation.
  32024. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  32025. m.op = op
  32026. }
  32027. // Type returns the node type of this mutation (UsageStatisticMonth).
  32028. func (m *UsageStatisticMonthMutation) Type() string {
  32029. return m.typ
  32030. }
  32031. // Fields returns all fields that were changed during this mutation. Note that in
  32032. // order to get all numeric fields that were incremented/decremented, call
  32033. // AddedFields().
  32034. func (m *UsageStatisticMonthMutation) Fields() []string {
  32035. fields := make([]string, 0, 17)
  32036. if m.created_at != nil {
  32037. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  32038. }
  32039. if m.updated_at != nil {
  32040. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  32041. }
  32042. if m.status != nil {
  32043. fields = append(fields, usagestatisticmonth.FieldStatus)
  32044. }
  32045. if m.deleted_at != nil {
  32046. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  32047. }
  32048. if m.addtime != nil {
  32049. fields = append(fields, usagestatisticmonth.FieldAddtime)
  32050. }
  32051. if m._type != nil {
  32052. fields = append(fields, usagestatisticmonth.FieldType)
  32053. }
  32054. if m.bot_id != nil {
  32055. fields = append(fields, usagestatisticmonth.FieldBotID)
  32056. }
  32057. if m.organization_id != nil {
  32058. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32059. }
  32060. if m.ai_response != nil {
  32061. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  32062. }
  32063. if m.sop_run != nil {
  32064. fields = append(fields, usagestatisticmonth.FieldSopRun)
  32065. }
  32066. if m.total_friend != nil {
  32067. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  32068. }
  32069. if m.total_group != nil {
  32070. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  32071. }
  32072. if m.account_balance != nil {
  32073. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  32074. }
  32075. if m.consume_token != nil {
  32076. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  32077. }
  32078. if m.active_user != nil {
  32079. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  32080. }
  32081. if m.new_user != nil {
  32082. fields = append(fields, usagestatisticmonth.FieldNewUser)
  32083. }
  32084. if m.label_dist != nil {
  32085. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  32086. }
  32087. return fields
  32088. }
  32089. // Field returns the value of a field with the given name. The second boolean
  32090. // return value indicates that this field was not set, or was not defined in the
  32091. // schema.
  32092. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  32093. switch name {
  32094. case usagestatisticmonth.FieldCreatedAt:
  32095. return m.CreatedAt()
  32096. case usagestatisticmonth.FieldUpdatedAt:
  32097. return m.UpdatedAt()
  32098. case usagestatisticmonth.FieldStatus:
  32099. return m.Status()
  32100. case usagestatisticmonth.FieldDeletedAt:
  32101. return m.DeletedAt()
  32102. case usagestatisticmonth.FieldAddtime:
  32103. return m.Addtime()
  32104. case usagestatisticmonth.FieldType:
  32105. return m.GetType()
  32106. case usagestatisticmonth.FieldBotID:
  32107. return m.BotID()
  32108. case usagestatisticmonth.FieldOrganizationID:
  32109. return m.OrganizationID()
  32110. case usagestatisticmonth.FieldAiResponse:
  32111. return m.AiResponse()
  32112. case usagestatisticmonth.FieldSopRun:
  32113. return m.SopRun()
  32114. case usagestatisticmonth.FieldTotalFriend:
  32115. return m.TotalFriend()
  32116. case usagestatisticmonth.FieldTotalGroup:
  32117. return m.TotalGroup()
  32118. case usagestatisticmonth.FieldAccountBalance:
  32119. return m.AccountBalance()
  32120. case usagestatisticmonth.FieldConsumeToken:
  32121. return m.ConsumeToken()
  32122. case usagestatisticmonth.FieldActiveUser:
  32123. return m.ActiveUser()
  32124. case usagestatisticmonth.FieldNewUser:
  32125. return m.NewUser()
  32126. case usagestatisticmonth.FieldLabelDist:
  32127. return m.LabelDist()
  32128. }
  32129. return nil, false
  32130. }
  32131. // OldField returns the old value of the field from the database. An error is
  32132. // returned if the mutation operation is not UpdateOne, or the query to the
  32133. // database failed.
  32134. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32135. switch name {
  32136. case usagestatisticmonth.FieldCreatedAt:
  32137. return m.OldCreatedAt(ctx)
  32138. case usagestatisticmonth.FieldUpdatedAt:
  32139. return m.OldUpdatedAt(ctx)
  32140. case usagestatisticmonth.FieldStatus:
  32141. return m.OldStatus(ctx)
  32142. case usagestatisticmonth.FieldDeletedAt:
  32143. return m.OldDeletedAt(ctx)
  32144. case usagestatisticmonth.FieldAddtime:
  32145. return m.OldAddtime(ctx)
  32146. case usagestatisticmonth.FieldType:
  32147. return m.OldType(ctx)
  32148. case usagestatisticmonth.FieldBotID:
  32149. return m.OldBotID(ctx)
  32150. case usagestatisticmonth.FieldOrganizationID:
  32151. return m.OldOrganizationID(ctx)
  32152. case usagestatisticmonth.FieldAiResponse:
  32153. return m.OldAiResponse(ctx)
  32154. case usagestatisticmonth.FieldSopRun:
  32155. return m.OldSopRun(ctx)
  32156. case usagestatisticmonth.FieldTotalFriend:
  32157. return m.OldTotalFriend(ctx)
  32158. case usagestatisticmonth.FieldTotalGroup:
  32159. return m.OldTotalGroup(ctx)
  32160. case usagestatisticmonth.FieldAccountBalance:
  32161. return m.OldAccountBalance(ctx)
  32162. case usagestatisticmonth.FieldConsumeToken:
  32163. return m.OldConsumeToken(ctx)
  32164. case usagestatisticmonth.FieldActiveUser:
  32165. return m.OldActiveUser(ctx)
  32166. case usagestatisticmonth.FieldNewUser:
  32167. return m.OldNewUser(ctx)
  32168. case usagestatisticmonth.FieldLabelDist:
  32169. return m.OldLabelDist(ctx)
  32170. }
  32171. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32172. }
  32173. // SetField sets the value of a field with the given name. It returns an error if
  32174. // the field is not defined in the schema, or if the type mismatched the field
  32175. // type.
  32176. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  32177. switch name {
  32178. case usagestatisticmonth.FieldCreatedAt:
  32179. v, ok := value.(time.Time)
  32180. if !ok {
  32181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32182. }
  32183. m.SetCreatedAt(v)
  32184. return nil
  32185. case usagestatisticmonth.FieldUpdatedAt:
  32186. v, ok := value.(time.Time)
  32187. if !ok {
  32188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32189. }
  32190. m.SetUpdatedAt(v)
  32191. return nil
  32192. case usagestatisticmonth.FieldStatus:
  32193. v, ok := value.(uint8)
  32194. if !ok {
  32195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32196. }
  32197. m.SetStatus(v)
  32198. return nil
  32199. case usagestatisticmonth.FieldDeletedAt:
  32200. v, ok := value.(time.Time)
  32201. if !ok {
  32202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32203. }
  32204. m.SetDeletedAt(v)
  32205. return nil
  32206. case usagestatisticmonth.FieldAddtime:
  32207. v, ok := value.(uint64)
  32208. if !ok {
  32209. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32210. }
  32211. m.SetAddtime(v)
  32212. return nil
  32213. case usagestatisticmonth.FieldType:
  32214. v, ok := value.(int)
  32215. if !ok {
  32216. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32217. }
  32218. m.SetType(v)
  32219. return nil
  32220. case usagestatisticmonth.FieldBotID:
  32221. v, ok := value.(string)
  32222. if !ok {
  32223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32224. }
  32225. m.SetBotID(v)
  32226. return nil
  32227. case usagestatisticmonth.FieldOrganizationID:
  32228. v, ok := value.(uint64)
  32229. if !ok {
  32230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32231. }
  32232. m.SetOrganizationID(v)
  32233. return nil
  32234. case usagestatisticmonth.FieldAiResponse:
  32235. v, ok := value.(uint64)
  32236. if !ok {
  32237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32238. }
  32239. m.SetAiResponse(v)
  32240. return nil
  32241. case usagestatisticmonth.FieldSopRun:
  32242. v, ok := value.(uint64)
  32243. if !ok {
  32244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32245. }
  32246. m.SetSopRun(v)
  32247. return nil
  32248. case usagestatisticmonth.FieldTotalFriend:
  32249. v, ok := value.(uint64)
  32250. if !ok {
  32251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32252. }
  32253. m.SetTotalFriend(v)
  32254. return nil
  32255. case usagestatisticmonth.FieldTotalGroup:
  32256. v, ok := value.(uint64)
  32257. if !ok {
  32258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32259. }
  32260. m.SetTotalGroup(v)
  32261. return nil
  32262. case usagestatisticmonth.FieldAccountBalance:
  32263. v, ok := value.(uint64)
  32264. if !ok {
  32265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32266. }
  32267. m.SetAccountBalance(v)
  32268. return nil
  32269. case usagestatisticmonth.FieldConsumeToken:
  32270. v, ok := value.(uint64)
  32271. if !ok {
  32272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32273. }
  32274. m.SetConsumeToken(v)
  32275. return nil
  32276. case usagestatisticmonth.FieldActiveUser:
  32277. v, ok := value.(uint64)
  32278. if !ok {
  32279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32280. }
  32281. m.SetActiveUser(v)
  32282. return nil
  32283. case usagestatisticmonth.FieldNewUser:
  32284. v, ok := value.(int64)
  32285. if !ok {
  32286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32287. }
  32288. m.SetNewUser(v)
  32289. return nil
  32290. case usagestatisticmonth.FieldLabelDist:
  32291. v, ok := value.([]custom_types.LabelDist)
  32292. if !ok {
  32293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32294. }
  32295. m.SetLabelDist(v)
  32296. return nil
  32297. }
  32298. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32299. }
  32300. // AddedFields returns all numeric fields that were incremented/decremented during
  32301. // this mutation.
  32302. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  32303. var fields []string
  32304. if m.addstatus != nil {
  32305. fields = append(fields, usagestatisticmonth.FieldStatus)
  32306. }
  32307. if m.addaddtime != nil {
  32308. fields = append(fields, usagestatisticmonth.FieldAddtime)
  32309. }
  32310. if m.add_type != nil {
  32311. fields = append(fields, usagestatisticmonth.FieldType)
  32312. }
  32313. if m.addorganization_id != nil {
  32314. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32315. }
  32316. if m.addai_response != nil {
  32317. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  32318. }
  32319. if m.addsop_run != nil {
  32320. fields = append(fields, usagestatisticmonth.FieldSopRun)
  32321. }
  32322. if m.addtotal_friend != nil {
  32323. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  32324. }
  32325. if m.addtotal_group != nil {
  32326. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  32327. }
  32328. if m.addaccount_balance != nil {
  32329. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  32330. }
  32331. if m.addconsume_token != nil {
  32332. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  32333. }
  32334. if m.addactive_user != nil {
  32335. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  32336. }
  32337. if m.addnew_user != nil {
  32338. fields = append(fields, usagestatisticmonth.FieldNewUser)
  32339. }
  32340. return fields
  32341. }
  32342. // AddedField returns the numeric value that was incremented/decremented on a field
  32343. // with the given name. The second boolean return value indicates that this field
  32344. // was not set, or was not defined in the schema.
  32345. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  32346. switch name {
  32347. case usagestatisticmonth.FieldStatus:
  32348. return m.AddedStatus()
  32349. case usagestatisticmonth.FieldAddtime:
  32350. return m.AddedAddtime()
  32351. case usagestatisticmonth.FieldType:
  32352. return m.AddedType()
  32353. case usagestatisticmonth.FieldOrganizationID:
  32354. return m.AddedOrganizationID()
  32355. case usagestatisticmonth.FieldAiResponse:
  32356. return m.AddedAiResponse()
  32357. case usagestatisticmonth.FieldSopRun:
  32358. return m.AddedSopRun()
  32359. case usagestatisticmonth.FieldTotalFriend:
  32360. return m.AddedTotalFriend()
  32361. case usagestatisticmonth.FieldTotalGroup:
  32362. return m.AddedTotalGroup()
  32363. case usagestatisticmonth.FieldAccountBalance:
  32364. return m.AddedAccountBalance()
  32365. case usagestatisticmonth.FieldConsumeToken:
  32366. return m.AddedConsumeToken()
  32367. case usagestatisticmonth.FieldActiveUser:
  32368. return m.AddedActiveUser()
  32369. case usagestatisticmonth.FieldNewUser:
  32370. return m.AddedNewUser()
  32371. }
  32372. return nil, false
  32373. }
  32374. // AddField adds the value to the field with the given name. It returns an error if
  32375. // the field is not defined in the schema, or if the type mismatched the field
  32376. // type.
  32377. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  32378. switch name {
  32379. case usagestatisticmonth.FieldStatus:
  32380. v, ok := value.(int8)
  32381. if !ok {
  32382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32383. }
  32384. m.AddStatus(v)
  32385. return nil
  32386. case usagestatisticmonth.FieldAddtime:
  32387. v, ok := value.(int64)
  32388. if !ok {
  32389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32390. }
  32391. m.AddAddtime(v)
  32392. return nil
  32393. case usagestatisticmonth.FieldType:
  32394. v, ok := value.(int)
  32395. if !ok {
  32396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32397. }
  32398. m.AddType(v)
  32399. return nil
  32400. case usagestatisticmonth.FieldOrganizationID:
  32401. v, ok := value.(int64)
  32402. if !ok {
  32403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32404. }
  32405. m.AddOrganizationID(v)
  32406. return nil
  32407. case usagestatisticmonth.FieldAiResponse:
  32408. v, ok := value.(int64)
  32409. if !ok {
  32410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32411. }
  32412. m.AddAiResponse(v)
  32413. return nil
  32414. case usagestatisticmonth.FieldSopRun:
  32415. v, ok := value.(int64)
  32416. if !ok {
  32417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32418. }
  32419. m.AddSopRun(v)
  32420. return nil
  32421. case usagestatisticmonth.FieldTotalFriend:
  32422. v, ok := value.(int64)
  32423. if !ok {
  32424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32425. }
  32426. m.AddTotalFriend(v)
  32427. return nil
  32428. case usagestatisticmonth.FieldTotalGroup:
  32429. v, ok := value.(int64)
  32430. if !ok {
  32431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32432. }
  32433. m.AddTotalGroup(v)
  32434. return nil
  32435. case usagestatisticmonth.FieldAccountBalance:
  32436. v, ok := value.(int64)
  32437. if !ok {
  32438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32439. }
  32440. m.AddAccountBalance(v)
  32441. return nil
  32442. case usagestatisticmonth.FieldConsumeToken:
  32443. v, ok := value.(int64)
  32444. if !ok {
  32445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32446. }
  32447. m.AddConsumeToken(v)
  32448. return nil
  32449. case usagestatisticmonth.FieldActiveUser:
  32450. v, ok := value.(int64)
  32451. if !ok {
  32452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32453. }
  32454. m.AddActiveUser(v)
  32455. return nil
  32456. case usagestatisticmonth.FieldNewUser:
  32457. v, ok := value.(int64)
  32458. if !ok {
  32459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32460. }
  32461. m.AddNewUser(v)
  32462. return nil
  32463. }
  32464. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  32465. }
  32466. // ClearedFields returns all nullable fields that were cleared during this
  32467. // mutation.
  32468. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  32469. var fields []string
  32470. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  32471. fields = append(fields, usagestatisticmonth.FieldStatus)
  32472. }
  32473. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  32474. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  32475. }
  32476. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  32477. fields = append(fields, usagestatisticmonth.FieldBotID)
  32478. }
  32479. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  32480. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32481. }
  32482. return fields
  32483. }
  32484. // FieldCleared returns a boolean indicating if a field with the given name was
  32485. // cleared in this mutation.
  32486. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  32487. _, ok := m.clearedFields[name]
  32488. return ok
  32489. }
  32490. // ClearField clears the value of the field with the given name. It returns an
  32491. // error if the field is not defined in the schema.
  32492. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  32493. switch name {
  32494. case usagestatisticmonth.FieldStatus:
  32495. m.ClearStatus()
  32496. return nil
  32497. case usagestatisticmonth.FieldDeletedAt:
  32498. m.ClearDeletedAt()
  32499. return nil
  32500. case usagestatisticmonth.FieldBotID:
  32501. m.ClearBotID()
  32502. return nil
  32503. case usagestatisticmonth.FieldOrganizationID:
  32504. m.ClearOrganizationID()
  32505. return nil
  32506. }
  32507. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  32508. }
  32509. // ResetField resets all changes in the mutation for the field with the given name.
  32510. // It returns an error if the field is not defined in the schema.
  32511. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  32512. switch name {
  32513. case usagestatisticmonth.FieldCreatedAt:
  32514. m.ResetCreatedAt()
  32515. return nil
  32516. case usagestatisticmonth.FieldUpdatedAt:
  32517. m.ResetUpdatedAt()
  32518. return nil
  32519. case usagestatisticmonth.FieldStatus:
  32520. m.ResetStatus()
  32521. return nil
  32522. case usagestatisticmonth.FieldDeletedAt:
  32523. m.ResetDeletedAt()
  32524. return nil
  32525. case usagestatisticmonth.FieldAddtime:
  32526. m.ResetAddtime()
  32527. return nil
  32528. case usagestatisticmonth.FieldType:
  32529. m.ResetType()
  32530. return nil
  32531. case usagestatisticmonth.FieldBotID:
  32532. m.ResetBotID()
  32533. return nil
  32534. case usagestatisticmonth.FieldOrganizationID:
  32535. m.ResetOrganizationID()
  32536. return nil
  32537. case usagestatisticmonth.FieldAiResponse:
  32538. m.ResetAiResponse()
  32539. return nil
  32540. case usagestatisticmonth.FieldSopRun:
  32541. m.ResetSopRun()
  32542. return nil
  32543. case usagestatisticmonth.FieldTotalFriend:
  32544. m.ResetTotalFriend()
  32545. return nil
  32546. case usagestatisticmonth.FieldTotalGroup:
  32547. m.ResetTotalGroup()
  32548. return nil
  32549. case usagestatisticmonth.FieldAccountBalance:
  32550. m.ResetAccountBalance()
  32551. return nil
  32552. case usagestatisticmonth.FieldConsumeToken:
  32553. m.ResetConsumeToken()
  32554. return nil
  32555. case usagestatisticmonth.FieldActiveUser:
  32556. m.ResetActiveUser()
  32557. return nil
  32558. case usagestatisticmonth.FieldNewUser:
  32559. m.ResetNewUser()
  32560. return nil
  32561. case usagestatisticmonth.FieldLabelDist:
  32562. m.ResetLabelDist()
  32563. return nil
  32564. }
  32565. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32566. }
  32567. // AddedEdges returns all edge names that were set/added in this mutation.
  32568. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  32569. edges := make([]string, 0, 0)
  32570. return edges
  32571. }
  32572. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32573. // name in this mutation.
  32574. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  32575. return nil
  32576. }
  32577. // RemovedEdges returns all edge names that were removed in this mutation.
  32578. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  32579. edges := make([]string, 0, 0)
  32580. return edges
  32581. }
  32582. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32583. // the given name in this mutation.
  32584. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  32585. return nil
  32586. }
  32587. // ClearedEdges returns all edge names that were cleared in this mutation.
  32588. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  32589. edges := make([]string, 0, 0)
  32590. return edges
  32591. }
  32592. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32593. // was cleared in this mutation.
  32594. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  32595. return false
  32596. }
  32597. // ClearEdge clears the value of the edge with the given name. It returns an error
  32598. // if that edge is not defined in the schema.
  32599. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  32600. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  32601. }
  32602. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32603. // It returns an error if the edge is not defined in the schema.
  32604. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  32605. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  32606. }
  32607. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  32608. type UsageTotalMutation struct {
  32609. config
  32610. op Op
  32611. typ string
  32612. id *uint64
  32613. created_at *time.Time
  32614. updated_at *time.Time
  32615. status *uint8
  32616. addstatus *int8
  32617. _type *int
  32618. add_type *int
  32619. bot_id *string
  32620. total_tokens *uint64
  32621. addtotal_tokens *int64
  32622. start_index *uint64
  32623. addstart_index *int64
  32624. end_index *uint64
  32625. addend_index *int64
  32626. organization_id *uint64
  32627. addorganization_id *int64
  32628. clearedFields map[string]struct{}
  32629. done bool
  32630. oldValue func(context.Context) (*UsageTotal, error)
  32631. predicates []predicate.UsageTotal
  32632. }
  32633. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  32634. // usagetotalOption allows management of the mutation configuration using functional options.
  32635. type usagetotalOption func(*UsageTotalMutation)
  32636. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  32637. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  32638. m := &UsageTotalMutation{
  32639. config: c,
  32640. op: op,
  32641. typ: TypeUsageTotal,
  32642. clearedFields: make(map[string]struct{}),
  32643. }
  32644. for _, opt := range opts {
  32645. opt(m)
  32646. }
  32647. return m
  32648. }
  32649. // withUsageTotalID sets the ID field of the mutation.
  32650. func withUsageTotalID(id uint64) usagetotalOption {
  32651. return func(m *UsageTotalMutation) {
  32652. var (
  32653. err error
  32654. once sync.Once
  32655. value *UsageTotal
  32656. )
  32657. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  32658. once.Do(func() {
  32659. if m.done {
  32660. err = errors.New("querying old values post mutation is not allowed")
  32661. } else {
  32662. value, err = m.Client().UsageTotal.Get(ctx, id)
  32663. }
  32664. })
  32665. return value, err
  32666. }
  32667. m.id = &id
  32668. }
  32669. }
  32670. // withUsageTotal sets the old UsageTotal of the mutation.
  32671. func withUsageTotal(node *UsageTotal) usagetotalOption {
  32672. return func(m *UsageTotalMutation) {
  32673. m.oldValue = func(context.Context) (*UsageTotal, error) {
  32674. return node, nil
  32675. }
  32676. m.id = &node.ID
  32677. }
  32678. }
  32679. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32680. // executed in a transaction (ent.Tx), a transactional client is returned.
  32681. func (m UsageTotalMutation) Client() *Client {
  32682. client := &Client{config: m.config}
  32683. client.init()
  32684. return client
  32685. }
  32686. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32687. // it returns an error otherwise.
  32688. func (m UsageTotalMutation) Tx() (*Tx, error) {
  32689. if _, ok := m.driver.(*txDriver); !ok {
  32690. return nil, errors.New("ent: mutation is not running in a transaction")
  32691. }
  32692. tx := &Tx{config: m.config}
  32693. tx.init()
  32694. return tx, nil
  32695. }
  32696. // SetID sets the value of the id field. Note that this
  32697. // operation is only accepted on creation of UsageTotal entities.
  32698. func (m *UsageTotalMutation) SetID(id uint64) {
  32699. m.id = &id
  32700. }
  32701. // ID returns the ID value in the mutation. Note that the ID is only available
  32702. // if it was provided to the builder or after it was returned from the database.
  32703. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  32704. if m.id == nil {
  32705. return
  32706. }
  32707. return *m.id, true
  32708. }
  32709. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32710. // That means, if the mutation is applied within a transaction with an isolation level such
  32711. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32712. // or updated by the mutation.
  32713. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  32714. switch {
  32715. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32716. id, exists := m.ID()
  32717. if exists {
  32718. return []uint64{id}, nil
  32719. }
  32720. fallthrough
  32721. case m.op.Is(OpUpdate | OpDelete):
  32722. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  32723. default:
  32724. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32725. }
  32726. }
  32727. // SetCreatedAt sets the "created_at" field.
  32728. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  32729. m.created_at = &t
  32730. }
  32731. // CreatedAt returns the value of the "created_at" field in the mutation.
  32732. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  32733. v := m.created_at
  32734. if v == nil {
  32735. return
  32736. }
  32737. return *v, true
  32738. }
  32739. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  32740. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32742. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32743. if !m.op.Is(OpUpdateOne) {
  32744. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32745. }
  32746. if m.id == nil || m.oldValue == nil {
  32747. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32748. }
  32749. oldValue, err := m.oldValue(ctx)
  32750. if err != nil {
  32751. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32752. }
  32753. return oldValue.CreatedAt, nil
  32754. }
  32755. // ResetCreatedAt resets all changes to the "created_at" field.
  32756. func (m *UsageTotalMutation) ResetCreatedAt() {
  32757. m.created_at = nil
  32758. }
  32759. // SetUpdatedAt sets the "updated_at" field.
  32760. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  32761. m.updated_at = &t
  32762. }
  32763. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32764. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  32765. v := m.updated_at
  32766. if v == nil {
  32767. return
  32768. }
  32769. return *v, true
  32770. }
  32771. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  32772. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32774. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32775. if !m.op.Is(OpUpdateOne) {
  32776. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32777. }
  32778. if m.id == nil || m.oldValue == nil {
  32779. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32780. }
  32781. oldValue, err := m.oldValue(ctx)
  32782. if err != nil {
  32783. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32784. }
  32785. return oldValue.UpdatedAt, nil
  32786. }
  32787. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32788. func (m *UsageTotalMutation) ResetUpdatedAt() {
  32789. m.updated_at = nil
  32790. }
  32791. // SetStatus sets the "status" field.
  32792. func (m *UsageTotalMutation) SetStatus(u uint8) {
  32793. m.status = &u
  32794. m.addstatus = nil
  32795. }
  32796. // Status returns the value of the "status" field in the mutation.
  32797. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  32798. v := m.status
  32799. if v == nil {
  32800. return
  32801. }
  32802. return *v, true
  32803. }
  32804. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  32805. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32807. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32808. if !m.op.Is(OpUpdateOne) {
  32809. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32810. }
  32811. if m.id == nil || m.oldValue == nil {
  32812. return v, errors.New("OldStatus requires an ID field in the mutation")
  32813. }
  32814. oldValue, err := m.oldValue(ctx)
  32815. if err != nil {
  32816. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32817. }
  32818. return oldValue.Status, nil
  32819. }
  32820. // AddStatus adds u to the "status" field.
  32821. func (m *UsageTotalMutation) AddStatus(u int8) {
  32822. if m.addstatus != nil {
  32823. *m.addstatus += u
  32824. } else {
  32825. m.addstatus = &u
  32826. }
  32827. }
  32828. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32829. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  32830. v := m.addstatus
  32831. if v == nil {
  32832. return
  32833. }
  32834. return *v, true
  32835. }
  32836. // ClearStatus clears the value of the "status" field.
  32837. func (m *UsageTotalMutation) ClearStatus() {
  32838. m.status = nil
  32839. m.addstatus = nil
  32840. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  32841. }
  32842. // StatusCleared returns if the "status" field was cleared in this mutation.
  32843. func (m *UsageTotalMutation) StatusCleared() bool {
  32844. _, ok := m.clearedFields[usagetotal.FieldStatus]
  32845. return ok
  32846. }
  32847. // ResetStatus resets all changes to the "status" field.
  32848. func (m *UsageTotalMutation) ResetStatus() {
  32849. m.status = nil
  32850. m.addstatus = nil
  32851. delete(m.clearedFields, usagetotal.FieldStatus)
  32852. }
  32853. // SetType sets the "type" field.
  32854. func (m *UsageTotalMutation) SetType(i int) {
  32855. m._type = &i
  32856. m.add_type = nil
  32857. }
  32858. // GetType returns the value of the "type" field in the mutation.
  32859. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  32860. v := m._type
  32861. if v == nil {
  32862. return
  32863. }
  32864. return *v, true
  32865. }
  32866. // OldType returns the old "type" field's value of the UsageTotal entity.
  32867. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32869. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  32870. if !m.op.Is(OpUpdateOne) {
  32871. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32872. }
  32873. if m.id == nil || m.oldValue == nil {
  32874. return v, errors.New("OldType requires an ID field in the mutation")
  32875. }
  32876. oldValue, err := m.oldValue(ctx)
  32877. if err != nil {
  32878. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32879. }
  32880. return oldValue.Type, nil
  32881. }
  32882. // AddType adds i to the "type" field.
  32883. func (m *UsageTotalMutation) AddType(i int) {
  32884. if m.add_type != nil {
  32885. *m.add_type += i
  32886. } else {
  32887. m.add_type = &i
  32888. }
  32889. }
  32890. // AddedType returns the value that was added to the "type" field in this mutation.
  32891. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  32892. v := m.add_type
  32893. if v == nil {
  32894. return
  32895. }
  32896. return *v, true
  32897. }
  32898. // ClearType clears the value of the "type" field.
  32899. func (m *UsageTotalMutation) ClearType() {
  32900. m._type = nil
  32901. m.add_type = nil
  32902. m.clearedFields[usagetotal.FieldType] = struct{}{}
  32903. }
  32904. // TypeCleared returns if the "type" field was cleared in this mutation.
  32905. func (m *UsageTotalMutation) TypeCleared() bool {
  32906. _, ok := m.clearedFields[usagetotal.FieldType]
  32907. return ok
  32908. }
  32909. // ResetType resets all changes to the "type" field.
  32910. func (m *UsageTotalMutation) ResetType() {
  32911. m._type = nil
  32912. m.add_type = nil
  32913. delete(m.clearedFields, usagetotal.FieldType)
  32914. }
  32915. // SetBotID sets the "bot_id" field.
  32916. func (m *UsageTotalMutation) SetBotID(s string) {
  32917. m.bot_id = &s
  32918. }
  32919. // BotID returns the value of the "bot_id" field in the mutation.
  32920. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  32921. v := m.bot_id
  32922. if v == nil {
  32923. return
  32924. }
  32925. return *v, true
  32926. }
  32927. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  32928. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32930. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  32931. if !m.op.Is(OpUpdateOne) {
  32932. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32933. }
  32934. if m.id == nil || m.oldValue == nil {
  32935. return v, errors.New("OldBotID requires an ID field in the mutation")
  32936. }
  32937. oldValue, err := m.oldValue(ctx)
  32938. if err != nil {
  32939. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32940. }
  32941. return oldValue.BotID, nil
  32942. }
  32943. // ResetBotID resets all changes to the "bot_id" field.
  32944. func (m *UsageTotalMutation) ResetBotID() {
  32945. m.bot_id = nil
  32946. }
  32947. // SetTotalTokens sets the "total_tokens" field.
  32948. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  32949. m.total_tokens = &u
  32950. m.addtotal_tokens = nil
  32951. }
  32952. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  32953. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  32954. v := m.total_tokens
  32955. if v == nil {
  32956. return
  32957. }
  32958. return *v, true
  32959. }
  32960. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  32961. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32962. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32963. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  32964. if !m.op.Is(OpUpdateOne) {
  32965. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  32966. }
  32967. if m.id == nil || m.oldValue == nil {
  32968. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  32969. }
  32970. oldValue, err := m.oldValue(ctx)
  32971. if err != nil {
  32972. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  32973. }
  32974. return oldValue.TotalTokens, nil
  32975. }
  32976. // AddTotalTokens adds u to the "total_tokens" field.
  32977. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  32978. if m.addtotal_tokens != nil {
  32979. *m.addtotal_tokens += u
  32980. } else {
  32981. m.addtotal_tokens = &u
  32982. }
  32983. }
  32984. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  32985. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  32986. v := m.addtotal_tokens
  32987. if v == nil {
  32988. return
  32989. }
  32990. return *v, true
  32991. }
  32992. // ClearTotalTokens clears the value of the "total_tokens" field.
  32993. func (m *UsageTotalMutation) ClearTotalTokens() {
  32994. m.total_tokens = nil
  32995. m.addtotal_tokens = nil
  32996. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  32997. }
  32998. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  32999. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  33000. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  33001. return ok
  33002. }
  33003. // ResetTotalTokens resets all changes to the "total_tokens" field.
  33004. func (m *UsageTotalMutation) ResetTotalTokens() {
  33005. m.total_tokens = nil
  33006. m.addtotal_tokens = nil
  33007. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  33008. }
  33009. // SetStartIndex sets the "start_index" field.
  33010. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  33011. m.start_index = &u
  33012. m.addstart_index = nil
  33013. }
  33014. // StartIndex returns the value of the "start_index" field in the mutation.
  33015. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  33016. v := m.start_index
  33017. if v == nil {
  33018. return
  33019. }
  33020. return *v, true
  33021. }
  33022. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  33023. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33025. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  33026. if !m.op.Is(OpUpdateOne) {
  33027. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  33028. }
  33029. if m.id == nil || m.oldValue == nil {
  33030. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  33031. }
  33032. oldValue, err := m.oldValue(ctx)
  33033. if err != nil {
  33034. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  33035. }
  33036. return oldValue.StartIndex, nil
  33037. }
  33038. // AddStartIndex adds u to the "start_index" field.
  33039. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  33040. if m.addstart_index != nil {
  33041. *m.addstart_index += u
  33042. } else {
  33043. m.addstart_index = &u
  33044. }
  33045. }
  33046. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  33047. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  33048. v := m.addstart_index
  33049. if v == nil {
  33050. return
  33051. }
  33052. return *v, true
  33053. }
  33054. // ClearStartIndex clears the value of the "start_index" field.
  33055. func (m *UsageTotalMutation) ClearStartIndex() {
  33056. m.start_index = nil
  33057. m.addstart_index = nil
  33058. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  33059. }
  33060. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  33061. func (m *UsageTotalMutation) StartIndexCleared() bool {
  33062. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  33063. return ok
  33064. }
  33065. // ResetStartIndex resets all changes to the "start_index" field.
  33066. func (m *UsageTotalMutation) ResetStartIndex() {
  33067. m.start_index = nil
  33068. m.addstart_index = nil
  33069. delete(m.clearedFields, usagetotal.FieldStartIndex)
  33070. }
  33071. // SetEndIndex sets the "end_index" field.
  33072. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  33073. m.end_index = &u
  33074. m.addend_index = nil
  33075. }
  33076. // EndIndex returns the value of the "end_index" field in the mutation.
  33077. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  33078. v := m.end_index
  33079. if v == nil {
  33080. return
  33081. }
  33082. return *v, true
  33083. }
  33084. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  33085. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33087. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  33088. if !m.op.Is(OpUpdateOne) {
  33089. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  33090. }
  33091. if m.id == nil || m.oldValue == nil {
  33092. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  33093. }
  33094. oldValue, err := m.oldValue(ctx)
  33095. if err != nil {
  33096. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  33097. }
  33098. return oldValue.EndIndex, nil
  33099. }
  33100. // AddEndIndex adds u to the "end_index" field.
  33101. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  33102. if m.addend_index != nil {
  33103. *m.addend_index += u
  33104. } else {
  33105. m.addend_index = &u
  33106. }
  33107. }
  33108. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  33109. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  33110. v := m.addend_index
  33111. if v == nil {
  33112. return
  33113. }
  33114. return *v, true
  33115. }
  33116. // ClearEndIndex clears the value of the "end_index" field.
  33117. func (m *UsageTotalMutation) ClearEndIndex() {
  33118. m.end_index = nil
  33119. m.addend_index = nil
  33120. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  33121. }
  33122. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  33123. func (m *UsageTotalMutation) EndIndexCleared() bool {
  33124. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  33125. return ok
  33126. }
  33127. // ResetEndIndex resets all changes to the "end_index" field.
  33128. func (m *UsageTotalMutation) ResetEndIndex() {
  33129. m.end_index = nil
  33130. m.addend_index = nil
  33131. delete(m.clearedFields, usagetotal.FieldEndIndex)
  33132. }
  33133. // SetOrganizationID sets the "organization_id" field.
  33134. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  33135. m.organization_id = &u
  33136. m.addorganization_id = nil
  33137. }
  33138. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33139. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  33140. v := m.organization_id
  33141. if v == nil {
  33142. return
  33143. }
  33144. return *v, true
  33145. }
  33146. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  33147. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33149. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33150. if !m.op.Is(OpUpdateOne) {
  33151. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33152. }
  33153. if m.id == nil || m.oldValue == nil {
  33154. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33155. }
  33156. oldValue, err := m.oldValue(ctx)
  33157. if err != nil {
  33158. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33159. }
  33160. return oldValue.OrganizationID, nil
  33161. }
  33162. // AddOrganizationID adds u to the "organization_id" field.
  33163. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  33164. if m.addorganization_id != nil {
  33165. *m.addorganization_id += u
  33166. } else {
  33167. m.addorganization_id = &u
  33168. }
  33169. }
  33170. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33171. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  33172. v := m.addorganization_id
  33173. if v == nil {
  33174. return
  33175. }
  33176. return *v, true
  33177. }
  33178. // ClearOrganizationID clears the value of the "organization_id" field.
  33179. func (m *UsageTotalMutation) ClearOrganizationID() {
  33180. m.organization_id = nil
  33181. m.addorganization_id = nil
  33182. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  33183. }
  33184. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33185. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  33186. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  33187. return ok
  33188. }
  33189. // ResetOrganizationID resets all changes to the "organization_id" field.
  33190. func (m *UsageTotalMutation) ResetOrganizationID() {
  33191. m.organization_id = nil
  33192. m.addorganization_id = nil
  33193. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  33194. }
  33195. // Where appends a list predicates to the UsageTotalMutation builder.
  33196. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  33197. m.predicates = append(m.predicates, ps...)
  33198. }
  33199. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  33200. // users can use type-assertion to append predicates that do not depend on any generated package.
  33201. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  33202. p := make([]predicate.UsageTotal, len(ps))
  33203. for i := range ps {
  33204. p[i] = ps[i]
  33205. }
  33206. m.Where(p...)
  33207. }
  33208. // Op returns the operation name.
  33209. func (m *UsageTotalMutation) Op() Op {
  33210. return m.op
  33211. }
  33212. // SetOp allows setting the mutation operation.
  33213. func (m *UsageTotalMutation) SetOp(op Op) {
  33214. m.op = op
  33215. }
  33216. // Type returns the node type of this mutation (UsageTotal).
  33217. func (m *UsageTotalMutation) Type() string {
  33218. return m.typ
  33219. }
  33220. // Fields returns all fields that were changed during this mutation. Note that in
  33221. // order to get all numeric fields that were incremented/decremented, call
  33222. // AddedFields().
  33223. func (m *UsageTotalMutation) Fields() []string {
  33224. fields := make([]string, 0, 9)
  33225. if m.created_at != nil {
  33226. fields = append(fields, usagetotal.FieldCreatedAt)
  33227. }
  33228. if m.updated_at != nil {
  33229. fields = append(fields, usagetotal.FieldUpdatedAt)
  33230. }
  33231. if m.status != nil {
  33232. fields = append(fields, usagetotal.FieldStatus)
  33233. }
  33234. if m._type != nil {
  33235. fields = append(fields, usagetotal.FieldType)
  33236. }
  33237. if m.bot_id != nil {
  33238. fields = append(fields, usagetotal.FieldBotID)
  33239. }
  33240. if m.total_tokens != nil {
  33241. fields = append(fields, usagetotal.FieldTotalTokens)
  33242. }
  33243. if m.start_index != nil {
  33244. fields = append(fields, usagetotal.FieldStartIndex)
  33245. }
  33246. if m.end_index != nil {
  33247. fields = append(fields, usagetotal.FieldEndIndex)
  33248. }
  33249. if m.organization_id != nil {
  33250. fields = append(fields, usagetotal.FieldOrganizationID)
  33251. }
  33252. return fields
  33253. }
  33254. // Field returns the value of a field with the given name. The second boolean
  33255. // return value indicates that this field was not set, or was not defined in the
  33256. // schema.
  33257. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  33258. switch name {
  33259. case usagetotal.FieldCreatedAt:
  33260. return m.CreatedAt()
  33261. case usagetotal.FieldUpdatedAt:
  33262. return m.UpdatedAt()
  33263. case usagetotal.FieldStatus:
  33264. return m.Status()
  33265. case usagetotal.FieldType:
  33266. return m.GetType()
  33267. case usagetotal.FieldBotID:
  33268. return m.BotID()
  33269. case usagetotal.FieldTotalTokens:
  33270. return m.TotalTokens()
  33271. case usagetotal.FieldStartIndex:
  33272. return m.StartIndex()
  33273. case usagetotal.FieldEndIndex:
  33274. return m.EndIndex()
  33275. case usagetotal.FieldOrganizationID:
  33276. return m.OrganizationID()
  33277. }
  33278. return nil, false
  33279. }
  33280. // OldField returns the old value of the field from the database. An error is
  33281. // returned if the mutation operation is not UpdateOne, or the query to the
  33282. // database failed.
  33283. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33284. switch name {
  33285. case usagetotal.FieldCreatedAt:
  33286. return m.OldCreatedAt(ctx)
  33287. case usagetotal.FieldUpdatedAt:
  33288. return m.OldUpdatedAt(ctx)
  33289. case usagetotal.FieldStatus:
  33290. return m.OldStatus(ctx)
  33291. case usagetotal.FieldType:
  33292. return m.OldType(ctx)
  33293. case usagetotal.FieldBotID:
  33294. return m.OldBotID(ctx)
  33295. case usagetotal.FieldTotalTokens:
  33296. return m.OldTotalTokens(ctx)
  33297. case usagetotal.FieldStartIndex:
  33298. return m.OldStartIndex(ctx)
  33299. case usagetotal.FieldEndIndex:
  33300. return m.OldEndIndex(ctx)
  33301. case usagetotal.FieldOrganizationID:
  33302. return m.OldOrganizationID(ctx)
  33303. }
  33304. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  33305. }
  33306. // SetField sets the value of a field with the given name. It returns an error if
  33307. // the field is not defined in the schema, or if the type mismatched the field
  33308. // type.
  33309. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  33310. switch name {
  33311. case usagetotal.FieldCreatedAt:
  33312. v, ok := value.(time.Time)
  33313. if !ok {
  33314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33315. }
  33316. m.SetCreatedAt(v)
  33317. return nil
  33318. case usagetotal.FieldUpdatedAt:
  33319. v, ok := value.(time.Time)
  33320. if !ok {
  33321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33322. }
  33323. m.SetUpdatedAt(v)
  33324. return nil
  33325. case usagetotal.FieldStatus:
  33326. v, ok := value.(uint8)
  33327. if !ok {
  33328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33329. }
  33330. m.SetStatus(v)
  33331. return nil
  33332. case usagetotal.FieldType:
  33333. v, ok := value.(int)
  33334. if !ok {
  33335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33336. }
  33337. m.SetType(v)
  33338. return nil
  33339. case usagetotal.FieldBotID:
  33340. v, ok := value.(string)
  33341. if !ok {
  33342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33343. }
  33344. m.SetBotID(v)
  33345. return nil
  33346. case usagetotal.FieldTotalTokens:
  33347. v, ok := value.(uint64)
  33348. if !ok {
  33349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33350. }
  33351. m.SetTotalTokens(v)
  33352. return nil
  33353. case usagetotal.FieldStartIndex:
  33354. v, ok := value.(uint64)
  33355. if !ok {
  33356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33357. }
  33358. m.SetStartIndex(v)
  33359. return nil
  33360. case usagetotal.FieldEndIndex:
  33361. v, ok := value.(uint64)
  33362. if !ok {
  33363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33364. }
  33365. m.SetEndIndex(v)
  33366. return nil
  33367. case usagetotal.FieldOrganizationID:
  33368. v, ok := value.(uint64)
  33369. if !ok {
  33370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33371. }
  33372. m.SetOrganizationID(v)
  33373. return nil
  33374. }
  33375. return fmt.Errorf("unknown UsageTotal field %s", name)
  33376. }
  33377. // AddedFields returns all numeric fields that were incremented/decremented during
  33378. // this mutation.
  33379. func (m *UsageTotalMutation) AddedFields() []string {
  33380. var fields []string
  33381. if m.addstatus != nil {
  33382. fields = append(fields, usagetotal.FieldStatus)
  33383. }
  33384. if m.add_type != nil {
  33385. fields = append(fields, usagetotal.FieldType)
  33386. }
  33387. if m.addtotal_tokens != nil {
  33388. fields = append(fields, usagetotal.FieldTotalTokens)
  33389. }
  33390. if m.addstart_index != nil {
  33391. fields = append(fields, usagetotal.FieldStartIndex)
  33392. }
  33393. if m.addend_index != nil {
  33394. fields = append(fields, usagetotal.FieldEndIndex)
  33395. }
  33396. if m.addorganization_id != nil {
  33397. fields = append(fields, usagetotal.FieldOrganizationID)
  33398. }
  33399. return fields
  33400. }
  33401. // AddedField returns the numeric value that was incremented/decremented on a field
  33402. // with the given name. The second boolean return value indicates that this field
  33403. // was not set, or was not defined in the schema.
  33404. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  33405. switch name {
  33406. case usagetotal.FieldStatus:
  33407. return m.AddedStatus()
  33408. case usagetotal.FieldType:
  33409. return m.AddedType()
  33410. case usagetotal.FieldTotalTokens:
  33411. return m.AddedTotalTokens()
  33412. case usagetotal.FieldStartIndex:
  33413. return m.AddedStartIndex()
  33414. case usagetotal.FieldEndIndex:
  33415. return m.AddedEndIndex()
  33416. case usagetotal.FieldOrganizationID:
  33417. return m.AddedOrganizationID()
  33418. }
  33419. return nil, false
  33420. }
  33421. // AddField adds the value to the field with the given name. It returns an error if
  33422. // the field is not defined in the schema, or if the type mismatched the field
  33423. // type.
  33424. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  33425. switch name {
  33426. case usagetotal.FieldStatus:
  33427. v, ok := value.(int8)
  33428. if !ok {
  33429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33430. }
  33431. m.AddStatus(v)
  33432. return nil
  33433. case usagetotal.FieldType:
  33434. v, ok := value.(int)
  33435. if !ok {
  33436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33437. }
  33438. m.AddType(v)
  33439. return nil
  33440. case usagetotal.FieldTotalTokens:
  33441. v, ok := value.(int64)
  33442. if !ok {
  33443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33444. }
  33445. m.AddTotalTokens(v)
  33446. return nil
  33447. case usagetotal.FieldStartIndex:
  33448. v, ok := value.(int64)
  33449. if !ok {
  33450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33451. }
  33452. m.AddStartIndex(v)
  33453. return nil
  33454. case usagetotal.FieldEndIndex:
  33455. v, ok := value.(int64)
  33456. if !ok {
  33457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33458. }
  33459. m.AddEndIndex(v)
  33460. return nil
  33461. case usagetotal.FieldOrganizationID:
  33462. v, ok := value.(int64)
  33463. if !ok {
  33464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33465. }
  33466. m.AddOrganizationID(v)
  33467. return nil
  33468. }
  33469. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  33470. }
  33471. // ClearedFields returns all nullable fields that were cleared during this
  33472. // mutation.
  33473. func (m *UsageTotalMutation) ClearedFields() []string {
  33474. var fields []string
  33475. if m.FieldCleared(usagetotal.FieldStatus) {
  33476. fields = append(fields, usagetotal.FieldStatus)
  33477. }
  33478. if m.FieldCleared(usagetotal.FieldType) {
  33479. fields = append(fields, usagetotal.FieldType)
  33480. }
  33481. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  33482. fields = append(fields, usagetotal.FieldTotalTokens)
  33483. }
  33484. if m.FieldCleared(usagetotal.FieldStartIndex) {
  33485. fields = append(fields, usagetotal.FieldStartIndex)
  33486. }
  33487. if m.FieldCleared(usagetotal.FieldEndIndex) {
  33488. fields = append(fields, usagetotal.FieldEndIndex)
  33489. }
  33490. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  33491. fields = append(fields, usagetotal.FieldOrganizationID)
  33492. }
  33493. return fields
  33494. }
  33495. // FieldCleared returns a boolean indicating if a field with the given name was
  33496. // cleared in this mutation.
  33497. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  33498. _, ok := m.clearedFields[name]
  33499. return ok
  33500. }
  33501. // ClearField clears the value of the field with the given name. It returns an
  33502. // error if the field is not defined in the schema.
  33503. func (m *UsageTotalMutation) ClearField(name string) error {
  33504. switch name {
  33505. case usagetotal.FieldStatus:
  33506. m.ClearStatus()
  33507. return nil
  33508. case usagetotal.FieldType:
  33509. m.ClearType()
  33510. return nil
  33511. case usagetotal.FieldTotalTokens:
  33512. m.ClearTotalTokens()
  33513. return nil
  33514. case usagetotal.FieldStartIndex:
  33515. m.ClearStartIndex()
  33516. return nil
  33517. case usagetotal.FieldEndIndex:
  33518. m.ClearEndIndex()
  33519. return nil
  33520. case usagetotal.FieldOrganizationID:
  33521. m.ClearOrganizationID()
  33522. return nil
  33523. }
  33524. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  33525. }
  33526. // ResetField resets all changes in the mutation for the field with the given name.
  33527. // It returns an error if the field is not defined in the schema.
  33528. func (m *UsageTotalMutation) ResetField(name string) error {
  33529. switch name {
  33530. case usagetotal.FieldCreatedAt:
  33531. m.ResetCreatedAt()
  33532. return nil
  33533. case usagetotal.FieldUpdatedAt:
  33534. m.ResetUpdatedAt()
  33535. return nil
  33536. case usagetotal.FieldStatus:
  33537. m.ResetStatus()
  33538. return nil
  33539. case usagetotal.FieldType:
  33540. m.ResetType()
  33541. return nil
  33542. case usagetotal.FieldBotID:
  33543. m.ResetBotID()
  33544. return nil
  33545. case usagetotal.FieldTotalTokens:
  33546. m.ResetTotalTokens()
  33547. return nil
  33548. case usagetotal.FieldStartIndex:
  33549. m.ResetStartIndex()
  33550. return nil
  33551. case usagetotal.FieldEndIndex:
  33552. m.ResetEndIndex()
  33553. return nil
  33554. case usagetotal.FieldOrganizationID:
  33555. m.ResetOrganizationID()
  33556. return nil
  33557. }
  33558. return fmt.Errorf("unknown UsageTotal field %s", name)
  33559. }
  33560. // AddedEdges returns all edge names that were set/added in this mutation.
  33561. func (m *UsageTotalMutation) AddedEdges() []string {
  33562. edges := make([]string, 0, 0)
  33563. return edges
  33564. }
  33565. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33566. // name in this mutation.
  33567. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  33568. return nil
  33569. }
  33570. // RemovedEdges returns all edge names that were removed in this mutation.
  33571. func (m *UsageTotalMutation) RemovedEdges() []string {
  33572. edges := make([]string, 0, 0)
  33573. return edges
  33574. }
  33575. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33576. // the given name in this mutation.
  33577. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  33578. return nil
  33579. }
  33580. // ClearedEdges returns all edge names that were cleared in this mutation.
  33581. func (m *UsageTotalMutation) ClearedEdges() []string {
  33582. edges := make([]string, 0, 0)
  33583. return edges
  33584. }
  33585. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33586. // was cleared in this mutation.
  33587. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  33588. return false
  33589. }
  33590. // ClearEdge clears the value of the edge with the given name. It returns an error
  33591. // if that edge is not defined in the schema.
  33592. func (m *UsageTotalMutation) ClearEdge(name string) error {
  33593. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  33594. }
  33595. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33596. // It returns an error if the edge is not defined in the schema.
  33597. func (m *UsageTotalMutation) ResetEdge(name string) error {
  33598. return fmt.Errorf("unknown UsageTotal edge %s", name)
  33599. }
  33600. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  33601. type WorkExperienceMutation struct {
  33602. config
  33603. op Op
  33604. typ string
  33605. id *uint64
  33606. created_at *time.Time
  33607. updated_at *time.Time
  33608. deleted_at *time.Time
  33609. start_date *time.Time
  33610. end_date *time.Time
  33611. company *string
  33612. experience *string
  33613. organization_id *uint64
  33614. addorganization_id *int64
  33615. clearedFields map[string]struct{}
  33616. employee *uint64
  33617. clearedemployee bool
  33618. done bool
  33619. oldValue func(context.Context) (*WorkExperience, error)
  33620. predicates []predicate.WorkExperience
  33621. }
  33622. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  33623. // workexperienceOption allows management of the mutation configuration using functional options.
  33624. type workexperienceOption func(*WorkExperienceMutation)
  33625. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  33626. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  33627. m := &WorkExperienceMutation{
  33628. config: c,
  33629. op: op,
  33630. typ: TypeWorkExperience,
  33631. clearedFields: make(map[string]struct{}),
  33632. }
  33633. for _, opt := range opts {
  33634. opt(m)
  33635. }
  33636. return m
  33637. }
  33638. // withWorkExperienceID sets the ID field of the mutation.
  33639. func withWorkExperienceID(id uint64) workexperienceOption {
  33640. return func(m *WorkExperienceMutation) {
  33641. var (
  33642. err error
  33643. once sync.Once
  33644. value *WorkExperience
  33645. )
  33646. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  33647. once.Do(func() {
  33648. if m.done {
  33649. err = errors.New("querying old values post mutation is not allowed")
  33650. } else {
  33651. value, err = m.Client().WorkExperience.Get(ctx, id)
  33652. }
  33653. })
  33654. return value, err
  33655. }
  33656. m.id = &id
  33657. }
  33658. }
  33659. // withWorkExperience sets the old WorkExperience of the mutation.
  33660. func withWorkExperience(node *WorkExperience) workexperienceOption {
  33661. return func(m *WorkExperienceMutation) {
  33662. m.oldValue = func(context.Context) (*WorkExperience, error) {
  33663. return node, nil
  33664. }
  33665. m.id = &node.ID
  33666. }
  33667. }
  33668. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33669. // executed in a transaction (ent.Tx), a transactional client is returned.
  33670. func (m WorkExperienceMutation) Client() *Client {
  33671. client := &Client{config: m.config}
  33672. client.init()
  33673. return client
  33674. }
  33675. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33676. // it returns an error otherwise.
  33677. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  33678. if _, ok := m.driver.(*txDriver); !ok {
  33679. return nil, errors.New("ent: mutation is not running in a transaction")
  33680. }
  33681. tx := &Tx{config: m.config}
  33682. tx.init()
  33683. return tx, nil
  33684. }
  33685. // SetID sets the value of the id field. Note that this
  33686. // operation is only accepted on creation of WorkExperience entities.
  33687. func (m *WorkExperienceMutation) SetID(id uint64) {
  33688. m.id = &id
  33689. }
  33690. // ID returns the ID value in the mutation. Note that the ID is only available
  33691. // if it was provided to the builder or after it was returned from the database.
  33692. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  33693. if m.id == nil {
  33694. return
  33695. }
  33696. return *m.id, true
  33697. }
  33698. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33699. // That means, if the mutation is applied within a transaction with an isolation level such
  33700. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33701. // or updated by the mutation.
  33702. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  33703. switch {
  33704. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33705. id, exists := m.ID()
  33706. if exists {
  33707. return []uint64{id}, nil
  33708. }
  33709. fallthrough
  33710. case m.op.Is(OpUpdate | OpDelete):
  33711. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  33712. default:
  33713. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33714. }
  33715. }
  33716. // SetCreatedAt sets the "created_at" field.
  33717. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  33718. m.created_at = &t
  33719. }
  33720. // CreatedAt returns the value of the "created_at" field in the mutation.
  33721. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  33722. v := m.created_at
  33723. if v == nil {
  33724. return
  33725. }
  33726. return *v, true
  33727. }
  33728. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  33729. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  33730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33731. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33732. if !m.op.Is(OpUpdateOne) {
  33733. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33734. }
  33735. if m.id == nil || m.oldValue == nil {
  33736. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33737. }
  33738. oldValue, err := m.oldValue(ctx)
  33739. if err != nil {
  33740. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33741. }
  33742. return oldValue.CreatedAt, nil
  33743. }
  33744. // ResetCreatedAt resets all changes to the "created_at" field.
  33745. func (m *WorkExperienceMutation) ResetCreatedAt() {
  33746. m.created_at = nil
  33747. }
  33748. // SetUpdatedAt sets the "updated_at" field.
  33749. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  33750. m.updated_at = &t
  33751. }
  33752. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33753. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  33754. v := m.updated_at
  33755. if v == nil {
  33756. return
  33757. }
  33758. return *v, true
  33759. }
  33760. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  33761. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  33762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33763. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33764. if !m.op.Is(OpUpdateOne) {
  33765. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33766. }
  33767. if m.id == nil || m.oldValue == nil {
  33768. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33769. }
  33770. oldValue, err := m.oldValue(ctx)
  33771. if err != nil {
  33772. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33773. }
  33774. return oldValue.UpdatedAt, nil
  33775. }
  33776. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33777. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  33778. m.updated_at = nil
  33779. }
  33780. // SetDeletedAt sets the "deleted_at" field.
  33781. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  33782. m.deleted_at = &t
  33783. }
  33784. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33785. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  33786. v := m.deleted_at
  33787. if v == nil {
  33788. return
  33789. }
  33790. return *v, true
  33791. }
  33792. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  33793. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  33794. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33795. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  33796. if !m.op.Is(OpUpdateOne) {
  33797. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  33798. }
  33799. if m.id == nil || m.oldValue == nil {
  33800. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  33801. }
  33802. oldValue, err := m.oldValue(ctx)
  33803. if err != nil {
  33804. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  33805. }
  33806. return oldValue.DeletedAt, nil
  33807. }
  33808. // ClearDeletedAt clears the value of the "deleted_at" field.
  33809. func (m *WorkExperienceMutation) ClearDeletedAt() {
  33810. m.deleted_at = nil
  33811. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  33812. }
  33813. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  33814. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  33815. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  33816. return ok
  33817. }
  33818. // ResetDeletedAt resets all changes to the "deleted_at" field.
  33819. func (m *WorkExperienceMutation) ResetDeletedAt() {
  33820. m.deleted_at = nil
  33821. delete(m.clearedFields, workexperience.FieldDeletedAt)
  33822. }
  33823. // SetEmployeeID sets the "employee_id" field.
  33824. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  33825. m.employee = &u
  33826. }
  33827. // EmployeeID returns the value of the "employee_id" field in the mutation.
  33828. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  33829. v := m.employee
  33830. if v == nil {
  33831. return
  33832. }
  33833. return *v, true
  33834. }
  33835. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  33836. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  33837. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33838. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  33839. if !m.op.Is(OpUpdateOne) {
  33840. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  33841. }
  33842. if m.id == nil || m.oldValue == nil {
  33843. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  33844. }
  33845. oldValue, err := m.oldValue(ctx)
  33846. if err != nil {
  33847. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  33848. }
  33849. return oldValue.EmployeeID, nil
  33850. }
  33851. // ResetEmployeeID resets all changes to the "employee_id" field.
  33852. func (m *WorkExperienceMutation) ResetEmployeeID() {
  33853. m.employee = nil
  33854. }
  33855. // SetStartDate sets the "start_date" field.
  33856. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  33857. m.start_date = &t
  33858. }
  33859. // StartDate returns the value of the "start_date" field in the mutation.
  33860. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  33861. v := m.start_date
  33862. if v == nil {
  33863. return
  33864. }
  33865. return *v, true
  33866. }
  33867. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  33868. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  33869. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33870. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  33871. if !m.op.Is(OpUpdateOne) {
  33872. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  33873. }
  33874. if m.id == nil || m.oldValue == nil {
  33875. return v, errors.New("OldStartDate requires an ID field in the mutation")
  33876. }
  33877. oldValue, err := m.oldValue(ctx)
  33878. if err != nil {
  33879. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  33880. }
  33881. return oldValue.StartDate, nil
  33882. }
  33883. // ResetStartDate resets all changes to the "start_date" field.
  33884. func (m *WorkExperienceMutation) ResetStartDate() {
  33885. m.start_date = nil
  33886. }
  33887. // SetEndDate sets the "end_date" field.
  33888. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  33889. m.end_date = &t
  33890. }
  33891. // EndDate returns the value of the "end_date" field in the mutation.
  33892. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  33893. v := m.end_date
  33894. if v == nil {
  33895. return
  33896. }
  33897. return *v, true
  33898. }
  33899. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  33900. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  33901. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33902. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  33903. if !m.op.Is(OpUpdateOne) {
  33904. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  33905. }
  33906. if m.id == nil || m.oldValue == nil {
  33907. return v, errors.New("OldEndDate requires an ID field in the mutation")
  33908. }
  33909. oldValue, err := m.oldValue(ctx)
  33910. if err != nil {
  33911. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  33912. }
  33913. return oldValue.EndDate, nil
  33914. }
  33915. // ResetEndDate resets all changes to the "end_date" field.
  33916. func (m *WorkExperienceMutation) ResetEndDate() {
  33917. m.end_date = nil
  33918. }
  33919. // SetCompany sets the "company" field.
  33920. func (m *WorkExperienceMutation) SetCompany(s string) {
  33921. m.company = &s
  33922. }
  33923. // Company returns the value of the "company" field in the mutation.
  33924. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  33925. v := m.company
  33926. if v == nil {
  33927. return
  33928. }
  33929. return *v, true
  33930. }
  33931. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  33932. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  33933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33934. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  33935. if !m.op.Is(OpUpdateOne) {
  33936. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  33937. }
  33938. if m.id == nil || m.oldValue == nil {
  33939. return v, errors.New("OldCompany requires an ID field in the mutation")
  33940. }
  33941. oldValue, err := m.oldValue(ctx)
  33942. if err != nil {
  33943. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  33944. }
  33945. return oldValue.Company, nil
  33946. }
  33947. // ResetCompany resets all changes to the "company" field.
  33948. func (m *WorkExperienceMutation) ResetCompany() {
  33949. m.company = nil
  33950. }
  33951. // SetExperience sets the "experience" field.
  33952. func (m *WorkExperienceMutation) SetExperience(s string) {
  33953. m.experience = &s
  33954. }
  33955. // Experience returns the value of the "experience" field in the mutation.
  33956. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  33957. v := m.experience
  33958. if v == nil {
  33959. return
  33960. }
  33961. return *v, true
  33962. }
  33963. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  33964. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  33965. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33966. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  33967. if !m.op.Is(OpUpdateOne) {
  33968. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  33969. }
  33970. if m.id == nil || m.oldValue == nil {
  33971. return v, errors.New("OldExperience requires an ID field in the mutation")
  33972. }
  33973. oldValue, err := m.oldValue(ctx)
  33974. if err != nil {
  33975. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  33976. }
  33977. return oldValue.Experience, nil
  33978. }
  33979. // ResetExperience resets all changes to the "experience" field.
  33980. func (m *WorkExperienceMutation) ResetExperience() {
  33981. m.experience = nil
  33982. }
  33983. // SetOrganizationID sets the "organization_id" field.
  33984. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  33985. m.organization_id = &u
  33986. m.addorganization_id = nil
  33987. }
  33988. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33989. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  33990. v := m.organization_id
  33991. if v == nil {
  33992. return
  33993. }
  33994. return *v, true
  33995. }
  33996. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  33997. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  33998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33999. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34000. if !m.op.Is(OpUpdateOne) {
  34001. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34002. }
  34003. if m.id == nil || m.oldValue == nil {
  34004. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34005. }
  34006. oldValue, err := m.oldValue(ctx)
  34007. if err != nil {
  34008. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34009. }
  34010. return oldValue.OrganizationID, nil
  34011. }
  34012. // AddOrganizationID adds u to the "organization_id" field.
  34013. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  34014. if m.addorganization_id != nil {
  34015. *m.addorganization_id += u
  34016. } else {
  34017. m.addorganization_id = &u
  34018. }
  34019. }
  34020. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34021. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  34022. v := m.addorganization_id
  34023. if v == nil {
  34024. return
  34025. }
  34026. return *v, true
  34027. }
  34028. // ResetOrganizationID resets all changes to the "organization_id" field.
  34029. func (m *WorkExperienceMutation) ResetOrganizationID() {
  34030. m.organization_id = nil
  34031. m.addorganization_id = nil
  34032. }
  34033. // ClearEmployee clears the "employee" edge to the Employee entity.
  34034. func (m *WorkExperienceMutation) ClearEmployee() {
  34035. m.clearedemployee = true
  34036. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  34037. }
  34038. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  34039. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  34040. return m.clearedemployee
  34041. }
  34042. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  34043. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  34044. // EmployeeID instead. It exists only for internal usage by the builders.
  34045. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  34046. if id := m.employee; id != nil {
  34047. ids = append(ids, *id)
  34048. }
  34049. return
  34050. }
  34051. // ResetEmployee resets all changes to the "employee" edge.
  34052. func (m *WorkExperienceMutation) ResetEmployee() {
  34053. m.employee = nil
  34054. m.clearedemployee = false
  34055. }
  34056. // Where appends a list predicates to the WorkExperienceMutation builder.
  34057. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  34058. m.predicates = append(m.predicates, ps...)
  34059. }
  34060. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  34061. // users can use type-assertion to append predicates that do not depend on any generated package.
  34062. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  34063. p := make([]predicate.WorkExperience, len(ps))
  34064. for i := range ps {
  34065. p[i] = ps[i]
  34066. }
  34067. m.Where(p...)
  34068. }
  34069. // Op returns the operation name.
  34070. func (m *WorkExperienceMutation) Op() Op {
  34071. return m.op
  34072. }
  34073. // SetOp allows setting the mutation operation.
  34074. func (m *WorkExperienceMutation) SetOp(op Op) {
  34075. m.op = op
  34076. }
  34077. // Type returns the node type of this mutation (WorkExperience).
  34078. func (m *WorkExperienceMutation) Type() string {
  34079. return m.typ
  34080. }
  34081. // Fields returns all fields that were changed during this mutation. Note that in
  34082. // order to get all numeric fields that were incremented/decremented, call
  34083. // AddedFields().
  34084. func (m *WorkExperienceMutation) Fields() []string {
  34085. fields := make([]string, 0, 9)
  34086. if m.created_at != nil {
  34087. fields = append(fields, workexperience.FieldCreatedAt)
  34088. }
  34089. if m.updated_at != nil {
  34090. fields = append(fields, workexperience.FieldUpdatedAt)
  34091. }
  34092. if m.deleted_at != nil {
  34093. fields = append(fields, workexperience.FieldDeletedAt)
  34094. }
  34095. if m.employee != nil {
  34096. fields = append(fields, workexperience.FieldEmployeeID)
  34097. }
  34098. if m.start_date != nil {
  34099. fields = append(fields, workexperience.FieldStartDate)
  34100. }
  34101. if m.end_date != nil {
  34102. fields = append(fields, workexperience.FieldEndDate)
  34103. }
  34104. if m.company != nil {
  34105. fields = append(fields, workexperience.FieldCompany)
  34106. }
  34107. if m.experience != nil {
  34108. fields = append(fields, workexperience.FieldExperience)
  34109. }
  34110. if m.organization_id != nil {
  34111. fields = append(fields, workexperience.FieldOrganizationID)
  34112. }
  34113. return fields
  34114. }
  34115. // Field returns the value of a field with the given name. The second boolean
  34116. // return value indicates that this field was not set, or was not defined in the
  34117. // schema.
  34118. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  34119. switch name {
  34120. case workexperience.FieldCreatedAt:
  34121. return m.CreatedAt()
  34122. case workexperience.FieldUpdatedAt:
  34123. return m.UpdatedAt()
  34124. case workexperience.FieldDeletedAt:
  34125. return m.DeletedAt()
  34126. case workexperience.FieldEmployeeID:
  34127. return m.EmployeeID()
  34128. case workexperience.FieldStartDate:
  34129. return m.StartDate()
  34130. case workexperience.FieldEndDate:
  34131. return m.EndDate()
  34132. case workexperience.FieldCompany:
  34133. return m.Company()
  34134. case workexperience.FieldExperience:
  34135. return m.Experience()
  34136. case workexperience.FieldOrganizationID:
  34137. return m.OrganizationID()
  34138. }
  34139. return nil, false
  34140. }
  34141. // OldField returns the old value of the field from the database. An error is
  34142. // returned if the mutation operation is not UpdateOne, or the query to the
  34143. // database failed.
  34144. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34145. switch name {
  34146. case workexperience.FieldCreatedAt:
  34147. return m.OldCreatedAt(ctx)
  34148. case workexperience.FieldUpdatedAt:
  34149. return m.OldUpdatedAt(ctx)
  34150. case workexperience.FieldDeletedAt:
  34151. return m.OldDeletedAt(ctx)
  34152. case workexperience.FieldEmployeeID:
  34153. return m.OldEmployeeID(ctx)
  34154. case workexperience.FieldStartDate:
  34155. return m.OldStartDate(ctx)
  34156. case workexperience.FieldEndDate:
  34157. return m.OldEndDate(ctx)
  34158. case workexperience.FieldCompany:
  34159. return m.OldCompany(ctx)
  34160. case workexperience.FieldExperience:
  34161. return m.OldExperience(ctx)
  34162. case workexperience.FieldOrganizationID:
  34163. return m.OldOrganizationID(ctx)
  34164. }
  34165. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  34166. }
  34167. // SetField sets the value of a field with the given name. It returns an error if
  34168. // the field is not defined in the schema, or if the type mismatched the field
  34169. // type.
  34170. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  34171. switch name {
  34172. case workexperience.FieldCreatedAt:
  34173. v, ok := value.(time.Time)
  34174. if !ok {
  34175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34176. }
  34177. m.SetCreatedAt(v)
  34178. return nil
  34179. case workexperience.FieldUpdatedAt:
  34180. v, ok := value.(time.Time)
  34181. if !ok {
  34182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34183. }
  34184. m.SetUpdatedAt(v)
  34185. return nil
  34186. case workexperience.FieldDeletedAt:
  34187. v, ok := value.(time.Time)
  34188. if !ok {
  34189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34190. }
  34191. m.SetDeletedAt(v)
  34192. return nil
  34193. case workexperience.FieldEmployeeID:
  34194. v, ok := value.(uint64)
  34195. if !ok {
  34196. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34197. }
  34198. m.SetEmployeeID(v)
  34199. return nil
  34200. case workexperience.FieldStartDate:
  34201. v, ok := value.(time.Time)
  34202. if !ok {
  34203. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34204. }
  34205. m.SetStartDate(v)
  34206. return nil
  34207. case workexperience.FieldEndDate:
  34208. v, ok := value.(time.Time)
  34209. if !ok {
  34210. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34211. }
  34212. m.SetEndDate(v)
  34213. return nil
  34214. case workexperience.FieldCompany:
  34215. v, ok := value.(string)
  34216. if !ok {
  34217. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34218. }
  34219. m.SetCompany(v)
  34220. return nil
  34221. case workexperience.FieldExperience:
  34222. v, ok := value.(string)
  34223. if !ok {
  34224. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34225. }
  34226. m.SetExperience(v)
  34227. return nil
  34228. case workexperience.FieldOrganizationID:
  34229. v, ok := value.(uint64)
  34230. if !ok {
  34231. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34232. }
  34233. m.SetOrganizationID(v)
  34234. return nil
  34235. }
  34236. return fmt.Errorf("unknown WorkExperience field %s", name)
  34237. }
  34238. // AddedFields returns all numeric fields that were incremented/decremented during
  34239. // this mutation.
  34240. func (m *WorkExperienceMutation) AddedFields() []string {
  34241. var fields []string
  34242. if m.addorganization_id != nil {
  34243. fields = append(fields, workexperience.FieldOrganizationID)
  34244. }
  34245. return fields
  34246. }
  34247. // AddedField returns the numeric value that was incremented/decremented on a field
  34248. // with the given name. The second boolean return value indicates that this field
  34249. // was not set, or was not defined in the schema.
  34250. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  34251. switch name {
  34252. case workexperience.FieldOrganizationID:
  34253. return m.AddedOrganizationID()
  34254. }
  34255. return nil, false
  34256. }
  34257. // AddField adds the value to the field with the given name. It returns an error if
  34258. // the field is not defined in the schema, or if the type mismatched the field
  34259. // type.
  34260. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  34261. switch name {
  34262. case workexperience.FieldOrganizationID:
  34263. v, ok := value.(int64)
  34264. if !ok {
  34265. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34266. }
  34267. m.AddOrganizationID(v)
  34268. return nil
  34269. }
  34270. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  34271. }
  34272. // ClearedFields returns all nullable fields that were cleared during this
  34273. // mutation.
  34274. func (m *WorkExperienceMutation) ClearedFields() []string {
  34275. var fields []string
  34276. if m.FieldCleared(workexperience.FieldDeletedAt) {
  34277. fields = append(fields, workexperience.FieldDeletedAt)
  34278. }
  34279. return fields
  34280. }
  34281. // FieldCleared returns a boolean indicating if a field with the given name was
  34282. // cleared in this mutation.
  34283. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  34284. _, ok := m.clearedFields[name]
  34285. return ok
  34286. }
  34287. // ClearField clears the value of the field with the given name. It returns an
  34288. // error if the field is not defined in the schema.
  34289. func (m *WorkExperienceMutation) ClearField(name string) error {
  34290. switch name {
  34291. case workexperience.FieldDeletedAt:
  34292. m.ClearDeletedAt()
  34293. return nil
  34294. }
  34295. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  34296. }
  34297. // ResetField resets all changes in the mutation for the field with the given name.
  34298. // It returns an error if the field is not defined in the schema.
  34299. func (m *WorkExperienceMutation) ResetField(name string) error {
  34300. switch name {
  34301. case workexperience.FieldCreatedAt:
  34302. m.ResetCreatedAt()
  34303. return nil
  34304. case workexperience.FieldUpdatedAt:
  34305. m.ResetUpdatedAt()
  34306. return nil
  34307. case workexperience.FieldDeletedAt:
  34308. m.ResetDeletedAt()
  34309. return nil
  34310. case workexperience.FieldEmployeeID:
  34311. m.ResetEmployeeID()
  34312. return nil
  34313. case workexperience.FieldStartDate:
  34314. m.ResetStartDate()
  34315. return nil
  34316. case workexperience.FieldEndDate:
  34317. m.ResetEndDate()
  34318. return nil
  34319. case workexperience.FieldCompany:
  34320. m.ResetCompany()
  34321. return nil
  34322. case workexperience.FieldExperience:
  34323. m.ResetExperience()
  34324. return nil
  34325. case workexperience.FieldOrganizationID:
  34326. m.ResetOrganizationID()
  34327. return nil
  34328. }
  34329. return fmt.Errorf("unknown WorkExperience field %s", name)
  34330. }
  34331. // AddedEdges returns all edge names that were set/added in this mutation.
  34332. func (m *WorkExperienceMutation) AddedEdges() []string {
  34333. edges := make([]string, 0, 1)
  34334. if m.employee != nil {
  34335. edges = append(edges, workexperience.EdgeEmployee)
  34336. }
  34337. return edges
  34338. }
  34339. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34340. // name in this mutation.
  34341. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  34342. switch name {
  34343. case workexperience.EdgeEmployee:
  34344. if id := m.employee; id != nil {
  34345. return []ent.Value{*id}
  34346. }
  34347. }
  34348. return nil
  34349. }
  34350. // RemovedEdges returns all edge names that were removed in this mutation.
  34351. func (m *WorkExperienceMutation) RemovedEdges() []string {
  34352. edges := make([]string, 0, 1)
  34353. return edges
  34354. }
  34355. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34356. // the given name in this mutation.
  34357. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  34358. return nil
  34359. }
  34360. // ClearedEdges returns all edge names that were cleared in this mutation.
  34361. func (m *WorkExperienceMutation) ClearedEdges() []string {
  34362. edges := make([]string, 0, 1)
  34363. if m.clearedemployee {
  34364. edges = append(edges, workexperience.EdgeEmployee)
  34365. }
  34366. return edges
  34367. }
  34368. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34369. // was cleared in this mutation.
  34370. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  34371. switch name {
  34372. case workexperience.EdgeEmployee:
  34373. return m.clearedemployee
  34374. }
  34375. return false
  34376. }
  34377. // ClearEdge clears the value of the edge with the given name. It returns an error
  34378. // if that edge is not defined in the schema.
  34379. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  34380. switch name {
  34381. case workexperience.EdgeEmployee:
  34382. m.ClearEmployee()
  34383. return nil
  34384. }
  34385. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  34386. }
  34387. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34388. // It returns an error if the edge is not defined in the schema.
  34389. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  34390. switch name {
  34391. case workexperience.EdgeEmployee:
  34392. m.ResetEmployee()
  34393. return nil
  34394. }
  34395. return fmt.Errorf("unknown WorkExperience edge %s", name)
  34396. }
  34397. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  34398. type WpChatroomMutation struct {
  34399. config
  34400. op Op
  34401. typ string
  34402. id *uint64
  34403. created_at *time.Time
  34404. updated_at *time.Time
  34405. status *uint8
  34406. addstatus *int8
  34407. wx_wxid *string
  34408. chatroom_id *string
  34409. nickname *string
  34410. owner *string
  34411. avatar *string
  34412. member_list *[]string
  34413. appendmember_list []string
  34414. clearedFields map[string]struct{}
  34415. done bool
  34416. oldValue func(context.Context) (*WpChatroom, error)
  34417. predicates []predicate.WpChatroom
  34418. }
  34419. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  34420. // wpchatroomOption allows management of the mutation configuration using functional options.
  34421. type wpchatroomOption func(*WpChatroomMutation)
  34422. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  34423. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  34424. m := &WpChatroomMutation{
  34425. config: c,
  34426. op: op,
  34427. typ: TypeWpChatroom,
  34428. clearedFields: make(map[string]struct{}),
  34429. }
  34430. for _, opt := range opts {
  34431. opt(m)
  34432. }
  34433. return m
  34434. }
  34435. // withWpChatroomID sets the ID field of the mutation.
  34436. func withWpChatroomID(id uint64) wpchatroomOption {
  34437. return func(m *WpChatroomMutation) {
  34438. var (
  34439. err error
  34440. once sync.Once
  34441. value *WpChatroom
  34442. )
  34443. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  34444. once.Do(func() {
  34445. if m.done {
  34446. err = errors.New("querying old values post mutation is not allowed")
  34447. } else {
  34448. value, err = m.Client().WpChatroom.Get(ctx, id)
  34449. }
  34450. })
  34451. return value, err
  34452. }
  34453. m.id = &id
  34454. }
  34455. }
  34456. // withWpChatroom sets the old WpChatroom of the mutation.
  34457. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  34458. return func(m *WpChatroomMutation) {
  34459. m.oldValue = func(context.Context) (*WpChatroom, error) {
  34460. return node, nil
  34461. }
  34462. m.id = &node.ID
  34463. }
  34464. }
  34465. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34466. // executed in a transaction (ent.Tx), a transactional client is returned.
  34467. func (m WpChatroomMutation) Client() *Client {
  34468. client := &Client{config: m.config}
  34469. client.init()
  34470. return client
  34471. }
  34472. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34473. // it returns an error otherwise.
  34474. func (m WpChatroomMutation) Tx() (*Tx, error) {
  34475. if _, ok := m.driver.(*txDriver); !ok {
  34476. return nil, errors.New("ent: mutation is not running in a transaction")
  34477. }
  34478. tx := &Tx{config: m.config}
  34479. tx.init()
  34480. return tx, nil
  34481. }
  34482. // SetID sets the value of the id field. Note that this
  34483. // operation is only accepted on creation of WpChatroom entities.
  34484. func (m *WpChatroomMutation) SetID(id uint64) {
  34485. m.id = &id
  34486. }
  34487. // ID returns the ID value in the mutation. Note that the ID is only available
  34488. // if it was provided to the builder or after it was returned from the database.
  34489. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  34490. if m.id == nil {
  34491. return
  34492. }
  34493. return *m.id, true
  34494. }
  34495. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34496. // That means, if the mutation is applied within a transaction with an isolation level such
  34497. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34498. // or updated by the mutation.
  34499. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  34500. switch {
  34501. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34502. id, exists := m.ID()
  34503. if exists {
  34504. return []uint64{id}, nil
  34505. }
  34506. fallthrough
  34507. case m.op.Is(OpUpdate | OpDelete):
  34508. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  34509. default:
  34510. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34511. }
  34512. }
  34513. // SetCreatedAt sets the "created_at" field.
  34514. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  34515. m.created_at = &t
  34516. }
  34517. // CreatedAt returns the value of the "created_at" field in the mutation.
  34518. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  34519. v := m.created_at
  34520. if v == nil {
  34521. return
  34522. }
  34523. return *v, true
  34524. }
  34525. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  34526. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  34527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34528. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34529. if !m.op.Is(OpUpdateOne) {
  34530. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34531. }
  34532. if m.id == nil || m.oldValue == nil {
  34533. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34534. }
  34535. oldValue, err := m.oldValue(ctx)
  34536. if err != nil {
  34537. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34538. }
  34539. return oldValue.CreatedAt, nil
  34540. }
  34541. // ResetCreatedAt resets all changes to the "created_at" field.
  34542. func (m *WpChatroomMutation) ResetCreatedAt() {
  34543. m.created_at = nil
  34544. }
  34545. // SetUpdatedAt sets the "updated_at" field.
  34546. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  34547. m.updated_at = &t
  34548. }
  34549. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34550. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  34551. v := m.updated_at
  34552. if v == nil {
  34553. return
  34554. }
  34555. return *v, true
  34556. }
  34557. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  34558. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  34559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34560. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34561. if !m.op.Is(OpUpdateOne) {
  34562. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34563. }
  34564. if m.id == nil || m.oldValue == nil {
  34565. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34566. }
  34567. oldValue, err := m.oldValue(ctx)
  34568. if err != nil {
  34569. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34570. }
  34571. return oldValue.UpdatedAt, nil
  34572. }
  34573. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34574. func (m *WpChatroomMutation) ResetUpdatedAt() {
  34575. m.updated_at = nil
  34576. }
  34577. // SetStatus sets the "status" field.
  34578. func (m *WpChatroomMutation) SetStatus(u uint8) {
  34579. m.status = &u
  34580. m.addstatus = nil
  34581. }
  34582. // Status returns the value of the "status" field in the mutation.
  34583. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  34584. v := m.status
  34585. if v == nil {
  34586. return
  34587. }
  34588. return *v, true
  34589. }
  34590. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  34591. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  34592. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34593. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  34594. if !m.op.Is(OpUpdateOne) {
  34595. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  34596. }
  34597. if m.id == nil || m.oldValue == nil {
  34598. return v, errors.New("OldStatus requires an ID field in the mutation")
  34599. }
  34600. oldValue, err := m.oldValue(ctx)
  34601. if err != nil {
  34602. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  34603. }
  34604. return oldValue.Status, nil
  34605. }
  34606. // AddStatus adds u to the "status" field.
  34607. func (m *WpChatroomMutation) AddStatus(u int8) {
  34608. if m.addstatus != nil {
  34609. *m.addstatus += u
  34610. } else {
  34611. m.addstatus = &u
  34612. }
  34613. }
  34614. // AddedStatus returns the value that was added to the "status" field in this mutation.
  34615. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  34616. v := m.addstatus
  34617. if v == nil {
  34618. return
  34619. }
  34620. return *v, true
  34621. }
  34622. // ClearStatus clears the value of the "status" field.
  34623. func (m *WpChatroomMutation) ClearStatus() {
  34624. m.status = nil
  34625. m.addstatus = nil
  34626. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  34627. }
  34628. // StatusCleared returns if the "status" field was cleared in this mutation.
  34629. func (m *WpChatroomMutation) StatusCleared() bool {
  34630. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  34631. return ok
  34632. }
  34633. // ResetStatus resets all changes to the "status" field.
  34634. func (m *WpChatroomMutation) ResetStatus() {
  34635. m.status = nil
  34636. m.addstatus = nil
  34637. delete(m.clearedFields, wpchatroom.FieldStatus)
  34638. }
  34639. // SetWxWxid sets the "wx_wxid" field.
  34640. func (m *WpChatroomMutation) SetWxWxid(s string) {
  34641. m.wx_wxid = &s
  34642. }
  34643. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  34644. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  34645. v := m.wx_wxid
  34646. if v == nil {
  34647. return
  34648. }
  34649. return *v, true
  34650. }
  34651. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  34652. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  34653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34654. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  34655. if !m.op.Is(OpUpdateOne) {
  34656. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  34657. }
  34658. if m.id == nil || m.oldValue == nil {
  34659. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  34660. }
  34661. oldValue, err := m.oldValue(ctx)
  34662. if err != nil {
  34663. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  34664. }
  34665. return oldValue.WxWxid, nil
  34666. }
  34667. // ResetWxWxid resets all changes to the "wx_wxid" field.
  34668. func (m *WpChatroomMutation) ResetWxWxid() {
  34669. m.wx_wxid = nil
  34670. }
  34671. // SetChatroomID sets the "chatroom_id" field.
  34672. func (m *WpChatroomMutation) SetChatroomID(s string) {
  34673. m.chatroom_id = &s
  34674. }
  34675. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  34676. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  34677. v := m.chatroom_id
  34678. if v == nil {
  34679. return
  34680. }
  34681. return *v, true
  34682. }
  34683. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  34684. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  34685. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34686. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  34687. if !m.op.Is(OpUpdateOne) {
  34688. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  34689. }
  34690. if m.id == nil || m.oldValue == nil {
  34691. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  34692. }
  34693. oldValue, err := m.oldValue(ctx)
  34694. if err != nil {
  34695. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  34696. }
  34697. return oldValue.ChatroomID, nil
  34698. }
  34699. // ResetChatroomID resets all changes to the "chatroom_id" field.
  34700. func (m *WpChatroomMutation) ResetChatroomID() {
  34701. m.chatroom_id = nil
  34702. }
  34703. // SetNickname sets the "nickname" field.
  34704. func (m *WpChatroomMutation) SetNickname(s string) {
  34705. m.nickname = &s
  34706. }
  34707. // Nickname returns the value of the "nickname" field in the mutation.
  34708. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  34709. v := m.nickname
  34710. if v == nil {
  34711. return
  34712. }
  34713. return *v, true
  34714. }
  34715. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  34716. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  34717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34718. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  34719. if !m.op.Is(OpUpdateOne) {
  34720. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  34721. }
  34722. if m.id == nil || m.oldValue == nil {
  34723. return v, errors.New("OldNickname requires an ID field in the mutation")
  34724. }
  34725. oldValue, err := m.oldValue(ctx)
  34726. if err != nil {
  34727. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  34728. }
  34729. return oldValue.Nickname, nil
  34730. }
  34731. // ResetNickname resets all changes to the "nickname" field.
  34732. func (m *WpChatroomMutation) ResetNickname() {
  34733. m.nickname = nil
  34734. }
  34735. // SetOwner sets the "owner" field.
  34736. func (m *WpChatroomMutation) SetOwner(s string) {
  34737. m.owner = &s
  34738. }
  34739. // Owner returns the value of the "owner" field in the mutation.
  34740. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  34741. v := m.owner
  34742. if v == nil {
  34743. return
  34744. }
  34745. return *v, true
  34746. }
  34747. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  34748. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  34749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34750. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  34751. if !m.op.Is(OpUpdateOne) {
  34752. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  34753. }
  34754. if m.id == nil || m.oldValue == nil {
  34755. return v, errors.New("OldOwner requires an ID field in the mutation")
  34756. }
  34757. oldValue, err := m.oldValue(ctx)
  34758. if err != nil {
  34759. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  34760. }
  34761. return oldValue.Owner, nil
  34762. }
  34763. // ResetOwner resets all changes to the "owner" field.
  34764. func (m *WpChatroomMutation) ResetOwner() {
  34765. m.owner = nil
  34766. }
  34767. // SetAvatar sets the "avatar" field.
  34768. func (m *WpChatroomMutation) SetAvatar(s string) {
  34769. m.avatar = &s
  34770. }
  34771. // Avatar returns the value of the "avatar" field in the mutation.
  34772. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  34773. v := m.avatar
  34774. if v == nil {
  34775. return
  34776. }
  34777. return *v, true
  34778. }
  34779. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  34780. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  34781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34782. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  34783. if !m.op.Is(OpUpdateOne) {
  34784. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  34785. }
  34786. if m.id == nil || m.oldValue == nil {
  34787. return v, errors.New("OldAvatar requires an ID field in the mutation")
  34788. }
  34789. oldValue, err := m.oldValue(ctx)
  34790. if err != nil {
  34791. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  34792. }
  34793. return oldValue.Avatar, nil
  34794. }
  34795. // ResetAvatar resets all changes to the "avatar" field.
  34796. func (m *WpChatroomMutation) ResetAvatar() {
  34797. m.avatar = nil
  34798. }
  34799. // SetMemberList sets the "member_list" field.
  34800. func (m *WpChatroomMutation) SetMemberList(s []string) {
  34801. m.member_list = &s
  34802. m.appendmember_list = nil
  34803. }
  34804. // MemberList returns the value of the "member_list" field in the mutation.
  34805. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  34806. v := m.member_list
  34807. if v == nil {
  34808. return
  34809. }
  34810. return *v, true
  34811. }
  34812. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  34813. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  34814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34815. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  34816. if !m.op.Is(OpUpdateOne) {
  34817. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  34818. }
  34819. if m.id == nil || m.oldValue == nil {
  34820. return v, errors.New("OldMemberList requires an ID field in the mutation")
  34821. }
  34822. oldValue, err := m.oldValue(ctx)
  34823. if err != nil {
  34824. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  34825. }
  34826. return oldValue.MemberList, nil
  34827. }
  34828. // AppendMemberList adds s to the "member_list" field.
  34829. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  34830. m.appendmember_list = append(m.appendmember_list, s...)
  34831. }
  34832. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  34833. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  34834. if len(m.appendmember_list) == 0 {
  34835. return nil, false
  34836. }
  34837. return m.appendmember_list, true
  34838. }
  34839. // ResetMemberList resets all changes to the "member_list" field.
  34840. func (m *WpChatroomMutation) ResetMemberList() {
  34841. m.member_list = nil
  34842. m.appendmember_list = nil
  34843. }
  34844. // Where appends a list predicates to the WpChatroomMutation builder.
  34845. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  34846. m.predicates = append(m.predicates, ps...)
  34847. }
  34848. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  34849. // users can use type-assertion to append predicates that do not depend on any generated package.
  34850. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  34851. p := make([]predicate.WpChatroom, len(ps))
  34852. for i := range ps {
  34853. p[i] = ps[i]
  34854. }
  34855. m.Where(p...)
  34856. }
  34857. // Op returns the operation name.
  34858. func (m *WpChatroomMutation) Op() Op {
  34859. return m.op
  34860. }
  34861. // SetOp allows setting the mutation operation.
  34862. func (m *WpChatroomMutation) SetOp(op Op) {
  34863. m.op = op
  34864. }
  34865. // Type returns the node type of this mutation (WpChatroom).
  34866. func (m *WpChatroomMutation) Type() string {
  34867. return m.typ
  34868. }
  34869. // Fields returns all fields that were changed during this mutation. Note that in
  34870. // order to get all numeric fields that were incremented/decremented, call
  34871. // AddedFields().
  34872. func (m *WpChatroomMutation) Fields() []string {
  34873. fields := make([]string, 0, 9)
  34874. if m.created_at != nil {
  34875. fields = append(fields, wpchatroom.FieldCreatedAt)
  34876. }
  34877. if m.updated_at != nil {
  34878. fields = append(fields, wpchatroom.FieldUpdatedAt)
  34879. }
  34880. if m.status != nil {
  34881. fields = append(fields, wpchatroom.FieldStatus)
  34882. }
  34883. if m.wx_wxid != nil {
  34884. fields = append(fields, wpchatroom.FieldWxWxid)
  34885. }
  34886. if m.chatroom_id != nil {
  34887. fields = append(fields, wpchatroom.FieldChatroomID)
  34888. }
  34889. if m.nickname != nil {
  34890. fields = append(fields, wpchatroom.FieldNickname)
  34891. }
  34892. if m.owner != nil {
  34893. fields = append(fields, wpchatroom.FieldOwner)
  34894. }
  34895. if m.avatar != nil {
  34896. fields = append(fields, wpchatroom.FieldAvatar)
  34897. }
  34898. if m.member_list != nil {
  34899. fields = append(fields, wpchatroom.FieldMemberList)
  34900. }
  34901. return fields
  34902. }
  34903. // Field returns the value of a field with the given name. The second boolean
  34904. // return value indicates that this field was not set, or was not defined in the
  34905. // schema.
  34906. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  34907. switch name {
  34908. case wpchatroom.FieldCreatedAt:
  34909. return m.CreatedAt()
  34910. case wpchatroom.FieldUpdatedAt:
  34911. return m.UpdatedAt()
  34912. case wpchatroom.FieldStatus:
  34913. return m.Status()
  34914. case wpchatroom.FieldWxWxid:
  34915. return m.WxWxid()
  34916. case wpchatroom.FieldChatroomID:
  34917. return m.ChatroomID()
  34918. case wpchatroom.FieldNickname:
  34919. return m.Nickname()
  34920. case wpchatroom.FieldOwner:
  34921. return m.Owner()
  34922. case wpchatroom.FieldAvatar:
  34923. return m.Avatar()
  34924. case wpchatroom.FieldMemberList:
  34925. return m.MemberList()
  34926. }
  34927. return nil, false
  34928. }
  34929. // OldField returns the old value of the field from the database. An error is
  34930. // returned if the mutation operation is not UpdateOne, or the query to the
  34931. // database failed.
  34932. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34933. switch name {
  34934. case wpchatroom.FieldCreatedAt:
  34935. return m.OldCreatedAt(ctx)
  34936. case wpchatroom.FieldUpdatedAt:
  34937. return m.OldUpdatedAt(ctx)
  34938. case wpchatroom.FieldStatus:
  34939. return m.OldStatus(ctx)
  34940. case wpchatroom.FieldWxWxid:
  34941. return m.OldWxWxid(ctx)
  34942. case wpchatroom.FieldChatroomID:
  34943. return m.OldChatroomID(ctx)
  34944. case wpchatroom.FieldNickname:
  34945. return m.OldNickname(ctx)
  34946. case wpchatroom.FieldOwner:
  34947. return m.OldOwner(ctx)
  34948. case wpchatroom.FieldAvatar:
  34949. return m.OldAvatar(ctx)
  34950. case wpchatroom.FieldMemberList:
  34951. return m.OldMemberList(ctx)
  34952. }
  34953. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  34954. }
  34955. // SetField sets the value of a field with the given name. It returns an error if
  34956. // the field is not defined in the schema, or if the type mismatched the field
  34957. // type.
  34958. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  34959. switch name {
  34960. case wpchatroom.FieldCreatedAt:
  34961. v, ok := value.(time.Time)
  34962. if !ok {
  34963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34964. }
  34965. m.SetCreatedAt(v)
  34966. return nil
  34967. case wpchatroom.FieldUpdatedAt:
  34968. v, ok := value.(time.Time)
  34969. if !ok {
  34970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34971. }
  34972. m.SetUpdatedAt(v)
  34973. return nil
  34974. case wpchatroom.FieldStatus:
  34975. v, ok := value.(uint8)
  34976. if !ok {
  34977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34978. }
  34979. m.SetStatus(v)
  34980. return nil
  34981. case wpchatroom.FieldWxWxid:
  34982. v, ok := value.(string)
  34983. if !ok {
  34984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34985. }
  34986. m.SetWxWxid(v)
  34987. return nil
  34988. case wpchatroom.FieldChatroomID:
  34989. v, ok := value.(string)
  34990. if !ok {
  34991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34992. }
  34993. m.SetChatroomID(v)
  34994. return nil
  34995. case wpchatroom.FieldNickname:
  34996. v, ok := value.(string)
  34997. if !ok {
  34998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34999. }
  35000. m.SetNickname(v)
  35001. return nil
  35002. case wpchatroom.FieldOwner:
  35003. v, ok := value.(string)
  35004. if !ok {
  35005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35006. }
  35007. m.SetOwner(v)
  35008. return nil
  35009. case wpchatroom.FieldAvatar:
  35010. v, ok := value.(string)
  35011. if !ok {
  35012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35013. }
  35014. m.SetAvatar(v)
  35015. return nil
  35016. case wpchatroom.FieldMemberList:
  35017. v, ok := value.([]string)
  35018. if !ok {
  35019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35020. }
  35021. m.SetMemberList(v)
  35022. return nil
  35023. }
  35024. return fmt.Errorf("unknown WpChatroom field %s", name)
  35025. }
  35026. // AddedFields returns all numeric fields that were incremented/decremented during
  35027. // this mutation.
  35028. func (m *WpChatroomMutation) AddedFields() []string {
  35029. var fields []string
  35030. if m.addstatus != nil {
  35031. fields = append(fields, wpchatroom.FieldStatus)
  35032. }
  35033. return fields
  35034. }
  35035. // AddedField returns the numeric value that was incremented/decremented on a field
  35036. // with the given name. The second boolean return value indicates that this field
  35037. // was not set, or was not defined in the schema.
  35038. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  35039. switch name {
  35040. case wpchatroom.FieldStatus:
  35041. return m.AddedStatus()
  35042. }
  35043. return nil, false
  35044. }
  35045. // AddField adds the value to the field with the given name. It returns an error if
  35046. // the field is not defined in the schema, or if the type mismatched the field
  35047. // type.
  35048. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  35049. switch name {
  35050. case wpchatroom.FieldStatus:
  35051. v, ok := value.(int8)
  35052. if !ok {
  35053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35054. }
  35055. m.AddStatus(v)
  35056. return nil
  35057. }
  35058. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  35059. }
  35060. // ClearedFields returns all nullable fields that were cleared during this
  35061. // mutation.
  35062. func (m *WpChatroomMutation) ClearedFields() []string {
  35063. var fields []string
  35064. if m.FieldCleared(wpchatroom.FieldStatus) {
  35065. fields = append(fields, wpchatroom.FieldStatus)
  35066. }
  35067. return fields
  35068. }
  35069. // FieldCleared returns a boolean indicating if a field with the given name was
  35070. // cleared in this mutation.
  35071. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  35072. _, ok := m.clearedFields[name]
  35073. return ok
  35074. }
  35075. // ClearField clears the value of the field with the given name. It returns an
  35076. // error if the field is not defined in the schema.
  35077. func (m *WpChatroomMutation) ClearField(name string) error {
  35078. switch name {
  35079. case wpchatroom.FieldStatus:
  35080. m.ClearStatus()
  35081. return nil
  35082. }
  35083. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  35084. }
  35085. // ResetField resets all changes in the mutation for the field with the given name.
  35086. // It returns an error if the field is not defined in the schema.
  35087. func (m *WpChatroomMutation) ResetField(name string) error {
  35088. switch name {
  35089. case wpchatroom.FieldCreatedAt:
  35090. m.ResetCreatedAt()
  35091. return nil
  35092. case wpchatroom.FieldUpdatedAt:
  35093. m.ResetUpdatedAt()
  35094. return nil
  35095. case wpchatroom.FieldStatus:
  35096. m.ResetStatus()
  35097. return nil
  35098. case wpchatroom.FieldWxWxid:
  35099. m.ResetWxWxid()
  35100. return nil
  35101. case wpchatroom.FieldChatroomID:
  35102. m.ResetChatroomID()
  35103. return nil
  35104. case wpchatroom.FieldNickname:
  35105. m.ResetNickname()
  35106. return nil
  35107. case wpchatroom.FieldOwner:
  35108. m.ResetOwner()
  35109. return nil
  35110. case wpchatroom.FieldAvatar:
  35111. m.ResetAvatar()
  35112. return nil
  35113. case wpchatroom.FieldMemberList:
  35114. m.ResetMemberList()
  35115. return nil
  35116. }
  35117. return fmt.Errorf("unknown WpChatroom field %s", name)
  35118. }
  35119. // AddedEdges returns all edge names that were set/added in this mutation.
  35120. func (m *WpChatroomMutation) AddedEdges() []string {
  35121. edges := make([]string, 0, 0)
  35122. return edges
  35123. }
  35124. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35125. // name in this mutation.
  35126. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  35127. return nil
  35128. }
  35129. // RemovedEdges returns all edge names that were removed in this mutation.
  35130. func (m *WpChatroomMutation) RemovedEdges() []string {
  35131. edges := make([]string, 0, 0)
  35132. return edges
  35133. }
  35134. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35135. // the given name in this mutation.
  35136. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  35137. return nil
  35138. }
  35139. // ClearedEdges returns all edge names that were cleared in this mutation.
  35140. func (m *WpChatroomMutation) ClearedEdges() []string {
  35141. edges := make([]string, 0, 0)
  35142. return edges
  35143. }
  35144. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35145. // was cleared in this mutation.
  35146. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  35147. return false
  35148. }
  35149. // ClearEdge clears the value of the edge with the given name. It returns an error
  35150. // if that edge is not defined in the schema.
  35151. func (m *WpChatroomMutation) ClearEdge(name string) error {
  35152. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  35153. }
  35154. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35155. // It returns an error if the edge is not defined in the schema.
  35156. func (m *WpChatroomMutation) ResetEdge(name string) error {
  35157. return fmt.Errorf("unknown WpChatroom edge %s", name)
  35158. }
  35159. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  35160. type WpChatroomMemberMutation struct {
  35161. config
  35162. op Op
  35163. typ string
  35164. id *uint64
  35165. created_at *time.Time
  35166. updated_at *time.Time
  35167. status *uint8
  35168. addstatus *int8
  35169. wx_wxid *string
  35170. wxid *string
  35171. nickname *string
  35172. avatar *string
  35173. clearedFields map[string]struct{}
  35174. done bool
  35175. oldValue func(context.Context) (*WpChatroomMember, error)
  35176. predicates []predicate.WpChatroomMember
  35177. }
  35178. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  35179. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  35180. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  35181. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  35182. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  35183. m := &WpChatroomMemberMutation{
  35184. config: c,
  35185. op: op,
  35186. typ: TypeWpChatroomMember,
  35187. clearedFields: make(map[string]struct{}),
  35188. }
  35189. for _, opt := range opts {
  35190. opt(m)
  35191. }
  35192. return m
  35193. }
  35194. // withWpChatroomMemberID sets the ID field of the mutation.
  35195. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  35196. return func(m *WpChatroomMemberMutation) {
  35197. var (
  35198. err error
  35199. once sync.Once
  35200. value *WpChatroomMember
  35201. )
  35202. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  35203. once.Do(func() {
  35204. if m.done {
  35205. err = errors.New("querying old values post mutation is not allowed")
  35206. } else {
  35207. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  35208. }
  35209. })
  35210. return value, err
  35211. }
  35212. m.id = &id
  35213. }
  35214. }
  35215. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  35216. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  35217. return func(m *WpChatroomMemberMutation) {
  35218. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  35219. return node, nil
  35220. }
  35221. m.id = &node.ID
  35222. }
  35223. }
  35224. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35225. // executed in a transaction (ent.Tx), a transactional client is returned.
  35226. func (m WpChatroomMemberMutation) Client() *Client {
  35227. client := &Client{config: m.config}
  35228. client.init()
  35229. return client
  35230. }
  35231. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35232. // it returns an error otherwise.
  35233. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  35234. if _, ok := m.driver.(*txDriver); !ok {
  35235. return nil, errors.New("ent: mutation is not running in a transaction")
  35236. }
  35237. tx := &Tx{config: m.config}
  35238. tx.init()
  35239. return tx, nil
  35240. }
  35241. // SetID sets the value of the id field. Note that this
  35242. // operation is only accepted on creation of WpChatroomMember entities.
  35243. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  35244. m.id = &id
  35245. }
  35246. // ID returns the ID value in the mutation. Note that the ID is only available
  35247. // if it was provided to the builder or after it was returned from the database.
  35248. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  35249. if m.id == nil {
  35250. return
  35251. }
  35252. return *m.id, true
  35253. }
  35254. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35255. // That means, if the mutation is applied within a transaction with an isolation level such
  35256. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35257. // or updated by the mutation.
  35258. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  35259. switch {
  35260. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35261. id, exists := m.ID()
  35262. if exists {
  35263. return []uint64{id}, nil
  35264. }
  35265. fallthrough
  35266. case m.op.Is(OpUpdate | OpDelete):
  35267. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  35268. default:
  35269. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35270. }
  35271. }
  35272. // SetCreatedAt sets the "created_at" field.
  35273. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  35274. m.created_at = &t
  35275. }
  35276. // CreatedAt returns the value of the "created_at" field in the mutation.
  35277. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  35278. v := m.created_at
  35279. if v == nil {
  35280. return
  35281. }
  35282. return *v, true
  35283. }
  35284. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  35285. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  35286. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35287. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35288. if !m.op.Is(OpUpdateOne) {
  35289. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35290. }
  35291. if m.id == nil || m.oldValue == nil {
  35292. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35293. }
  35294. oldValue, err := m.oldValue(ctx)
  35295. if err != nil {
  35296. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35297. }
  35298. return oldValue.CreatedAt, nil
  35299. }
  35300. // ResetCreatedAt resets all changes to the "created_at" field.
  35301. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  35302. m.created_at = nil
  35303. }
  35304. // SetUpdatedAt sets the "updated_at" field.
  35305. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  35306. m.updated_at = &t
  35307. }
  35308. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35309. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  35310. v := m.updated_at
  35311. if v == nil {
  35312. return
  35313. }
  35314. return *v, true
  35315. }
  35316. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  35317. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  35318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35319. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35320. if !m.op.Is(OpUpdateOne) {
  35321. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35322. }
  35323. if m.id == nil || m.oldValue == nil {
  35324. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35325. }
  35326. oldValue, err := m.oldValue(ctx)
  35327. if err != nil {
  35328. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35329. }
  35330. return oldValue.UpdatedAt, nil
  35331. }
  35332. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35333. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  35334. m.updated_at = nil
  35335. }
  35336. // SetStatus sets the "status" field.
  35337. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  35338. m.status = &u
  35339. m.addstatus = nil
  35340. }
  35341. // Status returns the value of the "status" field in the mutation.
  35342. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  35343. v := m.status
  35344. if v == nil {
  35345. return
  35346. }
  35347. return *v, true
  35348. }
  35349. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  35350. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  35351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35352. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35353. if !m.op.Is(OpUpdateOne) {
  35354. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35355. }
  35356. if m.id == nil || m.oldValue == nil {
  35357. return v, errors.New("OldStatus requires an ID field in the mutation")
  35358. }
  35359. oldValue, err := m.oldValue(ctx)
  35360. if err != nil {
  35361. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35362. }
  35363. return oldValue.Status, nil
  35364. }
  35365. // AddStatus adds u to the "status" field.
  35366. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  35367. if m.addstatus != nil {
  35368. *m.addstatus += u
  35369. } else {
  35370. m.addstatus = &u
  35371. }
  35372. }
  35373. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35374. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  35375. v := m.addstatus
  35376. if v == nil {
  35377. return
  35378. }
  35379. return *v, true
  35380. }
  35381. // ClearStatus clears the value of the "status" field.
  35382. func (m *WpChatroomMemberMutation) ClearStatus() {
  35383. m.status = nil
  35384. m.addstatus = nil
  35385. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  35386. }
  35387. // StatusCleared returns if the "status" field was cleared in this mutation.
  35388. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  35389. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  35390. return ok
  35391. }
  35392. // ResetStatus resets all changes to the "status" field.
  35393. func (m *WpChatroomMemberMutation) ResetStatus() {
  35394. m.status = nil
  35395. m.addstatus = nil
  35396. delete(m.clearedFields, wpchatroommember.FieldStatus)
  35397. }
  35398. // SetWxWxid sets the "wx_wxid" field.
  35399. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  35400. m.wx_wxid = &s
  35401. }
  35402. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  35403. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  35404. v := m.wx_wxid
  35405. if v == nil {
  35406. return
  35407. }
  35408. return *v, true
  35409. }
  35410. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  35411. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  35412. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35413. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  35414. if !m.op.Is(OpUpdateOne) {
  35415. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  35416. }
  35417. if m.id == nil || m.oldValue == nil {
  35418. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  35419. }
  35420. oldValue, err := m.oldValue(ctx)
  35421. if err != nil {
  35422. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  35423. }
  35424. return oldValue.WxWxid, nil
  35425. }
  35426. // ResetWxWxid resets all changes to the "wx_wxid" field.
  35427. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  35428. m.wx_wxid = nil
  35429. }
  35430. // SetWxid sets the "wxid" field.
  35431. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  35432. m.wxid = &s
  35433. }
  35434. // Wxid returns the value of the "wxid" field in the mutation.
  35435. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  35436. v := m.wxid
  35437. if v == nil {
  35438. return
  35439. }
  35440. return *v, true
  35441. }
  35442. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  35443. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  35444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35445. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  35446. if !m.op.Is(OpUpdateOne) {
  35447. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  35448. }
  35449. if m.id == nil || m.oldValue == nil {
  35450. return v, errors.New("OldWxid requires an ID field in the mutation")
  35451. }
  35452. oldValue, err := m.oldValue(ctx)
  35453. if err != nil {
  35454. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  35455. }
  35456. return oldValue.Wxid, nil
  35457. }
  35458. // ResetWxid resets all changes to the "wxid" field.
  35459. func (m *WpChatroomMemberMutation) ResetWxid() {
  35460. m.wxid = nil
  35461. }
  35462. // SetNickname sets the "nickname" field.
  35463. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  35464. m.nickname = &s
  35465. }
  35466. // Nickname returns the value of the "nickname" field in the mutation.
  35467. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  35468. v := m.nickname
  35469. if v == nil {
  35470. return
  35471. }
  35472. return *v, true
  35473. }
  35474. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  35475. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  35476. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35477. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  35478. if !m.op.Is(OpUpdateOne) {
  35479. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  35480. }
  35481. if m.id == nil || m.oldValue == nil {
  35482. return v, errors.New("OldNickname requires an ID field in the mutation")
  35483. }
  35484. oldValue, err := m.oldValue(ctx)
  35485. if err != nil {
  35486. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  35487. }
  35488. return oldValue.Nickname, nil
  35489. }
  35490. // ResetNickname resets all changes to the "nickname" field.
  35491. func (m *WpChatroomMemberMutation) ResetNickname() {
  35492. m.nickname = nil
  35493. }
  35494. // SetAvatar sets the "avatar" field.
  35495. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  35496. m.avatar = &s
  35497. }
  35498. // Avatar returns the value of the "avatar" field in the mutation.
  35499. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  35500. v := m.avatar
  35501. if v == nil {
  35502. return
  35503. }
  35504. return *v, true
  35505. }
  35506. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  35507. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  35508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35509. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  35510. if !m.op.Is(OpUpdateOne) {
  35511. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  35512. }
  35513. if m.id == nil || m.oldValue == nil {
  35514. return v, errors.New("OldAvatar requires an ID field in the mutation")
  35515. }
  35516. oldValue, err := m.oldValue(ctx)
  35517. if err != nil {
  35518. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  35519. }
  35520. return oldValue.Avatar, nil
  35521. }
  35522. // ResetAvatar resets all changes to the "avatar" field.
  35523. func (m *WpChatroomMemberMutation) ResetAvatar() {
  35524. m.avatar = nil
  35525. }
  35526. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  35527. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  35528. m.predicates = append(m.predicates, ps...)
  35529. }
  35530. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  35531. // users can use type-assertion to append predicates that do not depend on any generated package.
  35532. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  35533. p := make([]predicate.WpChatroomMember, len(ps))
  35534. for i := range ps {
  35535. p[i] = ps[i]
  35536. }
  35537. m.Where(p...)
  35538. }
  35539. // Op returns the operation name.
  35540. func (m *WpChatroomMemberMutation) Op() Op {
  35541. return m.op
  35542. }
  35543. // SetOp allows setting the mutation operation.
  35544. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  35545. m.op = op
  35546. }
  35547. // Type returns the node type of this mutation (WpChatroomMember).
  35548. func (m *WpChatroomMemberMutation) Type() string {
  35549. return m.typ
  35550. }
  35551. // Fields returns all fields that were changed during this mutation. Note that in
  35552. // order to get all numeric fields that were incremented/decremented, call
  35553. // AddedFields().
  35554. func (m *WpChatroomMemberMutation) Fields() []string {
  35555. fields := make([]string, 0, 7)
  35556. if m.created_at != nil {
  35557. fields = append(fields, wpchatroommember.FieldCreatedAt)
  35558. }
  35559. if m.updated_at != nil {
  35560. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  35561. }
  35562. if m.status != nil {
  35563. fields = append(fields, wpchatroommember.FieldStatus)
  35564. }
  35565. if m.wx_wxid != nil {
  35566. fields = append(fields, wpchatroommember.FieldWxWxid)
  35567. }
  35568. if m.wxid != nil {
  35569. fields = append(fields, wpchatroommember.FieldWxid)
  35570. }
  35571. if m.nickname != nil {
  35572. fields = append(fields, wpchatroommember.FieldNickname)
  35573. }
  35574. if m.avatar != nil {
  35575. fields = append(fields, wpchatroommember.FieldAvatar)
  35576. }
  35577. return fields
  35578. }
  35579. // Field returns the value of a field with the given name. The second boolean
  35580. // return value indicates that this field was not set, or was not defined in the
  35581. // schema.
  35582. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  35583. switch name {
  35584. case wpchatroommember.FieldCreatedAt:
  35585. return m.CreatedAt()
  35586. case wpchatroommember.FieldUpdatedAt:
  35587. return m.UpdatedAt()
  35588. case wpchatroommember.FieldStatus:
  35589. return m.Status()
  35590. case wpchatroommember.FieldWxWxid:
  35591. return m.WxWxid()
  35592. case wpchatroommember.FieldWxid:
  35593. return m.Wxid()
  35594. case wpchatroommember.FieldNickname:
  35595. return m.Nickname()
  35596. case wpchatroommember.FieldAvatar:
  35597. return m.Avatar()
  35598. }
  35599. return nil, false
  35600. }
  35601. // OldField returns the old value of the field from the database. An error is
  35602. // returned if the mutation operation is not UpdateOne, or the query to the
  35603. // database failed.
  35604. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35605. switch name {
  35606. case wpchatroommember.FieldCreatedAt:
  35607. return m.OldCreatedAt(ctx)
  35608. case wpchatroommember.FieldUpdatedAt:
  35609. return m.OldUpdatedAt(ctx)
  35610. case wpchatroommember.FieldStatus:
  35611. return m.OldStatus(ctx)
  35612. case wpchatroommember.FieldWxWxid:
  35613. return m.OldWxWxid(ctx)
  35614. case wpchatroommember.FieldWxid:
  35615. return m.OldWxid(ctx)
  35616. case wpchatroommember.FieldNickname:
  35617. return m.OldNickname(ctx)
  35618. case wpchatroommember.FieldAvatar:
  35619. return m.OldAvatar(ctx)
  35620. }
  35621. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  35622. }
  35623. // SetField sets the value of a field with the given name. It returns an error if
  35624. // the field is not defined in the schema, or if the type mismatched the field
  35625. // type.
  35626. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  35627. switch name {
  35628. case wpchatroommember.FieldCreatedAt:
  35629. v, ok := value.(time.Time)
  35630. if !ok {
  35631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35632. }
  35633. m.SetCreatedAt(v)
  35634. return nil
  35635. case wpchatroommember.FieldUpdatedAt:
  35636. v, ok := value.(time.Time)
  35637. if !ok {
  35638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35639. }
  35640. m.SetUpdatedAt(v)
  35641. return nil
  35642. case wpchatroommember.FieldStatus:
  35643. v, ok := value.(uint8)
  35644. if !ok {
  35645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35646. }
  35647. m.SetStatus(v)
  35648. return nil
  35649. case wpchatroommember.FieldWxWxid:
  35650. v, ok := value.(string)
  35651. if !ok {
  35652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35653. }
  35654. m.SetWxWxid(v)
  35655. return nil
  35656. case wpchatroommember.FieldWxid:
  35657. v, ok := value.(string)
  35658. if !ok {
  35659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35660. }
  35661. m.SetWxid(v)
  35662. return nil
  35663. case wpchatroommember.FieldNickname:
  35664. v, ok := value.(string)
  35665. if !ok {
  35666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35667. }
  35668. m.SetNickname(v)
  35669. return nil
  35670. case wpchatroommember.FieldAvatar:
  35671. v, ok := value.(string)
  35672. if !ok {
  35673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35674. }
  35675. m.SetAvatar(v)
  35676. return nil
  35677. }
  35678. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  35679. }
  35680. // AddedFields returns all numeric fields that were incremented/decremented during
  35681. // this mutation.
  35682. func (m *WpChatroomMemberMutation) AddedFields() []string {
  35683. var fields []string
  35684. if m.addstatus != nil {
  35685. fields = append(fields, wpchatroommember.FieldStatus)
  35686. }
  35687. return fields
  35688. }
  35689. // AddedField returns the numeric value that was incremented/decremented on a field
  35690. // with the given name. The second boolean return value indicates that this field
  35691. // was not set, or was not defined in the schema.
  35692. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  35693. switch name {
  35694. case wpchatroommember.FieldStatus:
  35695. return m.AddedStatus()
  35696. }
  35697. return nil, false
  35698. }
  35699. // AddField adds the value to the field with the given name. It returns an error if
  35700. // the field is not defined in the schema, or if the type mismatched the field
  35701. // type.
  35702. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  35703. switch name {
  35704. case wpchatroommember.FieldStatus:
  35705. v, ok := value.(int8)
  35706. if !ok {
  35707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35708. }
  35709. m.AddStatus(v)
  35710. return nil
  35711. }
  35712. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  35713. }
  35714. // ClearedFields returns all nullable fields that were cleared during this
  35715. // mutation.
  35716. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  35717. var fields []string
  35718. if m.FieldCleared(wpchatroommember.FieldStatus) {
  35719. fields = append(fields, wpchatroommember.FieldStatus)
  35720. }
  35721. return fields
  35722. }
  35723. // FieldCleared returns a boolean indicating if a field with the given name was
  35724. // cleared in this mutation.
  35725. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  35726. _, ok := m.clearedFields[name]
  35727. return ok
  35728. }
  35729. // ClearField clears the value of the field with the given name. It returns an
  35730. // error if the field is not defined in the schema.
  35731. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  35732. switch name {
  35733. case wpchatroommember.FieldStatus:
  35734. m.ClearStatus()
  35735. return nil
  35736. }
  35737. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  35738. }
  35739. // ResetField resets all changes in the mutation for the field with the given name.
  35740. // It returns an error if the field is not defined in the schema.
  35741. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  35742. switch name {
  35743. case wpchatroommember.FieldCreatedAt:
  35744. m.ResetCreatedAt()
  35745. return nil
  35746. case wpchatroommember.FieldUpdatedAt:
  35747. m.ResetUpdatedAt()
  35748. return nil
  35749. case wpchatroommember.FieldStatus:
  35750. m.ResetStatus()
  35751. return nil
  35752. case wpchatroommember.FieldWxWxid:
  35753. m.ResetWxWxid()
  35754. return nil
  35755. case wpchatroommember.FieldWxid:
  35756. m.ResetWxid()
  35757. return nil
  35758. case wpchatroommember.FieldNickname:
  35759. m.ResetNickname()
  35760. return nil
  35761. case wpchatroommember.FieldAvatar:
  35762. m.ResetAvatar()
  35763. return nil
  35764. }
  35765. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  35766. }
  35767. // AddedEdges returns all edge names that were set/added in this mutation.
  35768. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  35769. edges := make([]string, 0, 0)
  35770. return edges
  35771. }
  35772. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35773. // name in this mutation.
  35774. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  35775. return nil
  35776. }
  35777. // RemovedEdges returns all edge names that were removed in this mutation.
  35778. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  35779. edges := make([]string, 0, 0)
  35780. return edges
  35781. }
  35782. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35783. // the given name in this mutation.
  35784. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  35785. return nil
  35786. }
  35787. // ClearedEdges returns all edge names that were cleared in this mutation.
  35788. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  35789. edges := make([]string, 0, 0)
  35790. return edges
  35791. }
  35792. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35793. // was cleared in this mutation.
  35794. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  35795. return false
  35796. }
  35797. // ClearEdge clears the value of the edge with the given name. It returns an error
  35798. // if that edge is not defined in the schema.
  35799. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  35800. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  35801. }
  35802. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35803. // It returns an error if the edge is not defined in the schema.
  35804. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  35805. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  35806. }
  35807. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  35808. type WxMutation struct {
  35809. config
  35810. op Op
  35811. typ string
  35812. id *uint64
  35813. created_at *time.Time
  35814. updated_at *time.Time
  35815. status *uint8
  35816. addstatus *int8
  35817. deleted_at *time.Time
  35818. port *string
  35819. process_id *string
  35820. callback *string
  35821. wxid *string
  35822. account *string
  35823. nickname *string
  35824. tel *string
  35825. head_big *string
  35826. organization_id *uint64
  35827. addorganization_id *int64
  35828. api_base *string
  35829. api_key *string
  35830. allow_list *[]string
  35831. appendallow_list []string
  35832. group_allow_list *[]string
  35833. appendgroup_allow_list []string
  35834. block_list *[]string
  35835. appendblock_list []string
  35836. group_block_list *[]string
  35837. appendgroup_block_list []string
  35838. clearedFields map[string]struct{}
  35839. server *uint64
  35840. clearedserver bool
  35841. agent *uint64
  35842. clearedagent bool
  35843. done bool
  35844. oldValue func(context.Context) (*Wx, error)
  35845. predicates []predicate.Wx
  35846. }
  35847. var _ ent.Mutation = (*WxMutation)(nil)
  35848. // wxOption allows management of the mutation configuration using functional options.
  35849. type wxOption func(*WxMutation)
  35850. // newWxMutation creates new mutation for the Wx entity.
  35851. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  35852. m := &WxMutation{
  35853. config: c,
  35854. op: op,
  35855. typ: TypeWx,
  35856. clearedFields: make(map[string]struct{}),
  35857. }
  35858. for _, opt := range opts {
  35859. opt(m)
  35860. }
  35861. return m
  35862. }
  35863. // withWxID sets the ID field of the mutation.
  35864. func withWxID(id uint64) wxOption {
  35865. return func(m *WxMutation) {
  35866. var (
  35867. err error
  35868. once sync.Once
  35869. value *Wx
  35870. )
  35871. m.oldValue = func(ctx context.Context) (*Wx, error) {
  35872. once.Do(func() {
  35873. if m.done {
  35874. err = errors.New("querying old values post mutation is not allowed")
  35875. } else {
  35876. value, err = m.Client().Wx.Get(ctx, id)
  35877. }
  35878. })
  35879. return value, err
  35880. }
  35881. m.id = &id
  35882. }
  35883. }
  35884. // withWx sets the old Wx of the mutation.
  35885. func withWx(node *Wx) wxOption {
  35886. return func(m *WxMutation) {
  35887. m.oldValue = func(context.Context) (*Wx, error) {
  35888. return node, nil
  35889. }
  35890. m.id = &node.ID
  35891. }
  35892. }
  35893. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35894. // executed in a transaction (ent.Tx), a transactional client is returned.
  35895. func (m WxMutation) Client() *Client {
  35896. client := &Client{config: m.config}
  35897. client.init()
  35898. return client
  35899. }
  35900. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35901. // it returns an error otherwise.
  35902. func (m WxMutation) Tx() (*Tx, error) {
  35903. if _, ok := m.driver.(*txDriver); !ok {
  35904. return nil, errors.New("ent: mutation is not running in a transaction")
  35905. }
  35906. tx := &Tx{config: m.config}
  35907. tx.init()
  35908. return tx, nil
  35909. }
  35910. // SetID sets the value of the id field. Note that this
  35911. // operation is only accepted on creation of Wx entities.
  35912. func (m *WxMutation) SetID(id uint64) {
  35913. m.id = &id
  35914. }
  35915. // ID returns the ID value in the mutation. Note that the ID is only available
  35916. // if it was provided to the builder or after it was returned from the database.
  35917. func (m *WxMutation) ID() (id uint64, exists bool) {
  35918. if m.id == nil {
  35919. return
  35920. }
  35921. return *m.id, true
  35922. }
  35923. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35924. // That means, if the mutation is applied within a transaction with an isolation level such
  35925. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35926. // or updated by the mutation.
  35927. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  35928. switch {
  35929. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35930. id, exists := m.ID()
  35931. if exists {
  35932. return []uint64{id}, nil
  35933. }
  35934. fallthrough
  35935. case m.op.Is(OpUpdate | OpDelete):
  35936. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  35937. default:
  35938. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35939. }
  35940. }
  35941. // SetCreatedAt sets the "created_at" field.
  35942. func (m *WxMutation) SetCreatedAt(t time.Time) {
  35943. m.created_at = &t
  35944. }
  35945. // CreatedAt returns the value of the "created_at" field in the mutation.
  35946. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  35947. v := m.created_at
  35948. if v == nil {
  35949. return
  35950. }
  35951. return *v, true
  35952. }
  35953. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  35954. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  35955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35956. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35957. if !m.op.Is(OpUpdateOne) {
  35958. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35959. }
  35960. if m.id == nil || m.oldValue == nil {
  35961. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35962. }
  35963. oldValue, err := m.oldValue(ctx)
  35964. if err != nil {
  35965. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35966. }
  35967. return oldValue.CreatedAt, nil
  35968. }
  35969. // ResetCreatedAt resets all changes to the "created_at" field.
  35970. func (m *WxMutation) ResetCreatedAt() {
  35971. m.created_at = nil
  35972. }
  35973. // SetUpdatedAt sets the "updated_at" field.
  35974. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  35975. m.updated_at = &t
  35976. }
  35977. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35978. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  35979. v := m.updated_at
  35980. if v == nil {
  35981. return
  35982. }
  35983. return *v, true
  35984. }
  35985. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  35986. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  35987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35988. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35989. if !m.op.Is(OpUpdateOne) {
  35990. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35991. }
  35992. if m.id == nil || m.oldValue == nil {
  35993. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35994. }
  35995. oldValue, err := m.oldValue(ctx)
  35996. if err != nil {
  35997. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35998. }
  35999. return oldValue.UpdatedAt, nil
  36000. }
  36001. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36002. func (m *WxMutation) ResetUpdatedAt() {
  36003. m.updated_at = nil
  36004. }
  36005. // SetStatus sets the "status" field.
  36006. func (m *WxMutation) SetStatus(u uint8) {
  36007. m.status = &u
  36008. m.addstatus = nil
  36009. }
  36010. // Status returns the value of the "status" field in the mutation.
  36011. func (m *WxMutation) Status() (r uint8, exists bool) {
  36012. v := m.status
  36013. if v == nil {
  36014. return
  36015. }
  36016. return *v, true
  36017. }
  36018. // OldStatus returns the old "status" field's value of the Wx entity.
  36019. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36021. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36022. if !m.op.Is(OpUpdateOne) {
  36023. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36024. }
  36025. if m.id == nil || m.oldValue == nil {
  36026. return v, errors.New("OldStatus requires an ID field in the mutation")
  36027. }
  36028. oldValue, err := m.oldValue(ctx)
  36029. if err != nil {
  36030. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36031. }
  36032. return oldValue.Status, nil
  36033. }
  36034. // AddStatus adds u to the "status" field.
  36035. func (m *WxMutation) AddStatus(u int8) {
  36036. if m.addstatus != nil {
  36037. *m.addstatus += u
  36038. } else {
  36039. m.addstatus = &u
  36040. }
  36041. }
  36042. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36043. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  36044. v := m.addstatus
  36045. if v == nil {
  36046. return
  36047. }
  36048. return *v, true
  36049. }
  36050. // ClearStatus clears the value of the "status" field.
  36051. func (m *WxMutation) ClearStatus() {
  36052. m.status = nil
  36053. m.addstatus = nil
  36054. m.clearedFields[wx.FieldStatus] = struct{}{}
  36055. }
  36056. // StatusCleared returns if the "status" field was cleared in this mutation.
  36057. func (m *WxMutation) StatusCleared() bool {
  36058. _, ok := m.clearedFields[wx.FieldStatus]
  36059. return ok
  36060. }
  36061. // ResetStatus resets all changes to the "status" field.
  36062. func (m *WxMutation) ResetStatus() {
  36063. m.status = nil
  36064. m.addstatus = nil
  36065. delete(m.clearedFields, wx.FieldStatus)
  36066. }
  36067. // SetDeletedAt sets the "deleted_at" field.
  36068. func (m *WxMutation) SetDeletedAt(t time.Time) {
  36069. m.deleted_at = &t
  36070. }
  36071. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36072. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  36073. v := m.deleted_at
  36074. if v == nil {
  36075. return
  36076. }
  36077. return *v, true
  36078. }
  36079. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  36080. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36082. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36083. if !m.op.Is(OpUpdateOne) {
  36084. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36085. }
  36086. if m.id == nil || m.oldValue == nil {
  36087. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36088. }
  36089. oldValue, err := m.oldValue(ctx)
  36090. if err != nil {
  36091. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36092. }
  36093. return oldValue.DeletedAt, nil
  36094. }
  36095. // ClearDeletedAt clears the value of the "deleted_at" field.
  36096. func (m *WxMutation) ClearDeletedAt() {
  36097. m.deleted_at = nil
  36098. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  36099. }
  36100. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36101. func (m *WxMutation) DeletedAtCleared() bool {
  36102. _, ok := m.clearedFields[wx.FieldDeletedAt]
  36103. return ok
  36104. }
  36105. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36106. func (m *WxMutation) ResetDeletedAt() {
  36107. m.deleted_at = nil
  36108. delete(m.clearedFields, wx.FieldDeletedAt)
  36109. }
  36110. // SetServerID sets the "server_id" field.
  36111. func (m *WxMutation) SetServerID(u uint64) {
  36112. m.server = &u
  36113. }
  36114. // ServerID returns the value of the "server_id" field in the mutation.
  36115. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  36116. v := m.server
  36117. if v == nil {
  36118. return
  36119. }
  36120. return *v, true
  36121. }
  36122. // OldServerID returns the old "server_id" field's value of the Wx entity.
  36123. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36125. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  36126. if !m.op.Is(OpUpdateOne) {
  36127. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  36128. }
  36129. if m.id == nil || m.oldValue == nil {
  36130. return v, errors.New("OldServerID requires an ID field in the mutation")
  36131. }
  36132. oldValue, err := m.oldValue(ctx)
  36133. if err != nil {
  36134. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  36135. }
  36136. return oldValue.ServerID, nil
  36137. }
  36138. // ClearServerID clears the value of the "server_id" field.
  36139. func (m *WxMutation) ClearServerID() {
  36140. m.server = nil
  36141. m.clearedFields[wx.FieldServerID] = struct{}{}
  36142. }
  36143. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  36144. func (m *WxMutation) ServerIDCleared() bool {
  36145. _, ok := m.clearedFields[wx.FieldServerID]
  36146. return ok
  36147. }
  36148. // ResetServerID resets all changes to the "server_id" field.
  36149. func (m *WxMutation) ResetServerID() {
  36150. m.server = nil
  36151. delete(m.clearedFields, wx.FieldServerID)
  36152. }
  36153. // SetPort sets the "port" field.
  36154. func (m *WxMutation) SetPort(s string) {
  36155. m.port = &s
  36156. }
  36157. // Port returns the value of the "port" field in the mutation.
  36158. func (m *WxMutation) Port() (r string, exists bool) {
  36159. v := m.port
  36160. if v == nil {
  36161. return
  36162. }
  36163. return *v, true
  36164. }
  36165. // OldPort returns the old "port" field's value of the Wx entity.
  36166. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36167. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36168. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  36169. if !m.op.Is(OpUpdateOne) {
  36170. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  36171. }
  36172. if m.id == nil || m.oldValue == nil {
  36173. return v, errors.New("OldPort requires an ID field in the mutation")
  36174. }
  36175. oldValue, err := m.oldValue(ctx)
  36176. if err != nil {
  36177. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  36178. }
  36179. return oldValue.Port, nil
  36180. }
  36181. // ResetPort resets all changes to the "port" field.
  36182. func (m *WxMutation) ResetPort() {
  36183. m.port = nil
  36184. }
  36185. // SetProcessID sets the "process_id" field.
  36186. func (m *WxMutation) SetProcessID(s string) {
  36187. m.process_id = &s
  36188. }
  36189. // ProcessID returns the value of the "process_id" field in the mutation.
  36190. func (m *WxMutation) ProcessID() (r string, exists bool) {
  36191. v := m.process_id
  36192. if v == nil {
  36193. return
  36194. }
  36195. return *v, true
  36196. }
  36197. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  36198. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36200. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  36201. if !m.op.Is(OpUpdateOne) {
  36202. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  36203. }
  36204. if m.id == nil || m.oldValue == nil {
  36205. return v, errors.New("OldProcessID requires an ID field in the mutation")
  36206. }
  36207. oldValue, err := m.oldValue(ctx)
  36208. if err != nil {
  36209. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  36210. }
  36211. return oldValue.ProcessID, nil
  36212. }
  36213. // ResetProcessID resets all changes to the "process_id" field.
  36214. func (m *WxMutation) ResetProcessID() {
  36215. m.process_id = nil
  36216. }
  36217. // SetCallback sets the "callback" field.
  36218. func (m *WxMutation) SetCallback(s string) {
  36219. m.callback = &s
  36220. }
  36221. // Callback returns the value of the "callback" field in the mutation.
  36222. func (m *WxMutation) Callback() (r string, exists bool) {
  36223. v := m.callback
  36224. if v == nil {
  36225. return
  36226. }
  36227. return *v, true
  36228. }
  36229. // OldCallback returns the old "callback" field's value of the Wx entity.
  36230. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36232. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  36233. if !m.op.Is(OpUpdateOne) {
  36234. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  36235. }
  36236. if m.id == nil || m.oldValue == nil {
  36237. return v, errors.New("OldCallback requires an ID field in the mutation")
  36238. }
  36239. oldValue, err := m.oldValue(ctx)
  36240. if err != nil {
  36241. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  36242. }
  36243. return oldValue.Callback, nil
  36244. }
  36245. // ResetCallback resets all changes to the "callback" field.
  36246. func (m *WxMutation) ResetCallback() {
  36247. m.callback = nil
  36248. }
  36249. // SetWxid sets the "wxid" field.
  36250. func (m *WxMutation) SetWxid(s string) {
  36251. m.wxid = &s
  36252. }
  36253. // Wxid returns the value of the "wxid" field in the mutation.
  36254. func (m *WxMutation) Wxid() (r string, exists bool) {
  36255. v := m.wxid
  36256. if v == nil {
  36257. return
  36258. }
  36259. return *v, true
  36260. }
  36261. // OldWxid returns the old "wxid" field's value of the Wx entity.
  36262. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36264. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  36265. if !m.op.Is(OpUpdateOne) {
  36266. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  36267. }
  36268. if m.id == nil || m.oldValue == nil {
  36269. return v, errors.New("OldWxid requires an ID field in the mutation")
  36270. }
  36271. oldValue, err := m.oldValue(ctx)
  36272. if err != nil {
  36273. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  36274. }
  36275. return oldValue.Wxid, nil
  36276. }
  36277. // ResetWxid resets all changes to the "wxid" field.
  36278. func (m *WxMutation) ResetWxid() {
  36279. m.wxid = nil
  36280. }
  36281. // SetAccount sets the "account" field.
  36282. func (m *WxMutation) SetAccount(s string) {
  36283. m.account = &s
  36284. }
  36285. // Account returns the value of the "account" field in the mutation.
  36286. func (m *WxMutation) Account() (r string, exists bool) {
  36287. v := m.account
  36288. if v == nil {
  36289. return
  36290. }
  36291. return *v, true
  36292. }
  36293. // OldAccount returns the old "account" field's value of the Wx entity.
  36294. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36296. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  36297. if !m.op.Is(OpUpdateOne) {
  36298. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  36299. }
  36300. if m.id == nil || m.oldValue == nil {
  36301. return v, errors.New("OldAccount requires an ID field in the mutation")
  36302. }
  36303. oldValue, err := m.oldValue(ctx)
  36304. if err != nil {
  36305. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  36306. }
  36307. return oldValue.Account, nil
  36308. }
  36309. // ResetAccount resets all changes to the "account" field.
  36310. func (m *WxMutation) ResetAccount() {
  36311. m.account = nil
  36312. }
  36313. // SetNickname sets the "nickname" field.
  36314. func (m *WxMutation) SetNickname(s string) {
  36315. m.nickname = &s
  36316. }
  36317. // Nickname returns the value of the "nickname" field in the mutation.
  36318. func (m *WxMutation) Nickname() (r string, exists bool) {
  36319. v := m.nickname
  36320. if v == nil {
  36321. return
  36322. }
  36323. return *v, true
  36324. }
  36325. // OldNickname returns the old "nickname" field's value of the Wx entity.
  36326. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36327. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36328. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  36329. if !m.op.Is(OpUpdateOne) {
  36330. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  36331. }
  36332. if m.id == nil || m.oldValue == nil {
  36333. return v, errors.New("OldNickname requires an ID field in the mutation")
  36334. }
  36335. oldValue, err := m.oldValue(ctx)
  36336. if err != nil {
  36337. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  36338. }
  36339. return oldValue.Nickname, nil
  36340. }
  36341. // ResetNickname resets all changes to the "nickname" field.
  36342. func (m *WxMutation) ResetNickname() {
  36343. m.nickname = nil
  36344. }
  36345. // SetTel sets the "tel" field.
  36346. func (m *WxMutation) SetTel(s string) {
  36347. m.tel = &s
  36348. }
  36349. // Tel returns the value of the "tel" field in the mutation.
  36350. func (m *WxMutation) Tel() (r string, exists bool) {
  36351. v := m.tel
  36352. if v == nil {
  36353. return
  36354. }
  36355. return *v, true
  36356. }
  36357. // OldTel returns the old "tel" field's value of the Wx entity.
  36358. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36360. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  36361. if !m.op.Is(OpUpdateOne) {
  36362. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  36363. }
  36364. if m.id == nil || m.oldValue == nil {
  36365. return v, errors.New("OldTel requires an ID field in the mutation")
  36366. }
  36367. oldValue, err := m.oldValue(ctx)
  36368. if err != nil {
  36369. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  36370. }
  36371. return oldValue.Tel, nil
  36372. }
  36373. // ResetTel resets all changes to the "tel" field.
  36374. func (m *WxMutation) ResetTel() {
  36375. m.tel = nil
  36376. }
  36377. // SetHeadBig sets the "head_big" field.
  36378. func (m *WxMutation) SetHeadBig(s string) {
  36379. m.head_big = &s
  36380. }
  36381. // HeadBig returns the value of the "head_big" field in the mutation.
  36382. func (m *WxMutation) HeadBig() (r string, exists bool) {
  36383. v := m.head_big
  36384. if v == nil {
  36385. return
  36386. }
  36387. return *v, true
  36388. }
  36389. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  36390. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36392. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  36393. if !m.op.Is(OpUpdateOne) {
  36394. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  36395. }
  36396. if m.id == nil || m.oldValue == nil {
  36397. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  36398. }
  36399. oldValue, err := m.oldValue(ctx)
  36400. if err != nil {
  36401. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  36402. }
  36403. return oldValue.HeadBig, nil
  36404. }
  36405. // ResetHeadBig resets all changes to the "head_big" field.
  36406. func (m *WxMutation) ResetHeadBig() {
  36407. m.head_big = nil
  36408. }
  36409. // SetOrganizationID sets the "organization_id" field.
  36410. func (m *WxMutation) SetOrganizationID(u uint64) {
  36411. m.organization_id = &u
  36412. m.addorganization_id = nil
  36413. }
  36414. // OrganizationID returns the value of the "organization_id" field in the mutation.
  36415. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  36416. v := m.organization_id
  36417. if v == nil {
  36418. return
  36419. }
  36420. return *v, true
  36421. }
  36422. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  36423. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36425. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  36426. if !m.op.Is(OpUpdateOne) {
  36427. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  36428. }
  36429. if m.id == nil || m.oldValue == nil {
  36430. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  36431. }
  36432. oldValue, err := m.oldValue(ctx)
  36433. if err != nil {
  36434. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  36435. }
  36436. return oldValue.OrganizationID, nil
  36437. }
  36438. // AddOrganizationID adds u to the "organization_id" field.
  36439. func (m *WxMutation) AddOrganizationID(u int64) {
  36440. if m.addorganization_id != nil {
  36441. *m.addorganization_id += u
  36442. } else {
  36443. m.addorganization_id = &u
  36444. }
  36445. }
  36446. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  36447. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  36448. v := m.addorganization_id
  36449. if v == nil {
  36450. return
  36451. }
  36452. return *v, true
  36453. }
  36454. // ClearOrganizationID clears the value of the "organization_id" field.
  36455. func (m *WxMutation) ClearOrganizationID() {
  36456. m.organization_id = nil
  36457. m.addorganization_id = nil
  36458. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  36459. }
  36460. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  36461. func (m *WxMutation) OrganizationIDCleared() bool {
  36462. _, ok := m.clearedFields[wx.FieldOrganizationID]
  36463. return ok
  36464. }
  36465. // ResetOrganizationID resets all changes to the "organization_id" field.
  36466. func (m *WxMutation) ResetOrganizationID() {
  36467. m.organization_id = nil
  36468. m.addorganization_id = nil
  36469. delete(m.clearedFields, wx.FieldOrganizationID)
  36470. }
  36471. // SetAgentID sets the "agent_id" field.
  36472. func (m *WxMutation) SetAgentID(u uint64) {
  36473. m.agent = &u
  36474. }
  36475. // AgentID returns the value of the "agent_id" field in the mutation.
  36476. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  36477. v := m.agent
  36478. if v == nil {
  36479. return
  36480. }
  36481. return *v, true
  36482. }
  36483. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  36484. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36486. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  36487. if !m.op.Is(OpUpdateOne) {
  36488. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  36489. }
  36490. if m.id == nil || m.oldValue == nil {
  36491. return v, errors.New("OldAgentID requires an ID field in the mutation")
  36492. }
  36493. oldValue, err := m.oldValue(ctx)
  36494. if err != nil {
  36495. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  36496. }
  36497. return oldValue.AgentID, nil
  36498. }
  36499. // ResetAgentID resets all changes to the "agent_id" field.
  36500. func (m *WxMutation) ResetAgentID() {
  36501. m.agent = nil
  36502. }
  36503. // SetAPIBase sets the "api_base" field.
  36504. func (m *WxMutation) SetAPIBase(s string) {
  36505. m.api_base = &s
  36506. }
  36507. // APIBase returns the value of the "api_base" field in the mutation.
  36508. func (m *WxMutation) APIBase() (r string, exists bool) {
  36509. v := m.api_base
  36510. if v == nil {
  36511. return
  36512. }
  36513. return *v, true
  36514. }
  36515. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  36516. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36518. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  36519. if !m.op.Is(OpUpdateOne) {
  36520. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  36521. }
  36522. if m.id == nil || m.oldValue == nil {
  36523. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  36524. }
  36525. oldValue, err := m.oldValue(ctx)
  36526. if err != nil {
  36527. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  36528. }
  36529. return oldValue.APIBase, nil
  36530. }
  36531. // ClearAPIBase clears the value of the "api_base" field.
  36532. func (m *WxMutation) ClearAPIBase() {
  36533. m.api_base = nil
  36534. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  36535. }
  36536. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  36537. func (m *WxMutation) APIBaseCleared() bool {
  36538. _, ok := m.clearedFields[wx.FieldAPIBase]
  36539. return ok
  36540. }
  36541. // ResetAPIBase resets all changes to the "api_base" field.
  36542. func (m *WxMutation) ResetAPIBase() {
  36543. m.api_base = nil
  36544. delete(m.clearedFields, wx.FieldAPIBase)
  36545. }
  36546. // SetAPIKey sets the "api_key" field.
  36547. func (m *WxMutation) SetAPIKey(s string) {
  36548. m.api_key = &s
  36549. }
  36550. // APIKey returns the value of the "api_key" field in the mutation.
  36551. func (m *WxMutation) APIKey() (r string, exists bool) {
  36552. v := m.api_key
  36553. if v == nil {
  36554. return
  36555. }
  36556. return *v, true
  36557. }
  36558. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  36559. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36561. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  36562. if !m.op.Is(OpUpdateOne) {
  36563. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  36564. }
  36565. if m.id == nil || m.oldValue == nil {
  36566. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  36567. }
  36568. oldValue, err := m.oldValue(ctx)
  36569. if err != nil {
  36570. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  36571. }
  36572. return oldValue.APIKey, nil
  36573. }
  36574. // ClearAPIKey clears the value of the "api_key" field.
  36575. func (m *WxMutation) ClearAPIKey() {
  36576. m.api_key = nil
  36577. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  36578. }
  36579. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  36580. func (m *WxMutation) APIKeyCleared() bool {
  36581. _, ok := m.clearedFields[wx.FieldAPIKey]
  36582. return ok
  36583. }
  36584. // ResetAPIKey resets all changes to the "api_key" field.
  36585. func (m *WxMutation) ResetAPIKey() {
  36586. m.api_key = nil
  36587. delete(m.clearedFields, wx.FieldAPIKey)
  36588. }
  36589. // SetAllowList sets the "allow_list" field.
  36590. func (m *WxMutation) SetAllowList(s []string) {
  36591. m.allow_list = &s
  36592. m.appendallow_list = nil
  36593. }
  36594. // AllowList returns the value of the "allow_list" field in the mutation.
  36595. func (m *WxMutation) AllowList() (r []string, exists bool) {
  36596. v := m.allow_list
  36597. if v == nil {
  36598. return
  36599. }
  36600. return *v, true
  36601. }
  36602. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  36603. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36605. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  36606. if !m.op.Is(OpUpdateOne) {
  36607. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  36608. }
  36609. if m.id == nil || m.oldValue == nil {
  36610. return v, errors.New("OldAllowList requires an ID field in the mutation")
  36611. }
  36612. oldValue, err := m.oldValue(ctx)
  36613. if err != nil {
  36614. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  36615. }
  36616. return oldValue.AllowList, nil
  36617. }
  36618. // AppendAllowList adds s to the "allow_list" field.
  36619. func (m *WxMutation) AppendAllowList(s []string) {
  36620. m.appendallow_list = append(m.appendallow_list, s...)
  36621. }
  36622. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  36623. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  36624. if len(m.appendallow_list) == 0 {
  36625. return nil, false
  36626. }
  36627. return m.appendallow_list, true
  36628. }
  36629. // ResetAllowList resets all changes to the "allow_list" field.
  36630. func (m *WxMutation) ResetAllowList() {
  36631. m.allow_list = nil
  36632. m.appendallow_list = nil
  36633. }
  36634. // SetGroupAllowList sets the "group_allow_list" field.
  36635. func (m *WxMutation) SetGroupAllowList(s []string) {
  36636. m.group_allow_list = &s
  36637. m.appendgroup_allow_list = nil
  36638. }
  36639. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  36640. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  36641. v := m.group_allow_list
  36642. if v == nil {
  36643. return
  36644. }
  36645. return *v, true
  36646. }
  36647. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  36648. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36650. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  36651. if !m.op.Is(OpUpdateOne) {
  36652. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  36653. }
  36654. if m.id == nil || m.oldValue == nil {
  36655. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  36656. }
  36657. oldValue, err := m.oldValue(ctx)
  36658. if err != nil {
  36659. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  36660. }
  36661. return oldValue.GroupAllowList, nil
  36662. }
  36663. // AppendGroupAllowList adds s to the "group_allow_list" field.
  36664. func (m *WxMutation) AppendGroupAllowList(s []string) {
  36665. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  36666. }
  36667. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  36668. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  36669. if len(m.appendgroup_allow_list) == 0 {
  36670. return nil, false
  36671. }
  36672. return m.appendgroup_allow_list, true
  36673. }
  36674. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  36675. func (m *WxMutation) ResetGroupAllowList() {
  36676. m.group_allow_list = nil
  36677. m.appendgroup_allow_list = nil
  36678. }
  36679. // SetBlockList sets the "block_list" field.
  36680. func (m *WxMutation) SetBlockList(s []string) {
  36681. m.block_list = &s
  36682. m.appendblock_list = nil
  36683. }
  36684. // BlockList returns the value of the "block_list" field in the mutation.
  36685. func (m *WxMutation) BlockList() (r []string, exists bool) {
  36686. v := m.block_list
  36687. if v == nil {
  36688. return
  36689. }
  36690. return *v, true
  36691. }
  36692. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  36693. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36695. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  36696. if !m.op.Is(OpUpdateOne) {
  36697. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  36698. }
  36699. if m.id == nil || m.oldValue == nil {
  36700. return v, errors.New("OldBlockList requires an ID field in the mutation")
  36701. }
  36702. oldValue, err := m.oldValue(ctx)
  36703. if err != nil {
  36704. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  36705. }
  36706. return oldValue.BlockList, nil
  36707. }
  36708. // AppendBlockList adds s to the "block_list" field.
  36709. func (m *WxMutation) AppendBlockList(s []string) {
  36710. m.appendblock_list = append(m.appendblock_list, s...)
  36711. }
  36712. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  36713. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  36714. if len(m.appendblock_list) == 0 {
  36715. return nil, false
  36716. }
  36717. return m.appendblock_list, true
  36718. }
  36719. // ResetBlockList resets all changes to the "block_list" field.
  36720. func (m *WxMutation) ResetBlockList() {
  36721. m.block_list = nil
  36722. m.appendblock_list = nil
  36723. }
  36724. // SetGroupBlockList sets the "group_block_list" field.
  36725. func (m *WxMutation) SetGroupBlockList(s []string) {
  36726. m.group_block_list = &s
  36727. m.appendgroup_block_list = nil
  36728. }
  36729. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  36730. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  36731. v := m.group_block_list
  36732. if v == nil {
  36733. return
  36734. }
  36735. return *v, true
  36736. }
  36737. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  36738. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  36739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36740. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  36741. if !m.op.Is(OpUpdateOne) {
  36742. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  36743. }
  36744. if m.id == nil || m.oldValue == nil {
  36745. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  36746. }
  36747. oldValue, err := m.oldValue(ctx)
  36748. if err != nil {
  36749. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  36750. }
  36751. return oldValue.GroupBlockList, nil
  36752. }
  36753. // AppendGroupBlockList adds s to the "group_block_list" field.
  36754. func (m *WxMutation) AppendGroupBlockList(s []string) {
  36755. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  36756. }
  36757. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  36758. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  36759. if len(m.appendgroup_block_list) == 0 {
  36760. return nil, false
  36761. }
  36762. return m.appendgroup_block_list, true
  36763. }
  36764. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  36765. func (m *WxMutation) ResetGroupBlockList() {
  36766. m.group_block_list = nil
  36767. m.appendgroup_block_list = nil
  36768. }
  36769. // ClearServer clears the "server" edge to the Server entity.
  36770. func (m *WxMutation) ClearServer() {
  36771. m.clearedserver = true
  36772. m.clearedFields[wx.FieldServerID] = struct{}{}
  36773. }
  36774. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  36775. func (m *WxMutation) ServerCleared() bool {
  36776. return m.ServerIDCleared() || m.clearedserver
  36777. }
  36778. // ServerIDs returns the "server" edge IDs in the mutation.
  36779. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  36780. // ServerID instead. It exists only for internal usage by the builders.
  36781. func (m *WxMutation) ServerIDs() (ids []uint64) {
  36782. if id := m.server; id != nil {
  36783. ids = append(ids, *id)
  36784. }
  36785. return
  36786. }
  36787. // ResetServer resets all changes to the "server" edge.
  36788. func (m *WxMutation) ResetServer() {
  36789. m.server = nil
  36790. m.clearedserver = false
  36791. }
  36792. // ClearAgent clears the "agent" edge to the Agent entity.
  36793. func (m *WxMutation) ClearAgent() {
  36794. m.clearedagent = true
  36795. m.clearedFields[wx.FieldAgentID] = struct{}{}
  36796. }
  36797. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  36798. func (m *WxMutation) AgentCleared() bool {
  36799. return m.clearedagent
  36800. }
  36801. // AgentIDs returns the "agent" edge IDs in the mutation.
  36802. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  36803. // AgentID instead. It exists only for internal usage by the builders.
  36804. func (m *WxMutation) AgentIDs() (ids []uint64) {
  36805. if id := m.agent; id != nil {
  36806. ids = append(ids, *id)
  36807. }
  36808. return
  36809. }
  36810. // ResetAgent resets all changes to the "agent" edge.
  36811. func (m *WxMutation) ResetAgent() {
  36812. m.agent = nil
  36813. m.clearedagent = false
  36814. }
  36815. // Where appends a list predicates to the WxMutation builder.
  36816. func (m *WxMutation) Where(ps ...predicate.Wx) {
  36817. m.predicates = append(m.predicates, ps...)
  36818. }
  36819. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  36820. // users can use type-assertion to append predicates that do not depend on any generated package.
  36821. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  36822. p := make([]predicate.Wx, len(ps))
  36823. for i := range ps {
  36824. p[i] = ps[i]
  36825. }
  36826. m.Where(p...)
  36827. }
  36828. // Op returns the operation name.
  36829. func (m *WxMutation) Op() Op {
  36830. return m.op
  36831. }
  36832. // SetOp allows setting the mutation operation.
  36833. func (m *WxMutation) SetOp(op Op) {
  36834. m.op = op
  36835. }
  36836. // Type returns the node type of this mutation (Wx).
  36837. func (m *WxMutation) Type() string {
  36838. return m.typ
  36839. }
  36840. // Fields returns all fields that were changed during this mutation. Note that in
  36841. // order to get all numeric fields that were incremented/decremented, call
  36842. // AddedFields().
  36843. func (m *WxMutation) Fields() []string {
  36844. fields := make([]string, 0, 21)
  36845. if m.created_at != nil {
  36846. fields = append(fields, wx.FieldCreatedAt)
  36847. }
  36848. if m.updated_at != nil {
  36849. fields = append(fields, wx.FieldUpdatedAt)
  36850. }
  36851. if m.status != nil {
  36852. fields = append(fields, wx.FieldStatus)
  36853. }
  36854. if m.deleted_at != nil {
  36855. fields = append(fields, wx.FieldDeletedAt)
  36856. }
  36857. if m.server != nil {
  36858. fields = append(fields, wx.FieldServerID)
  36859. }
  36860. if m.port != nil {
  36861. fields = append(fields, wx.FieldPort)
  36862. }
  36863. if m.process_id != nil {
  36864. fields = append(fields, wx.FieldProcessID)
  36865. }
  36866. if m.callback != nil {
  36867. fields = append(fields, wx.FieldCallback)
  36868. }
  36869. if m.wxid != nil {
  36870. fields = append(fields, wx.FieldWxid)
  36871. }
  36872. if m.account != nil {
  36873. fields = append(fields, wx.FieldAccount)
  36874. }
  36875. if m.nickname != nil {
  36876. fields = append(fields, wx.FieldNickname)
  36877. }
  36878. if m.tel != nil {
  36879. fields = append(fields, wx.FieldTel)
  36880. }
  36881. if m.head_big != nil {
  36882. fields = append(fields, wx.FieldHeadBig)
  36883. }
  36884. if m.organization_id != nil {
  36885. fields = append(fields, wx.FieldOrganizationID)
  36886. }
  36887. if m.agent != nil {
  36888. fields = append(fields, wx.FieldAgentID)
  36889. }
  36890. if m.api_base != nil {
  36891. fields = append(fields, wx.FieldAPIBase)
  36892. }
  36893. if m.api_key != nil {
  36894. fields = append(fields, wx.FieldAPIKey)
  36895. }
  36896. if m.allow_list != nil {
  36897. fields = append(fields, wx.FieldAllowList)
  36898. }
  36899. if m.group_allow_list != nil {
  36900. fields = append(fields, wx.FieldGroupAllowList)
  36901. }
  36902. if m.block_list != nil {
  36903. fields = append(fields, wx.FieldBlockList)
  36904. }
  36905. if m.group_block_list != nil {
  36906. fields = append(fields, wx.FieldGroupBlockList)
  36907. }
  36908. return fields
  36909. }
  36910. // Field returns the value of a field with the given name. The second boolean
  36911. // return value indicates that this field was not set, or was not defined in the
  36912. // schema.
  36913. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  36914. switch name {
  36915. case wx.FieldCreatedAt:
  36916. return m.CreatedAt()
  36917. case wx.FieldUpdatedAt:
  36918. return m.UpdatedAt()
  36919. case wx.FieldStatus:
  36920. return m.Status()
  36921. case wx.FieldDeletedAt:
  36922. return m.DeletedAt()
  36923. case wx.FieldServerID:
  36924. return m.ServerID()
  36925. case wx.FieldPort:
  36926. return m.Port()
  36927. case wx.FieldProcessID:
  36928. return m.ProcessID()
  36929. case wx.FieldCallback:
  36930. return m.Callback()
  36931. case wx.FieldWxid:
  36932. return m.Wxid()
  36933. case wx.FieldAccount:
  36934. return m.Account()
  36935. case wx.FieldNickname:
  36936. return m.Nickname()
  36937. case wx.FieldTel:
  36938. return m.Tel()
  36939. case wx.FieldHeadBig:
  36940. return m.HeadBig()
  36941. case wx.FieldOrganizationID:
  36942. return m.OrganizationID()
  36943. case wx.FieldAgentID:
  36944. return m.AgentID()
  36945. case wx.FieldAPIBase:
  36946. return m.APIBase()
  36947. case wx.FieldAPIKey:
  36948. return m.APIKey()
  36949. case wx.FieldAllowList:
  36950. return m.AllowList()
  36951. case wx.FieldGroupAllowList:
  36952. return m.GroupAllowList()
  36953. case wx.FieldBlockList:
  36954. return m.BlockList()
  36955. case wx.FieldGroupBlockList:
  36956. return m.GroupBlockList()
  36957. }
  36958. return nil, false
  36959. }
  36960. // OldField returns the old value of the field from the database. An error is
  36961. // returned if the mutation operation is not UpdateOne, or the query to the
  36962. // database failed.
  36963. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36964. switch name {
  36965. case wx.FieldCreatedAt:
  36966. return m.OldCreatedAt(ctx)
  36967. case wx.FieldUpdatedAt:
  36968. return m.OldUpdatedAt(ctx)
  36969. case wx.FieldStatus:
  36970. return m.OldStatus(ctx)
  36971. case wx.FieldDeletedAt:
  36972. return m.OldDeletedAt(ctx)
  36973. case wx.FieldServerID:
  36974. return m.OldServerID(ctx)
  36975. case wx.FieldPort:
  36976. return m.OldPort(ctx)
  36977. case wx.FieldProcessID:
  36978. return m.OldProcessID(ctx)
  36979. case wx.FieldCallback:
  36980. return m.OldCallback(ctx)
  36981. case wx.FieldWxid:
  36982. return m.OldWxid(ctx)
  36983. case wx.FieldAccount:
  36984. return m.OldAccount(ctx)
  36985. case wx.FieldNickname:
  36986. return m.OldNickname(ctx)
  36987. case wx.FieldTel:
  36988. return m.OldTel(ctx)
  36989. case wx.FieldHeadBig:
  36990. return m.OldHeadBig(ctx)
  36991. case wx.FieldOrganizationID:
  36992. return m.OldOrganizationID(ctx)
  36993. case wx.FieldAgentID:
  36994. return m.OldAgentID(ctx)
  36995. case wx.FieldAPIBase:
  36996. return m.OldAPIBase(ctx)
  36997. case wx.FieldAPIKey:
  36998. return m.OldAPIKey(ctx)
  36999. case wx.FieldAllowList:
  37000. return m.OldAllowList(ctx)
  37001. case wx.FieldGroupAllowList:
  37002. return m.OldGroupAllowList(ctx)
  37003. case wx.FieldBlockList:
  37004. return m.OldBlockList(ctx)
  37005. case wx.FieldGroupBlockList:
  37006. return m.OldGroupBlockList(ctx)
  37007. }
  37008. return nil, fmt.Errorf("unknown Wx field %s", name)
  37009. }
  37010. // SetField sets the value of a field with the given name. It returns an error if
  37011. // the field is not defined in the schema, or if the type mismatched the field
  37012. // type.
  37013. func (m *WxMutation) SetField(name string, value ent.Value) error {
  37014. switch name {
  37015. case wx.FieldCreatedAt:
  37016. v, ok := value.(time.Time)
  37017. if !ok {
  37018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37019. }
  37020. m.SetCreatedAt(v)
  37021. return nil
  37022. case wx.FieldUpdatedAt:
  37023. v, ok := value.(time.Time)
  37024. if !ok {
  37025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37026. }
  37027. m.SetUpdatedAt(v)
  37028. return nil
  37029. case wx.FieldStatus:
  37030. v, ok := value.(uint8)
  37031. if !ok {
  37032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37033. }
  37034. m.SetStatus(v)
  37035. return nil
  37036. case wx.FieldDeletedAt:
  37037. v, ok := value.(time.Time)
  37038. if !ok {
  37039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37040. }
  37041. m.SetDeletedAt(v)
  37042. return nil
  37043. case wx.FieldServerID:
  37044. v, ok := value.(uint64)
  37045. if !ok {
  37046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37047. }
  37048. m.SetServerID(v)
  37049. return nil
  37050. case wx.FieldPort:
  37051. v, ok := value.(string)
  37052. if !ok {
  37053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37054. }
  37055. m.SetPort(v)
  37056. return nil
  37057. case wx.FieldProcessID:
  37058. v, ok := value.(string)
  37059. if !ok {
  37060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37061. }
  37062. m.SetProcessID(v)
  37063. return nil
  37064. case wx.FieldCallback:
  37065. v, ok := value.(string)
  37066. if !ok {
  37067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37068. }
  37069. m.SetCallback(v)
  37070. return nil
  37071. case wx.FieldWxid:
  37072. v, ok := value.(string)
  37073. if !ok {
  37074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37075. }
  37076. m.SetWxid(v)
  37077. return nil
  37078. case wx.FieldAccount:
  37079. v, ok := value.(string)
  37080. if !ok {
  37081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37082. }
  37083. m.SetAccount(v)
  37084. return nil
  37085. case wx.FieldNickname:
  37086. v, ok := value.(string)
  37087. if !ok {
  37088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37089. }
  37090. m.SetNickname(v)
  37091. return nil
  37092. case wx.FieldTel:
  37093. v, ok := value.(string)
  37094. if !ok {
  37095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37096. }
  37097. m.SetTel(v)
  37098. return nil
  37099. case wx.FieldHeadBig:
  37100. v, ok := value.(string)
  37101. if !ok {
  37102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37103. }
  37104. m.SetHeadBig(v)
  37105. return nil
  37106. case wx.FieldOrganizationID:
  37107. v, ok := value.(uint64)
  37108. if !ok {
  37109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37110. }
  37111. m.SetOrganizationID(v)
  37112. return nil
  37113. case wx.FieldAgentID:
  37114. v, ok := value.(uint64)
  37115. if !ok {
  37116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37117. }
  37118. m.SetAgentID(v)
  37119. return nil
  37120. case wx.FieldAPIBase:
  37121. v, ok := value.(string)
  37122. if !ok {
  37123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37124. }
  37125. m.SetAPIBase(v)
  37126. return nil
  37127. case wx.FieldAPIKey:
  37128. v, ok := value.(string)
  37129. if !ok {
  37130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37131. }
  37132. m.SetAPIKey(v)
  37133. return nil
  37134. case wx.FieldAllowList:
  37135. v, ok := value.([]string)
  37136. if !ok {
  37137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37138. }
  37139. m.SetAllowList(v)
  37140. return nil
  37141. case wx.FieldGroupAllowList:
  37142. v, ok := value.([]string)
  37143. if !ok {
  37144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37145. }
  37146. m.SetGroupAllowList(v)
  37147. return nil
  37148. case wx.FieldBlockList:
  37149. v, ok := value.([]string)
  37150. if !ok {
  37151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37152. }
  37153. m.SetBlockList(v)
  37154. return nil
  37155. case wx.FieldGroupBlockList:
  37156. v, ok := value.([]string)
  37157. if !ok {
  37158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37159. }
  37160. m.SetGroupBlockList(v)
  37161. return nil
  37162. }
  37163. return fmt.Errorf("unknown Wx field %s", name)
  37164. }
  37165. // AddedFields returns all numeric fields that were incremented/decremented during
  37166. // this mutation.
  37167. func (m *WxMutation) AddedFields() []string {
  37168. var fields []string
  37169. if m.addstatus != nil {
  37170. fields = append(fields, wx.FieldStatus)
  37171. }
  37172. if m.addorganization_id != nil {
  37173. fields = append(fields, wx.FieldOrganizationID)
  37174. }
  37175. return fields
  37176. }
  37177. // AddedField returns the numeric value that was incremented/decremented on a field
  37178. // with the given name. The second boolean return value indicates that this field
  37179. // was not set, or was not defined in the schema.
  37180. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  37181. switch name {
  37182. case wx.FieldStatus:
  37183. return m.AddedStatus()
  37184. case wx.FieldOrganizationID:
  37185. return m.AddedOrganizationID()
  37186. }
  37187. return nil, false
  37188. }
  37189. // AddField adds the value to the field with the given name. It returns an error if
  37190. // the field is not defined in the schema, or if the type mismatched the field
  37191. // type.
  37192. func (m *WxMutation) AddField(name string, value ent.Value) error {
  37193. switch name {
  37194. case wx.FieldStatus:
  37195. v, ok := value.(int8)
  37196. if !ok {
  37197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37198. }
  37199. m.AddStatus(v)
  37200. return nil
  37201. case wx.FieldOrganizationID:
  37202. v, ok := value.(int64)
  37203. if !ok {
  37204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37205. }
  37206. m.AddOrganizationID(v)
  37207. return nil
  37208. }
  37209. return fmt.Errorf("unknown Wx numeric field %s", name)
  37210. }
  37211. // ClearedFields returns all nullable fields that were cleared during this
  37212. // mutation.
  37213. func (m *WxMutation) ClearedFields() []string {
  37214. var fields []string
  37215. if m.FieldCleared(wx.FieldStatus) {
  37216. fields = append(fields, wx.FieldStatus)
  37217. }
  37218. if m.FieldCleared(wx.FieldDeletedAt) {
  37219. fields = append(fields, wx.FieldDeletedAt)
  37220. }
  37221. if m.FieldCleared(wx.FieldServerID) {
  37222. fields = append(fields, wx.FieldServerID)
  37223. }
  37224. if m.FieldCleared(wx.FieldOrganizationID) {
  37225. fields = append(fields, wx.FieldOrganizationID)
  37226. }
  37227. if m.FieldCleared(wx.FieldAPIBase) {
  37228. fields = append(fields, wx.FieldAPIBase)
  37229. }
  37230. if m.FieldCleared(wx.FieldAPIKey) {
  37231. fields = append(fields, wx.FieldAPIKey)
  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 *WxMutation) 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 *WxMutation) ClearField(name string) error {
  37244. switch name {
  37245. case wx.FieldStatus:
  37246. m.ClearStatus()
  37247. return nil
  37248. case wx.FieldDeletedAt:
  37249. m.ClearDeletedAt()
  37250. return nil
  37251. case wx.FieldServerID:
  37252. m.ClearServerID()
  37253. return nil
  37254. case wx.FieldOrganizationID:
  37255. m.ClearOrganizationID()
  37256. return nil
  37257. case wx.FieldAPIBase:
  37258. m.ClearAPIBase()
  37259. return nil
  37260. case wx.FieldAPIKey:
  37261. m.ClearAPIKey()
  37262. return nil
  37263. }
  37264. return fmt.Errorf("unknown Wx nullable field %s", name)
  37265. }
  37266. // ResetField resets all changes in the mutation for the field with the given name.
  37267. // It returns an error if the field is not defined in the schema.
  37268. func (m *WxMutation) ResetField(name string) error {
  37269. switch name {
  37270. case wx.FieldCreatedAt:
  37271. m.ResetCreatedAt()
  37272. return nil
  37273. case wx.FieldUpdatedAt:
  37274. m.ResetUpdatedAt()
  37275. return nil
  37276. case wx.FieldStatus:
  37277. m.ResetStatus()
  37278. return nil
  37279. case wx.FieldDeletedAt:
  37280. m.ResetDeletedAt()
  37281. return nil
  37282. case wx.FieldServerID:
  37283. m.ResetServerID()
  37284. return nil
  37285. case wx.FieldPort:
  37286. m.ResetPort()
  37287. return nil
  37288. case wx.FieldProcessID:
  37289. m.ResetProcessID()
  37290. return nil
  37291. case wx.FieldCallback:
  37292. m.ResetCallback()
  37293. return nil
  37294. case wx.FieldWxid:
  37295. m.ResetWxid()
  37296. return nil
  37297. case wx.FieldAccount:
  37298. m.ResetAccount()
  37299. return nil
  37300. case wx.FieldNickname:
  37301. m.ResetNickname()
  37302. return nil
  37303. case wx.FieldTel:
  37304. m.ResetTel()
  37305. return nil
  37306. case wx.FieldHeadBig:
  37307. m.ResetHeadBig()
  37308. return nil
  37309. case wx.FieldOrganizationID:
  37310. m.ResetOrganizationID()
  37311. return nil
  37312. case wx.FieldAgentID:
  37313. m.ResetAgentID()
  37314. return nil
  37315. case wx.FieldAPIBase:
  37316. m.ResetAPIBase()
  37317. return nil
  37318. case wx.FieldAPIKey:
  37319. m.ResetAPIKey()
  37320. return nil
  37321. case wx.FieldAllowList:
  37322. m.ResetAllowList()
  37323. return nil
  37324. case wx.FieldGroupAllowList:
  37325. m.ResetGroupAllowList()
  37326. return nil
  37327. case wx.FieldBlockList:
  37328. m.ResetBlockList()
  37329. return nil
  37330. case wx.FieldGroupBlockList:
  37331. m.ResetGroupBlockList()
  37332. return nil
  37333. }
  37334. return fmt.Errorf("unknown Wx field %s", name)
  37335. }
  37336. // AddedEdges returns all edge names that were set/added in this mutation.
  37337. func (m *WxMutation) AddedEdges() []string {
  37338. edges := make([]string, 0, 2)
  37339. if m.server != nil {
  37340. edges = append(edges, wx.EdgeServer)
  37341. }
  37342. if m.agent != nil {
  37343. edges = append(edges, wx.EdgeAgent)
  37344. }
  37345. return edges
  37346. }
  37347. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37348. // name in this mutation.
  37349. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  37350. switch name {
  37351. case wx.EdgeServer:
  37352. if id := m.server; id != nil {
  37353. return []ent.Value{*id}
  37354. }
  37355. case wx.EdgeAgent:
  37356. if id := m.agent; id != nil {
  37357. return []ent.Value{*id}
  37358. }
  37359. }
  37360. return nil
  37361. }
  37362. // RemovedEdges returns all edge names that were removed in this mutation.
  37363. func (m *WxMutation) RemovedEdges() []string {
  37364. edges := make([]string, 0, 2)
  37365. return edges
  37366. }
  37367. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37368. // the given name in this mutation.
  37369. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  37370. return nil
  37371. }
  37372. // ClearedEdges returns all edge names that were cleared in this mutation.
  37373. func (m *WxMutation) ClearedEdges() []string {
  37374. edges := make([]string, 0, 2)
  37375. if m.clearedserver {
  37376. edges = append(edges, wx.EdgeServer)
  37377. }
  37378. if m.clearedagent {
  37379. edges = append(edges, wx.EdgeAgent)
  37380. }
  37381. return edges
  37382. }
  37383. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37384. // was cleared in this mutation.
  37385. func (m *WxMutation) EdgeCleared(name string) bool {
  37386. switch name {
  37387. case wx.EdgeServer:
  37388. return m.clearedserver
  37389. case wx.EdgeAgent:
  37390. return m.clearedagent
  37391. }
  37392. return false
  37393. }
  37394. // ClearEdge clears the value of the edge with the given name. It returns an error
  37395. // if that edge is not defined in the schema.
  37396. func (m *WxMutation) ClearEdge(name string) error {
  37397. switch name {
  37398. case wx.EdgeServer:
  37399. m.ClearServer()
  37400. return nil
  37401. case wx.EdgeAgent:
  37402. m.ClearAgent()
  37403. return nil
  37404. }
  37405. return fmt.Errorf("unknown Wx unique edge %s", name)
  37406. }
  37407. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37408. // It returns an error if the edge is not defined in the schema.
  37409. func (m *WxMutation) ResetEdge(name string) error {
  37410. switch name {
  37411. case wx.EdgeServer:
  37412. m.ResetServer()
  37413. return nil
  37414. case wx.EdgeAgent:
  37415. m.ResetAgent()
  37416. return nil
  37417. }
  37418. return fmt.Errorf("unknown Wx edge %s", name)
  37419. }
  37420. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  37421. type WxCardMutation struct {
  37422. config
  37423. op Op
  37424. typ string
  37425. id *uint64
  37426. created_at *time.Time
  37427. updated_at *time.Time
  37428. deleted_at *time.Time
  37429. user_id *uint64
  37430. adduser_id *int64
  37431. wx_user_id *uint64
  37432. addwx_user_id *int64
  37433. avatar *string
  37434. logo *string
  37435. name *string
  37436. company *string
  37437. address *string
  37438. phone *string
  37439. official_account *string
  37440. wechat_account *string
  37441. email *string
  37442. api_base *string
  37443. api_key *string
  37444. ai_info *string
  37445. intro *string
  37446. clearedFields map[string]struct{}
  37447. done bool
  37448. oldValue func(context.Context) (*WxCard, error)
  37449. predicates []predicate.WxCard
  37450. }
  37451. var _ ent.Mutation = (*WxCardMutation)(nil)
  37452. // wxcardOption allows management of the mutation configuration using functional options.
  37453. type wxcardOption func(*WxCardMutation)
  37454. // newWxCardMutation creates new mutation for the WxCard entity.
  37455. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  37456. m := &WxCardMutation{
  37457. config: c,
  37458. op: op,
  37459. typ: TypeWxCard,
  37460. clearedFields: make(map[string]struct{}),
  37461. }
  37462. for _, opt := range opts {
  37463. opt(m)
  37464. }
  37465. return m
  37466. }
  37467. // withWxCardID sets the ID field of the mutation.
  37468. func withWxCardID(id uint64) wxcardOption {
  37469. return func(m *WxCardMutation) {
  37470. var (
  37471. err error
  37472. once sync.Once
  37473. value *WxCard
  37474. )
  37475. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  37476. once.Do(func() {
  37477. if m.done {
  37478. err = errors.New("querying old values post mutation is not allowed")
  37479. } else {
  37480. value, err = m.Client().WxCard.Get(ctx, id)
  37481. }
  37482. })
  37483. return value, err
  37484. }
  37485. m.id = &id
  37486. }
  37487. }
  37488. // withWxCard sets the old WxCard of the mutation.
  37489. func withWxCard(node *WxCard) wxcardOption {
  37490. return func(m *WxCardMutation) {
  37491. m.oldValue = func(context.Context) (*WxCard, error) {
  37492. return node, nil
  37493. }
  37494. m.id = &node.ID
  37495. }
  37496. }
  37497. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37498. // executed in a transaction (ent.Tx), a transactional client is returned.
  37499. func (m WxCardMutation) Client() *Client {
  37500. client := &Client{config: m.config}
  37501. client.init()
  37502. return client
  37503. }
  37504. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37505. // it returns an error otherwise.
  37506. func (m WxCardMutation) Tx() (*Tx, error) {
  37507. if _, ok := m.driver.(*txDriver); !ok {
  37508. return nil, errors.New("ent: mutation is not running in a transaction")
  37509. }
  37510. tx := &Tx{config: m.config}
  37511. tx.init()
  37512. return tx, nil
  37513. }
  37514. // SetID sets the value of the id field. Note that this
  37515. // operation is only accepted on creation of WxCard entities.
  37516. func (m *WxCardMutation) SetID(id uint64) {
  37517. m.id = &id
  37518. }
  37519. // ID returns the ID value in the mutation. Note that the ID is only available
  37520. // if it was provided to the builder or after it was returned from the database.
  37521. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  37522. if m.id == nil {
  37523. return
  37524. }
  37525. return *m.id, true
  37526. }
  37527. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37528. // That means, if the mutation is applied within a transaction with an isolation level such
  37529. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37530. // or updated by the mutation.
  37531. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  37532. switch {
  37533. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37534. id, exists := m.ID()
  37535. if exists {
  37536. return []uint64{id}, nil
  37537. }
  37538. fallthrough
  37539. case m.op.Is(OpUpdate | OpDelete):
  37540. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  37541. default:
  37542. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37543. }
  37544. }
  37545. // SetCreatedAt sets the "created_at" field.
  37546. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  37547. m.created_at = &t
  37548. }
  37549. // CreatedAt returns the value of the "created_at" field in the mutation.
  37550. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  37551. v := m.created_at
  37552. if v == nil {
  37553. return
  37554. }
  37555. return *v, true
  37556. }
  37557. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  37558. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37560. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37561. if !m.op.Is(OpUpdateOne) {
  37562. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37563. }
  37564. if m.id == nil || m.oldValue == nil {
  37565. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37566. }
  37567. oldValue, err := m.oldValue(ctx)
  37568. if err != nil {
  37569. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37570. }
  37571. return oldValue.CreatedAt, nil
  37572. }
  37573. // ResetCreatedAt resets all changes to the "created_at" field.
  37574. func (m *WxCardMutation) ResetCreatedAt() {
  37575. m.created_at = nil
  37576. }
  37577. // SetUpdatedAt sets the "updated_at" field.
  37578. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  37579. m.updated_at = &t
  37580. }
  37581. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37582. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  37583. v := m.updated_at
  37584. if v == nil {
  37585. return
  37586. }
  37587. return *v, true
  37588. }
  37589. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  37590. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37592. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37593. if !m.op.Is(OpUpdateOne) {
  37594. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37595. }
  37596. if m.id == nil || m.oldValue == nil {
  37597. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37598. }
  37599. oldValue, err := m.oldValue(ctx)
  37600. if err != nil {
  37601. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37602. }
  37603. return oldValue.UpdatedAt, nil
  37604. }
  37605. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37606. func (m *WxCardMutation) ResetUpdatedAt() {
  37607. m.updated_at = nil
  37608. }
  37609. // SetDeletedAt sets the "deleted_at" field.
  37610. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  37611. m.deleted_at = &t
  37612. }
  37613. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37614. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  37615. v := m.deleted_at
  37616. if v == nil {
  37617. return
  37618. }
  37619. return *v, true
  37620. }
  37621. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  37622. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37624. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37625. if !m.op.Is(OpUpdateOne) {
  37626. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37627. }
  37628. if m.id == nil || m.oldValue == nil {
  37629. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37630. }
  37631. oldValue, err := m.oldValue(ctx)
  37632. if err != nil {
  37633. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37634. }
  37635. return oldValue.DeletedAt, nil
  37636. }
  37637. // ClearDeletedAt clears the value of the "deleted_at" field.
  37638. func (m *WxCardMutation) ClearDeletedAt() {
  37639. m.deleted_at = nil
  37640. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  37641. }
  37642. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37643. func (m *WxCardMutation) DeletedAtCleared() bool {
  37644. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  37645. return ok
  37646. }
  37647. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37648. func (m *WxCardMutation) ResetDeletedAt() {
  37649. m.deleted_at = nil
  37650. delete(m.clearedFields, wxcard.FieldDeletedAt)
  37651. }
  37652. // SetUserID sets the "user_id" field.
  37653. func (m *WxCardMutation) SetUserID(u uint64) {
  37654. m.user_id = &u
  37655. m.adduser_id = nil
  37656. }
  37657. // UserID returns the value of the "user_id" field in the mutation.
  37658. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  37659. v := m.user_id
  37660. if v == nil {
  37661. return
  37662. }
  37663. return *v, true
  37664. }
  37665. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  37666. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37668. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  37669. if !m.op.Is(OpUpdateOne) {
  37670. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  37671. }
  37672. if m.id == nil || m.oldValue == nil {
  37673. return v, errors.New("OldUserID requires an ID field in the mutation")
  37674. }
  37675. oldValue, err := m.oldValue(ctx)
  37676. if err != nil {
  37677. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  37678. }
  37679. return oldValue.UserID, nil
  37680. }
  37681. // AddUserID adds u to the "user_id" field.
  37682. func (m *WxCardMutation) AddUserID(u int64) {
  37683. if m.adduser_id != nil {
  37684. *m.adduser_id += u
  37685. } else {
  37686. m.adduser_id = &u
  37687. }
  37688. }
  37689. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  37690. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  37691. v := m.adduser_id
  37692. if v == nil {
  37693. return
  37694. }
  37695. return *v, true
  37696. }
  37697. // ClearUserID clears the value of the "user_id" field.
  37698. func (m *WxCardMutation) ClearUserID() {
  37699. m.user_id = nil
  37700. m.adduser_id = nil
  37701. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  37702. }
  37703. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  37704. func (m *WxCardMutation) UserIDCleared() bool {
  37705. _, ok := m.clearedFields[wxcard.FieldUserID]
  37706. return ok
  37707. }
  37708. // ResetUserID resets all changes to the "user_id" field.
  37709. func (m *WxCardMutation) ResetUserID() {
  37710. m.user_id = nil
  37711. m.adduser_id = nil
  37712. delete(m.clearedFields, wxcard.FieldUserID)
  37713. }
  37714. // SetWxUserID sets the "wx_user_id" field.
  37715. func (m *WxCardMutation) SetWxUserID(u uint64) {
  37716. m.wx_user_id = &u
  37717. m.addwx_user_id = nil
  37718. }
  37719. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  37720. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  37721. v := m.wx_user_id
  37722. if v == nil {
  37723. return
  37724. }
  37725. return *v, true
  37726. }
  37727. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  37728. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37730. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  37731. if !m.op.Is(OpUpdateOne) {
  37732. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  37733. }
  37734. if m.id == nil || m.oldValue == nil {
  37735. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  37736. }
  37737. oldValue, err := m.oldValue(ctx)
  37738. if err != nil {
  37739. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  37740. }
  37741. return oldValue.WxUserID, nil
  37742. }
  37743. // AddWxUserID adds u to the "wx_user_id" field.
  37744. func (m *WxCardMutation) AddWxUserID(u int64) {
  37745. if m.addwx_user_id != nil {
  37746. *m.addwx_user_id += u
  37747. } else {
  37748. m.addwx_user_id = &u
  37749. }
  37750. }
  37751. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  37752. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  37753. v := m.addwx_user_id
  37754. if v == nil {
  37755. return
  37756. }
  37757. return *v, true
  37758. }
  37759. // ClearWxUserID clears the value of the "wx_user_id" field.
  37760. func (m *WxCardMutation) ClearWxUserID() {
  37761. m.wx_user_id = nil
  37762. m.addwx_user_id = nil
  37763. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  37764. }
  37765. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  37766. func (m *WxCardMutation) WxUserIDCleared() bool {
  37767. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  37768. return ok
  37769. }
  37770. // ResetWxUserID resets all changes to the "wx_user_id" field.
  37771. func (m *WxCardMutation) ResetWxUserID() {
  37772. m.wx_user_id = nil
  37773. m.addwx_user_id = nil
  37774. delete(m.clearedFields, wxcard.FieldWxUserID)
  37775. }
  37776. // SetAvatar sets the "avatar" field.
  37777. func (m *WxCardMutation) SetAvatar(s string) {
  37778. m.avatar = &s
  37779. }
  37780. // Avatar returns the value of the "avatar" field in the mutation.
  37781. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  37782. v := m.avatar
  37783. if v == nil {
  37784. return
  37785. }
  37786. return *v, true
  37787. }
  37788. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  37789. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37790. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37791. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  37792. if !m.op.Is(OpUpdateOne) {
  37793. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  37794. }
  37795. if m.id == nil || m.oldValue == nil {
  37796. return v, errors.New("OldAvatar requires an ID field in the mutation")
  37797. }
  37798. oldValue, err := m.oldValue(ctx)
  37799. if err != nil {
  37800. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  37801. }
  37802. return oldValue.Avatar, nil
  37803. }
  37804. // ResetAvatar resets all changes to the "avatar" field.
  37805. func (m *WxCardMutation) ResetAvatar() {
  37806. m.avatar = nil
  37807. }
  37808. // SetLogo sets the "logo" field.
  37809. func (m *WxCardMutation) SetLogo(s string) {
  37810. m.logo = &s
  37811. }
  37812. // Logo returns the value of the "logo" field in the mutation.
  37813. func (m *WxCardMutation) Logo() (r string, exists bool) {
  37814. v := m.logo
  37815. if v == nil {
  37816. return
  37817. }
  37818. return *v, true
  37819. }
  37820. // OldLogo returns the old "logo" field's value of the WxCard entity.
  37821. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37823. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  37824. if !m.op.Is(OpUpdateOne) {
  37825. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  37826. }
  37827. if m.id == nil || m.oldValue == nil {
  37828. return v, errors.New("OldLogo requires an ID field in the mutation")
  37829. }
  37830. oldValue, err := m.oldValue(ctx)
  37831. if err != nil {
  37832. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  37833. }
  37834. return oldValue.Logo, nil
  37835. }
  37836. // ResetLogo resets all changes to the "logo" field.
  37837. func (m *WxCardMutation) ResetLogo() {
  37838. m.logo = nil
  37839. }
  37840. // SetName sets the "name" field.
  37841. func (m *WxCardMutation) SetName(s string) {
  37842. m.name = &s
  37843. }
  37844. // Name returns the value of the "name" field in the mutation.
  37845. func (m *WxCardMutation) Name() (r string, exists bool) {
  37846. v := m.name
  37847. if v == nil {
  37848. return
  37849. }
  37850. return *v, true
  37851. }
  37852. // OldName returns the old "name" field's value of the WxCard entity.
  37853. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37855. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  37856. if !m.op.Is(OpUpdateOne) {
  37857. return v, errors.New("OldName is only allowed on UpdateOne operations")
  37858. }
  37859. if m.id == nil || m.oldValue == nil {
  37860. return v, errors.New("OldName requires an ID field in the mutation")
  37861. }
  37862. oldValue, err := m.oldValue(ctx)
  37863. if err != nil {
  37864. return v, fmt.Errorf("querying old value for OldName: %w", err)
  37865. }
  37866. return oldValue.Name, nil
  37867. }
  37868. // ResetName resets all changes to the "name" field.
  37869. func (m *WxCardMutation) ResetName() {
  37870. m.name = nil
  37871. }
  37872. // SetCompany sets the "company" field.
  37873. func (m *WxCardMutation) SetCompany(s string) {
  37874. m.company = &s
  37875. }
  37876. // Company returns the value of the "company" field in the mutation.
  37877. func (m *WxCardMutation) Company() (r string, exists bool) {
  37878. v := m.company
  37879. if v == nil {
  37880. return
  37881. }
  37882. return *v, true
  37883. }
  37884. // OldCompany returns the old "company" field's value of the WxCard entity.
  37885. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37887. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  37888. if !m.op.Is(OpUpdateOne) {
  37889. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  37890. }
  37891. if m.id == nil || m.oldValue == nil {
  37892. return v, errors.New("OldCompany requires an ID field in the mutation")
  37893. }
  37894. oldValue, err := m.oldValue(ctx)
  37895. if err != nil {
  37896. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  37897. }
  37898. return oldValue.Company, nil
  37899. }
  37900. // ResetCompany resets all changes to the "company" field.
  37901. func (m *WxCardMutation) ResetCompany() {
  37902. m.company = nil
  37903. }
  37904. // SetAddress sets the "address" field.
  37905. func (m *WxCardMutation) SetAddress(s string) {
  37906. m.address = &s
  37907. }
  37908. // Address returns the value of the "address" field in the mutation.
  37909. func (m *WxCardMutation) Address() (r string, exists bool) {
  37910. v := m.address
  37911. if v == nil {
  37912. return
  37913. }
  37914. return *v, true
  37915. }
  37916. // OldAddress returns the old "address" field's value of the WxCard entity.
  37917. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37919. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  37920. if !m.op.Is(OpUpdateOne) {
  37921. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  37922. }
  37923. if m.id == nil || m.oldValue == nil {
  37924. return v, errors.New("OldAddress requires an ID field in the mutation")
  37925. }
  37926. oldValue, err := m.oldValue(ctx)
  37927. if err != nil {
  37928. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  37929. }
  37930. return oldValue.Address, nil
  37931. }
  37932. // ResetAddress resets all changes to the "address" field.
  37933. func (m *WxCardMutation) ResetAddress() {
  37934. m.address = nil
  37935. }
  37936. // SetPhone sets the "phone" field.
  37937. func (m *WxCardMutation) SetPhone(s string) {
  37938. m.phone = &s
  37939. }
  37940. // Phone returns the value of the "phone" field in the mutation.
  37941. func (m *WxCardMutation) Phone() (r string, exists bool) {
  37942. v := m.phone
  37943. if v == nil {
  37944. return
  37945. }
  37946. return *v, true
  37947. }
  37948. // OldPhone returns the old "phone" field's value of the WxCard entity.
  37949. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37951. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  37952. if !m.op.Is(OpUpdateOne) {
  37953. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  37954. }
  37955. if m.id == nil || m.oldValue == nil {
  37956. return v, errors.New("OldPhone requires an ID field in the mutation")
  37957. }
  37958. oldValue, err := m.oldValue(ctx)
  37959. if err != nil {
  37960. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  37961. }
  37962. return oldValue.Phone, nil
  37963. }
  37964. // ResetPhone resets all changes to the "phone" field.
  37965. func (m *WxCardMutation) ResetPhone() {
  37966. m.phone = nil
  37967. }
  37968. // SetOfficialAccount sets the "official_account" field.
  37969. func (m *WxCardMutation) SetOfficialAccount(s string) {
  37970. m.official_account = &s
  37971. }
  37972. // OfficialAccount returns the value of the "official_account" field in the mutation.
  37973. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  37974. v := m.official_account
  37975. if v == nil {
  37976. return
  37977. }
  37978. return *v, true
  37979. }
  37980. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  37981. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37983. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  37984. if !m.op.Is(OpUpdateOne) {
  37985. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  37986. }
  37987. if m.id == nil || m.oldValue == nil {
  37988. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  37989. }
  37990. oldValue, err := m.oldValue(ctx)
  37991. if err != nil {
  37992. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  37993. }
  37994. return oldValue.OfficialAccount, nil
  37995. }
  37996. // ResetOfficialAccount resets all changes to the "official_account" field.
  37997. func (m *WxCardMutation) ResetOfficialAccount() {
  37998. m.official_account = nil
  37999. }
  38000. // SetWechatAccount sets the "wechat_account" field.
  38001. func (m *WxCardMutation) SetWechatAccount(s string) {
  38002. m.wechat_account = &s
  38003. }
  38004. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  38005. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  38006. v := m.wechat_account
  38007. if v == nil {
  38008. return
  38009. }
  38010. return *v, true
  38011. }
  38012. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  38013. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  38014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38015. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  38016. if !m.op.Is(OpUpdateOne) {
  38017. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  38018. }
  38019. if m.id == nil || m.oldValue == nil {
  38020. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  38021. }
  38022. oldValue, err := m.oldValue(ctx)
  38023. if err != nil {
  38024. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  38025. }
  38026. return oldValue.WechatAccount, nil
  38027. }
  38028. // ResetWechatAccount resets all changes to the "wechat_account" field.
  38029. func (m *WxCardMutation) ResetWechatAccount() {
  38030. m.wechat_account = nil
  38031. }
  38032. // SetEmail sets the "email" field.
  38033. func (m *WxCardMutation) SetEmail(s string) {
  38034. m.email = &s
  38035. }
  38036. // Email returns the value of the "email" field in the mutation.
  38037. func (m *WxCardMutation) Email() (r string, exists bool) {
  38038. v := m.email
  38039. if v == nil {
  38040. return
  38041. }
  38042. return *v, true
  38043. }
  38044. // OldEmail returns the old "email" field's value of the WxCard entity.
  38045. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  38046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38047. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  38048. if !m.op.Is(OpUpdateOne) {
  38049. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  38050. }
  38051. if m.id == nil || m.oldValue == nil {
  38052. return v, errors.New("OldEmail requires an ID field in the mutation")
  38053. }
  38054. oldValue, err := m.oldValue(ctx)
  38055. if err != nil {
  38056. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  38057. }
  38058. return oldValue.Email, nil
  38059. }
  38060. // ClearEmail clears the value of the "email" field.
  38061. func (m *WxCardMutation) ClearEmail() {
  38062. m.email = nil
  38063. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  38064. }
  38065. // EmailCleared returns if the "email" field was cleared in this mutation.
  38066. func (m *WxCardMutation) EmailCleared() bool {
  38067. _, ok := m.clearedFields[wxcard.FieldEmail]
  38068. return ok
  38069. }
  38070. // ResetEmail resets all changes to the "email" field.
  38071. func (m *WxCardMutation) ResetEmail() {
  38072. m.email = nil
  38073. delete(m.clearedFields, wxcard.FieldEmail)
  38074. }
  38075. // SetAPIBase sets the "api_base" field.
  38076. func (m *WxCardMutation) SetAPIBase(s string) {
  38077. m.api_base = &s
  38078. }
  38079. // APIBase returns the value of the "api_base" field in the mutation.
  38080. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  38081. v := m.api_base
  38082. if v == nil {
  38083. return
  38084. }
  38085. return *v, true
  38086. }
  38087. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  38088. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  38089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38090. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  38091. if !m.op.Is(OpUpdateOne) {
  38092. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  38093. }
  38094. if m.id == nil || m.oldValue == nil {
  38095. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  38096. }
  38097. oldValue, err := m.oldValue(ctx)
  38098. if err != nil {
  38099. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  38100. }
  38101. return oldValue.APIBase, nil
  38102. }
  38103. // ClearAPIBase clears the value of the "api_base" field.
  38104. func (m *WxCardMutation) ClearAPIBase() {
  38105. m.api_base = nil
  38106. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  38107. }
  38108. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  38109. func (m *WxCardMutation) APIBaseCleared() bool {
  38110. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  38111. return ok
  38112. }
  38113. // ResetAPIBase resets all changes to the "api_base" field.
  38114. func (m *WxCardMutation) ResetAPIBase() {
  38115. m.api_base = nil
  38116. delete(m.clearedFields, wxcard.FieldAPIBase)
  38117. }
  38118. // SetAPIKey sets the "api_key" field.
  38119. func (m *WxCardMutation) SetAPIKey(s string) {
  38120. m.api_key = &s
  38121. }
  38122. // APIKey returns the value of the "api_key" field in the mutation.
  38123. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  38124. v := m.api_key
  38125. if v == nil {
  38126. return
  38127. }
  38128. return *v, true
  38129. }
  38130. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  38131. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  38132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38133. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  38134. if !m.op.Is(OpUpdateOne) {
  38135. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  38136. }
  38137. if m.id == nil || m.oldValue == nil {
  38138. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  38139. }
  38140. oldValue, err := m.oldValue(ctx)
  38141. if err != nil {
  38142. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  38143. }
  38144. return oldValue.APIKey, nil
  38145. }
  38146. // ClearAPIKey clears the value of the "api_key" field.
  38147. func (m *WxCardMutation) ClearAPIKey() {
  38148. m.api_key = nil
  38149. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  38150. }
  38151. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  38152. func (m *WxCardMutation) APIKeyCleared() bool {
  38153. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  38154. return ok
  38155. }
  38156. // ResetAPIKey resets all changes to the "api_key" field.
  38157. func (m *WxCardMutation) ResetAPIKey() {
  38158. m.api_key = nil
  38159. delete(m.clearedFields, wxcard.FieldAPIKey)
  38160. }
  38161. // SetAiInfo sets the "ai_info" field.
  38162. func (m *WxCardMutation) SetAiInfo(s string) {
  38163. m.ai_info = &s
  38164. }
  38165. // AiInfo returns the value of the "ai_info" field in the mutation.
  38166. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  38167. v := m.ai_info
  38168. if v == nil {
  38169. return
  38170. }
  38171. return *v, true
  38172. }
  38173. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  38174. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  38175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38176. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  38177. if !m.op.Is(OpUpdateOne) {
  38178. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  38179. }
  38180. if m.id == nil || m.oldValue == nil {
  38181. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  38182. }
  38183. oldValue, err := m.oldValue(ctx)
  38184. if err != nil {
  38185. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  38186. }
  38187. return oldValue.AiInfo, nil
  38188. }
  38189. // ClearAiInfo clears the value of the "ai_info" field.
  38190. func (m *WxCardMutation) ClearAiInfo() {
  38191. m.ai_info = nil
  38192. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  38193. }
  38194. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  38195. func (m *WxCardMutation) AiInfoCleared() bool {
  38196. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  38197. return ok
  38198. }
  38199. // ResetAiInfo resets all changes to the "ai_info" field.
  38200. func (m *WxCardMutation) ResetAiInfo() {
  38201. m.ai_info = nil
  38202. delete(m.clearedFields, wxcard.FieldAiInfo)
  38203. }
  38204. // SetIntro sets the "intro" field.
  38205. func (m *WxCardMutation) SetIntro(s string) {
  38206. m.intro = &s
  38207. }
  38208. // Intro returns the value of the "intro" field in the mutation.
  38209. func (m *WxCardMutation) Intro() (r string, exists bool) {
  38210. v := m.intro
  38211. if v == nil {
  38212. return
  38213. }
  38214. return *v, true
  38215. }
  38216. // OldIntro returns the old "intro" field's value of the WxCard entity.
  38217. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  38218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38219. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  38220. if !m.op.Is(OpUpdateOne) {
  38221. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  38222. }
  38223. if m.id == nil || m.oldValue == nil {
  38224. return v, errors.New("OldIntro requires an ID field in the mutation")
  38225. }
  38226. oldValue, err := m.oldValue(ctx)
  38227. if err != nil {
  38228. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  38229. }
  38230. return oldValue.Intro, nil
  38231. }
  38232. // ClearIntro clears the value of the "intro" field.
  38233. func (m *WxCardMutation) ClearIntro() {
  38234. m.intro = nil
  38235. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  38236. }
  38237. // IntroCleared returns if the "intro" field was cleared in this mutation.
  38238. func (m *WxCardMutation) IntroCleared() bool {
  38239. _, ok := m.clearedFields[wxcard.FieldIntro]
  38240. return ok
  38241. }
  38242. // ResetIntro resets all changes to the "intro" field.
  38243. func (m *WxCardMutation) ResetIntro() {
  38244. m.intro = nil
  38245. delete(m.clearedFields, wxcard.FieldIntro)
  38246. }
  38247. // Where appends a list predicates to the WxCardMutation builder.
  38248. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  38249. m.predicates = append(m.predicates, ps...)
  38250. }
  38251. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  38252. // users can use type-assertion to append predicates that do not depend on any generated package.
  38253. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  38254. p := make([]predicate.WxCard, len(ps))
  38255. for i := range ps {
  38256. p[i] = ps[i]
  38257. }
  38258. m.Where(p...)
  38259. }
  38260. // Op returns the operation name.
  38261. func (m *WxCardMutation) Op() Op {
  38262. return m.op
  38263. }
  38264. // SetOp allows setting the mutation operation.
  38265. func (m *WxCardMutation) SetOp(op Op) {
  38266. m.op = op
  38267. }
  38268. // Type returns the node type of this mutation (WxCard).
  38269. func (m *WxCardMutation) Type() string {
  38270. return m.typ
  38271. }
  38272. // Fields returns all fields that were changed during this mutation. Note that in
  38273. // order to get all numeric fields that were incremented/decremented, call
  38274. // AddedFields().
  38275. func (m *WxCardMutation) Fields() []string {
  38276. fields := make([]string, 0, 18)
  38277. if m.created_at != nil {
  38278. fields = append(fields, wxcard.FieldCreatedAt)
  38279. }
  38280. if m.updated_at != nil {
  38281. fields = append(fields, wxcard.FieldUpdatedAt)
  38282. }
  38283. if m.deleted_at != nil {
  38284. fields = append(fields, wxcard.FieldDeletedAt)
  38285. }
  38286. if m.user_id != nil {
  38287. fields = append(fields, wxcard.FieldUserID)
  38288. }
  38289. if m.wx_user_id != nil {
  38290. fields = append(fields, wxcard.FieldWxUserID)
  38291. }
  38292. if m.avatar != nil {
  38293. fields = append(fields, wxcard.FieldAvatar)
  38294. }
  38295. if m.logo != nil {
  38296. fields = append(fields, wxcard.FieldLogo)
  38297. }
  38298. if m.name != nil {
  38299. fields = append(fields, wxcard.FieldName)
  38300. }
  38301. if m.company != nil {
  38302. fields = append(fields, wxcard.FieldCompany)
  38303. }
  38304. if m.address != nil {
  38305. fields = append(fields, wxcard.FieldAddress)
  38306. }
  38307. if m.phone != nil {
  38308. fields = append(fields, wxcard.FieldPhone)
  38309. }
  38310. if m.official_account != nil {
  38311. fields = append(fields, wxcard.FieldOfficialAccount)
  38312. }
  38313. if m.wechat_account != nil {
  38314. fields = append(fields, wxcard.FieldWechatAccount)
  38315. }
  38316. if m.email != nil {
  38317. fields = append(fields, wxcard.FieldEmail)
  38318. }
  38319. if m.api_base != nil {
  38320. fields = append(fields, wxcard.FieldAPIBase)
  38321. }
  38322. if m.api_key != nil {
  38323. fields = append(fields, wxcard.FieldAPIKey)
  38324. }
  38325. if m.ai_info != nil {
  38326. fields = append(fields, wxcard.FieldAiInfo)
  38327. }
  38328. if m.intro != nil {
  38329. fields = append(fields, wxcard.FieldIntro)
  38330. }
  38331. return fields
  38332. }
  38333. // Field returns the value of a field with the given name. The second boolean
  38334. // return value indicates that this field was not set, or was not defined in the
  38335. // schema.
  38336. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  38337. switch name {
  38338. case wxcard.FieldCreatedAt:
  38339. return m.CreatedAt()
  38340. case wxcard.FieldUpdatedAt:
  38341. return m.UpdatedAt()
  38342. case wxcard.FieldDeletedAt:
  38343. return m.DeletedAt()
  38344. case wxcard.FieldUserID:
  38345. return m.UserID()
  38346. case wxcard.FieldWxUserID:
  38347. return m.WxUserID()
  38348. case wxcard.FieldAvatar:
  38349. return m.Avatar()
  38350. case wxcard.FieldLogo:
  38351. return m.Logo()
  38352. case wxcard.FieldName:
  38353. return m.Name()
  38354. case wxcard.FieldCompany:
  38355. return m.Company()
  38356. case wxcard.FieldAddress:
  38357. return m.Address()
  38358. case wxcard.FieldPhone:
  38359. return m.Phone()
  38360. case wxcard.FieldOfficialAccount:
  38361. return m.OfficialAccount()
  38362. case wxcard.FieldWechatAccount:
  38363. return m.WechatAccount()
  38364. case wxcard.FieldEmail:
  38365. return m.Email()
  38366. case wxcard.FieldAPIBase:
  38367. return m.APIBase()
  38368. case wxcard.FieldAPIKey:
  38369. return m.APIKey()
  38370. case wxcard.FieldAiInfo:
  38371. return m.AiInfo()
  38372. case wxcard.FieldIntro:
  38373. return m.Intro()
  38374. }
  38375. return nil, false
  38376. }
  38377. // OldField returns the old value of the field from the database. An error is
  38378. // returned if the mutation operation is not UpdateOne, or the query to the
  38379. // database failed.
  38380. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38381. switch name {
  38382. case wxcard.FieldCreatedAt:
  38383. return m.OldCreatedAt(ctx)
  38384. case wxcard.FieldUpdatedAt:
  38385. return m.OldUpdatedAt(ctx)
  38386. case wxcard.FieldDeletedAt:
  38387. return m.OldDeletedAt(ctx)
  38388. case wxcard.FieldUserID:
  38389. return m.OldUserID(ctx)
  38390. case wxcard.FieldWxUserID:
  38391. return m.OldWxUserID(ctx)
  38392. case wxcard.FieldAvatar:
  38393. return m.OldAvatar(ctx)
  38394. case wxcard.FieldLogo:
  38395. return m.OldLogo(ctx)
  38396. case wxcard.FieldName:
  38397. return m.OldName(ctx)
  38398. case wxcard.FieldCompany:
  38399. return m.OldCompany(ctx)
  38400. case wxcard.FieldAddress:
  38401. return m.OldAddress(ctx)
  38402. case wxcard.FieldPhone:
  38403. return m.OldPhone(ctx)
  38404. case wxcard.FieldOfficialAccount:
  38405. return m.OldOfficialAccount(ctx)
  38406. case wxcard.FieldWechatAccount:
  38407. return m.OldWechatAccount(ctx)
  38408. case wxcard.FieldEmail:
  38409. return m.OldEmail(ctx)
  38410. case wxcard.FieldAPIBase:
  38411. return m.OldAPIBase(ctx)
  38412. case wxcard.FieldAPIKey:
  38413. return m.OldAPIKey(ctx)
  38414. case wxcard.FieldAiInfo:
  38415. return m.OldAiInfo(ctx)
  38416. case wxcard.FieldIntro:
  38417. return m.OldIntro(ctx)
  38418. }
  38419. return nil, fmt.Errorf("unknown WxCard field %s", name)
  38420. }
  38421. // SetField sets the value of a field with the given name. It returns an error if
  38422. // the field is not defined in the schema, or if the type mismatched the field
  38423. // type.
  38424. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  38425. switch name {
  38426. case wxcard.FieldCreatedAt:
  38427. v, ok := value.(time.Time)
  38428. if !ok {
  38429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38430. }
  38431. m.SetCreatedAt(v)
  38432. return nil
  38433. case wxcard.FieldUpdatedAt:
  38434. v, ok := value.(time.Time)
  38435. if !ok {
  38436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38437. }
  38438. m.SetUpdatedAt(v)
  38439. return nil
  38440. case wxcard.FieldDeletedAt:
  38441. v, ok := value.(time.Time)
  38442. if !ok {
  38443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38444. }
  38445. m.SetDeletedAt(v)
  38446. return nil
  38447. case wxcard.FieldUserID:
  38448. v, ok := value.(uint64)
  38449. if !ok {
  38450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38451. }
  38452. m.SetUserID(v)
  38453. return nil
  38454. case wxcard.FieldWxUserID:
  38455. v, ok := value.(uint64)
  38456. if !ok {
  38457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38458. }
  38459. m.SetWxUserID(v)
  38460. return nil
  38461. case wxcard.FieldAvatar:
  38462. v, ok := value.(string)
  38463. if !ok {
  38464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38465. }
  38466. m.SetAvatar(v)
  38467. return nil
  38468. case wxcard.FieldLogo:
  38469. v, ok := value.(string)
  38470. if !ok {
  38471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38472. }
  38473. m.SetLogo(v)
  38474. return nil
  38475. case wxcard.FieldName:
  38476. v, ok := value.(string)
  38477. if !ok {
  38478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38479. }
  38480. m.SetName(v)
  38481. return nil
  38482. case wxcard.FieldCompany:
  38483. v, ok := value.(string)
  38484. if !ok {
  38485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38486. }
  38487. m.SetCompany(v)
  38488. return nil
  38489. case wxcard.FieldAddress:
  38490. v, ok := value.(string)
  38491. if !ok {
  38492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38493. }
  38494. m.SetAddress(v)
  38495. return nil
  38496. case wxcard.FieldPhone:
  38497. v, ok := value.(string)
  38498. if !ok {
  38499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38500. }
  38501. m.SetPhone(v)
  38502. return nil
  38503. case wxcard.FieldOfficialAccount:
  38504. v, ok := value.(string)
  38505. if !ok {
  38506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38507. }
  38508. m.SetOfficialAccount(v)
  38509. return nil
  38510. case wxcard.FieldWechatAccount:
  38511. v, ok := value.(string)
  38512. if !ok {
  38513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38514. }
  38515. m.SetWechatAccount(v)
  38516. return nil
  38517. case wxcard.FieldEmail:
  38518. v, ok := value.(string)
  38519. if !ok {
  38520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38521. }
  38522. m.SetEmail(v)
  38523. return nil
  38524. case wxcard.FieldAPIBase:
  38525. v, ok := value.(string)
  38526. if !ok {
  38527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38528. }
  38529. m.SetAPIBase(v)
  38530. return nil
  38531. case wxcard.FieldAPIKey:
  38532. v, ok := value.(string)
  38533. if !ok {
  38534. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38535. }
  38536. m.SetAPIKey(v)
  38537. return nil
  38538. case wxcard.FieldAiInfo:
  38539. v, ok := value.(string)
  38540. if !ok {
  38541. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38542. }
  38543. m.SetAiInfo(v)
  38544. return nil
  38545. case wxcard.FieldIntro:
  38546. v, ok := value.(string)
  38547. if !ok {
  38548. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38549. }
  38550. m.SetIntro(v)
  38551. return nil
  38552. }
  38553. return fmt.Errorf("unknown WxCard field %s", name)
  38554. }
  38555. // AddedFields returns all numeric fields that were incremented/decremented during
  38556. // this mutation.
  38557. func (m *WxCardMutation) AddedFields() []string {
  38558. var fields []string
  38559. if m.adduser_id != nil {
  38560. fields = append(fields, wxcard.FieldUserID)
  38561. }
  38562. if m.addwx_user_id != nil {
  38563. fields = append(fields, wxcard.FieldWxUserID)
  38564. }
  38565. return fields
  38566. }
  38567. // AddedField returns the numeric value that was incremented/decremented on a field
  38568. // with the given name. The second boolean return value indicates that this field
  38569. // was not set, or was not defined in the schema.
  38570. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  38571. switch name {
  38572. case wxcard.FieldUserID:
  38573. return m.AddedUserID()
  38574. case wxcard.FieldWxUserID:
  38575. return m.AddedWxUserID()
  38576. }
  38577. return nil, false
  38578. }
  38579. // AddField adds the value to the field with the given name. It returns an error if
  38580. // the field is not defined in the schema, or if the type mismatched the field
  38581. // type.
  38582. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  38583. switch name {
  38584. case wxcard.FieldUserID:
  38585. v, ok := value.(int64)
  38586. if !ok {
  38587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38588. }
  38589. m.AddUserID(v)
  38590. return nil
  38591. case wxcard.FieldWxUserID:
  38592. v, ok := value.(int64)
  38593. if !ok {
  38594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38595. }
  38596. m.AddWxUserID(v)
  38597. return nil
  38598. }
  38599. return fmt.Errorf("unknown WxCard numeric field %s", name)
  38600. }
  38601. // ClearedFields returns all nullable fields that were cleared during this
  38602. // mutation.
  38603. func (m *WxCardMutation) ClearedFields() []string {
  38604. var fields []string
  38605. if m.FieldCleared(wxcard.FieldDeletedAt) {
  38606. fields = append(fields, wxcard.FieldDeletedAt)
  38607. }
  38608. if m.FieldCleared(wxcard.FieldUserID) {
  38609. fields = append(fields, wxcard.FieldUserID)
  38610. }
  38611. if m.FieldCleared(wxcard.FieldWxUserID) {
  38612. fields = append(fields, wxcard.FieldWxUserID)
  38613. }
  38614. if m.FieldCleared(wxcard.FieldEmail) {
  38615. fields = append(fields, wxcard.FieldEmail)
  38616. }
  38617. if m.FieldCleared(wxcard.FieldAPIBase) {
  38618. fields = append(fields, wxcard.FieldAPIBase)
  38619. }
  38620. if m.FieldCleared(wxcard.FieldAPIKey) {
  38621. fields = append(fields, wxcard.FieldAPIKey)
  38622. }
  38623. if m.FieldCleared(wxcard.FieldAiInfo) {
  38624. fields = append(fields, wxcard.FieldAiInfo)
  38625. }
  38626. if m.FieldCleared(wxcard.FieldIntro) {
  38627. fields = append(fields, wxcard.FieldIntro)
  38628. }
  38629. return fields
  38630. }
  38631. // FieldCleared returns a boolean indicating if a field with the given name was
  38632. // cleared in this mutation.
  38633. func (m *WxCardMutation) FieldCleared(name string) bool {
  38634. _, ok := m.clearedFields[name]
  38635. return ok
  38636. }
  38637. // ClearField clears the value of the field with the given name. It returns an
  38638. // error if the field is not defined in the schema.
  38639. func (m *WxCardMutation) ClearField(name string) error {
  38640. switch name {
  38641. case wxcard.FieldDeletedAt:
  38642. m.ClearDeletedAt()
  38643. return nil
  38644. case wxcard.FieldUserID:
  38645. m.ClearUserID()
  38646. return nil
  38647. case wxcard.FieldWxUserID:
  38648. m.ClearWxUserID()
  38649. return nil
  38650. case wxcard.FieldEmail:
  38651. m.ClearEmail()
  38652. return nil
  38653. case wxcard.FieldAPIBase:
  38654. m.ClearAPIBase()
  38655. return nil
  38656. case wxcard.FieldAPIKey:
  38657. m.ClearAPIKey()
  38658. return nil
  38659. case wxcard.FieldAiInfo:
  38660. m.ClearAiInfo()
  38661. return nil
  38662. case wxcard.FieldIntro:
  38663. m.ClearIntro()
  38664. return nil
  38665. }
  38666. return fmt.Errorf("unknown WxCard nullable field %s", name)
  38667. }
  38668. // ResetField resets all changes in the mutation for the field with the given name.
  38669. // It returns an error if the field is not defined in the schema.
  38670. func (m *WxCardMutation) ResetField(name string) error {
  38671. switch name {
  38672. case wxcard.FieldCreatedAt:
  38673. m.ResetCreatedAt()
  38674. return nil
  38675. case wxcard.FieldUpdatedAt:
  38676. m.ResetUpdatedAt()
  38677. return nil
  38678. case wxcard.FieldDeletedAt:
  38679. m.ResetDeletedAt()
  38680. return nil
  38681. case wxcard.FieldUserID:
  38682. m.ResetUserID()
  38683. return nil
  38684. case wxcard.FieldWxUserID:
  38685. m.ResetWxUserID()
  38686. return nil
  38687. case wxcard.FieldAvatar:
  38688. m.ResetAvatar()
  38689. return nil
  38690. case wxcard.FieldLogo:
  38691. m.ResetLogo()
  38692. return nil
  38693. case wxcard.FieldName:
  38694. m.ResetName()
  38695. return nil
  38696. case wxcard.FieldCompany:
  38697. m.ResetCompany()
  38698. return nil
  38699. case wxcard.FieldAddress:
  38700. m.ResetAddress()
  38701. return nil
  38702. case wxcard.FieldPhone:
  38703. m.ResetPhone()
  38704. return nil
  38705. case wxcard.FieldOfficialAccount:
  38706. m.ResetOfficialAccount()
  38707. return nil
  38708. case wxcard.FieldWechatAccount:
  38709. m.ResetWechatAccount()
  38710. return nil
  38711. case wxcard.FieldEmail:
  38712. m.ResetEmail()
  38713. return nil
  38714. case wxcard.FieldAPIBase:
  38715. m.ResetAPIBase()
  38716. return nil
  38717. case wxcard.FieldAPIKey:
  38718. m.ResetAPIKey()
  38719. return nil
  38720. case wxcard.FieldAiInfo:
  38721. m.ResetAiInfo()
  38722. return nil
  38723. case wxcard.FieldIntro:
  38724. m.ResetIntro()
  38725. return nil
  38726. }
  38727. return fmt.Errorf("unknown WxCard field %s", name)
  38728. }
  38729. // AddedEdges returns all edge names that were set/added in this mutation.
  38730. func (m *WxCardMutation) AddedEdges() []string {
  38731. edges := make([]string, 0, 0)
  38732. return edges
  38733. }
  38734. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38735. // name in this mutation.
  38736. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  38737. return nil
  38738. }
  38739. // RemovedEdges returns all edge names that were removed in this mutation.
  38740. func (m *WxCardMutation) RemovedEdges() []string {
  38741. edges := make([]string, 0, 0)
  38742. return edges
  38743. }
  38744. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38745. // the given name in this mutation.
  38746. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  38747. return nil
  38748. }
  38749. // ClearedEdges returns all edge names that were cleared in this mutation.
  38750. func (m *WxCardMutation) ClearedEdges() []string {
  38751. edges := make([]string, 0, 0)
  38752. return edges
  38753. }
  38754. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38755. // was cleared in this mutation.
  38756. func (m *WxCardMutation) EdgeCleared(name string) bool {
  38757. return false
  38758. }
  38759. // ClearEdge clears the value of the edge with the given name. It returns an error
  38760. // if that edge is not defined in the schema.
  38761. func (m *WxCardMutation) ClearEdge(name string) error {
  38762. return fmt.Errorf("unknown WxCard unique edge %s", name)
  38763. }
  38764. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38765. // It returns an error if the edge is not defined in the schema.
  38766. func (m *WxCardMutation) ResetEdge(name string) error {
  38767. return fmt.Errorf("unknown WxCard edge %s", name)
  38768. }
  38769. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  38770. type WxCardUserMutation struct {
  38771. config
  38772. op Op
  38773. typ string
  38774. id *uint64
  38775. created_at *time.Time
  38776. updated_at *time.Time
  38777. deleted_at *time.Time
  38778. wxid *string
  38779. account *string
  38780. avatar *string
  38781. nickname *string
  38782. remark *string
  38783. phone *string
  38784. open_id *string
  38785. union_id *string
  38786. session_key *string
  38787. is_vip *int
  38788. addis_vip *int
  38789. clearedFields map[string]struct{}
  38790. done bool
  38791. oldValue func(context.Context) (*WxCardUser, error)
  38792. predicates []predicate.WxCardUser
  38793. }
  38794. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  38795. // wxcarduserOption allows management of the mutation configuration using functional options.
  38796. type wxcarduserOption func(*WxCardUserMutation)
  38797. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  38798. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  38799. m := &WxCardUserMutation{
  38800. config: c,
  38801. op: op,
  38802. typ: TypeWxCardUser,
  38803. clearedFields: make(map[string]struct{}),
  38804. }
  38805. for _, opt := range opts {
  38806. opt(m)
  38807. }
  38808. return m
  38809. }
  38810. // withWxCardUserID sets the ID field of the mutation.
  38811. func withWxCardUserID(id uint64) wxcarduserOption {
  38812. return func(m *WxCardUserMutation) {
  38813. var (
  38814. err error
  38815. once sync.Once
  38816. value *WxCardUser
  38817. )
  38818. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  38819. once.Do(func() {
  38820. if m.done {
  38821. err = errors.New("querying old values post mutation is not allowed")
  38822. } else {
  38823. value, err = m.Client().WxCardUser.Get(ctx, id)
  38824. }
  38825. })
  38826. return value, err
  38827. }
  38828. m.id = &id
  38829. }
  38830. }
  38831. // withWxCardUser sets the old WxCardUser of the mutation.
  38832. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  38833. return func(m *WxCardUserMutation) {
  38834. m.oldValue = func(context.Context) (*WxCardUser, error) {
  38835. return node, nil
  38836. }
  38837. m.id = &node.ID
  38838. }
  38839. }
  38840. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38841. // executed in a transaction (ent.Tx), a transactional client is returned.
  38842. func (m WxCardUserMutation) Client() *Client {
  38843. client := &Client{config: m.config}
  38844. client.init()
  38845. return client
  38846. }
  38847. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38848. // it returns an error otherwise.
  38849. func (m WxCardUserMutation) Tx() (*Tx, error) {
  38850. if _, ok := m.driver.(*txDriver); !ok {
  38851. return nil, errors.New("ent: mutation is not running in a transaction")
  38852. }
  38853. tx := &Tx{config: m.config}
  38854. tx.init()
  38855. return tx, nil
  38856. }
  38857. // SetID sets the value of the id field. Note that this
  38858. // operation is only accepted on creation of WxCardUser entities.
  38859. func (m *WxCardUserMutation) SetID(id uint64) {
  38860. m.id = &id
  38861. }
  38862. // ID returns the ID value in the mutation. Note that the ID is only available
  38863. // if it was provided to the builder or after it was returned from the database.
  38864. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  38865. if m.id == nil {
  38866. return
  38867. }
  38868. return *m.id, true
  38869. }
  38870. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38871. // That means, if the mutation is applied within a transaction with an isolation level such
  38872. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38873. // or updated by the mutation.
  38874. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  38875. switch {
  38876. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38877. id, exists := m.ID()
  38878. if exists {
  38879. return []uint64{id}, nil
  38880. }
  38881. fallthrough
  38882. case m.op.Is(OpUpdate | OpDelete):
  38883. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  38884. default:
  38885. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38886. }
  38887. }
  38888. // SetCreatedAt sets the "created_at" field.
  38889. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  38890. m.created_at = &t
  38891. }
  38892. // CreatedAt returns the value of the "created_at" field in the mutation.
  38893. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  38894. v := m.created_at
  38895. if v == nil {
  38896. return
  38897. }
  38898. return *v, true
  38899. }
  38900. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  38901. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  38902. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38903. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38904. if !m.op.Is(OpUpdateOne) {
  38905. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38906. }
  38907. if m.id == nil || m.oldValue == nil {
  38908. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38909. }
  38910. oldValue, err := m.oldValue(ctx)
  38911. if err != nil {
  38912. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38913. }
  38914. return oldValue.CreatedAt, nil
  38915. }
  38916. // ResetCreatedAt resets all changes to the "created_at" field.
  38917. func (m *WxCardUserMutation) ResetCreatedAt() {
  38918. m.created_at = nil
  38919. }
  38920. // SetUpdatedAt sets the "updated_at" field.
  38921. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  38922. m.updated_at = &t
  38923. }
  38924. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38925. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  38926. v := m.updated_at
  38927. if v == nil {
  38928. return
  38929. }
  38930. return *v, true
  38931. }
  38932. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  38933. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  38934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38935. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38936. if !m.op.Is(OpUpdateOne) {
  38937. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38938. }
  38939. if m.id == nil || m.oldValue == nil {
  38940. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38941. }
  38942. oldValue, err := m.oldValue(ctx)
  38943. if err != nil {
  38944. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38945. }
  38946. return oldValue.UpdatedAt, nil
  38947. }
  38948. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38949. func (m *WxCardUserMutation) ResetUpdatedAt() {
  38950. m.updated_at = nil
  38951. }
  38952. // SetDeletedAt sets the "deleted_at" field.
  38953. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  38954. m.deleted_at = &t
  38955. }
  38956. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  38957. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  38958. v := m.deleted_at
  38959. if v == nil {
  38960. return
  38961. }
  38962. return *v, true
  38963. }
  38964. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  38965. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  38966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38967. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  38968. if !m.op.Is(OpUpdateOne) {
  38969. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  38970. }
  38971. if m.id == nil || m.oldValue == nil {
  38972. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  38973. }
  38974. oldValue, err := m.oldValue(ctx)
  38975. if err != nil {
  38976. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  38977. }
  38978. return oldValue.DeletedAt, nil
  38979. }
  38980. // ClearDeletedAt clears the value of the "deleted_at" field.
  38981. func (m *WxCardUserMutation) ClearDeletedAt() {
  38982. m.deleted_at = nil
  38983. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  38984. }
  38985. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  38986. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  38987. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  38988. return ok
  38989. }
  38990. // ResetDeletedAt resets all changes to the "deleted_at" field.
  38991. func (m *WxCardUserMutation) ResetDeletedAt() {
  38992. m.deleted_at = nil
  38993. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  38994. }
  38995. // SetWxid sets the "wxid" field.
  38996. func (m *WxCardUserMutation) SetWxid(s string) {
  38997. m.wxid = &s
  38998. }
  38999. // Wxid returns the value of the "wxid" field in the mutation.
  39000. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  39001. v := m.wxid
  39002. if v == nil {
  39003. return
  39004. }
  39005. return *v, true
  39006. }
  39007. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  39008. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  39009. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39010. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  39011. if !m.op.Is(OpUpdateOne) {
  39012. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  39013. }
  39014. if m.id == nil || m.oldValue == nil {
  39015. return v, errors.New("OldWxid requires an ID field in the mutation")
  39016. }
  39017. oldValue, err := m.oldValue(ctx)
  39018. if err != nil {
  39019. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  39020. }
  39021. return oldValue.Wxid, nil
  39022. }
  39023. // ResetWxid resets all changes to the "wxid" field.
  39024. func (m *WxCardUserMutation) ResetWxid() {
  39025. m.wxid = nil
  39026. }
  39027. // SetAccount sets the "account" field.
  39028. func (m *WxCardUserMutation) SetAccount(s string) {
  39029. m.account = &s
  39030. }
  39031. // Account returns the value of the "account" field in the mutation.
  39032. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  39033. v := m.account
  39034. if v == nil {
  39035. return
  39036. }
  39037. return *v, true
  39038. }
  39039. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  39040. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  39041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39042. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  39043. if !m.op.Is(OpUpdateOne) {
  39044. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  39045. }
  39046. if m.id == nil || m.oldValue == nil {
  39047. return v, errors.New("OldAccount requires an ID field in the mutation")
  39048. }
  39049. oldValue, err := m.oldValue(ctx)
  39050. if err != nil {
  39051. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  39052. }
  39053. return oldValue.Account, nil
  39054. }
  39055. // ResetAccount resets all changes to the "account" field.
  39056. func (m *WxCardUserMutation) ResetAccount() {
  39057. m.account = nil
  39058. }
  39059. // SetAvatar sets the "avatar" field.
  39060. func (m *WxCardUserMutation) SetAvatar(s string) {
  39061. m.avatar = &s
  39062. }
  39063. // Avatar returns the value of the "avatar" field in the mutation.
  39064. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  39065. v := m.avatar
  39066. if v == nil {
  39067. return
  39068. }
  39069. return *v, true
  39070. }
  39071. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  39072. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  39073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39074. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  39075. if !m.op.Is(OpUpdateOne) {
  39076. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  39077. }
  39078. if m.id == nil || m.oldValue == nil {
  39079. return v, errors.New("OldAvatar requires an ID field in the mutation")
  39080. }
  39081. oldValue, err := m.oldValue(ctx)
  39082. if err != nil {
  39083. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  39084. }
  39085. return oldValue.Avatar, nil
  39086. }
  39087. // ResetAvatar resets all changes to the "avatar" field.
  39088. func (m *WxCardUserMutation) ResetAvatar() {
  39089. m.avatar = nil
  39090. }
  39091. // SetNickname sets the "nickname" field.
  39092. func (m *WxCardUserMutation) SetNickname(s string) {
  39093. m.nickname = &s
  39094. }
  39095. // Nickname returns the value of the "nickname" field in the mutation.
  39096. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  39097. v := m.nickname
  39098. if v == nil {
  39099. return
  39100. }
  39101. return *v, true
  39102. }
  39103. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  39104. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  39105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39106. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  39107. if !m.op.Is(OpUpdateOne) {
  39108. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  39109. }
  39110. if m.id == nil || m.oldValue == nil {
  39111. return v, errors.New("OldNickname requires an ID field in the mutation")
  39112. }
  39113. oldValue, err := m.oldValue(ctx)
  39114. if err != nil {
  39115. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  39116. }
  39117. return oldValue.Nickname, nil
  39118. }
  39119. // ResetNickname resets all changes to the "nickname" field.
  39120. func (m *WxCardUserMutation) ResetNickname() {
  39121. m.nickname = nil
  39122. }
  39123. // SetRemark sets the "remark" field.
  39124. func (m *WxCardUserMutation) SetRemark(s string) {
  39125. m.remark = &s
  39126. }
  39127. // Remark returns the value of the "remark" field in the mutation.
  39128. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  39129. v := m.remark
  39130. if v == nil {
  39131. return
  39132. }
  39133. return *v, true
  39134. }
  39135. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  39136. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  39137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39138. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  39139. if !m.op.Is(OpUpdateOne) {
  39140. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  39141. }
  39142. if m.id == nil || m.oldValue == nil {
  39143. return v, errors.New("OldRemark requires an ID field in the mutation")
  39144. }
  39145. oldValue, err := m.oldValue(ctx)
  39146. if err != nil {
  39147. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  39148. }
  39149. return oldValue.Remark, nil
  39150. }
  39151. // ResetRemark resets all changes to the "remark" field.
  39152. func (m *WxCardUserMutation) ResetRemark() {
  39153. m.remark = nil
  39154. }
  39155. // SetPhone sets the "phone" field.
  39156. func (m *WxCardUserMutation) SetPhone(s string) {
  39157. m.phone = &s
  39158. }
  39159. // Phone returns the value of the "phone" field in the mutation.
  39160. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  39161. v := m.phone
  39162. if v == nil {
  39163. return
  39164. }
  39165. return *v, true
  39166. }
  39167. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  39168. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  39169. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39170. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  39171. if !m.op.Is(OpUpdateOne) {
  39172. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  39173. }
  39174. if m.id == nil || m.oldValue == nil {
  39175. return v, errors.New("OldPhone requires an ID field in the mutation")
  39176. }
  39177. oldValue, err := m.oldValue(ctx)
  39178. if err != nil {
  39179. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  39180. }
  39181. return oldValue.Phone, nil
  39182. }
  39183. // ResetPhone resets all changes to the "phone" field.
  39184. func (m *WxCardUserMutation) ResetPhone() {
  39185. m.phone = nil
  39186. }
  39187. // SetOpenID sets the "open_id" field.
  39188. func (m *WxCardUserMutation) SetOpenID(s string) {
  39189. m.open_id = &s
  39190. }
  39191. // OpenID returns the value of the "open_id" field in the mutation.
  39192. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  39193. v := m.open_id
  39194. if v == nil {
  39195. return
  39196. }
  39197. return *v, true
  39198. }
  39199. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  39200. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  39201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39202. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  39203. if !m.op.Is(OpUpdateOne) {
  39204. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  39205. }
  39206. if m.id == nil || m.oldValue == nil {
  39207. return v, errors.New("OldOpenID requires an ID field in the mutation")
  39208. }
  39209. oldValue, err := m.oldValue(ctx)
  39210. if err != nil {
  39211. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  39212. }
  39213. return oldValue.OpenID, nil
  39214. }
  39215. // ResetOpenID resets all changes to the "open_id" field.
  39216. func (m *WxCardUserMutation) ResetOpenID() {
  39217. m.open_id = nil
  39218. }
  39219. // SetUnionID sets the "union_id" field.
  39220. func (m *WxCardUserMutation) SetUnionID(s string) {
  39221. m.union_id = &s
  39222. }
  39223. // UnionID returns the value of the "union_id" field in the mutation.
  39224. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  39225. v := m.union_id
  39226. if v == nil {
  39227. return
  39228. }
  39229. return *v, true
  39230. }
  39231. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  39232. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  39233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39234. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  39235. if !m.op.Is(OpUpdateOne) {
  39236. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  39237. }
  39238. if m.id == nil || m.oldValue == nil {
  39239. return v, errors.New("OldUnionID requires an ID field in the mutation")
  39240. }
  39241. oldValue, err := m.oldValue(ctx)
  39242. if err != nil {
  39243. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  39244. }
  39245. return oldValue.UnionID, nil
  39246. }
  39247. // ResetUnionID resets all changes to the "union_id" field.
  39248. func (m *WxCardUserMutation) ResetUnionID() {
  39249. m.union_id = nil
  39250. }
  39251. // SetSessionKey sets the "session_key" field.
  39252. func (m *WxCardUserMutation) SetSessionKey(s string) {
  39253. m.session_key = &s
  39254. }
  39255. // SessionKey returns the value of the "session_key" field in the mutation.
  39256. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  39257. v := m.session_key
  39258. if v == nil {
  39259. return
  39260. }
  39261. return *v, true
  39262. }
  39263. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  39264. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  39265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39266. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  39267. if !m.op.Is(OpUpdateOne) {
  39268. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  39269. }
  39270. if m.id == nil || m.oldValue == nil {
  39271. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  39272. }
  39273. oldValue, err := m.oldValue(ctx)
  39274. if err != nil {
  39275. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  39276. }
  39277. return oldValue.SessionKey, nil
  39278. }
  39279. // ResetSessionKey resets all changes to the "session_key" field.
  39280. func (m *WxCardUserMutation) ResetSessionKey() {
  39281. m.session_key = nil
  39282. }
  39283. // SetIsVip sets the "is_vip" field.
  39284. func (m *WxCardUserMutation) SetIsVip(i int) {
  39285. m.is_vip = &i
  39286. m.addis_vip = nil
  39287. }
  39288. // IsVip returns the value of the "is_vip" field in the mutation.
  39289. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  39290. v := m.is_vip
  39291. if v == nil {
  39292. return
  39293. }
  39294. return *v, true
  39295. }
  39296. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  39297. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  39298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39299. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  39300. if !m.op.Is(OpUpdateOne) {
  39301. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  39302. }
  39303. if m.id == nil || m.oldValue == nil {
  39304. return v, errors.New("OldIsVip requires an ID field in the mutation")
  39305. }
  39306. oldValue, err := m.oldValue(ctx)
  39307. if err != nil {
  39308. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  39309. }
  39310. return oldValue.IsVip, nil
  39311. }
  39312. // AddIsVip adds i to the "is_vip" field.
  39313. func (m *WxCardUserMutation) AddIsVip(i int) {
  39314. if m.addis_vip != nil {
  39315. *m.addis_vip += i
  39316. } else {
  39317. m.addis_vip = &i
  39318. }
  39319. }
  39320. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  39321. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  39322. v := m.addis_vip
  39323. if v == nil {
  39324. return
  39325. }
  39326. return *v, true
  39327. }
  39328. // ResetIsVip resets all changes to the "is_vip" field.
  39329. func (m *WxCardUserMutation) ResetIsVip() {
  39330. m.is_vip = nil
  39331. m.addis_vip = nil
  39332. }
  39333. // Where appends a list predicates to the WxCardUserMutation builder.
  39334. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  39335. m.predicates = append(m.predicates, ps...)
  39336. }
  39337. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  39338. // users can use type-assertion to append predicates that do not depend on any generated package.
  39339. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  39340. p := make([]predicate.WxCardUser, len(ps))
  39341. for i := range ps {
  39342. p[i] = ps[i]
  39343. }
  39344. m.Where(p...)
  39345. }
  39346. // Op returns the operation name.
  39347. func (m *WxCardUserMutation) Op() Op {
  39348. return m.op
  39349. }
  39350. // SetOp allows setting the mutation operation.
  39351. func (m *WxCardUserMutation) SetOp(op Op) {
  39352. m.op = op
  39353. }
  39354. // Type returns the node type of this mutation (WxCardUser).
  39355. func (m *WxCardUserMutation) Type() string {
  39356. return m.typ
  39357. }
  39358. // Fields returns all fields that were changed during this mutation. Note that in
  39359. // order to get all numeric fields that were incremented/decremented, call
  39360. // AddedFields().
  39361. func (m *WxCardUserMutation) Fields() []string {
  39362. fields := make([]string, 0, 13)
  39363. if m.created_at != nil {
  39364. fields = append(fields, wxcarduser.FieldCreatedAt)
  39365. }
  39366. if m.updated_at != nil {
  39367. fields = append(fields, wxcarduser.FieldUpdatedAt)
  39368. }
  39369. if m.deleted_at != nil {
  39370. fields = append(fields, wxcarduser.FieldDeletedAt)
  39371. }
  39372. if m.wxid != nil {
  39373. fields = append(fields, wxcarduser.FieldWxid)
  39374. }
  39375. if m.account != nil {
  39376. fields = append(fields, wxcarduser.FieldAccount)
  39377. }
  39378. if m.avatar != nil {
  39379. fields = append(fields, wxcarduser.FieldAvatar)
  39380. }
  39381. if m.nickname != nil {
  39382. fields = append(fields, wxcarduser.FieldNickname)
  39383. }
  39384. if m.remark != nil {
  39385. fields = append(fields, wxcarduser.FieldRemark)
  39386. }
  39387. if m.phone != nil {
  39388. fields = append(fields, wxcarduser.FieldPhone)
  39389. }
  39390. if m.open_id != nil {
  39391. fields = append(fields, wxcarduser.FieldOpenID)
  39392. }
  39393. if m.union_id != nil {
  39394. fields = append(fields, wxcarduser.FieldUnionID)
  39395. }
  39396. if m.session_key != nil {
  39397. fields = append(fields, wxcarduser.FieldSessionKey)
  39398. }
  39399. if m.is_vip != nil {
  39400. fields = append(fields, wxcarduser.FieldIsVip)
  39401. }
  39402. return fields
  39403. }
  39404. // Field returns the value of a field with the given name. The second boolean
  39405. // return value indicates that this field was not set, or was not defined in the
  39406. // schema.
  39407. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  39408. switch name {
  39409. case wxcarduser.FieldCreatedAt:
  39410. return m.CreatedAt()
  39411. case wxcarduser.FieldUpdatedAt:
  39412. return m.UpdatedAt()
  39413. case wxcarduser.FieldDeletedAt:
  39414. return m.DeletedAt()
  39415. case wxcarduser.FieldWxid:
  39416. return m.Wxid()
  39417. case wxcarduser.FieldAccount:
  39418. return m.Account()
  39419. case wxcarduser.FieldAvatar:
  39420. return m.Avatar()
  39421. case wxcarduser.FieldNickname:
  39422. return m.Nickname()
  39423. case wxcarduser.FieldRemark:
  39424. return m.Remark()
  39425. case wxcarduser.FieldPhone:
  39426. return m.Phone()
  39427. case wxcarduser.FieldOpenID:
  39428. return m.OpenID()
  39429. case wxcarduser.FieldUnionID:
  39430. return m.UnionID()
  39431. case wxcarduser.FieldSessionKey:
  39432. return m.SessionKey()
  39433. case wxcarduser.FieldIsVip:
  39434. return m.IsVip()
  39435. }
  39436. return nil, false
  39437. }
  39438. // OldField returns the old value of the field from the database. An error is
  39439. // returned if the mutation operation is not UpdateOne, or the query to the
  39440. // database failed.
  39441. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39442. switch name {
  39443. case wxcarduser.FieldCreatedAt:
  39444. return m.OldCreatedAt(ctx)
  39445. case wxcarduser.FieldUpdatedAt:
  39446. return m.OldUpdatedAt(ctx)
  39447. case wxcarduser.FieldDeletedAt:
  39448. return m.OldDeletedAt(ctx)
  39449. case wxcarduser.FieldWxid:
  39450. return m.OldWxid(ctx)
  39451. case wxcarduser.FieldAccount:
  39452. return m.OldAccount(ctx)
  39453. case wxcarduser.FieldAvatar:
  39454. return m.OldAvatar(ctx)
  39455. case wxcarduser.FieldNickname:
  39456. return m.OldNickname(ctx)
  39457. case wxcarduser.FieldRemark:
  39458. return m.OldRemark(ctx)
  39459. case wxcarduser.FieldPhone:
  39460. return m.OldPhone(ctx)
  39461. case wxcarduser.FieldOpenID:
  39462. return m.OldOpenID(ctx)
  39463. case wxcarduser.FieldUnionID:
  39464. return m.OldUnionID(ctx)
  39465. case wxcarduser.FieldSessionKey:
  39466. return m.OldSessionKey(ctx)
  39467. case wxcarduser.FieldIsVip:
  39468. return m.OldIsVip(ctx)
  39469. }
  39470. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  39471. }
  39472. // SetField sets the value of a field with the given name. It returns an error if
  39473. // the field is not defined in the schema, or if the type mismatched the field
  39474. // type.
  39475. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  39476. switch name {
  39477. case wxcarduser.FieldCreatedAt:
  39478. v, ok := value.(time.Time)
  39479. if !ok {
  39480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39481. }
  39482. m.SetCreatedAt(v)
  39483. return nil
  39484. case wxcarduser.FieldUpdatedAt:
  39485. v, ok := value.(time.Time)
  39486. if !ok {
  39487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39488. }
  39489. m.SetUpdatedAt(v)
  39490. return nil
  39491. case wxcarduser.FieldDeletedAt:
  39492. v, ok := value.(time.Time)
  39493. if !ok {
  39494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39495. }
  39496. m.SetDeletedAt(v)
  39497. return nil
  39498. case wxcarduser.FieldWxid:
  39499. v, ok := value.(string)
  39500. if !ok {
  39501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39502. }
  39503. m.SetWxid(v)
  39504. return nil
  39505. case wxcarduser.FieldAccount:
  39506. v, ok := value.(string)
  39507. if !ok {
  39508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39509. }
  39510. m.SetAccount(v)
  39511. return nil
  39512. case wxcarduser.FieldAvatar:
  39513. v, ok := value.(string)
  39514. if !ok {
  39515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39516. }
  39517. m.SetAvatar(v)
  39518. return nil
  39519. case wxcarduser.FieldNickname:
  39520. v, ok := value.(string)
  39521. if !ok {
  39522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39523. }
  39524. m.SetNickname(v)
  39525. return nil
  39526. case wxcarduser.FieldRemark:
  39527. v, ok := value.(string)
  39528. if !ok {
  39529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39530. }
  39531. m.SetRemark(v)
  39532. return nil
  39533. case wxcarduser.FieldPhone:
  39534. v, ok := value.(string)
  39535. if !ok {
  39536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39537. }
  39538. m.SetPhone(v)
  39539. return nil
  39540. case wxcarduser.FieldOpenID:
  39541. v, ok := value.(string)
  39542. if !ok {
  39543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39544. }
  39545. m.SetOpenID(v)
  39546. return nil
  39547. case wxcarduser.FieldUnionID:
  39548. v, ok := value.(string)
  39549. if !ok {
  39550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39551. }
  39552. m.SetUnionID(v)
  39553. return nil
  39554. case wxcarduser.FieldSessionKey:
  39555. v, ok := value.(string)
  39556. if !ok {
  39557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39558. }
  39559. m.SetSessionKey(v)
  39560. return nil
  39561. case wxcarduser.FieldIsVip:
  39562. v, ok := value.(int)
  39563. if !ok {
  39564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39565. }
  39566. m.SetIsVip(v)
  39567. return nil
  39568. }
  39569. return fmt.Errorf("unknown WxCardUser field %s", name)
  39570. }
  39571. // AddedFields returns all numeric fields that were incremented/decremented during
  39572. // this mutation.
  39573. func (m *WxCardUserMutation) AddedFields() []string {
  39574. var fields []string
  39575. if m.addis_vip != nil {
  39576. fields = append(fields, wxcarduser.FieldIsVip)
  39577. }
  39578. return fields
  39579. }
  39580. // AddedField returns the numeric value that was incremented/decremented on a field
  39581. // with the given name. The second boolean return value indicates that this field
  39582. // was not set, or was not defined in the schema.
  39583. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  39584. switch name {
  39585. case wxcarduser.FieldIsVip:
  39586. return m.AddedIsVip()
  39587. }
  39588. return nil, false
  39589. }
  39590. // AddField adds the value to the field with the given name. It returns an error if
  39591. // the field is not defined in the schema, or if the type mismatched the field
  39592. // type.
  39593. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  39594. switch name {
  39595. case wxcarduser.FieldIsVip:
  39596. v, ok := value.(int)
  39597. if !ok {
  39598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39599. }
  39600. m.AddIsVip(v)
  39601. return nil
  39602. }
  39603. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  39604. }
  39605. // ClearedFields returns all nullable fields that were cleared during this
  39606. // mutation.
  39607. func (m *WxCardUserMutation) ClearedFields() []string {
  39608. var fields []string
  39609. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  39610. fields = append(fields, wxcarduser.FieldDeletedAt)
  39611. }
  39612. return fields
  39613. }
  39614. // FieldCleared returns a boolean indicating if a field with the given name was
  39615. // cleared in this mutation.
  39616. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  39617. _, ok := m.clearedFields[name]
  39618. return ok
  39619. }
  39620. // ClearField clears the value of the field with the given name. It returns an
  39621. // error if the field is not defined in the schema.
  39622. func (m *WxCardUserMutation) ClearField(name string) error {
  39623. switch name {
  39624. case wxcarduser.FieldDeletedAt:
  39625. m.ClearDeletedAt()
  39626. return nil
  39627. }
  39628. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  39629. }
  39630. // ResetField resets all changes in the mutation for the field with the given name.
  39631. // It returns an error if the field is not defined in the schema.
  39632. func (m *WxCardUserMutation) ResetField(name string) error {
  39633. switch name {
  39634. case wxcarduser.FieldCreatedAt:
  39635. m.ResetCreatedAt()
  39636. return nil
  39637. case wxcarduser.FieldUpdatedAt:
  39638. m.ResetUpdatedAt()
  39639. return nil
  39640. case wxcarduser.FieldDeletedAt:
  39641. m.ResetDeletedAt()
  39642. return nil
  39643. case wxcarduser.FieldWxid:
  39644. m.ResetWxid()
  39645. return nil
  39646. case wxcarduser.FieldAccount:
  39647. m.ResetAccount()
  39648. return nil
  39649. case wxcarduser.FieldAvatar:
  39650. m.ResetAvatar()
  39651. return nil
  39652. case wxcarduser.FieldNickname:
  39653. m.ResetNickname()
  39654. return nil
  39655. case wxcarduser.FieldRemark:
  39656. m.ResetRemark()
  39657. return nil
  39658. case wxcarduser.FieldPhone:
  39659. m.ResetPhone()
  39660. return nil
  39661. case wxcarduser.FieldOpenID:
  39662. m.ResetOpenID()
  39663. return nil
  39664. case wxcarduser.FieldUnionID:
  39665. m.ResetUnionID()
  39666. return nil
  39667. case wxcarduser.FieldSessionKey:
  39668. m.ResetSessionKey()
  39669. return nil
  39670. case wxcarduser.FieldIsVip:
  39671. m.ResetIsVip()
  39672. return nil
  39673. }
  39674. return fmt.Errorf("unknown WxCardUser field %s", name)
  39675. }
  39676. // AddedEdges returns all edge names that were set/added in this mutation.
  39677. func (m *WxCardUserMutation) AddedEdges() []string {
  39678. edges := make([]string, 0, 0)
  39679. return edges
  39680. }
  39681. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39682. // name in this mutation.
  39683. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  39684. return nil
  39685. }
  39686. // RemovedEdges returns all edge names that were removed in this mutation.
  39687. func (m *WxCardUserMutation) RemovedEdges() []string {
  39688. edges := make([]string, 0, 0)
  39689. return edges
  39690. }
  39691. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39692. // the given name in this mutation.
  39693. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  39694. return nil
  39695. }
  39696. // ClearedEdges returns all edge names that were cleared in this mutation.
  39697. func (m *WxCardUserMutation) ClearedEdges() []string {
  39698. edges := make([]string, 0, 0)
  39699. return edges
  39700. }
  39701. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39702. // was cleared in this mutation.
  39703. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  39704. return false
  39705. }
  39706. // ClearEdge clears the value of the edge with the given name. It returns an error
  39707. // if that edge is not defined in the schema.
  39708. func (m *WxCardUserMutation) ClearEdge(name string) error {
  39709. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  39710. }
  39711. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39712. // It returns an error if the edge is not defined in the schema.
  39713. func (m *WxCardUserMutation) ResetEdge(name string) error {
  39714. return fmt.Errorf("unknown WxCardUser edge %s", name)
  39715. }
  39716. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  39717. type WxCardVisitMutation struct {
  39718. config
  39719. op Op
  39720. typ string
  39721. id *uint64
  39722. created_at *time.Time
  39723. updated_at *time.Time
  39724. deleted_at *time.Time
  39725. user_id *uint64
  39726. adduser_id *int64
  39727. bot_id *uint64
  39728. addbot_id *int64
  39729. bot_type *uint8
  39730. addbot_type *int8
  39731. clearedFields map[string]struct{}
  39732. done bool
  39733. oldValue func(context.Context) (*WxCardVisit, error)
  39734. predicates []predicate.WxCardVisit
  39735. }
  39736. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  39737. // wxcardvisitOption allows management of the mutation configuration using functional options.
  39738. type wxcardvisitOption func(*WxCardVisitMutation)
  39739. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  39740. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  39741. m := &WxCardVisitMutation{
  39742. config: c,
  39743. op: op,
  39744. typ: TypeWxCardVisit,
  39745. clearedFields: make(map[string]struct{}),
  39746. }
  39747. for _, opt := range opts {
  39748. opt(m)
  39749. }
  39750. return m
  39751. }
  39752. // withWxCardVisitID sets the ID field of the mutation.
  39753. func withWxCardVisitID(id uint64) wxcardvisitOption {
  39754. return func(m *WxCardVisitMutation) {
  39755. var (
  39756. err error
  39757. once sync.Once
  39758. value *WxCardVisit
  39759. )
  39760. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  39761. once.Do(func() {
  39762. if m.done {
  39763. err = errors.New("querying old values post mutation is not allowed")
  39764. } else {
  39765. value, err = m.Client().WxCardVisit.Get(ctx, id)
  39766. }
  39767. })
  39768. return value, err
  39769. }
  39770. m.id = &id
  39771. }
  39772. }
  39773. // withWxCardVisit sets the old WxCardVisit of the mutation.
  39774. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  39775. return func(m *WxCardVisitMutation) {
  39776. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  39777. return node, nil
  39778. }
  39779. m.id = &node.ID
  39780. }
  39781. }
  39782. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39783. // executed in a transaction (ent.Tx), a transactional client is returned.
  39784. func (m WxCardVisitMutation) Client() *Client {
  39785. client := &Client{config: m.config}
  39786. client.init()
  39787. return client
  39788. }
  39789. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39790. // it returns an error otherwise.
  39791. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  39792. if _, ok := m.driver.(*txDriver); !ok {
  39793. return nil, errors.New("ent: mutation is not running in a transaction")
  39794. }
  39795. tx := &Tx{config: m.config}
  39796. tx.init()
  39797. return tx, nil
  39798. }
  39799. // SetID sets the value of the id field. Note that this
  39800. // operation is only accepted on creation of WxCardVisit entities.
  39801. func (m *WxCardVisitMutation) SetID(id uint64) {
  39802. m.id = &id
  39803. }
  39804. // ID returns the ID value in the mutation. Note that the ID is only available
  39805. // if it was provided to the builder or after it was returned from the database.
  39806. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  39807. if m.id == nil {
  39808. return
  39809. }
  39810. return *m.id, true
  39811. }
  39812. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39813. // That means, if the mutation is applied within a transaction with an isolation level such
  39814. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39815. // or updated by the mutation.
  39816. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  39817. switch {
  39818. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39819. id, exists := m.ID()
  39820. if exists {
  39821. return []uint64{id}, nil
  39822. }
  39823. fallthrough
  39824. case m.op.Is(OpUpdate | OpDelete):
  39825. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  39826. default:
  39827. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39828. }
  39829. }
  39830. // SetCreatedAt sets the "created_at" field.
  39831. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  39832. m.created_at = &t
  39833. }
  39834. // CreatedAt returns the value of the "created_at" field in the mutation.
  39835. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  39836. v := m.created_at
  39837. if v == nil {
  39838. return
  39839. }
  39840. return *v, true
  39841. }
  39842. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  39843. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  39844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39845. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39846. if !m.op.Is(OpUpdateOne) {
  39847. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39848. }
  39849. if m.id == nil || m.oldValue == nil {
  39850. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39851. }
  39852. oldValue, err := m.oldValue(ctx)
  39853. if err != nil {
  39854. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39855. }
  39856. return oldValue.CreatedAt, nil
  39857. }
  39858. // ResetCreatedAt resets all changes to the "created_at" field.
  39859. func (m *WxCardVisitMutation) ResetCreatedAt() {
  39860. m.created_at = nil
  39861. }
  39862. // SetUpdatedAt sets the "updated_at" field.
  39863. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  39864. m.updated_at = &t
  39865. }
  39866. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39867. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  39868. v := m.updated_at
  39869. if v == nil {
  39870. return
  39871. }
  39872. return *v, true
  39873. }
  39874. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  39875. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  39876. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39877. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39878. if !m.op.Is(OpUpdateOne) {
  39879. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39880. }
  39881. if m.id == nil || m.oldValue == nil {
  39882. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39883. }
  39884. oldValue, err := m.oldValue(ctx)
  39885. if err != nil {
  39886. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39887. }
  39888. return oldValue.UpdatedAt, nil
  39889. }
  39890. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39891. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  39892. m.updated_at = nil
  39893. }
  39894. // SetDeletedAt sets the "deleted_at" field.
  39895. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  39896. m.deleted_at = &t
  39897. }
  39898. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39899. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  39900. v := m.deleted_at
  39901. if v == nil {
  39902. return
  39903. }
  39904. return *v, true
  39905. }
  39906. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  39907. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  39908. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39909. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39910. if !m.op.Is(OpUpdateOne) {
  39911. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39912. }
  39913. if m.id == nil || m.oldValue == nil {
  39914. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39915. }
  39916. oldValue, err := m.oldValue(ctx)
  39917. if err != nil {
  39918. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39919. }
  39920. return oldValue.DeletedAt, nil
  39921. }
  39922. // ClearDeletedAt clears the value of the "deleted_at" field.
  39923. func (m *WxCardVisitMutation) ClearDeletedAt() {
  39924. m.deleted_at = nil
  39925. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  39926. }
  39927. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39928. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  39929. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  39930. return ok
  39931. }
  39932. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39933. func (m *WxCardVisitMutation) ResetDeletedAt() {
  39934. m.deleted_at = nil
  39935. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  39936. }
  39937. // SetUserID sets the "user_id" field.
  39938. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  39939. m.user_id = &u
  39940. m.adduser_id = nil
  39941. }
  39942. // UserID returns the value of the "user_id" field in the mutation.
  39943. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  39944. v := m.user_id
  39945. if v == nil {
  39946. return
  39947. }
  39948. return *v, true
  39949. }
  39950. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  39951. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  39952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39953. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  39954. if !m.op.Is(OpUpdateOne) {
  39955. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  39956. }
  39957. if m.id == nil || m.oldValue == nil {
  39958. return v, errors.New("OldUserID requires an ID field in the mutation")
  39959. }
  39960. oldValue, err := m.oldValue(ctx)
  39961. if err != nil {
  39962. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  39963. }
  39964. return oldValue.UserID, nil
  39965. }
  39966. // AddUserID adds u to the "user_id" field.
  39967. func (m *WxCardVisitMutation) AddUserID(u int64) {
  39968. if m.adduser_id != nil {
  39969. *m.adduser_id += u
  39970. } else {
  39971. m.adduser_id = &u
  39972. }
  39973. }
  39974. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  39975. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  39976. v := m.adduser_id
  39977. if v == nil {
  39978. return
  39979. }
  39980. return *v, true
  39981. }
  39982. // ClearUserID clears the value of the "user_id" field.
  39983. func (m *WxCardVisitMutation) ClearUserID() {
  39984. m.user_id = nil
  39985. m.adduser_id = nil
  39986. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  39987. }
  39988. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  39989. func (m *WxCardVisitMutation) UserIDCleared() bool {
  39990. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  39991. return ok
  39992. }
  39993. // ResetUserID resets all changes to the "user_id" field.
  39994. func (m *WxCardVisitMutation) ResetUserID() {
  39995. m.user_id = nil
  39996. m.adduser_id = nil
  39997. delete(m.clearedFields, wxcardvisit.FieldUserID)
  39998. }
  39999. // SetBotID sets the "bot_id" field.
  40000. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  40001. m.bot_id = &u
  40002. m.addbot_id = nil
  40003. }
  40004. // BotID returns the value of the "bot_id" field in the mutation.
  40005. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  40006. v := m.bot_id
  40007. if v == nil {
  40008. return
  40009. }
  40010. return *v, true
  40011. }
  40012. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  40013. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  40014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40015. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  40016. if !m.op.Is(OpUpdateOne) {
  40017. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  40018. }
  40019. if m.id == nil || m.oldValue == nil {
  40020. return v, errors.New("OldBotID requires an ID field in the mutation")
  40021. }
  40022. oldValue, err := m.oldValue(ctx)
  40023. if err != nil {
  40024. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  40025. }
  40026. return oldValue.BotID, nil
  40027. }
  40028. // AddBotID adds u to the "bot_id" field.
  40029. func (m *WxCardVisitMutation) AddBotID(u int64) {
  40030. if m.addbot_id != nil {
  40031. *m.addbot_id += u
  40032. } else {
  40033. m.addbot_id = &u
  40034. }
  40035. }
  40036. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  40037. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  40038. v := m.addbot_id
  40039. if v == nil {
  40040. return
  40041. }
  40042. return *v, true
  40043. }
  40044. // ResetBotID resets all changes to the "bot_id" field.
  40045. func (m *WxCardVisitMutation) ResetBotID() {
  40046. m.bot_id = nil
  40047. m.addbot_id = nil
  40048. }
  40049. // SetBotType sets the "bot_type" field.
  40050. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  40051. m.bot_type = &u
  40052. m.addbot_type = nil
  40053. }
  40054. // BotType returns the value of the "bot_type" field in the mutation.
  40055. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  40056. v := m.bot_type
  40057. if v == nil {
  40058. return
  40059. }
  40060. return *v, true
  40061. }
  40062. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  40063. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  40064. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40065. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  40066. if !m.op.Is(OpUpdateOne) {
  40067. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  40068. }
  40069. if m.id == nil || m.oldValue == nil {
  40070. return v, errors.New("OldBotType requires an ID field in the mutation")
  40071. }
  40072. oldValue, err := m.oldValue(ctx)
  40073. if err != nil {
  40074. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  40075. }
  40076. return oldValue.BotType, nil
  40077. }
  40078. // AddBotType adds u to the "bot_type" field.
  40079. func (m *WxCardVisitMutation) AddBotType(u int8) {
  40080. if m.addbot_type != nil {
  40081. *m.addbot_type += u
  40082. } else {
  40083. m.addbot_type = &u
  40084. }
  40085. }
  40086. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  40087. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  40088. v := m.addbot_type
  40089. if v == nil {
  40090. return
  40091. }
  40092. return *v, true
  40093. }
  40094. // ResetBotType resets all changes to the "bot_type" field.
  40095. func (m *WxCardVisitMutation) ResetBotType() {
  40096. m.bot_type = nil
  40097. m.addbot_type = nil
  40098. }
  40099. // Where appends a list predicates to the WxCardVisitMutation builder.
  40100. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  40101. m.predicates = append(m.predicates, ps...)
  40102. }
  40103. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  40104. // users can use type-assertion to append predicates that do not depend on any generated package.
  40105. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  40106. p := make([]predicate.WxCardVisit, len(ps))
  40107. for i := range ps {
  40108. p[i] = ps[i]
  40109. }
  40110. m.Where(p...)
  40111. }
  40112. // Op returns the operation name.
  40113. func (m *WxCardVisitMutation) Op() Op {
  40114. return m.op
  40115. }
  40116. // SetOp allows setting the mutation operation.
  40117. func (m *WxCardVisitMutation) SetOp(op Op) {
  40118. m.op = op
  40119. }
  40120. // Type returns the node type of this mutation (WxCardVisit).
  40121. func (m *WxCardVisitMutation) Type() string {
  40122. return m.typ
  40123. }
  40124. // Fields returns all fields that were changed during this mutation. Note that in
  40125. // order to get all numeric fields that were incremented/decremented, call
  40126. // AddedFields().
  40127. func (m *WxCardVisitMutation) Fields() []string {
  40128. fields := make([]string, 0, 6)
  40129. if m.created_at != nil {
  40130. fields = append(fields, wxcardvisit.FieldCreatedAt)
  40131. }
  40132. if m.updated_at != nil {
  40133. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  40134. }
  40135. if m.deleted_at != nil {
  40136. fields = append(fields, wxcardvisit.FieldDeletedAt)
  40137. }
  40138. if m.user_id != nil {
  40139. fields = append(fields, wxcardvisit.FieldUserID)
  40140. }
  40141. if m.bot_id != nil {
  40142. fields = append(fields, wxcardvisit.FieldBotID)
  40143. }
  40144. if m.bot_type != nil {
  40145. fields = append(fields, wxcardvisit.FieldBotType)
  40146. }
  40147. return fields
  40148. }
  40149. // Field returns the value of a field with the given name. The second boolean
  40150. // return value indicates that this field was not set, or was not defined in the
  40151. // schema.
  40152. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  40153. switch name {
  40154. case wxcardvisit.FieldCreatedAt:
  40155. return m.CreatedAt()
  40156. case wxcardvisit.FieldUpdatedAt:
  40157. return m.UpdatedAt()
  40158. case wxcardvisit.FieldDeletedAt:
  40159. return m.DeletedAt()
  40160. case wxcardvisit.FieldUserID:
  40161. return m.UserID()
  40162. case wxcardvisit.FieldBotID:
  40163. return m.BotID()
  40164. case wxcardvisit.FieldBotType:
  40165. return m.BotType()
  40166. }
  40167. return nil, false
  40168. }
  40169. // OldField returns the old value of the field from the database. An error is
  40170. // returned if the mutation operation is not UpdateOne, or the query to the
  40171. // database failed.
  40172. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40173. switch name {
  40174. case wxcardvisit.FieldCreatedAt:
  40175. return m.OldCreatedAt(ctx)
  40176. case wxcardvisit.FieldUpdatedAt:
  40177. return m.OldUpdatedAt(ctx)
  40178. case wxcardvisit.FieldDeletedAt:
  40179. return m.OldDeletedAt(ctx)
  40180. case wxcardvisit.FieldUserID:
  40181. return m.OldUserID(ctx)
  40182. case wxcardvisit.FieldBotID:
  40183. return m.OldBotID(ctx)
  40184. case wxcardvisit.FieldBotType:
  40185. return m.OldBotType(ctx)
  40186. }
  40187. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  40188. }
  40189. // SetField sets the value of a field with the given name. It returns an error if
  40190. // the field is not defined in the schema, or if the type mismatched the field
  40191. // type.
  40192. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  40193. switch name {
  40194. case wxcardvisit.FieldCreatedAt:
  40195. v, ok := value.(time.Time)
  40196. if !ok {
  40197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40198. }
  40199. m.SetCreatedAt(v)
  40200. return nil
  40201. case wxcardvisit.FieldUpdatedAt:
  40202. v, ok := value.(time.Time)
  40203. if !ok {
  40204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40205. }
  40206. m.SetUpdatedAt(v)
  40207. return nil
  40208. case wxcardvisit.FieldDeletedAt:
  40209. v, ok := value.(time.Time)
  40210. if !ok {
  40211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40212. }
  40213. m.SetDeletedAt(v)
  40214. return nil
  40215. case wxcardvisit.FieldUserID:
  40216. v, ok := value.(uint64)
  40217. if !ok {
  40218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40219. }
  40220. m.SetUserID(v)
  40221. return nil
  40222. case wxcardvisit.FieldBotID:
  40223. v, ok := value.(uint64)
  40224. if !ok {
  40225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40226. }
  40227. m.SetBotID(v)
  40228. return nil
  40229. case wxcardvisit.FieldBotType:
  40230. v, ok := value.(uint8)
  40231. if !ok {
  40232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40233. }
  40234. m.SetBotType(v)
  40235. return nil
  40236. }
  40237. return fmt.Errorf("unknown WxCardVisit field %s", name)
  40238. }
  40239. // AddedFields returns all numeric fields that were incremented/decremented during
  40240. // this mutation.
  40241. func (m *WxCardVisitMutation) AddedFields() []string {
  40242. var fields []string
  40243. if m.adduser_id != nil {
  40244. fields = append(fields, wxcardvisit.FieldUserID)
  40245. }
  40246. if m.addbot_id != nil {
  40247. fields = append(fields, wxcardvisit.FieldBotID)
  40248. }
  40249. if m.addbot_type != nil {
  40250. fields = append(fields, wxcardvisit.FieldBotType)
  40251. }
  40252. return fields
  40253. }
  40254. // AddedField returns the numeric value that was incremented/decremented on a field
  40255. // with the given name. The second boolean return value indicates that this field
  40256. // was not set, or was not defined in the schema.
  40257. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  40258. switch name {
  40259. case wxcardvisit.FieldUserID:
  40260. return m.AddedUserID()
  40261. case wxcardvisit.FieldBotID:
  40262. return m.AddedBotID()
  40263. case wxcardvisit.FieldBotType:
  40264. return m.AddedBotType()
  40265. }
  40266. return nil, false
  40267. }
  40268. // AddField adds the value to the field with the given name. It returns an error if
  40269. // the field is not defined in the schema, or if the type mismatched the field
  40270. // type.
  40271. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  40272. switch name {
  40273. case wxcardvisit.FieldUserID:
  40274. v, ok := value.(int64)
  40275. if !ok {
  40276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40277. }
  40278. m.AddUserID(v)
  40279. return nil
  40280. case wxcardvisit.FieldBotID:
  40281. v, ok := value.(int64)
  40282. if !ok {
  40283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40284. }
  40285. m.AddBotID(v)
  40286. return nil
  40287. case wxcardvisit.FieldBotType:
  40288. v, ok := value.(int8)
  40289. if !ok {
  40290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40291. }
  40292. m.AddBotType(v)
  40293. return nil
  40294. }
  40295. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  40296. }
  40297. // ClearedFields returns all nullable fields that were cleared during this
  40298. // mutation.
  40299. func (m *WxCardVisitMutation) ClearedFields() []string {
  40300. var fields []string
  40301. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  40302. fields = append(fields, wxcardvisit.FieldDeletedAt)
  40303. }
  40304. if m.FieldCleared(wxcardvisit.FieldUserID) {
  40305. fields = append(fields, wxcardvisit.FieldUserID)
  40306. }
  40307. return fields
  40308. }
  40309. // FieldCleared returns a boolean indicating if a field with the given name was
  40310. // cleared in this mutation.
  40311. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  40312. _, ok := m.clearedFields[name]
  40313. return ok
  40314. }
  40315. // ClearField clears the value of the field with the given name. It returns an
  40316. // error if the field is not defined in the schema.
  40317. func (m *WxCardVisitMutation) ClearField(name string) error {
  40318. switch name {
  40319. case wxcardvisit.FieldDeletedAt:
  40320. m.ClearDeletedAt()
  40321. return nil
  40322. case wxcardvisit.FieldUserID:
  40323. m.ClearUserID()
  40324. return nil
  40325. }
  40326. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  40327. }
  40328. // ResetField resets all changes in the mutation for the field with the given name.
  40329. // It returns an error if the field is not defined in the schema.
  40330. func (m *WxCardVisitMutation) ResetField(name string) error {
  40331. switch name {
  40332. case wxcardvisit.FieldCreatedAt:
  40333. m.ResetCreatedAt()
  40334. return nil
  40335. case wxcardvisit.FieldUpdatedAt:
  40336. m.ResetUpdatedAt()
  40337. return nil
  40338. case wxcardvisit.FieldDeletedAt:
  40339. m.ResetDeletedAt()
  40340. return nil
  40341. case wxcardvisit.FieldUserID:
  40342. m.ResetUserID()
  40343. return nil
  40344. case wxcardvisit.FieldBotID:
  40345. m.ResetBotID()
  40346. return nil
  40347. case wxcardvisit.FieldBotType:
  40348. m.ResetBotType()
  40349. return nil
  40350. }
  40351. return fmt.Errorf("unknown WxCardVisit field %s", name)
  40352. }
  40353. // AddedEdges returns all edge names that were set/added in this mutation.
  40354. func (m *WxCardVisitMutation) AddedEdges() []string {
  40355. edges := make([]string, 0, 0)
  40356. return edges
  40357. }
  40358. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40359. // name in this mutation.
  40360. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  40361. return nil
  40362. }
  40363. // RemovedEdges returns all edge names that were removed in this mutation.
  40364. func (m *WxCardVisitMutation) RemovedEdges() []string {
  40365. edges := make([]string, 0, 0)
  40366. return edges
  40367. }
  40368. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40369. // the given name in this mutation.
  40370. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  40371. return nil
  40372. }
  40373. // ClearedEdges returns all edge names that were cleared in this mutation.
  40374. func (m *WxCardVisitMutation) ClearedEdges() []string {
  40375. edges := make([]string, 0, 0)
  40376. return edges
  40377. }
  40378. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40379. // was cleared in this mutation.
  40380. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  40381. return false
  40382. }
  40383. // ClearEdge clears the value of the edge with the given name. It returns an error
  40384. // if that edge is not defined in the schema.
  40385. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  40386. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  40387. }
  40388. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40389. // It returns an error if the edge is not defined in the schema.
  40390. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  40391. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  40392. }