mutation.go 1.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348
  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/message"
  26. "wechat-api/ent/messagerecords"
  27. "wechat-api/ent/msg"
  28. "wechat-api/ent/payrecharge"
  29. "wechat-api/ent/predicate"
  30. "wechat-api/ent/server"
  31. "wechat-api/ent/sopnode"
  32. "wechat-api/ent/sopstage"
  33. "wechat-api/ent/soptask"
  34. "wechat-api/ent/token"
  35. "wechat-api/ent/tutorial"
  36. "wechat-api/ent/usagedetail"
  37. "wechat-api/ent/usagestatisticday"
  38. "wechat-api/ent/usagestatistichour"
  39. "wechat-api/ent/usagestatisticmonth"
  40. "wechat-api/ent/usagetotal"
  41. "wechat-api/ent/workexperience"
  42. "wechat-api/ent/wpchatroom"
  43. "wechat-api/ent/wpchatroommember"
  44. "wechat-api/ent/wx"
  45. "wechat-api/ent/wxcard"
  46. "wechat-api/ent/wxcarduser"
  47. "wechat-api/ent/wxcardvisit"
  48. "entgo.io/ent"
  49. "entgo.io/ent/dialect/sql"
  50. )
  51. const (
  52. // Operation types.
  53. OpCreate = ent.OpCreate
  54. OpDelete = ent.OpDelete
  55. OpDeleteOne = ent.OpDeleteOne
  56. OpUpdate = ent.OpUpdate
  57. OpUpdateOne = ent.OpUpdateOne
  58. // Node types.
  59. TypeAgent = "Agent"
  60. TypeAgentBase = "AgentBase"
  61. TypeAliyunAvatar = "AliyunAvatar"
  62. TypeAllocAgent = "AllocAgent"
  63. TypeBatchMsg = "BatchMsg"
  64. TypeCategory = "Category"
  65. TypeChatRecords = "ChatRecords"
  66. TypeChatSession = "ChatSession"
  67. TypeContact = "Contact"
  68. TypeCreditBalance = "CreditBalance"
  69. TypeCreditUsage = "CreditUsage"
  70. TypeEmployee = "Employee"
  71. TypeEmployeeConfig = "EmployeeConfig"
  72. TypeLabel = "Label"
  73. TypeLabelRelationship = "LabelRelationship"
  74. TypeMessage = "Message"
  75. TypeMessageRecords = "MessageRecords"
  76. TypeMsg = "Msg"
  77. TypePayRecharge = "PayRecharge"
  78. TypeServer = "Server"
  79. TypeSopNode = "SopNode"
  80. TypeSopStage = "SopStage"
  81. TypeSopTask = "SopTask"
  82. TypeToken = "Token"
  83. TypeTutorial = "Tutorial"
  84. TypeUsageDetail = "UsageDetail"
  85. TypeUsageStatisticDay = "UsageStatisticDay"
  86. TypeUsageStatisticHour = "UsageStatisticHour"
  87. TypeUsageStatisticMonth = "UsageStatisticMonth"
  88. TypeUsageTotal = "UsageTotal"
  89. TypeWorkExperience = "WorkExperience"
  90. TypeWpChatroom = "WpChatroom"
  91. TypeWpChatroomMember = "WpChatroomMember"
  92. TypeWx = "Wx"
  93. TypeWxCard = "WxCard"
  94. TypeWxCardUser = "WxCardUser"
  95. TypeWxCardVisit = "WxCardVisit"
  96. )
  97. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  98. type AgentMutation struct {
  99. config
  100. op Op
  101. typ string
  102. id *uint64
  103. created_at *time.Time
  104. updated_at *time.Time
  105. deleted_at *time.Time
  106. name *string
  107. role *string
  108. status *int
  109. addstatus *int
  110. background *string
  111. examples *string
  112. organization_id *uint64
  113. addorganization_id *int64
  114. dataset_id *string
  115. collection_id *string
  116. clearedFields map[string]struct{}
  117. wx_agent map[uint64]struct{}
  118. removedwx_agent map[uint64]struct{}
  119. clearedwx_agent bool
  120. token_agent map[uint64]struct{}
  121. removedtoken_agent map[uint64]struct{}
  122. clearedtoken_agent bool
  123. done bool
  124. oldValue func(context.Context) (*Agent, error)
  125. predicates []predicate.Agent
  126. }
  127. var _ ent.Mutation = (*AgentMutation)(nil)
  128. // agentOption allows management of the mutation configuration using functional options.
  129. type agentOption func(*AgentMutation)
  130. // newAgentMutation creates new mutation for the Agent entity.
  131. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  132. m := &AgentMutation{
  133. config: c,
  134. op: op,
  135. typ: TypeAgent,
  136. clearedFields: make(map[string]struct{}),
  137. }
  138. for _, opt := range opts {
  139. opt(m)
  140. }
  141. return m
  142. }
  143. // withAgentID sets the ID field of the mutation.
  144. func withAgentID(id uint64) agentOption {
  145. return func(m *AgentMutation) {
  146. var (
  147. err error
  148. once sync.Once
  149. value *Agent
  150. )
  151. m.oldValue = func(ctx context.Context) (*Agent, error) {
  152. once.Do(func() {
  153. if m.done {
  154. err = errors.New("querying old values post mutation is not allowed")
  155. } else {
  156. value, err = m.Client().Agent.Get(ctx, id)
  157. }
  158. })
  159. return value, err
  160. }
  161. m.id = &id
  162. }
  163. }
  164. // withAgent sets the old Agent of the mutation.
  165. func withAgent(node *Agent) agentOption {
  166. return func(m *AgentMutation) {
  167. m.oldValue = func(context.Context) (*Agent, error) {
  168. return node, nil
  169. }
  170. m.id = &node.ID
  171. }
  172. }
  173. // Client returns a new `ent.Client` from the mutation. If the mutation was
  174. // executed in a transaction (ent.Tx), a transactional client is returned.
  175. func (m AgentMutation) Client() *Client {
  176. client := &Client{config: m.config}
  177. client.init()
  178. return client
  179. }
  180. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  181. // it returns an error otherwise.
  182. func (m AgentMutation) Tx() (*Tx, error) {
  183. if _, ok := m.driver.(*txDriver); !ok {
  184. return nil, errors.New("ent: mutation is not running in a transaction")
  185. }
  186. tx := &Tx{config: m.config}
  187. tx.init()
  188. return tx, nil
  189. }
  190. // SetID sets the value of the id field. Note that this
  191. // operation is only accepted on creation of Agent entities.
  192. func (m *AgentMutation) SetID(id uint64) {
  193. m.id = &id
  194. }
  195. // ID returns the ID value in the mutation. Note that the ID is only available
  196. // if it was provided to the builder or after it was returned from the database.
  197. func (m *AgentMutation) ID() (id uint64, exists bool) {
  198. if m.id == nil {
  199. return
  200. }
  201. return *m.id, true
  202. }
  203. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  204. // That means, if the mutation is applied within a transaction with an isolation level such
  205. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  206. // or updated by the mutation.
  207. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  208. switch {
  209. case m.op.Is(OpUpdateOne | OpDeleteOne):
  210. id, exists := m.ID()
  211. if exists {
  212. return []uint64{id}, nil
  213. }
  214. fallthrough
  215. case m.op.Is(OpUpdate | OpDelete):
  216. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  217. default:
  218. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  219. }
  220. }
  221. // SetCreatedAt sets the "created_at" field.
  222. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  223. m.created_at = &t
  224. }
  225. // CreatedAt returns the value of the "created_at" field in the mutation.
  226. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  227. v := m.created_at
  228. if v == nil {
  229. return
  230. }
  231. return *v, true
  232. }
  233. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  234. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  236. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  237. if !m.op.Is(OpUpdateOne) {
  238. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  239. }
  240. if m.id == nil || m.oldValue == nil {
  241. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  242. }
  243. oldValue, err := m.oldValue(ctx)
  244. if err != nil {
  245. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  246. }
  247. return oldValue.CreatedAt, nil
  248. }
  249. // ResetCreatedAt resets all changes to the "created_at" field.
  250. func (m *AgentMutation) ResetCreatedAt() {
  251. m.created_at = nil
  252. }
  253. // SetUpdatedAt sets the "updated_at" field.
  254. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  255. m.updated_at = &t
  256. }
  257. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  258. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  259. v := m.updated_at
  260. if v == nil {
  261. return
  262. }
  263. return *v, true
  264. }
  265. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  266. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  268. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  269. if !m.op.Is(OpUpdateOne) {
  270. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  271. }
  272. if m.id == nil || m.oldValue == nil {
  273. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  274. }
  275. oldValue, err := m.oldValue(ctx)
  276. if err != nil {
  277. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  278. }
  279. return oldValue.UpdatedAt, nil
  280. }
  281. // ResetUpdatedAt resets all changes to the "updated_at" field.
  282. func (m *AgentMutation) ResetUpdatedAt() {
  283. m.updated_at = nil
  284. }
  285. // SetDeletedAt sets the "deleted_at" field.
  286. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  287. m.deleted_at = &t
  288. }
  289. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  290. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  291. v := m.deleted_at
  292. if v == nil {
  293. return
  294. }
  295. return *v, true
  296. }
  297. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  298. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  300. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  301. if !m.op.Is(OpUpdateOne) {
  302. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  303. }
  304. if m.id == nil || m.oldValue == nil {
  305. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  306. }
  307. oldValue, err := m.oldValue(ctx)
  308. if err != nil {
  309. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  310. }
  311. return oldValue.DeletedAt, nil
  312. }
  313. // ClearDeletedAt clears the value of the "deleted_at" field.
  314. func (m *AgentMutation) ClearDeletedAt() {
  315. m.deleted_at = nil
  316. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  317. }
  318. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  319. func (m *AgentMutation) DeletedAtCleared() bool {
  320. _, ok := m.clearedFields[agent.FieldDeletedAt]
  321. return ok
  322. }
  323. // ResetDeletedAt resets all changes to the "deleted_at" field.
  324. func (m *AgentMutation) ResetDeletedAt() {
  325. m.deleted_at = nil
  326. delete(m.clearedFields, agent.FieldDeletedAt)
  327. }
  328. // SetName sets the "name" field.
  329. func (m *AgentMutation) SetName(s string) {
  330. m.name = &s
  331. }
  332. // Name returns the value of the "name" field in the mutation.
  333. func (m *AgentMutation) Name() (r string, exists bool) {
  334. v := m.name
  335. if v == nil {
  336. return
  337. }
  338. return *v, true
  339. }
  340. // OldName returns the old "name" field's value of the Agent entity.
  341. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  342. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  343. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  344. if !m.op.Is(OpUpdateOne) {
  345. return v, errors.New("OldName is only allowed on UpdateOne operations")
  346. }
  347. if m.id == nil || m.oldValue == nil {
  348. return v, errors.New("OldName requires an ID field in the mutation")
  349. }
  350. oldValue, err := m.oldValue(ctx)
  351. if err != nil {
  352. return v, fmt.Errorf("querying old value for OldName: %w", err)
  353. }
  354. return oldValue.Name, nil
  355. }
  356. // ResetName resets all changes to the "name" field.
  357. func (m *AgentMutation) ResetName() {
  358. m.name = nil
  359. }
  360. // SetRole sets the "role" field.
  361. func (m *AgentMutation) SetRole(s string) {
  362. m.role = &s
  363. }
  364. // Role returns the value of the "role" field in the mutation.
  365. func (m *AgentMutation) Role() (r string, exists bool) {
  366. v := m.role
  367. if v == nil {
  368. return
  369. }
  370. return *v, true
  371. }
  372. // OldRole returns the old "role" field's value of the Agent entity.
  373. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  374. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  375. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  376. if !m.op.Is(OpUpdateOne) {
  377. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  378. }
  379. if m.id == nil || m.oldValue == nil {
  380. return v, errors.New("OldRole requires an ID field in the mutation")
  381. }
  382. oldValue, err := m.oldValue(ctx)
  383. if err != nil {
  384. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  385. }
  386. return oldValue.Role, nil
  387. }
  388. // ResetRole resets all changes to the "role" field.
  389. func (m *AgentMutation) ResetRole() {
  390. m.role = nil
  391. }
  392. // SetStatus sets the "status" field.
  393. func (m *AgentMutation) SetStatus(i int) {
  394. m.status = &i
  395. m.addstatus = nil
  396. }
  397. // Status returns the value of the "status" field in the mutation.
  398. func (m *AgentMutation) Status() (r int, exists bool) {
  399. v := m.status
  400. if v == nil {
  401. return
  402. }
  403. return *v, true
  404. }
  405. // OldStatus returns the old "status" field's value of the Agent entity.
  406. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  408. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  409. if !m.op.Is(OpUpdateOne) {
  410. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  411. }
  412. if m.id == nil || m.oldValue == nil {
  413. return v, errors.New("OldStatus requires an ID field in the mutation")
  414. }
  415. oldValue, err := m.oldValue(ctx)
  416. if err != nil {
  417. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  418. }
  419. return oldValue.Status, nil
  420. }
  421. // AddStatus adds i to the "status" field.
  422. func (m *AgentMutation) AddStatus(i int) {
  423. if m.addstatus != nil {
  424. *m.addstatus += i
  425. } else {
  426. m.addstatus = &i
  427. }
  428. }
  429. // AddedStatus returns the value that was added to the "status" field in this mutation.
  430. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  431. v := m.addstatus
  432. if v == nil {
  433. return
  434. }
  435. return *v, true
  436. }
  437. // ClearStatus clears the value of the "status" field.
  438. func (m *AgentMutation) ClearStatus() {
  439. m.status = nil
  440. m.addstatus = nil
  441. m.clearedFields[agent.FieldStatus] = struct{}{}
  442. }
  443. // StatusCleared returns if the "status" field was cleared in this mutation.
  444. func (m *AgentMutation) StatusCleared() bool {
  445. _, ok := m.clearedFields[agent.FieldStatus]
  446. return ok
  447. }
  448. // ResetStatus resets all changes to the "status" field.
  449. func (m *AgentMutation) ResetStatus() {
  450. m.status = nil
  451. m.addstatus = nil
  452. delete(m.clearedFields, agent.FieldStatus)
  453. }
  454. // SetBackground sets the "background" field.
  455. func (m *AgentMutation) SetBackground(s string) {
  456. m.background = &s
  457. }
  458. // Background returns the value of the "background" field in the mutation.
  459. func (m *AgentMutation) Background() (r string, exists bool) {
  460. v := m.background
  461. if v == nil {
  462. return
  463. }
  464. return *v, true
  465. }
  466. // OldBackground returns the old "background" field's value of the Agent entity.
  467. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  469. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  470. if !m.op.Is(OpUpdateOne) {
  471. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  472. }
  473. if m.id == nil || m.oldValue == nil {
  474. return v, errors.New("OldBackground requires an ID field in the mutation")
  475. }
  476. oldValue, err := m.oldValue(ctx)
  477. if err != nil {
  478. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  479. }
  480. return oldValue.Background, nil
  481. }
  482. // ClearBackground clears the value of the "background" field.
  483. func (m *AgentMutation) ClearBackground() {
  484. m.background = nil
  485. m.clearedFields[agent.FieldBackground] = struct{}{}
  486. }
  487. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  488. func (m *AgentMutation) BackgroundCleared() bool {
  489. _, ok := m.clearedFields[agent.FieldBackground]
  490. return ok
  491. }
  492. // ResetBackground resets all changes to the "background" field.
  493. func (m *AgentMutation) ResetBackground() {
  494. m.background = nil
  495. delete(m.clearedFields, agent.FieldBackground)
  496. }
  497. // SetExamples sets the "examples" field.
  498. func (m *AgentMutation) SetExamples(s string) {
  499. m.examples = &s
  500. }
  501. // Examples returns the value of the "examples" field in the mutation.
  502. func (m *AgentMutation) Examples() (r string, exists bool) {
  503. v := m.examples
  504. if v == nil {
  505. return
  506. }
  507. return *v, true
  508. }
  509. // OldExamples returns the old "examples" field's value of the Agent entity.
  510. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  512. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  513. if !m.op.Is(OpUpdateOne) {
  514. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  515. }
  516. if m.id == nil || m.oldValue == nil {
  517. return v, errors.New("OldExamples requires an ID field in the mutation")
  518. }
  519. oldValue, err := m.oldValue(ctx)
  520. if err != nil {
  521. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  522. }
  523. return oldValue.Examples, nil
  524. }
  525. // ClearExamples clears the value of the "examples" field.
  526. func (m *AgentMutation) ClearExamples() {
  527. m.examples = nil
  528. m.clearedFields[agent.FieldExamples] = struct{}{}
  529. }
  530. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  531. func (m *AgentMutation) ExamplesCleared() bool {
  532. _, ok := m.clearedFields[agent.FieldExamples]
  533. return ok
  534. }
  535. // ResetExamples resets all changes to the "examples" field.
  536. func (m *AgentMutation) ResetExamples() {
  537. m.examples = nil
  538. delete(m.clearedFields, agent.FieldExamples)
  539. }
  540. // SetOrganizationID sets the "organization_id" field.
  541. func (m *AgentMutation) SetOrganizationID(u uint64) {
  542. m.organization_id = &u
  543. m.addorganization_id = nil
  544. }
  545. // OrganizationID returns the value of the "organization_id" field in the mutation.
  546. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  547. v := m.organization_id
  548. if v == nil {
  549. return
  550. }
  551. return *v, true
  552. }
  553. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  554. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  556. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  557. if !m.op.Is(OpUpdateOne) {
  558. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  559. }
  560. if m.id == nil || m.oldValue == nil {
  561. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  562. }
  563. oldValue, err := m.oldValue(ctx)
  564. if err != nil {
  565. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  566. }
  567. return oldValue.OrganizationID, nil
  568. }
  569. // AddOrganizationID adds u to the "organization_id" field.
  570. func (m *AgentMutation) AddOrganizationID(u int64) {
  571. if m.addorganization_id != nil {
  572. *m.addorganization_id += u
  573. } else {
  574. m.addorganization_id = &u
  575. }
  576. }
  577. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  578. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  579. v := m.addorganization_id
  580. if v == nil {
  581. return
  582. }
  583. return *v, true
  584. }
  585. // ResetOrganizationID resets all changes to the "organization_id" field.
  586. func (m *AgentMutation) ResetOrganizationID() {
  587. m.organization_id = nil
  588. m.addorganization_id = nil
  589. }
  590. // SetDatasetID sets the "dataset_id" field.
  591. func (m *AgentMutation) SetDatasetID(s string) {
  592. m.dataset_id = &s
  593. }
  594. // DatasetID returns the value of the "dataset_id" field in the mutation.
  595. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  596. v := m.dataset_id
  597. if v == nil {
  598. return
  599. }
  600. return *v, true
  601. }
  602. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  603. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  605. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  606. if !m.op.Is(OpUpdateOne) {
  607. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  608. }
  609. if m.id == nil || m.oldValue == nil {
  610. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  611. }
  612. oldValue, err := m.oldValue(ctx)
  613. if err != nil {
  614. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  615. }
  616. return oldValue.DatasetID, nil
  617. }
  618. // ResetDatasetID resets all changes to the "dataset_id" field.
  619. func (m *AgentMutation) ResetDatasetID() {
  620. m.dataset_id = nil
  621. }
  622. // SetCollectionID sets the "collection_id" field.
  623. func (m *AgentMutation) SetCollectionID(s string) {
  624. m.collection_id = &s
  625. }
  626. // CollectionID returns the value of the "collection_id" field in the mutation.
  627. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  628. v := m.collection_id
  629. if v == nil {
  630. return
  631. }
  632. return *v, true
  633. }
  634. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  635. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  637. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  638. if !m.op.Is(OpUpdateOne) {
  639. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  640. }
  641. if m.id == nil || m.oldValue == nil {
  642. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  643. }
  644. oldValue, err := m.oldValue(ctx)
  645. if err != nil {
  646. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  647. }
  648. return oldValue.CollectionID, nil
  649. }
  650. // ResetCollectionID resets all changes to the "collection_id" field.
  651. func (m *AgentMutation) ResetCollectionID() {
  652. m.collection_id = nil
  653. }
  654. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  655. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  656. if m.wx_agent == nil {
  657. m.wx_agent = make(map[uint64]struct{})
  658. }
  659. for i := range ids {
  660. m.wx_agent[ids[i]] = struct{}{}
  661. }
  662. }
  663. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  664. func (m *AgentMutation) ClearWxAgent() {
  665. m.clearedwx_agent = true
  666. }
  667. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  668. func (m *AgentMutation) WxAgentCleared() bool {
  669. return m.clearedwx_agent
  670. }
  671. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  672. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  673. if m.removedwx_agent == nil {
  674. m.removedwx_agent = make(map[uint64]struct{})
  675. }
  676. for i := range ids {
  677. delete(m.wx_agent, ids[i])
  678. m.removedwx_agent[ids[i]] = struct{}{}
  679. }
  680. }
  681. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  682. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  683. for id := range m.removedwx_agent {
  684. ids = append(ids, id)
  685. }
  686. return
  687. }
  688. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  689. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  690. for id := range m.wx_agent {
  691. ids = append(ids, id)
  692. }
  693. return
  694. }
  695. // ResetWxAgent resets all changes to the "wx_agent" edge.
  696. func (m *AgentMutation) ResetWxAgent() {
  697. m.wx_agent = nil
  698. m.clearedwx_agent = false
  699. m.removedwx_agent = nil
  700. }
  701. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  702. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  703. if m.token_agent == nil {
  704. m.token_agent = make(map[uint64]struct{})
  705. }
  706. for i := range ids {
  707. m.token_agent[ids[i]] = struct{}{}
  708. }
  709. }
  710. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  711. func (m *AgentMutation) ClearTokenAgent() {
  712. m.clearedtoken_agent = true
  713. }
  714. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  715. func (m *AgentMutation) TokenAgentCleared() bool {
  716. return m.clearedtoken_agent
  717. }
  718. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  719. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  720. if m.removedtoken_agent == nil {
  721. m.removedtoken_agent = make(map[uint64]struct{})
  722. }
  723. for i := range ids {
  724. delete(m.token_agent, ids[i])
  725. m.removedtoken_agent[ids[i]] = struct{}{}
  726. }
  727. }
  728. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  729. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  730. for id := range m.removedtoken_agent {
  731. ids = append(ids, id)
  732. }
  733. return
  734. }
  735. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  736. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  737. for id := range m.token_agent {
  738. ids = append(ids, id)
  739. }
  740. return
  741. }
  742. // ResetTokenAgent resets all changes to the "token_agent" edge.
  743. func (m *AgentMutation) ResetTokenAgent() {
  744. m.token_agent = nil
  745. m.clearedtoken_agent = false
  746. m.removedtoken_agent = nil
  747. }
  748. // Where appends a list predicates to the AgentMutation builder.
  749. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  750. m.predicates = append(m.predicates, ps...)
  751. }
  752. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  753. // users can use type-assertion to append predicates that do not depend on any generated package.
  754. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  755. p := make([]predicate.Agent, len(ps))
  756. for i := range ps {
  757. p[i] = ps[i]
  758. }
  759. m.Where(p...)
  760. }
  761. // Op returns the operation name.
  762. func (m *AgentMutation) Op() Op {
  763. return m.op
  764. }
  765. // SetOp allows setting the mutation operation.
  766. func (m *AgentMutation) SetOp(op Op) {
  767. m.op = op
  768. }
  769. // Type returns the node type of this mutation (Agent).
  770. func (m *AgentMutation) Type() string {
  771. return m.typ
  772. }
  773. // Fields returns all fields that were changed during this mutation. Note that in
  774. // order to get all numeric fields that were incremented/decremented, call
  775. // AddedFields().
  776. func (m *AgentMutation) Fields() []string {
  777. fields := make([]string, 0, 11)
  778. if m.created_at != nil {
  779. fields = append(fields, agent.FieldCreatedAt)
  780. }
  781. if m.updated_at != nil {
  782. fields = append(fields, agent.FieldUpdatedAt)
  783. }
  784. if m.deleted_at != nil {
  785. fields = append(fields, agent.FieldDeletedAt)
  786. }
  787. if m.name != nil {
  788. fields = append(fields, agent.FieldName)
  789. }
  790. if m.role != nil {
  791. fields = append(fields, agent.FieldRole)
  792. }
  793. if m.status != nil {
  794. fields = append(fields, agent.FieldStatus)
  795. }
  796. if m.background != nil {
  797. fields = append(fields, agent.FieldBackground)
  798. }
  799. if m.examples != nil {
  800. fields = append(fields, agent.FieldExamples)
  801. }
  802. if m.organization_id != nil {
  803. fields = append(fields, agent.FieldOrganizationID)
  804. }
  805. if m.dataset_id != nil {
  806. fields = append(fields, agent.FieldDatasetID)
  807. }
  808. if m.collection_id != nil {
  809. fields = append(fields, agent.FieldCollectionID)
  810. }
  811. return fields
  812. }
  813. // Field returns the value of a field with the given name. The second boolean
  814. // return value indicates that this field was not set, or was not defined in the
  815. // schema.
  816. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  817. switch name {
  818. case agent.FieldCreatedAt:
  819. return m.CreatedAt()
  820. case agent.FieldUpdatedAt:
  821. return m.UpdatedAt()
  822. case agent.FieldDeletedAt:
  823. return m.DeletedAt()
  824. case agent.FieldName:
  825. return m.Name()
  826. case agent.FieldRole:
  827. return m.Role()
  828. case agent.FieldStatus:
  829. return m.Status()
  830. case agent.FieldBackground:
  831. return m.Background()
  832. case agent.FieldExamples:
  833. return m.Examples()
  834. case agent.FieldOrganizationID:
  835. return m.OrganizationID()
  836. case agent.FieldDatasetID:
  837. return m.DatasetID()
  838. case agent.FieldCollectionID:
  839. return m.CollectionID()
  840. }
  841. return nil, false
  842. }
  843. // OldField returns the old value of the field from the database. An error is
  844. // returned if the mutation operation is not UpdateOne, or the query to the
  845. // database failed.
  846. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  847. switch name {
  848. case agent.FieldCreatedAt:
  849. return m.OldCreatedAt(ctx)
  850. case agent.FieldUpdatedAt:
  851. return m.OldUpdatedAt(ctx)
  852. case agent.FieldDeletedAt:
  853. return m.OldDeletedAt(ctx)
  854. case agent.FieldName:
  855. return m.OldName(ctx)
  856. case agent.FieldRole:
  857. return m.OldRole(ctx)
  858. case agent.FieldStatus:
  859. return m.OldStatus(ctx)
  860. case agent.FieldBackground:
  861. return m.OldBackground(ctx)
  862. case agent.FieldExamples:
  863. return m.OldExamples(ctx)
  864. case agent.FieldOrganizationID:
  865. return m.OldOrganizationID(ctx)
  866. case agent.FieldDatasetID:
  867. return m.OldDatasetID(ctx)
  868. case agent.FieldCollectionID:
  869. return m.OldCollectionID(ctx)
  870. }
  871. return nil, fmt.Errorf("unknown Agent field %s", name)
  872. }
  873. // SetField sets the value of a field with the given name. It returns an error if
  874. // the field is not defined in the schema, or if the type mismatched the field
  875. // type.
  876. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  877. switch name {
  878. case agent.FieldCreatedAt:
  879. v, ok := value.(time.Time)
  880. if !ok {
  881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  882. }
  883. m.SetCreatedAt(v)
  884. return nil
  885. case agent.FieldUpdatedAt:
  886. v, ok := value.(time.Time)
  887. if !ok {
  888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  889. }
  890. m.SetUpdatedAt(v)
  891. return nil
  892. case agent.FieldDeletedAt:
  893. v, ok := value.(time.Time)
  894. if !ok {
  895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  896. }
  897. m.SetDeletedAt(v)
  898. return nil
  899. case agent.FieldName:
  900. v, ok := value.(string)
  901. if !ok {
  902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  903. }
  904. m.SetName(v)
  905. return nil
  906. case agent.FieldRole:
  907. v, ok := value.(string)
  908. if !ok {
  909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  910. }
  911. m.SetRole(v)
  912. return nil
  913. case agent.FieldStatus:
  914. v, ok := value.(int)
  915. if !ok {
  916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  917. }
  918. m.SetStatus(v)
  919. return nil
  920. case agent.FieldBackground:
  921. v, ok := value.(string)
  922. if !ok {
  923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  924. }
  925. m.SetBackground(v)
  926. return nil
  927. case agent.FieldExamples:
  928. v, ok := value.(string)
  929. if !ok {
  930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  931. }
  932. m.SetExamples(v)
  933. return nil
  934. case agent.FieldOrganizationID:
  935. v, ok := value.(uint64)
  936. if !ok {
  937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  938. }
  939. m.SetOrganizationID(v)
  940. return nil
  941. case agent.FieldDatasetID:
  942. v, ok := value.(string)
  943. if !ok {
  944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  945. }
  946. m.SetDatasetID(v)
  947. return nil
  948. case agent.FieldCollectionID:
  949. v, ok := value.(string)
  950. if !ok {
  951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  952. }
  953. m.SetCollectionID(v)
  954. return nil
  955. }
  956. return fmt.Errorf("unknown Agent field %s", name)
  957. }
  958. // AddedFields returns all numeric fields that were incremented/decremented during
  959. // this mutation.
  960. func (m *AgentMutation) AddedFields() []string {
  961. var fields []string
  962. if m.addstatus != nil {
  963. fields = append(fields, agent.FieldStatus)
  964. }
  965. if m.addorganization_id != nil {
  966. fields = append(fields, agent.FieldOrganizationID)
  967. }
  968. return fields
  969. }
  970. // AddedField returns the numeric value that was incremented/decremented on a field
  971. // with the given name. The second boolean return value indicates that this field
  972. // was not set, or was not defined in the schema.
  973. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  974. switch name {
  975. case agent.FieldStatus:
  976. return m.AddedStatus()
  977. case agent.FieldOrganizationID:
  978. return m.AddedOrganizationID()
  979. }
  980. return nil, false
  981. }
  982. // AddField adds the value to the field with the given name. It returns an error if
  983. // the field is not defined in the schema, or if the type mismatched the field
  984. // type.
  985. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  986. switch name {
  987. case agent.FieldStatus:
  988. v, ok := value.(int)
  989. if !ok {
  990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  991. }
  992. m.AddStatus(v)
  993. return nil
  994. case agent.FieldOrganizationID:
  995. v, ok := value.(int64)
  996. if !ok {
  997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  998. }
  999. m.AddOrganizationID(v)
  1000. return nil
  1001. }
  1002. return fmt.Errorf("unknown Agent numeric field %s", name)
  1003. }
  1004. // ClearedFields returns all nullable fields that were cleared during this
  1005. // mutation.
  1006. func (m *AgentMutation) ClearedFields() []string {
  1007. var fields []string
  1008. if m.FieldCleared(agent.FieldDeletedAt) {
  1009. fields = append(fields, agent.FieldDeletedAt)
  1010. }
  1011. if m.FieldCleared(agent.FieldStatus) {
  1012. fields = append(fields, agent.FieldStatus)
  1013. }
  1014. if m.FieldCleared(agent.FieldBackground) {
  1015. fields = append(fields, agent.FieldBackground)
  1016. }
  1017. if m.FieldCleared(agent.FieldExamples) {
  1018. fields = append(fields, agent.FieldExamples)
  1019. }
  1020. return fields
  1021. }
  1022. // FieldCleared returns a boolean indicating if a field with the given name was
  1023. // cleared in this mutation.
  1024. func (m *AgentMutation) FieldCleared(name string) bool {
  1025. _, ok := m.clearedFields[name]
  1026. return ok
  1027. }
  1028. // ClearField clears the value of the field with the given name. It returns an
  1029. // error if the field is not defined in the schema.
  1030. func (m *AgentMutation) ClearField(name string) error {
  1031. switch name {
  1032. case agent.FieldDeletedAt:
  1033. m.ClearDeletedAt()
  1034. return nil
  1035. case agent.FieldStatus:
  1036. m.ClearStatus()
  1037. return nil
  1038. case agent.FieldBackground:
  1039. m.ClearBackground()
  1040. return nil
  1041. case agent.FieldExamples:
  1042. m.ClearExamples()
  1043. return nil
  1044. }
  1045. return fmt.Errorf("unknown Agent nullable field %s", name)
  1046. }
  1047. // ResetField resets all changes in the mutation for the field with the given name.
  1048. // It returns an error if the field is not defined in the schema.
  1049. func (m *AgentMutation) ResetField(name string) error {
  1050. switch name {
  1051. case agent.FieldCreatedAt:
  1052. m.ResetCreatedAt()
  1053. return nil
  1054. case agent.FieldUpdatedAt:
  1055. m.ResetUpdatedAt()
  1056. return nil
  1057. case agent.FieldDeletedAt:
  1058. m.ResetDeletedAt()
  1059. return nil
  1060. case agent.FieldName:
  1061. m.ResetName()
  1062. return nil
  1063. case agent.FieldRole:
  1064. m.ResetRole()
  1065. return nil
  1066. case agent.FieldStatus:
  1067. m.ResetStatus()
  1068. return nil
  1069. case agent.FieldBackground:
  1070. m.ResetBackground()
  1071. return nil
  1072. case agent.FieldExamples:
  1073. m.ResetExamples()
  1074. return nil
  1075. case agent.FieldOrganizationID:
  1076. m.ResetOrganizationID()
  1077. return nil
  1078. case agent.FieldDatasetID:
  1079. m.ResetDatasetID()
  1080. return nil
  1081. case agent.FieldCollectionID:
  1082. m.ResetCollectionID()
  1083. return nil
  1084. }
  1085. return fmt.Errorf("unknown Agent field %s", name)
  1086. }
  1087. // AddedEdges returns all edge names that were set/added in this mutation.
  1088. func (m *AgentMutation) AddedEdges() []string {
  1089. edges := make([]string, 0, 2)
  1090. if m.wx_agent != nil {
  1091. edges = append(edges, agent.EdgeWxAgent)
  1092. }
  1093. if m.token_agent != nil {
  1094. edges = append(edges, agent.EdgeTokenAgent)
  1095. }
  1096. return edges
  1097. }
  1098. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1099. // name in this mutation.
  1100. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1101. switch name {
  1102. case agent.EdgeWxAgent:
  1103. ids := make([]ent.Value, 0, len(m.wx_agent))
  1104. for id := range m.wx_agent {
  1105. ids = append(ids, id)
  1106. }
  1107. return ids
  1108. case agent.EdgeTokenAgent:
  1109. ids := make([]ent.Value, 0, len(m.token_agent))
  1110. for id := range m.token_agent {
  1111. ids = append(ids, id)
  1112. }
  1113. return ids
  1114. }
  1115. return nil
  1116. }
  1117. // RemovedEdges returns all edge names that were removed in this mutation.
  1118. func (m *AgentMutation) RemovedEdges() []string {
  1119. edges := make([]string, 0, 2)
  1120. if m.removedwx_agent != nil {
  1121. edges = append(edges, agent.EdgeWxAgent)
  1122. }
  1123. if m.removedtoken_agent != nil {
  1124. edges = append(edges, agent.EdgeTokenAgent)
  1125. }
  1126. return edges
  1127. }
  1128. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1129. // the given name in this mutation.
  1130. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1131. switch name {
  1132. case agent.EdgeWxAgent:
  1133. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1134. for id := range m.removedwx_agent {
  1135. ids = append(ids, id)
  1136. }
  1137. return ids
  1138. case agent.EdgeTokenAgent:
  1139. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1140. for id := range m.removedtoken_agent {
  1141. ids = append(ids, id)
  1142. }
  1143. return ids
  1144. }
  1145. return nil
  1146. }
  1147. // ClearedEdges returns all edge names that were cleared in this mutation.
  1148. func (m *AgentMutation) ClearedEdges() []string {
  1149. edges := make([]string, 0, 2)
  1150. if m.clearedwx_agent {
  1151. edges = append(edges, agent.EdgeWxAgent)
  1152. }
  1153. if m.clearedtoken_agent {
  1154. edges = append(edges, agent.EdgeTokenAgent)
  1155. }
  1156. return edges
  1157. }
  1158. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1159. // was cleared in this mutation.
  1160. func (m *AgentMutation) EdgeCleared(name string) bool {
  1161. switch name {
  1162. case agent.EdgeWxAgent:
  1163. return m.clearedwx_agent
  1164. case agent.EdgeTokenAgent:
  1165. return m.clearedtoken_agent
  1166. }
  1167. return false
  1168. }
  1169. // ClearEdge clears the value of the edge with the given name. It returns an error
  1170. // if that edge is not defined in the schema.
  1171. func (m *AgentMutation) ClearEdge(name string) error {
  1172. switch name {
  1173. }
  1174. return fmt.Errorf("unknown Agent unique edge %s", name)
  1175. }
  1176. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1177. // It returns an error if the edge is not defined in the schema.
  1178. func (m *AgentMutation) ResetEdge(name string) error {
  1179. switch name {
  1180. case agent.EdgeWxAgent:
  1181. m.ResetWxAgent()
  1182. return nil
  1183. case agent.EdgeTokenAgent:
  1184. m.ResetTokenAgent()
  1185. return nil
  1186. }
  1187. return fmt.Errorf("unknown Agent edge %s", name)
  1188. }
  1189. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1190. type AgentBaseMutation struct {
  1191. config
  1192. op Op
  1193. typ string
  1194. id *string
  1195. q *string
  1196. a *string
  1197. chunk_index *uint64
  1198. addchunk_index *int64
  1199. indexes *[]string
  1200. appendindexes []string
  1201. dataset_id *string
  1202. collection_id *string
  1203. source_name *string
  1204. can_write *[]bool
  1205. appendcan_write []bool
  1206. is_owner *[]bool
  1207. appendis_owner []bool
  1208. clearedFields map[string]struct{}
  1209. wx_agent map[uint64]struct{}
  1210. removedwx_agent map[uint64]struct{}
  1211. clearedwx_agent bool
  1212. done bool
  1213. oldValue func(context.Context) (*AgentBase, error)
  1214. predicates []predicate.AgentBase
  1215. }
  1216. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1217. // agentbaseOption allows management of the mutation configuration using functional options.
  1218. type agentbaseOption func(*AgentBaseMutation)
  1219. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1220. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1221. m := &AgentBaseMutation{
  1222. config: c,
  1223. op: op,
  1224. typ: TypeAgentBase,
  1225. clearedFields: make(map[string]struct{}),
  1226. }
  1227. for _, opt := range opts {
  1228. opt(m)
  1229. }
  1230. return m
  1231. }
  1232. // withAgentBaseID sets the ID field of the mutation.
  1233. func withAgentBaseID(id string) agentbaseOption {
  1234. return func(m *AgentBaseMutation) {
  1235. var (
  1236. err error
  1237. once sync.Once
  1238. value *AgentBase
  1239. )
  1240. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1241. once.Do(func() {
  1242. if m.done {
  1243. err = errors.New("querying old values post mutation is not allowed")
  1244. } else {
  1245. value, err = m.Client().AgentBase.Get(ctx, id)
  1246. }
  1247. })
  1248. return value, err
  1249. }
  1250. m.id = &id
  1251. }
  1252. }
  1253. // withAgentBase sets the old AgentBase of the mutation.
  1254. func withAgentBase(node *AgentBase) agentbaseOption {
  1255. return func(m *AgentBaseMutation) {
  1256. m.oldValue = func(context.Context) (*AgentBase, error) {
  1257. return node, nil
  1258. }
  1259. m.id = &node.ID
  1260. }
  1261. }
  1262. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1263. // executed in a transaction (ent.Tx), a transactional client is returned.
  1264. func (m AgentBaseMutation) Client() *Client {
  1265. client := &Client{config: m.config}
  1266. client.init()
  1267. return client
  1268. }
  1269. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1270. // it returns an error otherwise.
  1271. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1272. if _, ok := m.driver.(*txDriver); !ok {
  1273. return nil, errors.New("ent: mutation is not running in a transaction")
  1274. }
  1275. tx := &Tx{config: m.config}
  1276. tx.init()
  1277. return tx, nil
  1278. }
  1279. // SetID sets the value of the id field. Note that this
  1280. // operation is only accepted on creation of AgentBase entities.
  1281. func (m *AgentBaseMutation) SetID(id string) {
  1282. m.id = &id
  1283. }
  1284. // ID returns the ID value in the mutation. Note that the ID is only available
  1285. // if it was provided to the builder or after it was returned from the database.
  1286. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1287. if m.id == nil {
  1288. return
  1289. }
  1290. return *m.id, true
  1291. }
  1292. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1293. // That means, if the mutation is applied within a transaction with an isolation level such
  1294. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1295. // or updated by the mutation.
  1296. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1297. switch {
  1298. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1299. id, exists := m.ID()
  1300. if exists {
  1301. return []string{id}, nil
  1302. }
  1303. fallthrough
  1304. case m.op.Is(OpUpdate | OpDelete):
  1305. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1306. default:
  1307. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1308. }
  1309. }
  1310. // SetQ sets the "q" field.
  1311. func (m *AgentBaseMutation) SetQ(s string) {
  1312. m.q = &s
  1313. }
  1314. // Q returns the value of the "q" field in the mutation.
  1315. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1316. v := m.q
  1317. if v == nil {
  1318. return
  1319. }
  1320. return *v, true
  1321. }
  1322. // OldQ returns the old "q" field's value of the AgentBase entity.
  1323. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1325. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1326. if !m.op.Is(OpUpdateOne) {
  1327. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1328. }
  1329. if m.id == nil || m.oldValue == nil {
  1330. return v, errors.New("OldQ requires an ID field in the mutation")
  1331. }
  1332. oldValue, err := m.oldValue(ctx)
  1333. if err != nil {
  1334. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1335. }
  1336. return oldValue.Q, nil
  1337. }
  1338. // ClearQ clears the value of the "q" field.
  1339. func (m *AgentBaseMutation) ClearQ() {
  1340. m.q = nil
  1341. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1342. }
  1343. // QCleared returns if the "q" field was cleared in this mutation.
  1344. func (m *AgentBaseMutation) QCleared() bool {
  1345. _, ok := m.clearedFields[agentbase.FieldQ]
  1346. return ok
  1347. }
  1348. // ResetQ resets all changes to the "q" field.
  1349. func (m *AgentBaseMutation) ResetQ() {
  1350. m.q = nil
  1351. delete(m.clearedFields, agentbase.FieldQ)
  1352. }
  1353. // SetA sets the "a" field.
  1354. func (m *AgentBaseMutation) SetA(s string) {
  1355. m.a = &s
  1356. }
  1357. // A returns the value of the "a" field in the mutation.
  1358. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1359. v := m.a
  1360. if v == nil {
  1361. return
  1362. }
  1363. return *v, true
  1364. }
  1365. // OldA returns the old "a" field's value of the AgentBase entity.
  1366. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1368. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1369. if !m.op.Is(OpUpdateOne) {
  1370. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1371. }
  1372. if m.id == nil || m.oldValue == nil {
  1373. return v, errors.New("OldA requires an ID field in the mutation")
  1374. }
  1375. oldValue, err := m.oldValue(ctx)
  1376. if err != nil {
  1377. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1378. }
  1379. return oldValue.A, nil
  1380. }
  1381. // ClearA clears the value of the "a" field.
  1382. func (m *AgentBaseMutation) ClearA() {
  1383. m.a = nil
  1384. m.clearedFields[agentbase.FieldA] = struct{}{}
  1385. }
  1386. // ACleared returns if the "a" field was cleared in this mutation.
  1387. func (m *AgentBaseMutation) ACleared() bool {
  1388. _, ok := m.clearedFields[agentbase.FieldA]
  1389. return ok
  1390. }
  1391. // ResetA resets all changes to the "a" field.
  1392. func (m *AgentBaseMutation) ResetA() {
  1393. m.a = nil
  1394. delete(m.clearedFields, agentbase.FieldA)
  1395. }
  1396. // SetChunkIndex sets the "chunk_index" field.
  1397. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1398. m.chunk_index = &u
  1399. m.addchunk_index = nil
  1400. }
  1401. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1402. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1403. v := m.chunk_index
  1404. if v == nil {
  1405. return
  1406. }
  1407. return *v, true
  1408. }
  1409. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1410. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1412. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1413. if !m.op.Is(OpUpdateOne) {
  1414. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1415. }
  1416. if m.id == nil || m.oldValue == nil {
  1417. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1418. }
  1419. oldValue, err := m.oldValue(ctx)
  1420. if err != nil {
  1421. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1422. }
  1423. return oldValue.ChunkIndex, nil
  1424. }
  1425. // AddChunkIndex adds u to the "chunk_index" field.
  1426. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1427. if m.addchunk_index != nil {
  1428. *m.addchunk_index += u
  1429. } else {
  1430. m.addchunk_index = &u
  1431. }
  1432. }
  1433. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1434. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1435. v := m.addchunk_index
  1436. if v == nil {
  1437. return
  1438. }
  1439. return *v, true
  1440. }
  1441. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1442. func (m *AgentBaseMutation) ResetChunkIndex() {
  1443. m.chunk_index = nil
  1444. m.addchunk_index = nil
  1445. }
  1446. // SetIndexes sets the "indexes" field.
  1447. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1448. m.indexes = &s
  1449. m.appendindexes = nil
  1450. }
  1451. // Indexes returns the value of the "indexes" field in the mutation.
  1452. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1453. v := m.indexes
  1454. if v == nil {
  1455. return
  1456. }
  1457. return *v, true
  1458. }
  1459. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1460. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1462. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1463. if !m.op.Is(OpUpdateOne) {
  1464. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1465. }
  1466. if m.id == nil || m.oldValue == nil {
  1467. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1468. }
  1469. oldValue, err := m.oldValue(ctx)
  1470. if err != nil {
  1471. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1472. }
  1473. return oldValue.Indexes, nil
  1474. }
  1475. // AppendIndexes adds s to the "indexes" field.
  1476. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1477. m.appendindexes = append(m.appendindexes, s...)
  1478. }
  1479. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1480. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1481. if len(m.appendindexes) == 0 {
  1482. return nil, false
  1483. }
  1484. return m.appendindexes, true
  1485. }
  1486. // ClearIndexes clears the value of the "indexes" field.
  1487. func (m *AgentBaseMutation) ClearIndexes() {
  1488. m.indexes = nil
  1489. m.appendindexes = nil
  1490. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1491. }
  1492. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1493. func (m *AgentBaseMutation) IndexesCleared() bool {
  1494. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1495. return ok
  1496. }
  1497. // ResetIndexes resets all changes to the "indexes" field.
  1498. func (m *AgentBaseMutation) ResetIndexes() {
  1499. m.indexes = nil
  1500. m.appendindexes = nil
  1501. delete(m.clearedFields, agentbase.FieldIndexes)
  1502. }
  1503. // SetDatasetID sets the "dataset_id" field.
  1504. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1505. m.dataset_id = &s
  1506. }
  1507. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1508. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1509. v := m.dataset_id
  1510. if v == nil {
  1511. return
  1512. }
  1513. return *v, true
  1514. }
  1515. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1516. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1518. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1519. if !m.op.Is(OpUpdateOne) {
  1520. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1521. }
  1522. if m.id == nil || m.oldValue == nil {
  1523. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1524. }
  1525. oldValue, err := m.oldValue(ctx)
  1526. if err != nil {
  1527. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1528. }
  1529. return oldValue.DatasetID, nil
  1530. }
  1531. // ClearDatasetID clears the value of the "dataset_id" field.
  1532. func (m *AgentBaseMutation) ClearDatasetID() {
  1533. m.dataset_id = nil
  1534. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1535. }
  1536. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1537. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1538. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1539. return ok
  1540. }
  1541. // ResetDatasetID resets all changes to the "dataset_id" field.
  1542. func (m *AgentBaseMutation) ResetDatasetID() {
  1543. m.dataset_id = nil
  1544. delete(m.clearedFields, agentbase.FieldDatasetID)
  1545. }
  1546. // SetCollectionID sets the "collection_id" field.
  1547. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1548. m.collection_id = &s
  1549. }
  1550. // CollectionID returns the value of the "collection_id" field in the mutation.
  1551. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1552. v := m.collection_id
  1553. if v == nil {
  1554. return
  1555. }
  1556. return *v, true
  1557. }
  1558. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1559. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1560. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1561. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1562. if !m.op.Is(OpUpdateOne) {
  1563. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1564. }
  1565. if m.id == nil || m.oldValue == nil {
  1566. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1567. }
  1568. oldValue, err := m.oldValue(ctx)
  1569. if err != nil {
  1570. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1571. }
  1572. return oldValue.CollectionID, nil
  1573. }
  1574. // ClearCollectionID clears the value of the "collection_id" field.
  1575. func (m *AgentBaseMutation) ClearCollectionID() {
  1576. m.collection_id = nil
  1577. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1578. }
  1579. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1580. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1581. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1582. return ok
  1583. }
  1584. // ResetCollectionID resets all changes to the "collection_id" field.
  1585. func (m *AgentBaseMutation) ResetCollectionID() {
  1586. m.collection_id = nil
  1587. delete(m.clearedFields, agentbase.FieldCollectionID)
  1588. }
  1589. // SetSourceName sets the "source_name" field.
  1590. func (m *AgentBaseMutation) SetSourceName(s string) {
  1591. m.source_name = &s
  1592. }
  1593. // SourceName returns the value of the "source_name" field in the mutation.
  1594. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1595. v := m.source_name
  1596. if v == nil {
  1597. return
  1598. }
  1599. return *v, true
  1600. }
  1601. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1602. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1604. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1605. if !m.op.Is(OpUpdateOne) {
  1606. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1607. }
  1608. if m.id == nil || m.oldValue == nil {
  1609. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1610. }
  1611. oldValue, err := m.oldValue(ctx)
  1612. if err != nil {
  1613. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1614. }
  1615. return oldValue.SourceName, nil
  1616. }
  1617. // ClearSourceName clears the value of the "source_name" field.
  1618. func (m *AgentBaseMutation) ClearSourceName() {
  1619. m.source_name = nil
  1620. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1621. }
  1622. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1623. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1624. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1625. return ok
  1626. }
  1627. // ResetSourceName resets all changes to the "source_name" field.
  1628. func (m *AgentBaseMutation) ResetSourceName() {
  1629. m.source_name = nil
  1630. delete(m.clearedFields, agentbase.FieldSourceName)
  1631. }
  1632. // SetCanWrite sets the "can_write" field.
  1633. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1634. m.can_write = &b
  1635. m.appendcan_write = nil
  1636. }
  1637. // CanWrite returns the value of the "can_write" field in the mutation.
  1638. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1639. v := m.can_write
  1640. if v == nil {
  1641. return
  1642. }
  1643. return *v, true
  1644. }
  1645. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1646. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1648. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1649. if !m.op.Is(OpUpdateOne) {
  1650. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1651. }
  1652. if m.id == nil || m.oldValue == nil {
  1653. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1654. }
  1655. oldValue, err := m.oldValue(ctx)
  1656. if err != nil {
  1657. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1658. }
  1659. return oldValue.CanWrite, nil
  1660. }
  1661. // AppendCanWrite adds b to the "can_write" field.
  1662. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1663. m.appendcan_write = append(m.appendcan_write, b...)
  1664. }
  1665. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1666. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1667. if len(m.appendcan_write) == 0 {
  1668. return nil, false
  1669. }
  1670. return m.appendcan_write, true
  1671. }
  1672. // ClearCanWrite clears the value of the "can_write" field.
  1673. func (m *AgentBaseMutation) ClearCanWrite() {
  1674. m.can_write = nil
  1675. m.appendcan_write = nil
  1676. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1677. }
  1678. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1679. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1680. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1681. return ok
  1682. }
  1683. // ResetCanWrite resets all changes to the "can_write" field.
  1684. func (m *AgentBaseMutation) ResetCanWrite() {
  1685. m.can_write = nil
  1686. m.appendcan_write = nil
  1687. delete(m.clearedFields, agentbase.FieldCanWrite)
  1688. }
  1689. // SetIsOwner sets the "is_owner" field.
  1690. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1691. m.is_owner = &b
  1692. m.appendis_owner = nil
  1693. }
  1694. // IsOwner returns the value of the "is_owner" field in the mutation.
  1695. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1696. v := m.is_owner
  1697. if v == nil {
  1698. return
  1699. }
  1700. return *v, true
  1701. }
  1702. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1703. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1705. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1706. if !m.op.Is(OpUpdateOne) {
  1707. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1708. }
  1709. if m.id == nil || m.oldValue == nil {
  1710. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1711. }
  1712. oldValue, err := m.oldValue(ctx)
  1713. if err != nil {
  1714. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1715. }
  1716. return oldValue.IsOwner, nil
  1717. }
  1718. // AppendIsOwner adds b to the "is_owner" field.
  1719. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1720. m.appendis_owner = append(m.appendis_owner, b...)
  1721. }
  1722. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1723. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1724. if len(m.appendis_owner) == 0 {
  1725. return nil, false
  1726. }
  1727. return m.appendis_owner, true
  1728. }
  1729. // ClearIsOwner clears the value of the "is_owner" field.
  1730. func (m *AgentBaseMutation) ClearIsOwner() {
  1731. m.is_owner = nil
  1732. m.appendis_owner = nil
  1733. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1734. }
  1735. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1736. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1737. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1738. return ok
  1739. }
  1740. // ResetIsOwner resets all changes to the "is_owner" field.
  1741. func (m *AgentBaseMutation) ResetIsOwner() {
  1742. m.is_owner = nil
  1743. m.appendis_owner = nil
  1744. delete(m.clearedFields, agentbase.FieldIsOwner)
  1745. }
  1746. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1747. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1748. if m.wx_agent == nil {
  1749. m.wx_agent = make(map[uint64]struct{})
  1750. }
  1751. for i := range ids {
  1752. m.wx_agent[ids[i]] = struct{}{}
  1753. }
  1754. }
  1755. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1756. func (m *AgentBaseMutation) ClearWxAgent() {
  1757. m.clearedwx_agent = true
  1758. }
  1759. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1760. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1761. return m.clearedwx_agent
  1762. }
  1763. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1764. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1765. if m.removedwx_agent == nil {
  1766. m.removedwx_agent = make(map[uint64]struct{})
  1767. }
  1768. for i := range ids {
  1769. delete(m.wx_agent, ids[i])
  1770. m.removedwx_agent[ids[i]] = struct{}{}
  1771. }
  1772. }
  1773. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1774. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1775. for id := range m.removedwx_agent {
  1776. ids = append(ids, id)
  1777. }
  1778. return
  1779. }
  1780. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1781. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1782. for id := range m.wx_agent {
  1783. ids = append(ids, id)
  1784. }
  1785. return
  1786. }
  1787. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1788. func (m *AgentBaseMutation) ResetWxAgent() {
  1789. m.wx_agent = nil
  1790. m.clearedwx_agent = false
  1791. m.removedwx_agent = nil
  1792. }
  1793. // Where appends a list predicates to the AgentBaseMutation builder.
  1794. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1795. m.predicates = append(m.predicates, ps...)
  1796. }
  1797. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1798. // users can use type-assertion to append predicates that do not depend on any generated package.
  1799. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1800. p := make([]predicate.AgentBase, len(ps))
  1801. for i := range ps {
  1802. p[i] = ps[i]
  1803. }
  1804. m.Where(p...)
  1805. }
  1806. // Op returns the operation name.
  1807. func (m *AgentBaseMutation) Op() Op {
  1808. return m.op
  1809. }
  1810. // SetOp allows setting the mutation operation.
  1811. func (m *AgentBaseMutation) SetOp(op Op) {
  1812. m.op = op
  1813. }
  1814. // Type returns the node type of this mutation (AgentBase).
  1815. func (m *AgentBaseMutation) Type() string {
  1816. return m.typ
  1817. }
  1818. // Fields returns all fields that were changed during this mutation. Note that in
  1819. // order to get all numeric fields that were incremented/decremented, call
  1820. // AddedFields().
  1821. func (m *AgentBaseMutation) Fields() []string {
  1822. fields := make([]string, 0, 9)
  1823. if m.q != nil {
  1824. fields = append(fields, agentbase.FieldQ)
  1825. }
  1826. if m.a != nil {
  1827. fields = append(fields, agentbase.FieldA)
  1828. }
  1829. if m.chunk_index != nil {
  1830. fields = append(fields, agentbase.FieldChunkIndex)
  1831. }
  1832. if m.indexes != nil {
  1833. fields = append(fields, agentbase.FieldIndexes)
  1834. }
  1835. if m.dataset_id != nil {
  1836. fields = append(fields, agentbase.FieldDatasetID)
  1837. }
  1838. if m.collection_id != nil {
  1839. fields = append(fields, agentbase.FieldCollectionID)
  1840. }
  1841. if m.source_name != nil {
  1842. fields = append(fields, agentbase.FieldSourceName)
  1843. }
  1844. if m.can_write != nil {
  1845. fields = append(fields, agentbase.FieldCanWrite)
  1846. }
  1847. if m.is_owner != nil {
  1848. fields = append(fields, agentbase.FieldIsOwner)
  1849. }
  1850. return fields
  1851. }
  1852. // Field returns the value of a field with the given name. The second boolean
  1853. // return value indicates that this field was not set, or was not defined in the
  1854. // schema.
  1855. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1856. switch name {
  1857. case agentbase.FieldQ:
  1858. return m.Q()
  1859. case agentbase.FieldA:
  1860. return m.A()
  1861. case agentbase.FieldChunkIndex:
  1862. return m.ChunkIndex()
  1863. case agentbase.FieldIndexes:
  1864. return m.Indexes()
  1865. case agentbase.FieldDatasetID:
  1866. return m.DatasetID()
  1867. case agentbase.FieldCollectionID:
  1868. return m.CollectionID()
  1869. case agentbase.FieldSourceName:
  1870. return m.SourceName()
  1871. case agentbase.FieldCanWrite:
  1872. return m.CanWrite()
  1873. case agentbase.FieldIsOwner:
  1874. return m.IsOwner()
  1875. }
  1876. return nil, false
  1877. }
  1878. // OldField returns the old value of the field from the database. An error is
  1879. // returned if the mutation operation is not UpdateOne, or the query to the
  1880. // database failed.
  1881. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1882. switch name {
  1883. case agentbase.FieldQ:
  1884. return m.OldQ(ctx)
  1885. case agentbase.FieldA:
  1886. return m.OldA(ctx)
  1887. case agentbase.FieldChunkIndex:
  1888. return m.OldChunkIndex(ctx)
  1889. case agentbase.FieldIndexes:
  1890. return m.OldIndexes(ctx)
  1891. case agentbase.FieldDatasetID:
  1892. return m.OldDatasetID(ctx)
  1893. case agentbase.FieldCollectionID:
  1894. return m.OldCollectionID(ctx)
  1895. case agentbase.FieldSourceName:
  1896. return m.OldSourceName(ctx)
  1897. case agentbase.FieldCanWrite:
  1898. return m.OldCanWrite(ctx)
  1899. case agentbase.FieldIsOwner:
  1900. return m.OldIsOwner(ctx)
  1901. }
  1902. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1903. }
  1904. // SetField sets the value of a field with the given name. It returns an error if
  1905. // the field is not defined in the schema, or if the type mismatched the field
  1906. // type.
  1907. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1908. switch name {
  1909. case agentbase.FieldQ:
  1910. v, ok := value.(string)
  1911. if !ok {
  1912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1913. }
  1914. m.SetQ(v)
  1915. return nil
  1916. case agentbase.FieldA:
  1917. v, ok := value.(string)
  1918. if !ok {
  1919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1920. }
  1921. m.SetA(v)
  1922. return nil
  1923. case agentbase.FieldChunkIndex:
  1924. v, ok := value.(uint64)
  1925. if !ok {
  1926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1927. }
  1928. m.SetChunkIndex(v)
  1929. return nil
  1930. case agentbase.FieldIndexes:
  1931. v, ok := value.([]string)
  1932. if !ok {
  1933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1934. }
  1935. m.SetIndexes(v)
  1936. return nil
  1937. case agentbase.FieldDatasetID:
  1938. v, ok := value.(string)
  1939. if !ok {
  1940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1941. }
  1942. m.SetDatasetID(v)
  1943. return nil
  1944. case agentbase.FieldCollectionID:
  1945. v, ok := value.(string)
  1946. if !ok {
  1947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1948. }
  1949. m.SetCollectionID(v)
  1950. return nil
  1951. case agentbase.FieldSourceName:
  1952. v, ok := value.(string)
  1953. if !ok {
  1954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1955. }
  1956. m.SetSourceName(v)
  1957. return nil
  1958. case agentbase.FieldCanWrite:
  1959. v, ok := value.([]bool)
  1960. if !ok {
  1961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1962. }
  1963. m.SetCanWrite(v)
  1964. return nil
  1965. case agentbase.FieldIsOwner:
  1966. v, ok := value.([]bool)
  1967. if !ok {
  1968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1969. }
  1970. m.SetIsOwner(v)
  1971. return nil
  1972. }
  1973. return fmt.Errorf("unknown AgentBase field %s", name)
  1974. }
  1975. // AddedFields returns all numeric fields that were incremented/decremented during
  1976. // this mutation.
  1977. func (m *AgentBaseMutation) AddedFields() []string {
  1978. var fields []string
  1979. if m.addchunk_index != nil {
  1980. fields = append(fields, agentbase.FieldChunkIndex)
  1981. }
  1982. return fields
  1983. }
  1984. // AddedField returns the numeric value that was incremented/decremented on a field
  1985. // with the given name. The second boolean return value indicates that this field
  1986. // was not set, or was not defined in the schema.
  1987. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  1988. switch name {
  1989. case agentbase.FieldChunkIndex:
  1990. return m.AddedChunkIndex()
  1991. }
  1992. return nil, false
  1993. }
  1994. // AddField adds the value to the field with the given name. It returns an error if
  1995. // the field is not defined in the schema, or if the type mismatched the field
  1996. // type.
  1997. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  1998. switch name {
  1999. case agentbase.FieldChunkIndex:
  2000. v, ok := value.(int64)
  2001. if !ok {
  2002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2003. }
  2004. m.AddChunkIndex(v)
  2005. return nil
  2006. }
  2007. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2008. }
  2009. // ClearedFields returns all nullable fields that were cleared during this
  2010. // mutation.
  2011. func (m *AgentBaseMutation) ClearedFields() []string {
  2012. var fields []string
  2013. if m.FieldCleared(agentbase.FieldQ) {
  2014. fields = append(fields, agentbase.FieldQ)
  2015. }
  2016. if m.FieldCleared(agentbase.FieldA) {
  2017. fields = append(fields, agentbase.FieldA)
  2018. }
  2019. if m.FieldCleared(agentbase.FieldIndexes) {
  2020. fields = append(fields, agentbase.FieldIndexes)
  2021. }
  2022. if m.FieldCleared(agentbase.FieldDatasetID) {
  2023. fields = append(fields, agentbase.FieldDatasetID)
  2024. }
  2025. if m.FieldCleared(agentbase.FieldCollectionID) {
  2026. fields = append(fields, agentbase.FieldCollectionID)
  2027. }
  2028. if m.FieldCleared(agentbase.FieldSourceName) {
  2029. fields = append(fields, agentbase.FieldSourceName)
  2030. }
  2031. if m.FieldCleared(agentbase.FieldCanWrite) {
  2032. fields = append(fields, agentbase.FieldCanWrite)
  2033. }
  2034. if m.FieldCleared(agentbase.FieldIsOwner) {
  2035. fields = append(fields, agentbase.FieldIsOwner)
  2036. }
  2037. return fields
  2038. }
  2039. // FieldCleared returns a boolean indicating if a field with the given name was
  2040. // cleared in this mutation.
  2041. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2042. _, ok := m.clearedFields[name]
  2043. return ok
  2044. }
  2045. // ClearField clears the value of the field with the given name. It returns an
  2046. // error if the field is not defined in the schema.
  2047. func (m *AgentBaseMutation) ClearField(name string) error {
  2048. switch name {
  2049. case agentbase.FieldQ:
  2050. m.ClearQ()
  2051. return nil
  2052. case agentbase.FieldA:
  2053. m.ClearA()
  2054. return nil
  2055. case agentbase.FieldIndexes:
  2056. m.ClearIndexes()
  2057. return nil
  2058. case agentbase.FieldDatasetID:
  2059. m.ClearDatasetID()
  2060. return nil
  2061. case agentbase.FieldCollectionID:
  2062. m.ClearCollectionID()
  2063. return nil
  2064. case agentbase.FieldSourceName:
  2065. m.ClearSourceName()
  2066. return nil
  2067. case agentbase.FieldCanWrite:
  2068. m.ClearCanWrite()
  2069. return nil
  2070. case agentbase.FieldIsOwner:
  2071. m.ClearIsOwner()
  2072. return nil
  2073. }
  2074. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2075. }
  2076. // ResetField resets all changes in the mutation for the field with the given name.
  2077. // It returns an error if the field is not defined in the schema.
  2078. func (m *AgentBaseMutation) ResetField(name string) error {
  2079. switch name {
  2080. case agentbase.FieldQ:
  2081. m.ResetQ()
  2082. return nil
  2083. case agentbase.FieldA:
  2084. m.ResetA()
  2085. return nil
  2086. case agentbase.FieldChunkIndex:
  2087. m.ResetChunkIndex()
  2088. return nil
  2089. case agentbase.FieldIndexes:
  2090. m.ResetIndexes()
  2091. return nil
  2092. case agentbase.FieldDatasetID:
  2093. m.ResetDatasetID()
  2094. return nil
  2095. case agentbase.FieldCollectionID:
  2096. m.ResetCollectionID()
  2097. return nil
  2098. case agentbase.FieldSourceName:
  2099. m.ResetSourceName()
  2100. return nil
  2101. case agentbase.FieldCanWrite:
  2102. m.ResetCanWrite()
  2103. return nil
  2104. case agentbase.FieldIsOwner:
  2105. m.ResetIsOwner()
  2106. return nil
  2107. }
  2108. return fmt.Errorf("unknown AgentBase field %s", name)
  2109. }
  2110. // AddedEdges returns all edge names that were set/added in this mutation.
  2111. func (m *AgentBaseMutation) AddedEdges() []string {
  2112. edges := make([]string, 0, 1)
  2113. if m.wx_agent != nil {
  2114. edges = append(edges, agentbase.EdgeWxAgent)
  2115. }
  2116. return edges
  2117. }
  2118. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2119. // name in this mutation.
  2120. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2121. switch name {
  2122. case agentbase.EdgeWxAgent:
  2123. ids := make([]ent.Value, 0, len(m.wx_agent))
  2124. for id := range m.wx_agent {
  2125. ids = append(ids, id)
  2126. }
  2127. return ids
  2128. }
  2129. return nil
  2130. }
  2131. // RemovedEdges returns all edge names that were removed in this mutation.
  2132. func (m *AgentBaseMutation) RemovedEdges() []string {
  2133. edges := make([]string, 0, 1)
  2134. if m.removedwx_agent != nil {
  2135. edges = append(edges, agentbase.EdgeWxAgent)
  2136. }
  2137. return edges
  2138. }
  2139. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2140. // the given name in this mutation.
  2141. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2142. switch name {
  2143. case agentbase.EdgeWxAgent:
  2144. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2145. for id := range m.removedwx_agent {
  2146. ids = append(ids, id)
  2147. }
  2148. return ids
  2149. }
  2150. return nil
  2151. }
  2152. // ClearedEdges returns all edge names that were cleared in this mutation.
  2153. func (m *AgentBaseMutation) ClearedEdges() []string {
  2154. edges := make([]string, 0, 1)
  2155. if m.clearedwx_agent {
  2156. edges = append(edges, agentbase.EdgeWxAgent)
  2157. }
  2158. return edges
  2159. }
  2160. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2161. // was cleared in this mutation.
  2162. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2163. switch name {
  2164. case agentbase.EdgeWxAgent:
  2165. return m.clearedwx_agent
  2166. }
  2167. return false
  2168. }
  2169. // ClearEdge clears the value of the edge with the given name. It returns an error
  2170. // if that edge is not defined in the schema.
  2171. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2172. switch name {
  2173. }
  2174. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2175. }
  2176. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2177. // It returns an error if the edge is not defined in the schema.
  2178. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2179. switch name {
  2180. case agentbase.EdgeWxAgent:
  2181. m.ResetWxAgent()
  2182. return nil
  2183. }
  2184. return fmt.Errorf("unknown AgentBase edge %s", name)
  2185. }
  2186. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2187. type AliyunAvatarMutation struct {
  2188. config
  2189. op Op
  2190. typ string
  2191. id *uint64
  2192. created_at *time.Time
  2193. updated_at *time.Time
  2194. deleted_at *time.Time
  2195. user_id *uint64
  2196. adduser_id *int64
  2197. biz_id *string
  2198. access_key_id *string
  2199. access_key_secret *string
  2200. app_id *string
  2201. tenant_id *uint64
  2202. addtenant_id *int64
  2203. response *string
  2204. token *string
  2205. session_id *string
  2206. clearedFields map[string]struct{}
  2207. done bool
  2208. oldValue func(context.Context) (*AliyunAvatar, error)
  2209. predicates []predicate.AliyunAvatar
  2210. }
  2211. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2212. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2213. type aliyunavatarOption func(*AliyunAvatarMutation)
  2214. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2215. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2216. m := &AliyunAvatarMutation{
  2217. config: c,
  2218. op: op,
  2219. typ: TypeAliyunAvatar,
  2220. clearedFields: make(map[string]struct{}),
  2221. }
  2222. for _, opt := range opts {
  2223. opt(m)
  2224. }
  2225. return m
  2226. }
  2227. // withAliyunAvatarID sets the ID field of the mutation.
  2228. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2229. return func(m *AliyunAvatarMutation) {
  2230. var (
  2231. err error
  2232. once sync.Once
  2233. value *AliyunAvatar
  2234. )
  2235. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2236. once.Do(func() {
  2237. if m.done {
  2238. err = errors.New("querying old values post mutation is not allowed")
  2239. } else {
  2240. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2241. }
  2242. })
  2243. return value, err
  2244. }
  2245. m.id = &id
  2246. }
  2247. }
  2248. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2249. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2250. return func(m *AliyunAvatarMutation) {
  2251. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2252. return node, nil
  2253. }
  2254. m.id = &node.ID
  2255. }
  2256. }
  2257. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2258. // executed in a transaction (ent.Tx), a transactional client is returned.
  2259. func (m AliyunAvatarMutation) Client() *Client {
  2260. client := &Client{config: m.config}
  2261. client.init()
  2262. return client
  2263. }
  2264. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2265. // it returns an error otherwise.
  2266. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2267. if _, ok := m.driver.(*txDriver); !ok {
  2268. return nil, errors.New("ent: mutation is not running in a transaction")
  2269. }
  2270. tx := &Tx{config: m.config}
  2271. tx.init()
  2272. return tx, nil
  2273. }
  2274. // SetID sets the value of the id field. Note that this
  2275. // operation is only accepted on creation of AliyunAvatar entities.
  2276. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2277. m.id = &id
  2278. }
  2279. // ID returns the ID value in the mutation. Note that the ID is only available
  2280. // if it was provided to the builder or after it was returned from the database.
  2281. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2282. if m.id == nil {
  2283. return
  2284. }
  2285. return *m.id, true
  2286. }
  2287. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2288. // That means, if the mutation is applied within a transaction with an isolation level such
  2289. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2290. // or updated by the mutation.
  2291. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2292. switch {
  2293. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2294. id, exists := m.ID()
  2295. if exists {
  2296. return []uint64{id}, nil
  2297. }
  2298. fallthrough
  2299. case m.op.Is(OpUpdate | OpDelete):
  2300. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2301. default:
  2302. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2303. }
  2304. }
  2305. // SetCreatedAt sets the "created_at" field.
  2306. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2307. m.created_at = &t
  2308. }
  2309. // CreatedAt returns the value of the "created_at" field in the mutation.
  2310. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2311. v := m.created_at
  2312. if v == nil {
  2313. return
  2314. }
  2315. return *v, true
  2316. }
  2317. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2318. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2320. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2321. if !m.op.Is(OpUpdateOne) {
  2322. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2323. }
  2324. if m.id == nil || m.oldValue == nil {
  2325. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2326. }
  2327. oldValue, err := m.oldValue(ctx)
  2328. if err != nil {
  2329. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2330. }
  2331. return oldValue.CreatedAt, nil
  2332. }
  2333. // ResetCreatedAt resets all changes to the "created_at" field.
  2334. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2335. m.created_at = nil
  2336. }
  2337. // SetUpdatedAt sets the "updated_at" field.
  2338. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2339. m.updated_at = &t
  2340. }
  2341. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2342. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2343. v := m.updated_at
  2344. if v == nil {
  2345. return
  2346. }
  2347. return *v, true
  2348. }
  2349. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2350. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2351. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2352. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2353. if !m.op.Is(OpUpdateOne) {
  2354. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2355. }
  2356. if m.id == nil || m.oldValue == nil {
  2357. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2358. }
  2359. oldValue, err := m.oldValue(ctx)
  2360. if err != nil {
  2361. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2362. }
  2363. return oldValue.UpdatedAt, nil
  2364. }
  2365. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2366. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2367. m.updated_at = nil
  2368. }
  2369. // SetDeletedAt sets the "deleted_at" field.
  2370. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2371. m.deleted_at = &t
  2372. }
  2373. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2374. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2375. v := m.deleted_at
  2376. if v == nil {
  2377. return
  2378. }
  2379. return *v, true
  2380. }
  2381. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2382. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2384. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2385. if !m.op.Is(OpUpdateOne) {
  2386. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2387. }
  2388. if m.id == nil || m.oldValue == nil {
  2389. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2390. }
  2391. oldValue, err := m.oldValue(ctx)
  2392. if err != nil {
  2393. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2394. }
  2395. return oldValue.DeletedAt, nil
  2396. }
  2397. // ClearDeletedAt clears the value of the "deleted_at" field.
  2398. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2399. m.deleted_at = nil
  2400. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2401. }
  2402. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2403. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2404. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2405. return ok
  2406. }
  2407. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2408. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2409. m.deleted_at = nil
  2410. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2411. }
  2412. // SetUserID sets the "user_id" field.
  2413. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2414. m.user_id = &u
  2415. m.adduser_id = nil
  2416. }
  2417. // UserID returns the value of the "user_id" field in the mutation.
  2418. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2419. v := m.user_id
  2420. if v == nil {
  2421. return
  2422. }
  2423. return *v, true
  2424. }
  2425. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2426. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2428. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2429. if !m.op.Is(OpUpdateOne) {
  2430. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2431. }
  2432. if m.id == nil || m.oldValue == nil {
  2433. return v, errors.New("OldUserID requires an ID field in the mutation")
  2434. }
  2435. oldValue, err := m.oldValue(ctx)
  2436. if err != nil {
  2437. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2438. }
  2439. return oldValue.UserID, nil
  2440. }
  2441. // AddUserID adds u to the "user_id" field.
  2442. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2443. if m.adduser_id != nil {
  2444. *m.adduser_id += u
  2445. } else {
  2446. m.adduser_id = &u
  2447. }
  2448. }
  2449. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2450. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2451. v := m.adduser_id
  2452. if v == nil {
  2453. return
  2454. }
  2455. return *v, true
  2456. }
  2457. // ResetUserID resets all changes to the "user_id" field.
  2458. func (m *AliyunAvatarMutation) ResetUserID() {
  2459. m.user_id = nil
  2460. m.adduser_id = nil
  2461. }
  2462. // SetBizID sets the "biz_id" field.
  2463. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2464. m.biz_id = &s
  2465. }
  2466. // BizID returns the value of the "biz_id" field in the mutation.
  2467. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2468. v := m.biz_id
  2469. if v == nil {
  2470. return
  2471. }
  2472. return *v, true
  2473. }
  2474. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2475. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2476. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2477. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2478. if !m.op.Is(OpUpdateOne) {
  2479. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2480. }
  2481. if m.id == nil || m.oldValue == nil {
  2482. return v, errors.New("OldBizID requires an ID field in the mutation")
  2483. }
  2484. oldValue, err := m.oldValue(ctx)
  2485. if err != nil {
  2486. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2487. }
  2488. return oldValue.BizID, nil
  2489. }
  2490. // ResetBizID resets all changes to the "biz_id" field.
  2491. func (m *AliyunAvatarMutation) ResetBizID() {
  2492. m.biz_id = nil
  2493. }
  2494. // SetAccessKeyID sets the "access_key_id" field.
  2495. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2496. m.access_key_id = &s
  2497. }
  2498. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2499. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2500. v := m.access_key_id
  2501. if v == nil {
  2502. return
  2503. }
  2504. return *v, true
  2505. }
  2506. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2507. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2509. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2510. if !m.op.Is(OpUpdateOne) {
  2511. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2512. }
  2513. if m.id == nil || m.oldValue == nil {
  2514. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2515. }
  2516. oldValue, err := m.oldValue(ctx)
  2517. if err != nil {
  2518. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2519. }
  2520. return oldValue.AccessKeyID, nil
  2521. }
  2522. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2523. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2524. m.access_key_id = nil
  2525. }
  2526. // SetAccessKeySecret sets the "access_key_secret" field.
  2527. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2528. m.access_key_secret = &s
  2529. }
  2530. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2531. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2532. v := m.access_key_secret
  2533. if v == nil {
  2534. return
  2535. }
  2536. return *v, true
  2537. }
  2538. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2539. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2541. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2542. if !m.op.Is(OpUpdateOne) {
  2543. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2544. }
  2545. if m.id == nil || m.oldValue == nil {
  2546. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2547. }
  2548. oldValue, err := m.oldValue(ctx)
  2549. if err != nil {
  2550. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2551. }
  2552. return oldValue.AccessKeySecret, nil
  2553. }
  2554. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2555. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2556. m.access_key_secret = nil
  2557. }
  2558. // SetAppID sets the "app_id" field.
  2559. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2560. m.app_id = &s
  2561. }
  2562. // AppID returns the value of the "app_id" field in the mutation.
  2563. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2564. v := m.app_id
  2565. if v == nil {
  2566. return
  2567. }
  2568. return *v, true
  2569. }
  2570. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2571. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2572. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2573. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2574. if !m.op.Is(OpUpdateOne) {
  2575. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2576. }
  2577. if m.id == nil || m.oldValue == nil {
  2578. return v, errors.New("OldAppID requires an ID field in the mutation")
  2579. }
  2580. oldValue, err := m.oldValue(ctx)
  2581. if err != nil {
  2582. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2583. }
  2584. return oldValue.AppID, nil
  2585. }
  2586. // ClearAppID clears the value of the "app_id" field.
  2587. func (m *AliyunAvatarMutation) ClearAppID() {
  2588. m.app_id = nil
  2589. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2590. }
  2591. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2592. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2593. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2594. return ok
  2595. }
  2596. // ResetAppID resets all changes to the "app_id" field.
  2597. func (m *AliyunAvatarMutation) ResetAppID() {
  2598. m.app_id = nil
  2599. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2600. }
  2601. // SetTenantID sets the "tenant_id" field.
  2602. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2603. m.tenant_id = &u
  2604. m.addtenant_id = nil
  2605. }
  2606. // TenantID returns the value of the "tenant_id" field in the mutation.
  2607. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2608. v := m.tenant_id
  2609. if v == nil {
  2610. return
  2611. }
  2612. return *v, true
  2613. }
  2614. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2615. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2617. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2618. if !m.op.Is(OpUpdateOne) {
  2619. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2620. }
  2621. if m.id == nil || m.oldValue == nil {
  2622. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2623. }
  2624. oldValue, err := m.oldValue(ctx)
  2625. if err != nil {
  2626. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2627. }
  2628. return oldValue.TenantID, nil
  2629. }
  2630. // AddTenantID adds u to the "tenant_id" field.
  2631. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2632. if m.addtenant_id != nil {
  2633. *m.addtenant_id += u
  2634. } else {
  2635. m.addtenant_id = &u
  2636. }
  2637. }
  2638. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2639. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2640. v := m.addtenant_id
  2641. if v == nil {
  2642. return
  2643. }
  2644. return *v, true
  2645. }
  2646. // ResetTenantID resets all changes to the "tenant_id" field.
  2647. func (m *AliyunAvatarMutation) ResetTenantID() {
  2648. m.tenant_id = nil
  2649. m.addtenant_id = nil
  2650. }
  2651. // SetResponse sets the "response" field.
  2652. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2653. m.response = &s
  2654. }
  2655. // Response returns the value of the "response" field in the mutation.
  2656. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2657. v := m.response
  2658. if v == nil {
  2659. return
  2660. }
  2661. return *v, true
  2662. }
  2663. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2664. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2666. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2667. if !m.op.Is(OpUpdateOne) {
  2668. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2669. }
  2670. if m.id == nil || m.oldValue == nil {
  2671. return v, errors.New("OldResponse requires an ID field in the mutation")
  2672. }
  2673. oldValue, err := m.oldValue(ctx)
  2674. if err != nil {
  2675. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2676. }
  2677. return oldValue.Response, nil
  2678. }
  2679. // ResetResponse resets all changes to the "response" field.
  2680. func (m *AliyunAvatarMutation) ResetResponse() {
  2681. m.response = nil
  2682. }
  2683. // SetToken sets the "token" field.
  2684. func (m *AliyunAvatarMutation) SetToken(s string) {
  2685. m.token = &s
  2686. }
  2687. // Token returns the value of the "token" field in the mutation.
  2688. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2689. v := m.token
  2690. if v == nil {
  2691. return
  2692. }
  2693. return *v, true
  2694. }
  2695. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2696. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2697. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2698. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2699. if !m.op.Is(OpUpdateOne) {
  2700. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2701. }
  2702. if m.id == nil || m.oldValue == nil {
  2703. return v, errors.New("OldToken requires an ID field in the mutation")
  2704. }
  2705. oldValue, err := m.oldValue(ctx)
  2706. if err != nil {
  2707. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2708. }
  2709. return oldValue.Token, nil
  2710. }
  2711. // ResetToken resets all changes to the "token" field.
  2712. func (m *AliyunAvatarMutation) ResetToken() {
  2713. m.token = nil
  2714. }
  2715. // SetSessionID sets the "session_id" field.
  2716. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2717. m.session_id = &s
  2718. }
  2719. // SessionID returns the value of the "session_id" field in the mutation.
  2720. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2721. v := m.session_id
  2722. if v == nil {
  2723. return
  2724. }
  2725. return *v, true
  2726. }
  2727. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2728. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2729. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2730. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2731. if !m.op.Is(OpUpdateOne) {
  2732. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2733. }
  2734. if m.id == nil || m.oldValue == nil {
  2735. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2736. }
  2737. oldValue, err := m.oldValue(ctx)
  2738. if err != nil {
  2739. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2740. }
  2741. return oldValue.SessionID, nil
  2742. }
  2743. // ResetSessionID resets all changes to the "session_id" field.
  2744. func (m *AliyunAvatarMutation) ResetSessionID() {
  2745. m.session_id = nil
  2746. }
  2747. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2748. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2749. m.predicates = append(m.predicates, ps...)
  2750. }
  2751. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2752. // users can use type-assertion to append predicates that do not depend on any generated package.
  2753. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2754. p := make([]predicate.AliyunAvatar, len(ps))
  2755. for i := range ps {
  2756. p[i] = ps[i]
  2757. }
  2758. m.Where(p...)
  2759. }
  2760. // Op returns the operation name.
  2761. func (m *AliyunAvatarMutation) Op() Op {
  2762. return m.op
  2763. }
  2764. // SetOp allows setting the mutation operation.
  2765. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2766. m.op = op
  2767. }
  2768. // Type returns the node type of this mutation (AliyunAvatar).
  2769. func (m *AliyunAvatarMutation) Type() string {
  2770. return m.typ
  2771. }
  2772. // Fields returns all fields that were changed during this mutation. Note that in
  2773. // order to get all numeric fields that were incremented/decremented, call
  2774. // AddedFields().
  2775. func (m *AliyunAvatarMutation) Fields() []string {
  2776. fields := make([]string, 0, 12)
  2777. if m.created_at != nil {
  2778. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2779. }
  2780. if m.updated_at != nil {
  2781. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2782. }
  2783. if m.deleted_at != nil {
  2784. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2785. }
  2786. if m.user_id != nil {
  2787. fields = append(fields, aliyunavatar.FieldUserID)
  2788. }
  2789. if m.biz_id != nil {
  2790. fields = append(fields, aliyunavatar.FieldBizID)
  2791. }
  2792. if m.access_key_id != nil {
  2793. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2794. }
  2795. if m.access_key_secret != nil {
  2796. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2797. }
  2798. if m.app_id != nil {
  2799. fields = append(fields, aliyunavatar.FieldAppID)
  2800. }
  2801. if m.tenant_id != nil {
  2802. fields = append(fields, aliyunavatar.FieldTenantID)
  2803. }
  2804. if m.response != nil {
  2805. fields = append(fields, aliyunavatar.FieldResponse)
  2806. }
  2807. if m.token != nil {
  2808. fields = append(fields, aliyunavatar.FieldToken)
  2809. }
  2810. if m.session_id != nil {
  2811. fields = append(fields, aliyunavatar.FieldSessionID)
  2812. }
  2813. return fields
  2814. }
  2815. // Field returns the value of a field with the given name. The second boolean
  2816. // return value indicates that this field was not set, or was not defined in the
  2817. // schema.
  2818. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2819. switch name {
  2820. case aliyunavatar.FieldCreatedAt:
  2821. return m.CreatedAt()
  2822. case aliyunavatar.FieldUpdatedAt:
  2823. return m.UpdatedAt()
  2824. case aliyunavatar.FieldDeletedAt:
  2825. return m.DeletedAt()
  2826. case aliyunavatar.FieldUserID:
  2827. return m.UserID()
  2828. case aliyunavatar.FieldBizID:
  2829. return m.BizID()
  2830. case aliyunavatar.FieldAccessKeyID:
  2831. return m.AccessKeyID()
  2832. case aliyunavatar.FieldAccessKeySecret:
  2833. return m.AccessKeySecret()
  2834. case aliyunavatar.FieldAppID:
  2835. return m.AppID()
  2836. case aliyunavatar.FieldTenantID:
  2837. return m.TenantID()
  2838. case aliyunavatar.FieldResponse:
  2839. return m.Response()
  2840. case aliyunavatar.FieldToken:
  2841. return m.Token()
  2842. case aliyunavatar.FieldSessionID:
  2843. return m.SessionID()
  2844. }
  2845. return nil, false
  2846. }
  2847. // OldField returns the old value of the field from the database. An error is
  2848. // returned if the mutation operation is not UpdateOne, or the query to the
  2849. // database failed.
  2850. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2851. switch name {
  2852. case aliyunavatar.FieldCreatedAt:
  2853. return m.OldCreatedAt(ctx)
  2854. case aliyunavatar.FieldUpdatedAt:
  2855. return m.OldUpdatedAt(ctx)
  2856. case aliyunavatar.FieldDeletedAt:
  2857. return m.OldDeletedAt(ctx)
  2858. case aliyunavatar.FieldUserID:
  2859. return m.OldUserID(ctx)
  2860. case aliyunavatar.FieldBizID:
  2861. return m.OldBizID(ctx)
  2862. case aliyunavatar.FieldAccessKeyID:
  2863. return m.OldAccessKeyID(ctx)
  2864. case aliyunavatar.FieldAccessKeySecret:
  2865. return m.OldAccessKeySecret(ctx)
  2866. case aliyunavatar.FieldAppID:
  2867. return m.OldAppID(ctx)
  2868. case aliyunavatar.FieldTenantID:
  2869. return m.OldTenantID(ctx)
  2870. case aliyunavatar.FieldResponse:
  2871. return m.OldResponse(ctx)
  2872. case aliyunavatar.FieldToken:
  2873. return m.OldToken(ctx)
  2874. case aliyunavatar.FieldSessionID:
  2875. return m.OldSessionID(ctx)
  2876. }
  2877. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2878. }
  2879. // SetField sets the value of a field with the given name. It returns an error if
  2880. // the field is not defined in the schema, or if the type mismatched the field
  2881. // type.
  2882. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2883. switch name {
  2884. case aliyunavatar.FieldCreatedAt:
  2885. v, ok := value.(time.Time)
  2886. if !ok {
  2887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2888. }
  2889. m.SetCreatedAt(v)
  2890. return nil
  2891. case aliyunavatar.FieldUpdatedAt:
  2892. v, ok := value.(time.Time)
  2893. if !ok {
  2894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2895. }
  2896. m.SetUpdatedAt(v)
  2897. return nil
  2898. case aliyunavatar.FieldDeletedAt:
  2899. v, ok := value.(time.Time)
  2900. if !ok {
  2901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2902. }
  2903. m.SetDeletedAt(v)
  2904. return nil
  2905. case aliyunavatar.FieldUserID:
  2906. v, ok := value.(uint64)
  2907. if !ok {
  2908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2909. }
  2910. m.SetUserID(v)
  2911. return nil
  2912. case aliyunavatar.FieldBizID:
  2913. v, ok := value.(string)
  2914. if !ok {
  2915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2916. }
  2917. m.SetBizID(v)
  2918. return nil
  2919. case aliyunavatar.FieldAccessKeyID:
  2920. v, ok := value.(string)
  2921. if !ok {
  2922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2923. }
  2924. m.SetAccessKeyID(v)
  2925. return nil
  2926. case aliyunavatar.FieldAccessKeySecret:
  2927. v, ok := value.(string)
  2928. if !ok {
  2929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2930. }
  2931. m.SetAccessKeySecret(v)
  2932. return nil
  2933. case aliyunavatar.FieldAppID:
  2934. v, ok := value.(string)
  2935. if !ok {
  2936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2937. }
  2938. m.SetAppID(v)
  2939. return nil
  2940. case aliyunavatar.FieldTenantID:
  2941. v, ok := value.(uint64)
  2942. if !ok {
  2943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2944. }
  2945. m.SetTenantID(v)
  2946. return nil
  2947. case aliyunavatar.FieldResponse:
  2948. v, ok := value.(string)
  2949. if !ok {
  2950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2951. }
  2952. m.SetResponse(v)
  2953. return nil
  2954. case aliyunavatar.FieldToken:
  2955. v, ok := value.(string)
  2956. if !ok {
  2957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2958. }
  2959. m.SetToken(v)
  2960. return nil
  2961. case aliyunavatar.FieldSessionID:
  2962. v, ok := value.(string)
  2963. if !ok {
  2964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2965. }
  2966. m.SetSessionID(v)
  2967. return nil
  2968. }
  2969. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  2970. }
  2971. // AddedFields returns all numeric fields that were incremented/decremented during
  2972. // this mutation.
  2973. func (m *AliyunAvatarMutation) AddedFields() []string {
  2974. var fields []string
  2975. if m.adduser_id != nil {
  2976. fields = append(fields, aliyunavatar.FieldUserID)
  2977. }
  2978. if m.addtenant_id != nil {
  2979. fields = append(fields, aliyunavatar.FieldTenantID)
  2980. }
  2981. return fields
  2982. }
  2983. // AddedField returns the numeric value that was incremented/decremented on a field
  2984. // with the given name. The second boolean return value indicates that this field
  2985. // was not set, or was not defined in the schema.
  2986. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  2987. switch name {
  2988. case aliyunavatar.FieldUserID:
  2989. return m.AddedUserID()
  2990. case aliyunavatar.FieldTenantID:
  2991. return m.AddedTenantID()
  2992. }
  2993. return nil, false
  2994. }
  2995. // AddField adds the value to the field with the given name. It returns an error if
  2996. // the field is not defined in the schema, or if the type mismatched the field
  2997. // type.
  2998. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  2999. switch name {
  3000. case aliyunavatar.FieldUserID:
  3001. v, ok := value.(int64)
  3002. if !ok {
  3003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3004. }
  3005. m.AddUserID(v)
  3006. return nil
  3007. case aliyunavatar.FieldTenantID:
  3008. v, ok := value.(int64)
  3009. if !ok {
  3010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3011. }
  3012. m.AddTenantID(v)
  3013. return nil
  3014. }
  3015. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3016. }
  3017. // ClearedFields returns all nullable fields that were cleared during this
  3018. // mutation.
  3019. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3020. var fields []string
  3021. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3022. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3023. }
  3024. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3025. fields = append(fields, aliyunavatar.FieldAppID)
  3026. }
  3027. return fields
  3028. }
  3029. // FieldCleared returns a boolean indicating if a field with the given name was
  3030. // cleared in this mutation.
  3031. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3032. _, ok := m.clearedFields[name]
  3033. return ok
  3034. }
  3035. // ClearField clears the value of the field with the given name. It returns an
  3036. // error if the field is not defined in the schema.
  3037. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3038. switch name {
  3039. case aliyunavatar.FieldDeletedAt:
  3040. m.ClearDeletedAt()
  3041. return nil
  3042. case aliyunavatar.FieldAppID:
  3043. m.ClearAppID()
  3044. return nil
  3045. }
  3046. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3047. }
  3048. // ResetField resets all changes in the mutation for the field with the given name.
  3049. // It returns an error if the field is not defined in the schema.
  3050. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3051. switch name {
  3052. case aliyunavatar.FieldCreatedAt:
  3053. m.ResetCreatedAt()
  3054. return nil
  3055. case aliyunavatar.FieldUpdatedAt:
  3056. m.ResetUpdatedAt()
  3057. return nil
  3058. case aliyunavatar.FieldDeletedAt:
  3059. m.ResetDeletedAt()
  3060. return nil
  3061. case aliyunavatar.FieldUserID:
  3062. m.ResetUserID()
  3063. return nil
  3064. case aliyunavatar.FieldBizID:
  3065. m.ResetBizID()
  3066. return nil
  3067. case aliyunavatar.FieldAccessKeyID:
  3068. m.ResetAccessKeyID()
  3069. return nil
  3070. case aliyunavatar.FieldAccessKeySecret:
  3071. m.ResetAccessKeySecret()
  3072. return nil
  3073. case aliyunavatar.FieldAppID:
  3074. m.ResetAppID()
  3075. return nil
  3076. case aliyunavatar.FieldTenantID:
  3077. m.ResetTenantID()
  3078. return nil
  3079. case aliyunavatar.FieldResponse:
  3080. m.ResetResponse()
  3081. return nil
  3082. case aliyunavatar.FieldToken:
  3083. m.ResetToken()
  3084. return nil
  3085. case aliyunavatar.FieldSessionID:
  3086. m.ResetSessionID()
  3087. return nil
  3088. }
  3089. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3090. }
  3091. // AddedEdges returns all edge names that were set/added in this mutation.
  3092. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3093. edges := make([]string, 0, 0)
  3094. return edges
  3095. }
  3096. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3097. // name in this mutation.
  3098. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3099. return nil
  3100. }
  3101. // RemovedEdges returns all edge names that were removed in this mutation.
  3102. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3103. edges := make([]string, 0, 0)
  3104. return edges
  3105. }
  3106. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3107. // the given name in this mutation.
  3108. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3109. return nil
  3110. }
  3111. // ClearedEdges returns all edge names that were cleared in this mutation.
  3112. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3113. edges := make([]string, 0, 0)
  3114. return edges
  3115. }
  3116. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3117. // was cleared in this mutation.
  3118. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3119. return false
  3120. }
  3121. // ClearEdge clears the value of the edge with the given name. It returns an error
  3122. // if that edge is not defined in the schema.
  3123. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3124. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3125. }
  3126. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3127. // It returns an error if the edge is not defined in the schema.
  3128. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3129. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3130. }
  3131. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3132. type AllocAgentMutation struct {
  3133. config
  3134. op Op
  3135. typ string
  3136. id *uint64
  3137. created_at *time.Time
  3138. updated_at *time.Time
  3139. deleted_at *time.Time
  3140. user_id *string
  3141. organization_id *uint64
  3142. addorganization_id *int64
  3143. agents *[]uint64
  3144. appendagents []uint64
  3145. status *int
  3146. addstatus *int
  3147. clearedFields map[string]struct{}
  3148. done bool
  3149. oldValue func(context.Context) (*AllocAgent, error)
  3150. predicates []predicate.AllocAgent
  3151. }
  3152. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3153. // allocagentOption allows management of the mutation configuration using functional options.
  3154. type allocagentOption func(*AllocAgentMutation)
  3155. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3156. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3157. m := &AllocAgentMutation{
  3158. config: c,
  3159. op: op,
  3160. typ: TypeAllocAgent,
  3161. clearedFields: make(map[string]struct{}),
  3162. }
  3163. for _, opt := range opts {
  3164. opt(m)
  3165. }
  3166. return m
  3167. }
  3168. // withAllocAgentID sets the ID field of the mutation.
  3169. func withAllocAgentID(id uint64) allocagentOption {
  3170. return func(m *AllocAgentMutation) {
  3171. var (
  3172. err error
  3173. once sync.Once
  3174. value *AllocAgent
  3175. )
  3176. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3177. once.Do(func() {
  3178. if m.done {
  3179. err = errors.New("querying old values post mutation is not allowed")
  3180. } else {
  3181. value, err = m.Client().AllocAgent.Get(ctx, id)
  3182. }
  3183. })
  3184. return value, err
  3185. }
  3186. m.id = &id
  3187. }
  3188. }
  3189. // withAllocAgent sets the old AllocAgent of the mutation.
  3190. func withAllocAgent(node *AllocAgent) allocagentOption {
  3191. return func(m *AllocAgentMutation) {
  3192. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3193. return node, nil
  3194. }
  3195. m.id = &node.ID
  3196. }
  3197. }
  3198. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3199. // executed in a transaction (ent.Tx), a transactional client is returned.
  3200. func (m AllocAgentMutation) Client() *Client {
  3201. client := &Client{config: m.config}
  3202. client.init()
  3203. return client
  3204. }
  3205. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3206. // it returns an error otherwise.
  3207. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3208. if _, ok := m.driver.(*txDriver); !ok {
  3209. return nil, errors.New("ent: mutation is not running in a transaction")
  3210. }
  3211. tx := &Tx{config: m.config}
  3212. tx.init()
  3213. return tx, nil
  3214. }
  3215. // SetID sets the value of the id field. Note that this
  3216. // operation is only accepted on creation of AllocAgent entities.
  3217. func (m *AllocAgentMutation) SetID(id uint64) {
  3218. m.id = &id
  3219. }
  3220. // ID returns the ID value in the mutation. Note that the ID is only available
  3221. // if it was provided to the builder or after it was returned from the database.
  3222. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3223. if m.id == nil {
  3224. return
  3225. }
  3226. return *m.id, true
  3227. }
  3228. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3229. // That means, if the mutation is applied within a transaction with an isolation level such
  3230. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3231. // or updated by the mutation.
  3232. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3233. switch {
  3234. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3235. id, exists := m.ID()
  3236. if exists {
  3237. return []uint64{id}, nil
  3238. }
  3239. fallthrough
  3240. case m.op.Is(OpUpdate | OpDelete):
  3241. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3242. default:
  3243. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3244. }
  3245. }
  3246. // SetCreatedAt sets the "created_at" field.
  3247. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3248. m.created_at = &t
  3249. }
  3250. // CreatedAt returns the value of the "created_at" field in the mutation.
  3251. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3252. v := m.created_at
  3253. if v == nil {
  3254. return
  3255. }
  3256. return *v, true
  3257. }
  3258. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3259. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3261. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3262. if !m.op.Is(OpUpdateOne) {
  3263. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3264. }
  3265. if m.id == nil || m.oldValue == nil {
  3266. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3267. }
  3268. oldValue, err := m.oldValue(ctx)
  3269. if err != nil {
  3270. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3271. }
  3272. return oldValue.CreatedAt, nil
  3273. }
  3274. // ResetCreatedAt resets all changes to the "created_at" field.
  3275. func (m *AllocAgentMutation) ResetCreatedAt() {
  3276. m.created_at = nil
  3277. }
  3278. // SetUpdatedAt sets the "updated_at" field.
  3279. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3280. m.updated_at = &t
  3281. }
  3282. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3283. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3284. v := m.updated_at
  3285. if v == nil {
  3286. return
  3287. }
  3288. return *v, true
  3289. }
  3290. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3291. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3292. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3293. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3294. if !m.op.Is(OpUpdateOne) {
  3295. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3296. }
  3297. if m.id == nil || m.oldValue == nil {
  3298. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3299. }
  3300. oldValue, err := m.oldValue(ctx)
  3301. if err != nil {
  3302. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3303. }
  3304. return oldValue.UpdatedAt, nil
  3305. }
  3306. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3307. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3308. m.updated_at = nil
  3309. }
  3310. // SetDeletedAt sets the "deleted_at" field.
  3311. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3312. m.deleted_at = &t
  3313. }
  3314. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3315. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3316. v := m.deleted_at
  3317. if v == nil {
  3318. return
  3319. }
  3320. return *v, true
  3321. }
  3322. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3323. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3325. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3326. if !m.op.Is(OpUpdateOne) {
  3327. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3328. }
  3329. if m.id == nil || m.oldValue == nil {
  3330. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3331. }
  3332. oldValue, err := m.oldValue(ctx)
  3333. if err != nil {
  3334. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3335. }
  3336. return oldValue.DeletedAt, nil
  3337. }
  3338. // ClearDeletedAt clears the value of the "deleted_at" field.
  3339. func (m *AllocAgentMutation) ClearDeletedAt() {
  3340. m.deleted_at = nil
  3341. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3342. }
  3343. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3344. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3345. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3346. return ok
  3347. }
  3348. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3349. func (m *AllocAgentMutation) ResetDeletedAt() {
  3350. m.deleted_at = nil
  3351. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3352. }
  3353. // SetUserID sets the "user_id" field.
  3354. func (m *AllocAgentMutation) SetUserID(s string) {
  3355. m.user_id = &s
  3356. }
  3357. // UserID returns the value of the "user_id" field in the mutation.
  3358. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3359. v := m.user_id
  3360. if v == nil {
  3361. return
  3362. }
  3363. return *v, true
  3364. }
  3365. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3366. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3368. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3369. if !m.op.Is(OpUpdateOne) {
  3370. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3371. }
  3372. if m.id == nil || m.oldValue == nil {
  3373. return v, errors.New("OldUserID requires an ID field in the mutation")
  3374. }
  3375. oldValue, err := m.oldValue(ctx)
  3376. if err != nil {
  3377. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3378. }
  3379. return oldValue.UserID, nil
  3380. }
  3381. // ClearUserID clears the value of the "user_id" field.
  3382. func (m *AllocAgentMutation) ClearUserID() {
  3383. m.user_id = nil
  3384. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3385. }
  3386. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3387. func (m *AllocAgentMutation) UserIDCleared() bool {
  3388. _, ok := m.clearedFields[allocagent.FieldUserID]
  3389. return ok
  3390. }
  3391. // ResetUserID resets all changes to the "user_id" field.
  3392. func (m *AllocAgentMutation) ResetUserID() {
  3393. m.user_id = nil
  3394. delete(m.clearedFields, allocagent.FieldUserID)
  3395. }
  3396. // SetOrganizationID sets the "organization_id" field.
  3397. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3398. m.organization_id = &u
  3399. m.addorganization_id = nil
  3400. }
  3401. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3402. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3403. v := m.organization_id
  3404. if v == nil {
  3405. return
  3406. }
  3407. return *v, true
  3408. }
  3409. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3410. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3412. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3413. if !m.op.Is(OpUpdateOne) {
  3414. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3415. }
  3416. if m.id == nil || m.oldValue == nil {
  3417. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3418. }
  3419. oldValue, err := m.oldValue(ctx)
  3420. if err != nil {
  3421. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3422. }
  3423. return oldValue.OrganizationID, nil
  3424. }
  3425. // AddOrganizationID adds u to the "organization_id" field.
  3426. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3427. if m.addorganization_id != nil {
  3428. *m.addorganization_id += u
  3429. } else {
  3430. m.addorganization_id = &u
  3431. }
  3432. }
  3433. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3434. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3435. v := m.addorganization_id
  3436. if v == nil {
  3437. return
  3438. }
  3439. return *v, true
  3440. }
  3441. // ClearOrganizationID clears the value of the "organization_id" field.
  3442. func (m *AllocAgentMutation) ClearOrganizationID() {
  3443. m.organization_id = nil
  3444. m.addorganization_id = nil
  3445. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3446. }
  3447. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3448. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3449. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3450. return ok
  3451. }
  3452. // ResetOrganizationID resets all changes to the "organization_id" field.
  3453. func (m *AllocAgentMutation) ResetOrganizationID() {
  3454. m.organization_id = nil
  3455. m.addorganization_id = nil
  3456. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3457. }
  3458. // SetAgents sets the "agents" field.
  3459. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3460. m.agents = &u
  3461. m.appendagents = nil
  3462. }
  3463. // Agents returns the value of the "agents" field in the mutation.
  3464. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3465. v := m.agents
  3466. if v == nil {
  3467. return
  3468. }
  3469. return *v, true
  3470. }
  3471. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3472. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3474. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3475. if !m.op.Is(OpUpdateOne) {
  3476. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3477. }
  3478. if m.id == nil || m.oldValue == nil {
  3479. return v, errors.New("OldAgents requires an ID field in the mutation")
  3480. }
  3481. oldValue, err := m.oldValue(ctx)
  3482. if err != nil {
  3483. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3484. }
  3485. return oldValue.Agents, nil
  3486. }
  3487. // AppendAgents adds u to the "agents" field.
  3488. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3489. m.appendagents = append(m.appendagents, u...)
  3490. }
  3491. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3492. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3493. if len(m.appendagents) == 0 {
  3494. return nil, false
  3495. }
  3496. return m.appendagents, true
  3497. }
  3498. // ResetAgents resets all changes to the "agents" field.
  3499. func (m *AllocAgentMutation) ResetAgents() {
  3500. m.agents = nil
  3501. m.appendagents = nil
  3502. }
  3503. // SetStatus sets the "status" field.
  3504. func (m *AllocAgentMutation) SetStatus(i int) {
  3505. m.status = &i
  3506. m.addstatus = nil
  3507. }
  3508. // Status returns the value of the "status" field in the mutation.
  3509. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3510. v := m.status
  3511. if v == nil {
  3512. return
  3513. }
  3514. return *v, true
  3515. }
  3516. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3517. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3519. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3520. if !m.op.Is(OpUpdateOne) {
  3521. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3522. }
  3523. if m.id == nil || m.oldValue == nil {
  3524. return v, errors.New("OldStatus requires an ID field in the mutation")
  3525. }
  3526. oldValue, err := m.oldValue(ctx)
  3527. if err != nil {
  3528. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3529. }
  3530. return oldValue.Status, nil
  3531. }
  3532. // AddStatus adds i to the "status" field.
  3533. func (m *AllocAgentMutation) AddStatus(i int) {
  3534. if m.addstatus != nil {
  3535. *m.addstatus += i
  3536. } else {
  3537. m.addstatus = &i
  3538. }
  3539. }
  3540. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3541. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3542. v := m.addstatus
  3543. if v == nil {
  3544. return
  3545. }
  3546. return *v, true
  3547. }
  3548. // ClearStatus clears the value of the "status" field.
  3549. func (m *AllocAgentMutation) ClearStatus() {
  3550. m.status = nil
  3551. m.addstatus = nil
  3552. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3553. }
  3554. // StatusCleared returns if the "status" field was cleared in this mutation.
  3555. func (m *AllocAgentMutation) StatusCleared() bool {
  3556. _, ok := m.clearedFields[allocagent.FieldStatus]
  3557. return ok
  3558. }
  3559. // ResetStatus resets all changes to the "status" field.
  3560. func (m *AllocAgentMutation) ResetStatus() {
  3561. m.status = nil
  3562. m.addstatus = nil
  3563. delete(m.clearedFields, allocagent.FieldStatus)
  3564. }
  3565. // Where appends a list predicates to the AllocAgentMutation builder.
  3566. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3567. m.predicates = append(m.predicates, ps...)
  3568. }
  3569. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3570. // users can use type-assertion to append predicates that do not depend on any generated package.
  3571. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3572. p := make([]predicate.AllocAgent, len(ps))
  3573. for i := range ps {
  3574. p[i] = ps[i]
  3575. }
  3576. m.Where(p...)
  3577. }
  3578. // Op returns the operation name.
  3579. func (m *AllocAgentMutation) Op() Op {
  3580. return m.op
  3581. }
  3582. // SetOp allows setting the mutation operation.
  3583. func (m *AllocAgentMutation) SetOp(op Op) {
  3584. m.op = op
  3585. }
  3586. // Type returns the node type of this mutation (AllocAgent).
  3587. func (m *AllocAgentMutation) Type() string {
  3588. return m.typ
  3589. }
  3590. // Fields returns all fields that were changed during this mutation. Note that in
  3591. // order to get all numeric fields that were incremented/decremented, call
  3592. // AddedFields().
  3593. func (m *AllocAgentMutation) Fields() []string {
  3594. fields := make([]string, 0, 7)
  3595. if m.created_at != nil {
  3596. fields = append(fields, allocagent.FieldCreatedAt)
  3597. }
  3598. if m.updated_at != nil {
  3599. fields = append(fields, allocagent.FieldUpdatedAt)
  3600. }
  3601. if m.deleted_at != nil {
  3602. fields = append(fields, allocagent.FieldDeletedAt)
  3603. }
  3604. if m.user_id != nil {
  3605. fields = append(fields, allocagent.FieldUserID)
  3606. }
  3607. if m.organization_id != nil {
  3608. fields = append(fields, allocagent.FieldOrganizationID)
  3609. }
  3610. if m.agents != nil {
  3611. fields = append(fields, allocagent.FieldAgents)
  3612. }
  3613. if m.status != nil {
  3614. fields = append(fields, allocagent.FieldStatus)
  3615. }
  3616. return fields
  3617. }
  3618. // Field returns the value of a field with the given name. The second boolean
  3619. // return value indicates that this field was not set, or was not defined in the
  3620. // schema.
  3621. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3622. switch name {
  3623. case allocagent.FieldCreatedAt:
  3624. return m.CreatedAt()
  3625. case allocagent.FieldUpdatedAt:
  3626. return m.UpdatedAt()
  3627. case allocagent.FieldDeletedAt:
  3628. return m.DeletedAt()
  3629. case allocagent.FieldUserID:
  3630. return m.UserID()
  3631. case allocagent.FieldOrganizationID:
  3632. return m.OrganizationID()
  3633. case allocagent.FieldAgents:
  3634. return m.Agents()
  3635. case allocagent.FieldStatus:
  3636. return m.Status()
  3637. }
  3638. return nil, false
  3639. }
  3640. // OldField returns the old value of the field from the database. An error is
  3641. // returned if the mutation operation is not UpdateOne, or the query to the
  3642. // database failed.
  3643. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3644. switch name {
  3645. case allocagent.FieldCreatedAt:
  3646. return m.OldCreatedAt(ctx)
  3647. case allocagent.FieldUpdatedAt:
  3648. return m.OldUpdatedAt(ctx)
  3649. case allocagent.FieldDeletedAt:
  3650. return m.OldDeletedAt(ctx)
  3651. case allocagent.FieldUserID:
  3652. return m.OldUserID(ctx)
  3653. case allocagent.FieldOrganizationID:
  3654. return m.OldOrganizationID(ctx)
  3655. case allocagent.FieldAgents:
  3656. return m.OldAgents(ctx)
  3657. case allocagent.FieldStatus:
  3658. return m.OldStatus(ctx)
  3659. }
  3660. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3661. }
  3662. // SetField sets the value of a field with the given name. It returns an error if
  3663. // the field is not defined in the schema, or if the type mismatched the field
  3664. // type.
  3665. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3666. switch name {
  3667. case allocagent.FieldCreatedAt:
  3668. v, ok := value.(time.Time)
  3669. if !ok {
  3670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3671. }
  3672. m.SetCreatedAt(v)
  3673. return nil
  3674. case allocagent.FieldUpdatedAt:
  3675. v, ok := value.(time.Time)
  3676. if !ok {
  3677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3678. }
  3679. m.SetUpdatedAt(v)
  3680. return nil
  3681. case allocagent.FieldDeletedAt:
  3682. v, ok := value.(time.Time)
  3683. if !ok {
  3684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3685. }
  3686. m.SetDeletedAt(v)
  3687. return nil
  3688. case allocagent.FieldUserID:
  3689. v, ok := value.(string)
  3690. if !ok {
  3691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3692. }
  3693. m.SetUserID(v)
  3694. return nil
  3695. case allocagent.FieldOrganizationID:
  3696. v, ok := value.(uint64)
  3697. if !ok {
  3698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3699. }
  3700. m.SetOrganizationID(v)
  3701. return nil
  3702. case allocagent.FieldAgents:
  3703. v, ok := value.([]uint64)
  3704. if !ok {
  3705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3706. }
  3707. m.SetAgents(v)
  3708. return nil
  3709. case allocagent.FieldStatus:
  3710. v, ok := value.(int)
  3711. if !ok {
  3712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3713. }
  3714. m.SetStatus(v)
  3715. return nil
  3716. }
  3717. return fmt.Errorf("unknown AllocAgent field %s", name)
  3718. }
  3719. // AddedFields returns all numeric fields that were incremented/decremented during
  3720. // this mutation.
  3721. func (m *AllocAgentMutation) AddedFields() []string {
  3722. var fields []string
  3723. if m.addorganization_id != nil {
  3724. fields = append(fields, allocagent.FieldOrganizationID)
  3725. }
  3726. if m.addstatus != nil {
  3727. fields = append(fields, allocagent.FieldStatus)
  3728. }
  3729. return fields
  3730. }
  3731. // AddedField returns the numeric value that was incremented/decremented on a field
  3732. // with the given name. The second boolean return value indicates that this field
  3733. // was not set, or was not defined in the schema.
  3734. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3735. switch name {
  3736. case allocagent.FieldOrganizationID:
  3737. return m.AddedOrganizationID()
  3738. case allocagent.FieldStatus:
  3739. return m.AddedStatus()
  3740. }
  3741. return nil, false
  3742. }
  3743. // AddField adds the value to the field with the given name. It returns an error if
  3744. // the field is not defined in the schema, or if the type mismatched the field
  3745. // type.
  3746. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3747. switch name {
  3748. case allocagent.FieldOrganizationID:
  3749. v, ok := value.(int64)
  3750. if !ok {
  3751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3752. }
  3753. m.AddOrganizationID(v)
  3754. return nil
  3755. case allocagent.FieldStatus:
  3756. v, ok := value.(int)
  3757. if !ok {
  3758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3759. }
  3760. m.AddStatus(v)
  3761. return nil
  3762. }
  3763. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  3764. }
  3765. // ClearedFields returns all nullable fields that were cleared during this
  3766. // mutation.
  3767. func (m *AllocAgentMutation) ClearedFields() []string {
  3768. var fields []string
  3769. if m.FieldCleared(allocagent.FieldDeletedAt) {
  3770. fields = append(fields, allocagent.FieldDeletedAt)
  3771. }
  3772. if m.FieldCleared(allocagent.FieldUserID) {
  3773. fields = append(fields, allocagent.FieldUserID)
  3774. }
  3775. if m.FieldCleared(allocagent.FieldOrganizationID) {
  3776. fields = append(fields, allocagent.FieldOrganizationID)
  3777. }
  3778. if m.FieldCleared(allocagent.FieldStatus) {
  3779. fields = append(fields, allocagent.FieldStatus)
  3780. }
  3781. return fields
  3782. }
  3783. // FieldCleared returns a boolean indicating if a field with the given name was
  3784. // cleared in this mutation.
  3785. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  3786. _, ok := m.clearedFields[name]
  3787. return ok
  3788. }
  3789. // ClearField clears the value of the field with the given name. It returns an
  3790. // error if the field is not defined in the schema.
  3791. func (m *AllocAgentMutation) ClearField(name string) error {
  3792. switch name {
  3793. case allocagent.FieldDeletedAt:
  3794. m.ClearDeletedAt()
  3795. return nil
  3796. case allocagent.FieldUserID:
  3797. m.ClearUserID()
  3798. return nil
  3799. case allocagent.FieldOrganizationID:
  3800. m.ClearOrganizationID()
  3801. return nil
  3802. case allocagent.FieldStatus:
  3803. m.ClearStatus()
  3804. return nil
  3805. }
  3806. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  3807. }
  3808. // ResetField resets all changes in the mutation for the field with the given name.
  3809. // It returns an error if the field is not defined in the schema.
  3810. func (m *AllocAgentMutation) ResetField(name string) error {
  3811. switch name {
  3812. case allocagent.FieldCreatedAt:
  3813. m.ResetCreatedAt()
  3814. return nil
  3815. case allocagent.FieldUpdatedAt:
  3816. m.ResetUpdatedAt()
  3817. return nil
  3818. case allocagent.FieldDeletedAt:
  3819. m.ResetDeletedAt()
  3820. return nil
  3821. case allocagent.FieldUserID:
  3822. m.ResetUserID()
  3823. return nil
  3824. case allocagent.FieldOrganizationID:
  3825. m.ResetOrganizationID()
  3826. return nil
  3827. case allocagent.FieldAgents:
  3828. m.ResetAgents()
  3829. return nil
  3830. case allocagent.FieldStatus:
  3831. m.ResetStatus()
  3832. return nil
  3833. }
  3834. return fmt.Errorf("unknown AllocAgent field %s", name)
  3835. }
  3836. // AddedEdges returns all edge names that were set/added in this mutation.
  3837. func (m *AllocAgentMutation) AddedEdges() []string {
  3838. edges := make([]string, 0, 0)
  3839. return edges
  3840. }
  3841. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3842. // name in this mutation.
  3843. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  3844. return nil
  3845. }
  3846. // RemovedEdges returns all edge names that were removed in this mutation.
  3847. func (m *AllocAgentMutation) RemovedEdges() []string {
  3848. edges := make([]string, 0, 0)
  3849. return edges
  3850. }
  3851. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3852. // the given name in this mutation.
  3853. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  3854. return nil
  3855. }
  3856. // ClearedEdges returns all edge names that were cleared in this mutation.
  3857. func (m *AllocAgentMutation) ClearedEdges() []string {
  3858. edges := make([]string, 0, 0)
  3859. return edges
  3860. }
  3861. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3862. // was cleared in this mutation.
  3863. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  3864. return false
  3865. }
  3866. // ClearEdge clears the value of the edge with the given name. It returns an error
  3867. // if that edge is not defined in the schema.
  3868. func (m *AllocAgentMutation) ClearEdge(name string) error {
  3869. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  3870. }
  3871. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3872. // It returns an error if the edge is not defined in the schema.
  3873. func (m *AllocAgentMutation) ResetEdge(name string) error {
  3874. return fmt.Errorf("unknown AllocAgent edge %s", name)
  3875. }
  3876. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3877. type BatchMsgMutation struct {
  3878. config
  3879. op Op
  3880. typ string
  3881. id *uint64
  3882. created_at *time.Time
  3883. updated_at *time.Time
  3884. deleted_at *time.Time
  3885. status *uint8
  3886. addstatus *int8
  3887. batch_no *string
  3888. task_name *string
  3889. fromwxid *string
  3890. msg *string
  3891. tag *string
  3892. tagids *string
  3893. total *int32
  3894. addtotal *int32
  3895. success *int32
  3896. addsuccess *int32
  3897. fail *int32
  3898. addfail *int32
  3899. start_time *time.Time
  3900. stop_time *time.Time
  3901. send_time *time.Time
  3902. _type *int32
  3903. add_type *int32
  3904. organization_id *uint64
  3905. addorganization_id *int64
  3906. clearedFields map[string]struct{}
  3907. done bool
  3908. oldValue func(context.Context) (*BatchMsg, error)
  3909. predicates []predicate.BatchMsg
  3910. }
  3911. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  3912. // batchmsgOption allows management of the mutation configuration using functional options.
  3913. type batchmsgOption func(*BatchMsgMutation)
  3914. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  3915. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  3916. m := &BatchMsgMutation{
  3917. config: c,
  3918. op: op,
  3919. typ: TypeBatchMsg,
  3920. clearedFields: make(map[string]struct{}),
  3921. }
  3922. for _, opt := range opts {
  3923. opt(m)
  3924. }
  3925. return m
  3926. }
  3927. // withBatchMsgID sets the ID field of the mutation.
  3928. func withBatchMsgID(id uint64) batchmsgOption {
  3929. return func(m *BatchMsgMutation) {
  3930. var (
  3931. err error
  3932. once sync.Once
  3933. value *BatchMsg
  3934. )
  3935. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  3936. once.Do(func() {
  3937. if m.done {
  3938. err = errors.New("querying old values post mutation is not allowed")
  3939. } else {
  3940. value, err = m.Client().BatchMsg.Get(ctx, id)
  3941. }
  3942. })
  3943. return value, err
  3944. }
  3945. m.id = &id
  3946. }
  3947. }
  3948. // withBatchMsg sets the old BatchMsg of the mutation.
  3949. func withBatchMsg(node *BatchMsg) batchmsgOption {
  3950. return func(m *BatchMsgMutation) {
  3951. m.oldValue = func(context.Context) (*BatchMsg, error) {
  3952. return node, nil
  3953. }
  3954. m.id = &node.ID
  3955. }
  3956. }
  3957. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3958. // executed in a transaction (ent.Tx), a transactional client is returned.
  3959. func (m BatchMsgMutation) Client() *Client {
  3960. client := &Client{config: m.config}
  3961. client.init()
  3962. return client
  3963. }
  3964. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3965. // it returns an error otherwise.
  3966. func (m BatchMsgMutation) Tx() (*Tx, error) {
  3967. if _, ok := m.driver.(*txDriver); !ok {
  3968. return nil, errors.New("ent: mutation is not running in a transaction")
  3969. }
  3970. tx := &Tx{config: m.config}
  3971. tx.init()
  3972. return tx, nil
  3973. }
  3974. // SetID sets the value of the id field. Note that this
  3975. // operation is only accepted on creation of BatchMsg entities.
  3976. func (m *BatchMsgMutation) SetID(id uint64) {
  3977. m.id = &id
  3978. }
  3979. // ID returns the ID value in the mutation. Note that the ID is only available
  3980. // if it was provided to the builder or after it was returned from the database.
  3981. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  3982. if m.id == nil {
  3983. return
  3984. }
  3985. return *m.id, true
  3986. }
  3987. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3988. // That means, if the mutation is applied within a transaction with an isolation level such
  3989. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3990. // or updated by the mutation.
  3991. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  3992. switch {
  3993. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3994. id, exists := m.ID()
  3995. if exists {
  3996. return []uint64{id}, nil
  3997. }
  3998. fallthrough
  3999. case m.op.Is(OpUpdate | OpDelete):
  4000. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  4001. default:
  4002. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4003. }
  4004. }
  4005. // SetCreatedAt sets the "created_at" field.
  4006. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  4007. m.created_at = &t
  4008. }
  4009. // CreatedAt returns the value of the "created_at" field in the mutation.
  4010. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  4011. v := m.created_at
  4012. if v == nil {
  4013. return
  4014. }
  4015. return *v, true
  4016. }
  4017. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  4018. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4020. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4021. if !m.op.Is(OpUpdateOne) {
  4022. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4023. }
  4024. if m.id == nil || m.oldValue == nil {
  4025. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4026. }
  4027. oldValue, err := m.oldValue(ctx)
  4028. if err != nil {
  4029. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4030. }
  4031. return oldValue.CreatedAt, nil
  4032. }
  4033. // ResetCreatedAt resets all changes to the "created_at" field.
  4034. func (m *BatchMsgMutation) ResetCreatedAt() {
  4035. m.created_at = nil
  4036. }
  4037. // SetUpdatedAt sets the "updated_at" field.
  4038. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  4039. m.updated_at = &t
  4040. }
  4041. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4042. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  4043. v := m.updated_at
  4044. if v == nil {
  4045. return
  4046. }
  4047. return *v, true
  4048. }
  4049. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  4050. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4052. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4053. if !m.op.Is(OpUpdateOne) {
  4054. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4055. }
  4056. if m.id == nil || m.oldValue == nil {
  4057. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4058. }
  4059. oldValue, err := m.oldValue(ctx)
  4060. if err != nil {
  4061. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4062. }
  4063. return oldValue.UpdatedAt, nil
  4064. }
  4065. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4066. func (m *BatchMsgMutation) ResetUpdatedAt() {
  4067. m.updated_at = nil
  4068. }
  4069. // SetDeletedAt sets the "deleted_at" field.
  4070. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  4071. m.deleted_at = &t
  4072. }
  4073. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4074. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  4075. v := m.deleted_at
  4076. if v == nil {
  4077. return
  4078. }
  4079. return *v, true
  4080. }
  4081. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  4082. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4084. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4085. if !m.op.Is(OpUpdateOne) {
  4086. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4087. }
  4088. if m.id == nil || m.oldValue == nil {
  4089. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4090. }
  4091. oldValue, err := m.oldValue(ctx)
  4092. if err != nil {
  4093. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4094. }
  4095. return oldValue.DeletedAt, nil
  4096. }
  4097. // ClearDeletedAt clears the value of the "deleted_at" field.
  4098. func (m *BatchMsgMutation) ClearDeletedAt() {
  4099. m.deleted_at = nil
  4100. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  4101. }
  4102. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4103. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  4104. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  4105. return ok
  4106. }
  4107. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4108. func (m *BatchMsgMutation) ResetDeletedAt() {
  4109. m.deleted_at = nil
  4110. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  4111. }
  4112. // SetStatus sets the "status" field.
  4113. func (m *BatchMsgMutation) SetStatus(u uint8) {
  4114. m.status = &u
  4115. m.addstatus = nil
  4116. }
  4117. // Status returns the value of the "status" field in the mutation.
  4118. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  4119. v := m.status
  4120. if v == nil {
  4121. return
  4122. }
  4123. return *v, true
  4124. }
  4125. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  4126. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4127. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4128. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4129. if !m.op.Is(OpUpdateOne) {
  4130. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4131. }
  4132. if m.id == nil || m.oldValue == nil {
  4133. return v, errors.New("OldStatus requires an ID field in the mutation")
  4134. }
  4135. oldValue, err := m.oldValue(ctx)
  4136. if err != nil {
  4137. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4138. }
  4139. return oldValue.Status, nil
  4140. }
  4141. // AddStatus adds u to the "status" field.
  4142. func (m *BatchMsgMutation) AddStatus(u int8) {
  4143. if m.addstatus != nil {
  4144. *m.addstatus += u
  4145. } else {
  4146. m.addstatus = &u
  4147. }
  4148. }
  4149. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4150. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  4151. v := m.addstatus
  4152. if v == nil {
  4153. return
  4154. }
  4155. return *v, true
  4156. }
  4157. // ClearStatus clears the value of the "status" field.
  4158. func (m *BatchMsgMutation) ClearStatus() {
  4159. m.status = nil
  4160. m.addstatus = nil
  4161. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  4162. }
  4163. // StatusCleared returns if the "status" field was cleared in this mutation.
  4164. func (m *BatchMsgMutation) StatusCleared() bool {
  4165. _, ok := m.clearedFields[batchmsg.FieldStatus]
  4166. return ok
  4167. }
  4168. // ResetStatus resets all changes to the "status" field.
  4169. func (m *BatchMsgMutation) ResetStatus() {
  4170. m.status = nil
  4171. m.addstatus = nil
  4172. delete(m.clearedFields, batchmsg.FieldStatus)
  4173. }
  4174. // SetBatchNo sets the "batch_no" field.
  4175. func (m *BatchMsgMutation) SetBatchNo(s string) {
  4176. m.batch_no = &s
  4177. }
  4178. // BatchNo returns the value of the "batch_no" field in the mutation.
  4179. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  4180. v := m.batch_no
  4181. if v == nil {
  4182. return
  4183. }
  4184. return *v, true
  4185. }
  4186. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  4187. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4189. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  4190. if !m.op.Is(OpUpdateOne) {
  4191. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  4192. }
  4193. if m.id == nil || m.oldValue == nil {
  4194. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  4195. }
  4196. oldValue, err := m.oldValue(ctx)
  4197. if err != nil {
  4198. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  4199. }
  4200. return oldValue.BatchNo, nil
  4201. }
  4202. // ClearBatchNo clears the value of the "batch_no" field.
  4203. func (m *BatchMsgMutation) ClearBatchNo() {
  4204. m.batch_no = nil
  4205. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  4206. }
  4207. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  4208. func (m *BatchMsgMutation) BatchNoCleared() bool {
  4209. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  4210. return ok
  4211. }
  4212. // ResetBatchNo resets all changes to the "batch_no" field.
  4213. func (m *BatchMsgMutation) ResetBatchNo() {
  4214. m.batch_no = nil
  4215. delete(m.clearedFields, batchmsg.FieldBatchNo)
  4216. }
  4217. // SetTaskName sets the "task_name" field.
  4218. func (m *BatchMsgMutation) SetTaskName(s string) {
  4219. m.task_name = &s
  4220. }
  4221. // TaskName returns the value of the "task_name" field in the mutation.
  4222. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  4223. v := m.task_name
  4224. if v == nil {
  4225. return
  4226. }
  4227. return *v, true
  4228. }
  4229. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  4230. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4232. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  4233. if !m.op.Is(OpUpdateOne) {
  4234. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  4235. }
  4236. if m.id == nil || m.oldValue == nil {
  4237. return v, errors.New("OldTaskName requires an ID field in the mutation")
  4238. }
  4239. oldValue, err := m.oldValue(ctx)
  4240. if err != nil {
  4241. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  4242. }
  4243. return oldValue.TaskName, nil
  4244. }
  4245. // ClearTaskName clears the value of the "task_name" field.
  4246. func (m *BatchMsgMutation) ClearTaskName() {
  4247. m.task_name = nil
  4248. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  4249. }
  4250. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  4251. func (m *BatchMsgMutation) TaskNameCleared() bool {
  4252. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  4253. return ok
  4254. }
  4255. // ResetTaskName resets all changes to the "task_name" field.
  4256. func (m *BatchMsgMutation) ResetTaskName() {
  4257. m.task_name = nil
  4258. delete(m.clearedFields, batchmsg.FieldTaskName)
  4259. }
  4260. // SetFromwxid sets the "fromwxid" field.
  4261. func (m *BatchMsgMutation) SetFromwxid(s string) {
  4262. m.fromwxid = &s
  4263. }
  4264. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  4265. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  4266. v := m.fromwxid
  4267. if v == nil {
  4268. return
  4269. }
  4270. return *v, true
  4271. }
  4272. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  4273. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4275. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  4276. if !m.op.Is(OpUpdateOne) {
  4277. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  4278. }
  4279. if m.id == nil || m.oldValue == nil {
  4280. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  4281. }
  4282. oldValue, err := m.oldValue(ctx)
  4283. if err != nil {
  4284. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  4285. }
  4286. return oldValue.Fromwxid, nil
  4287. }
  4288. // ClearFromwxid clears the value of the "fromwxid" field.
  4289. func (m *BatchMsgMutation) ClearFromwxid() {
  4290. m.fromwxid = nil
  4291. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  4292. }
  4293. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  4294. func (m *BatchMsgMutation) FromwxidCleared() bool {
  4295. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  4296. return ok
  4297. }
  4298. // ResetFromwxid resets all changes to the "fromwxid" field.
  4299. func (m *BatchMsgMutation) ResetFromwxid() {
  4300. m.fromwxid = nil
  4301. delete(m.clearedFields, batchmsg.FieldFromwxid)
  4302. }
  4303. // SetMsg sets the "msg" field.
  4304. func (m *BatchMsgMutation) SetMsg(s string) {
  4305. m.msg = &s
  4306. }
  4307. // Msg returns the value of the "msg" field in the mutation.
  4308. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  4309. v := m.msg
  4310. if v == nil {
  4311. return
  4312. }
  4313. return *v, true
  4314. }
  4315. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  4316. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4318. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  4319. if !m.op.Is(OpUpdateOne) {
  4320. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  4321. }
  4322. if m.id == nil || m.oldValue == nil {
  4323. return v, errors.New("OldMsg requires an ID field in the mutation")
  4324. }
  4325. oldValue, err := m.oldValue(ctx)
  4326. if err != nil {
  4327. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  4328. }
  4329. return oldValue.Msg, nil
  4330. }
  4331. // ClearMsg clears the value of the "msg" field.
  4332. func (m *BatchMsgMutation) ClearMsg() {
  4333. m.msg = nil
  4334. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  4335. }
  4336. // MsgCleared returns if the "msg" field was cleared in this mutation.
  4337. func (m *BatchMsgMutation) MsgCleared() bool {
  4338. _, ok := m.clearedFields[batchmsg.FieldMsg]
  4339. return ok
  4340. }
  4341. // ResetMsg resets all changes to the "msg" field.
  4342. func (m *BatchMsgMutation) ResetMsg() {
  4343. m.msg = nil
  4344. delete(m.clearedFields, batchmsg.FieldMsg)
  4345. }
  4346. // SetTag sets the "tag" field.
  4347. func (m *BatchMsgMutation) SetTag(s string) {
  4348. m.tag = &s
  4349. }
  4350. // Tag returns the value of the "tag" field in the mutation.
  4351. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  4352. v := m.tag
  4353. if v == nil {
  4354. return
  4355. }
  4356. return *v, true
  4357. }
  4358. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  4359. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4361. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  4362. if !m.op.Is(OpUpdateOne) {
  4363. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  4364. }
  4365. if m.id == nil || m.oldValue == nil {
  4366. return v, errors.New("OldTag requires an ID field in the mutation")
  4367. }
  4368. oldValue, err := m.oldValue(ctx)
  4369. if err != nil {
  4370. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  4371. }
  4372. return oldValue.Tag, nil
  4373. }
  4374. // ClearTag clears the value of the "tag" field.
  4375. func (m *BatchMsgMutation) ClearTag() {
  4376. m.tag = nil
  4377. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  4378. }
  4379. // TagCleared returns if the "tag" field was cleared in this mutation.
  4380. func (m *BatchMsgMutation) TagCleared() bool {
  4381. _, ok := m.clearedFields[batchmsg.FieldTag]
  4382. return ok
  4383. }
  4384. // ResetTag resets all changes to the "tag" field.
  4385. func (m *BatchMsgMutation) ResetTag() {
  4386. m.tag = nil
  4387. delete(m.clearedFields, batchmsg.FieldTag)
  4388. }
  4389. // SetTagids sets the "tagids" field.
  4390. func (m *BatchMsgMutation) SetTagids(s string) {
  4391. m.tagids = &s
  4392. }
  4393. // Tagids returns the value of the "tagids" field in the mutation.
  4394. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  4395. v := m.tagids
  4396. if v == nil {
  4397. return
  4398. }
  4399. return *v, true
  4400. }
  4401. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  4402. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4404. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  4405. if !m.op.Is(OpUpdateOne) {
  4406. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  4407. }
  4408. if m.id == nil || m.oldValue == nil {
  4409. return v, errors.New("OldTagids requires an ID field in the mutation")
  4410. }
  4411. oldValue, err := m.oldValue(ctx)
  4412. if err != nil {
  4413. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  4414. }
  4415. return oldValue.Tagids, nil
  4416. }
  4417. // ClearTagids clears the value of the "tagids" field.
  4418. func (m *BatchMsgMutation) ClearTagids() {
  4419. m.tagids = nil
  4420. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  4421. }
  4422. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  4423. func (m *BatchMsgMutation) TagidsCleared() bool {
  4424. _, ok := m.clearedFields[batchmsg.FieldTagids]
  4425. return ok
  4426. }
  4427. // ResetTagids resets all changes to the "tagids" field.
  4428. func (m *BatchMsgMutation) ResetTagids() {
  4429. m.tagids = nil
  4430. delete(m.clearedFields, batchmsg.FieldTagids)
  4431. }
  4432. // SetTotal sets the "total" field.
  4433. func (m *BatchMsgMutation) SetTotal(i int32) {
  4434. m.total = &i
  4435. m.addtotal = nil
  4436. }
  4437. // Total returns the value of the "total" field in the mutation.
  4438. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  4439. v := m.total
  4440. if v == nil {
  4441. return
  4442. }
  4443. return *v, true
  4444. }
  4445. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  4446. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4447. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4448. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  4449. if !m.op.Is(OpUpdateOne) {
  4450. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  4451. }
  4452. if m.id == nil || m.oldValue == nil {
  4453. return v, errors.New("OldTotal requires an ID field in the mutation")
  4454. }
  4455. oldValue, err := m.oldValue(ctx)
  4456. if err != nil {
  4457. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  4458. }
  4459. return oldValue.Total, nil
  4460. }
  4461. // AddTotal adds i to the "total" field.
  4462. func (m *BatchMsgMutation) AddTotal(i int32) {
  4463. if m.addtotal != nil {
  4464. *m.addtotal += i
  4465. } else {
  4466. m.addtotal = &i
  4467. }
  4468. }
  4469. // AddedTotal returns the value that was added to the "total" field in this mutation.
  4470. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  4471. v := m.addtotal
  4472. if v == nil {
  4473. return
  4474. }
  4475. return *v, true
  4476. }
  4477. // ClearTotal clears the value of the "total" field.
  4478. func (m *BatchMsgMutation) ClearTotal() {
  4479. m.total = nil
  4480. m.addtotal = nil
  4481. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  4482. }
  4483. // TotalCleared returns if the "total" field was cleared in this mutation.
  4484. func (m *BatchMsgMutation) TotalCleared() bool {
  4485. _, ok := m.clearedFields[batchmsg.FieldTotal]
  4486. return ok
  4487. }
  4488. // ResetTotal resets all changes to the "total" field.
  4489. func (m *BatchMsgMutation) ResetTotal() {
  4490. m.total = nil
  4491. m.addtotal = nil
  4492. delete(m.clearedFields, batchmsg.FieldTotal)
  4493. }
  4494. // SetSuccess sets the "success" field.
  4495. func (m *BatchMsgMutation) SetSuccess(i int32) {
  4496. m.success = &i
  4497. m.addsuccess = nil
  4498. }
  4499. // Success returns the value of the "success" field in the mutation.
  4500. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  4501. v := m.success
  4502. if v == nil {
  4503. return
  4504. }
  4505. return *v, true
  4506. }
  4507. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  4508. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4510. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  4511. if !m.op.Is(OpUpdateOne) {
  4512. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  4513. }
  4514. if m.id == nil || m.oldValue == nil {
  4515. return v, errors.New("OldSuccess requires an ID field in the mutation")
  4516. }
  4517. oldValue, err := m.oldValue(ctx)
  4518. if err != nil {
  4519. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  4520. }
  4521. return oldValue.Success, nil
  4522. }
  4523. // AddSuccess adds i to the "success" field.
  4524. func (m *BatchMsgMutation) AddSuccess(i int32) {
  4525. if m.addsuccess != nil {
  4526. *m.addsuccess += i
  4527. } else {
  4528. m.addsuccess = &i
  4529. }
  4530. }
  4531. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  4532. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  4533. v := m.addsuccess
  4534. if v == nil {
  4535. return
  4536. }
  4537. return *v, true
  4538. }
  4539. // ClearSuccess clears the value of the "success" field.
  4540. func (m *BatchMsgMutation) ClearSuccess() {
  4541. m.success = nil
  4542. m.addsuccess = nil
  4543. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  4544. }
  4545. // SuccessCleared returns if the "success" field was cleared in this mutation.
  4546. func (m *BatchMsgMutation) SuccessCleared() bool {
  4547. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  4548. return ok
  4549. }
  4550. // ResetSuccess resets all changes to the "success" field.
  4551. func (m *BatchMsgMutation) ResetSuccess() {
  4552. m.success = nil
  4553. m.addsuccess = nil
  4554. delete(m.clearedFields, batchmsg.FieldSuccess)
  4555. }
  4556. // SetFail sets the "fail" field.
  4557. func (m *BatchMsgMutation) SetFail(i int32) {
  4558. m.fail = &i
  4559. m.addfail = nil
  4560. }
  4561. // Fail returns the value of the "fail" field in the mutation.
  4562. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  4563. v := m.fail
  4564. if v == nil {
  4565. return
  4566. }
  4567. return *v, true
  4568. }
  4569. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  4570. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4572. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  4573. if !m.op.Is(OpUpdateOne) {
  4574. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  4575. }
  4576. if m.id == nil || m.oldValue == nil {
  4577. return v, errors.New("OldFail requires an ID field in the mutation")
  4578. }
  4579. oldValue, err := m.oldValue(ctx)
  4580. if err != nil {
  4581. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  4582. }
  4583. return oldValue.Fail, nil
  4584. }
  4585. // AddFail adds i to the "fail" field.
  4586. func (m *BatchMsgMutation) AddFail(i int32) {
  4587. if m.addfail != nil {
  4588. *m.addfail += i
  4589. } else {
  4590. m.addfail = &i
  4591. }
  4592. }
  4593. // AddedFail returns the value that was added to the "fail" field in this mutation.
  4594. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  4595. v := m.addfail
  4596. if v == nil {
  4597. return
  4598. }
  4599. return *v, true
  4600. }
  4601. // ClearFail clears the value of the "fail" field.
  4602. func (m *BatchMsgMutation) ClearFail() {
  4603. m.fail = nil
  4604. m.addfail = nil
  4605. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  4606. }
  4607. // FailCleared returns if the "fail" field was cleared in this mutation.
  4608. func (m *BatchMsgMutation) FailCleared() bool {
  4609. _, ok := m.clearedFields[batchmsg.FieldFail]
  4610. return ok
  4611. }
  4612. // ResetFail resets all changes to the "fail" field.
  4613. func (m *BatchMsgMutation) ResetFail() {
  4614. m.fail = nil
  4615. m.addfail = nil
  4616. delete(m.clearedFields, batchmsg.FieldFail)
  4617. }
  4618. // SetStartTime sets the "start_time" field.
  4619. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  4620. m.start_time = &t
  4621. }
  4622. // StartTime returns the value of the "start_time" field in the mutation.
  4623. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  4624. v := m.start_time
  4625. if v == nil {
  4626. return
  4627. }
  4628. return *v, true
  4629. }
  4630. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  4631. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4633. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  4634. if !m.op.Is(OpUpdateOne) {
  4635. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  4636. }
  4637. if m.id == nil || m.oldValue == nil {
  4638. return v, errors.New("OldStartTime requires an ID field in the mutation")
  4639. }
  4640. oldValue, err := m.oldValue(ctx)
  4641. if err != nil {
  4642. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  4643. }
  4644. return oldValue.StartTime, nil
  4645. }
  4646. // ClearStartTime clears the value of the "start_time" field.
  4647. func (m *BatchMsgMutation) ClearStartTime() {
  4648. m.start_time = nil
  4649. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  4650. }
  4651. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  4652. func (m *BatchMsgMutation) StartTimeCleared() bool {
  4653. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  4654. return ok
  4655. }
  4656. // ResetStartTime resets all changes to the "start_time" field.
  4657. func (m *BatchMsgMutation) ResetStartTime() {
  4658. m.start_time = nil
  4659. delete(m.clearedFields, batchmsg.FieldStartTime)
  4660. }
  4661. // SetStopTime sets the "stop_time" field.
  4662. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  4663. m.stop_time = &t
  4664. }
  4665. // StopTime returns the value of the "stop_time" field in the mutation.
  4666. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  4667. v := m.stop_time
  4668. if v == nil {
  4669. return
  4670. }
  4671. return *v, true
  4672. }
  4673. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  4674. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4676. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  4677. if !m.op.Is(OpUpdateOne) {
  4678. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  4679. }
  4680. if m.id == nil || m.oldValue == nil {
  4681. return v, errors.New("OldStopTime requires an ID field in the mutation")
  4682. }
  4683. oldValue, err := m.oldValue(ctx)
  4684. if err != nil {
  4685. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  4686. }
  4687. return oldValue.StopTime, nil
  4688. }
  4689. // ClearStopTime clears the value of the "stop_time" field.
  4690. func (m *BatchMsgMutation) ClearStopTime() {
  4691. m.stop_time = nil
  4692. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  4693. }
  4694. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  4695. func (m *BatchMsgMutation) StopTimeCleared() bool {
  4696. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  4697. return ok
  4698. }
  4699. // ResetStopTime resets all changes to the "stop_time" field.
  4700. func (m *BatchMsgMutation) ResetStopTime() {
  4701. m.stop_time = nil
  4702. delete(m.clearedFields, batchmsg.FieldStopTime)
  4703. }
  4704. // SetSendTime sets the "send_time" field.
  4705. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  4706. m.send_time = &t
  4707. }
  4708. // SendTime returns the value of the "send_time" field in the mutation.
  4709. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  4710. v := m.send_time
  4711. if v == nil {
  4712. return
  4713. }
  4714. return *v, true
  4715. }
  4716. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  4717. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4718. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4719. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  4720. if !m.op.Is(OpUpdateOne) {
  4721. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  4722. }
  4723. if m.id == nil || m.oldValue == nil {
  4724. return v, errors.New("OldSendTime requires an ID field in the mutation")
  4725. }
  4726. oldValue, err := m.oldValue(ctx)
  4727. if err != nil {
  4728. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  4729. }
  4730. return oldValue.SendTime, nil
  4731. }
  4732. // ClearSendTime clears the value of the "send_time" field.
  4733. func (m *BatchMsgMutation) ClearSendTime() {
  4734. m.send_time = nil
  4735. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  4736. }
  4737. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  4738. func (m *BatchMsgMutation) SendTimeCleared() bool {
  4739. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  4740. return ok
  4741. }
  4742. // ResetSendTime resets all changes to the "send_time" field.
  4743. func (m *BatchMsgMutation) ResetSendTime() {
  4744. m.send_time = nil
  4745. delete(m.clearedFields, batchmsg.FieldSendTime)
  4746. }
  4747. // SetType sets the "type" field.
  4748. func (m *BatchMsgMutation) SetType(i int32) {
  4749. m._type = &i
  4750. m.add_type = nil
  4751. }
  4752. // GetType returns the value of the "type" field in the mutation.
  4753. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  4754. v := m._type
  4755. if v == nil {
  4756. return
  4757. }
  4758. return *v, true
  4759. }
  4760. // OldType returns the old "type" field's value of the BatchMsg entity.
  4761. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4763. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  4764. if !m.op.Is(OpUpdateOne) {
  4765. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4766. }
  4767. if m.id == nil || m.oldValue == nil {
  4768. return v, errors.New("OldType requires an ID field in the mutation")
  4769. }
  4770. oldValue, err := m.oldValue(ctx)
  4771. if err != nil {
  4772. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4773. }
  4774. return oldValue.Type, nil
  4775. }
  4776. // AddType adds i to the "type" field.
  4777. func (m *BatchMsgMutation) AddType(i int32) {
  4778. if m.add_type != nil {
  4779. *m.add_type += i
  4780. } else {
  4781. m.add_type = &i
  4782. }
  4783. }
  4784. // AddedType returns the value that was added to the "type" field in this mutation.
  4785. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4786. v := m.add_type
  4787. if v == nil {
  4788. return
  4789. }
  4790. return *v, true
  4791. }
  4792. // ClearType clears the value of the "type" field.
  4793. func (m *BatchMsgMutation) ClearType() {
  4794. m._type = nil
  4795. m.add_type = nil
  4796. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4797. }
  4798. // TypeCleared returns if the "type" field was cleared in this mutation.
  4799. func (m *BatchMsgMutation) TypeCleared() bool {
  4800. _, ok := m.clearedFields[batchmsg.FieldType]
  4801. return ok
  4802. }
  4803. // ResetType resets all changes to the "type" field.
  4804. func (m *BatchMsgMutation) ResetType() {
  4805. m._type = nil
  4806. m.add_type = nil
  4807. delete(m.clearedFields, batchmsg.FieldType)
  4808. }
  4809. // SetOrganizationID sets the "organization_id" field.
  4810. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4811. m.organization_id = &u
  4812. m.addorganization_id = nil
  4813. }
  4814. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4815. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4816. v := m.organization_id
  4817. if v == nil {
  4818. return
  4819. }
  4820. return *v, true
  4821. }
  4822. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4823. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4825. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4826. if !m.op.Is(OpUpdateOne) {
  4827. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4828. }
  4829. if m.id == nil || m.oldValue == nil {
  4830. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4831. }
  4832. oldValue, err := m.oldValue(ctx)
  4833. if err != nil {
  4834. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4835. }
  4836. return oldValue.OrganizationID, nil
  4837. }
  4838. // AddOrganizationID adds u to the "organization_id" field.
  4839. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4840. if m.addorganization_id != nil {
  4841. *m.addorganization_id += u
  4842. } else {
  4843. m.addorganization_id = &u
  4844. }
  4845. }
  4846. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4847. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4848. v := m.addorganization_id
  4849. if v == nil {
  4850. return
  4851. }
  4852. return *v, true
  4853. }
  4854. // ResetOrganizationID resets all changes to the "organization_id" field.
  4855. func (m *BatchMsgMutation) ResetOrganizationID() {
  4856. m.organization_id = nil
  4857. m.addorganization_id = nil
  4858. }
  4859. // Where appends a list predicates to the BatchMsgMutation builder.
  4860. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  4861. m.predicates = append(m.predicates, ps...)
  4862. }
  4863. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  4864. // users can use type-assertion to append predicates that do not depend on any generated package.
  4865. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  4866. p := make([]predicate.BatchMsg, len(ps))
  4867. for i := range ps {
  4868. p[i] = ps[i]
  4869. }
  4870. m.Where(p...)
  4871. }
  4872. // Op returns the operation name.
  4873. func (m *BatchMsgMutation) Op() Op {
  4874. return m.op
  4875. }
  4876. // SetOp allows setting the mutation operation.
  4877. func (m *BatchMsgMutation) SetOp(op Op) {
  4878. m.op = op
  4879. }
  4880. // Type returns the node type of this mutation (BatchMsg).
  4881. func (m *BatchMsgMutation) Type() string {
  4882. return m.typ
  4883. }
  4884. // Fields returns all fields that were changed during this mutation. Note that in
  4885. // order to get all numeric fields that were incremented/decremented, call
  4886. // AddedFields().
  4887. func (m *BatchMsgMutation) Fields() []string {
  4888. fields := make([]string, 0, 18)
  4889. if m.created_at != nil {
  4890. fields = append(fields, batchmsg.FieldCreatedAt)
  4891. }
  4892. if m.updated_at != nil {
  4893. fields = append(fields, batchmsg.FieldUpdatedAt)
  4894. }
  4895. if m.deleted_at != nil {
  4896. fields = append(fields, batchmsg.FieldDeletedAt)
  4897. }
  4898. if m.status != nil {
  4899. fields = append(fields, batchmsg.FieldStatus)
  4900. }
  4901. if m.batch_no != nil {
  4902. fields = append(fields, batchmsg.FieldBatchNo)
  4903. }
  4904. if m.task_name != nil {
  4905. fields = append(fields, batchmsg.FieldTaskName)
  4906. }
  4907. if m.fromwxid != nil {
  4908. fields = append(fields, batchmsg.FieldFromwxid)
  4909. }
  4910. if m.msg != nil {
  4911. fields = append(fields, batchmsg.FieldMsg)
  4912. }
  4913. if m.tag != nil {
  4914. fields = append(fields, batchmsg.FieldTag)
  4915. }
  4916. if m.tagids != nil {
  4917. fields = append(fields, batchmsg.FieldTagids)
  4918. }
  4919. if m.total != nil {
  4920. fields = append(fields, batchmsg.FieldTotal)
  4921. }
  4922. if m.success != nil {
  4923. fields = append(fields, batchmsg.FieldSuccess)
  4924. }
  4925. if m.fail != nil {
  4926. fields = append(fields, batchmsg.FieldFail)
  4927. }
  4928. if m.start_time != nil {
  4929. fields = append(fields, batchmsg.FieldStartTime)
  4930. }
  4931. if m.stop_time != nil {
  4932. fields = append(fields, batchmsg.FieldStopTime)
  4933. }
  4934. if m.send_time != nil {
  4935. fields = append(fields, batchmsg.FieldSendTime)
  4936. }
  4937. if m._type != nil {
  4938. fields = append(fields, batchmsg.FieldType)
  4939. }
  4940. if m.organization_id != nil {
  4941. fields = append(fields, batchmsg.FieldOrganizationID)
  4942. }
  4943. return fields
  4944. }
  4945. // Field returns the value of a field with the given name. The second boolean
  4946. // return value indicates that this field was not set, or was not defined in the
  4947. // schema.
  4948. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  4949. switch name {
  4950. case batchmsg.FieldCreatedAt:
  4951. return m.CreatedAt()
  4952. case batchmsg.FieldUpdatedAt:
  4953. return m.UpdatedAt()
  4954. case batchmsg.FieldDeletedAt:
  4955. return m.DeletedAt()
  4956. case batchmsg.FieldStatus:
  4957. return m.Status()
  4958. case batchmsg.FieldBatchNo:
  4959. return m.BatchNo()
  4960. case batchmsg.FieldTaskName:
  4961. return m.TaskName()
  4962. case batchmsg.FieldFromwxid:
  4963. return m.Fromwxid()
  4964. case batchmsg.FieldMsg:
  4965. return m.Msg()
  4966. case batchmsg.FieldTag:
  4967. return m.Tag()
  4968. case batchmsg.FieldTagids:
  4969. return m.Tagids()
  4970. case batchmsg.FieldTotal:
  4971. return m.Total()
  4972. case batchmsg.FieldSuccess:
  4973. return m.Success()
  4974. case batchmsg.FieldFail:
  4975. return m.Fail()
  4976. case batchmsg.FieldStartTime:
  4977. return m.StartTime()
  4978. case batchmsg.FieldStopTime:
  4979. return m.StopTime()
  4980. case batchmsg.FieldSendTime:
  4981. return m.SendTime()
  4982. case batchmsg.FieldType:
  4983. return m.GetType()
  4984. case batchmsg.FieldOrganizationID:
  4985. return m.OrganizationID()
  4986. }
  4987. return nil, false
  4988. }
  4989. // OldField returns the old value of the field from the database. An error is
  4990. // returned if the mutation operation is not UpdateOne, or the query to the
  4991. // database failed.
  4992. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4993. switch name {
  4994. case batchmsg.FieldCreatedAt:
  4995. return m.OldCreatedAt(ctx)
  4996. case batchmsg.FieldUpdatedAt:
  4997. return m.OldUpdatedAt(ctx)
  4998. case batchmsg.FieldDeletedAt:
  4999. return m.OldDeletedAt(ctx)
  5000. case batchmsg.FieldStatus:
  5001. return m.OldStatus(ctx)
  5002. case batchmsg.FieldBatchNo:
  5003. return m.OldBatchNo(ctx)
  5004. case batchmsg.FieldTaskName:
  5005. return m.OldTaskName(ctx)
  5006. case batchmsg.FieldFromwxid:
  5007. return m.OldFromwxid(ctx)
  5008. case batchmsg.FieldMsg:
  5009. return m.OldMsg(ctx)
  5010. case batchmsg.FieldTag:
  5011. return m.OldTag(ctx)
  5012. case batchmsg.FieldTagids:
  5013. return m.OldTagids(ctx)
  5014. case batchmsg.FieldTotal:
  5015. return m.OldTotal(ctx)
  5016. case batchmsg.FieldSuccess:
  5017. return m.OldSuccess(ctx)
  5018. case batchmsg.FieldFail:
  5019. return m.OldFail(ctx)
  5020. case batchmsg.FieldStartTime:
  5021. return m.OldStartTime(ctx)
  5022. case batchmsg.FieldStopTime:
  5023. return m.OldStopTime(ctx)
  5024. case batchmsg.FieldSendTime:
  5025. return m.OldSendTime(ctx)
  5026. case batchmsg.FieldType:
  5027. return m.OldType(ctx)
  5028. case batchmsg.FieldOrganizationID:
  5029. return m.OldOrganizationID(ctx)
  5030. }
  5031. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  5032. }
  5033. // SetField sets the value of a field with the given name. It returns an error if
  5034. // the field is not defined in the schema, or if the type mismatched the field
  5035. // type.
  5036. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  5037. switch name {
  5038. case batchmsg.FieldCreatedAt:
  5039. v, ok := value.(time.Time)
  5040. if !ok {
  5041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5042. }
  5043. m.SetCreatedAt(v)
  5044. return nil
  5045. case batchmsg.FieldUpdatedAt:
  5046. v, ok := value.(time.Time)
  5047. if !ok {
  5048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5049. }
  5050. m.SetUpdatedAt(v)
  5051. return nil
  5052. case batchmsg.FieldDeletedAt:
  5053. v, ok := value.(time.Time)
  5054. if !ok {
  5055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5056. }
  5057. m.SetDeletedAt(v)
  5058. return nil
  5059. case batchmsg.FieldStatus:
  5060. v, ok := value.(uint8)
  5061. if !ok {
  5062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5063. }
  5064. m.SetStatus(v)
  5065. return nil
  5066. case batchmsg.FieldBatchNo:
  5067. v, ok := value.(string)
  5068. if !ok {
  5069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5070. }
  5071. m.SetBatchNo(v)
  5072. return nil
  5073. case batchmsg.FieldTaskName:
  5074. v, ok := value.(string)
  5075. if !ok {
  5076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5077. }
  5078. m.SetTaskName(v)
  5079. return nil
  5080. case batchmsg.FieldFromwxid:
  5081. v, ok := value.(string)
  5082. if !ok {
  5083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5084. }
  5085. m.SetFromwxid(v)
  5086. return nil
  5087. case batchmsg.FieldMsg:
  5088. v, ok := value.(string)
  5089. if !ok {
  5090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5091. }
  5092. m.SetMsg(v)
  5093. return nil
  5094. case batchmsg.FieldTag:
  5095. v, ok := value.(string)
  5096. if !ok {
  5097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5098. }
  5099. m.SetTag(v)
  5100. return nil
  5101. case batchmsg.FieldTagids:
  5102. v, ok := value.(string)
  5103. if !ok {
  5104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5105. }
  5106. m.SetTagids(v)
  5107. return nil
  5108. case batchmsg.FieldTotal:
  5109. v, ok := value.(int32)
  5110. if !ok {
  5111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5112. }
  5113. m.SetTotal(v)
  5114. return nil
  5115. case batchmsg.FieldSuccess:
  5116. v, ok := value.(int32)
  5117. if !ok {
  5118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5119. }
  5120. m.SetSuccess(v)
  5121. return nil
  5122. case batchmsg.FieldFail:
  5123. v, ok := value.(int32)
  5124. if !ok {
  5125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5126. }
  5127. m.SetFail(v)
  5128. return nil
  5129. case batchmsg.FieldStartTime:
  5130. v, ok := value.(time.Time)
  5131. if !ok {
  5132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5133. }
  5134. m.SetStartTime(v)
  5135. return nil
  5136. case batchmsg.FieldStopTime:
  5137. v, ok := value.(time.Time)
  5138. if !ok {
  5139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5140. }
  5141. m.SetStopTime(v)
  5142. return nil
  5143. case batchmsg.FieldSendTime:
  5144. v, ok := value.(time.Time)
  5145. if !ok {
  5146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5147. }
  5148. m.SetSendTime(v)
  5149. return nil
  5150. case batchmsg.FieldType:
  5151. v, ok := value.(int32)
  5152. if !ok {
  5153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5154. }
  5155. m.SetType(v)
  5156. return nil
  5157. case batchmsg.FieldOrganizationID:
  5158. v, ok := value.(uint64)
  5159. if !ok {
  5160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5161. }
  5162. m.SetOrganizationID(v)
  5163. return nil
  5164. }
  5165. return fmt.Errorf("unknown BatchMsg field %s", name)
  5166. }
  5167. // AddedFields returns all numeric fields that were incremented/decremented during
  5168. // this mutation.
  5169. func (m *BatchMsgMutation) AddedFields() []string {
  5170. var fields []string
  5171. if m.addstatus != nil {
  5172. fields = append(fields, batchmsg.FieldStatus)
  5173. }
  5174. if m.addtotal != nil {
  5175. fields = append(fields, batchmsg.FieldTotal)
  5176. }
  5177. if m.addsuccess != nil {
  5178. fields = append(fields, batchmsg.FieldSuccess)
  5179. }
  5180. if m.addfail != nil {
  5181. fields = append(fields, batchmsg.FieldFail)
  5182. }
  5183. if m.add_type != nil {
  5184. fields = append(fields, batchmsg.FieldType)
  5185. }
  5186. if m.addorganization_id != nil {
  5187. fields = append(fields, batchmsg.FieldOrganizationID)
  5188. }
  5189. return fields
  5190. }
  5191. // AddedField returns the numeric value that was incremented/decremented on a field
  5192. // with the given name. The second boolean return value indicates that this field
  5193. // was not set, or was not defined in the schema.
  5194. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  5195. switch name {
  5196. case batchmsg.FieldStatus:
  5197. return m.AddedStatus()
  5198. case batchmsg.FieldTotal:
  5199. return m.AddedTotal()
  5200. case batchmsg.FieldSuccess:
  5201. return m.AddedSuccess()
  5202. case batchmsg.FieldFail:
  5203. return m.AddedFail()
  5204. case batchmsg.FieldType:
  5205. return m.AddedType()
  5206. case batchmsg.FieldOrganizationID:
  5207. return m.AddedOrganizationID()
  5208. }
  5209. return nil, false
  5210. }
  5211. // AddField adds the value to the field with the given name. It returns an error if
  5212. // the field is not defined in the schema, or if the type mismatched the field
  5213. // type.
  5214. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  5215. switch name {
  5216. case batchmsg.FieldStatus:
  5217. v, ok := value.(int8)
  5218. if !ok {
  5219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5220. }
  5221. m.AddStatus(v)
  5222. return nil
  5223. case batchmsg.FieldTotal:
  5224. v, ok := value.(int32)
  5225. if !ok {
  5226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5227. }
  5228. m.AddTotal(v)
  5229. return nil
  5230. case batchmsg.FieldSuccess:
  5231. v, ok := value.(int32)
  5232. if !ok {
  5233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5234. }
  5235. m.AddSuccess(v)
  5236. return nil
  5237. case batchmsg.FieldFail:
  5238. v, ok := value.(int32)
  5239. if !ok {
  5240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5241. }
  5242. m.AddFail(v)
  5243. return nil
  5244. case batchmsg.FieldType:
  5245. v, ok := value.(int32)
  5246. if !ok {
  5247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5248. }
  5249. m.AddType(v)
  5250. return nil
  5251. case batchmsg.FieldOrganizationID:
  5252. v, ok := value.(int64)
  5253. if !ok {
  5254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5255. }
  5256. m.AddOrganizationID(v)
  5257. return nil
  5258. }
  5259. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  5260. }
  5261. // ClearedFields returns all nullable fields that were cleared during this
  5262. // mutation.
  5263. func (m *BatchMsgMutation) ClearedFields() []string {
  5264. var fields []string
  5265. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  5266. fields = append(fields, batchmsg.FieldDeletedAt)
  5267. }
  5268. if m.FieldCleared(batchmsg.FieldStatus) {
  5269. fields = append(fields, batchmsg.FieldStatus)
  5270. }
  5271. if m.FieldCleared(batchmsg.FieldBatchNo) {
  5272. fields = append(fields, batchmsg.FieldBatchNo)
  5273. }
  5274. if m.FieldCleared(batchmsg.FieldTaskName) {
  5275. fields = append(fields, batchmsg.FieldTaskName)
  5276. }
  5277. if m.FieldCleared(batchmsg.FieldFromwxid) {
  5278. fields = append(fields, batchmsg.FieldFromwxid)
  5279. }
  5280. if m.FieldCleared(batchmsg.FieldMsg) {
  5281. fields = append(fields, batchmsg.FieldMsg)
  5282. }
  5283. if m.FieldCleared(batchmsg.FieldTag) {
  5284. fields = append(fields, batchmsg.FieldTag)
  5285. }
  5286. if m.FieldCleared(batchmsg.FieldTagids) {
  5287. fields = append(fields, batchmsg.FieldTagids)
  5288. }
  5289. if m.FieldCleared(batchmsg.FieldTotal) {
  5290. fields = append(fields, batchmsg.FieldTotal)
  5291. }
  5292. if m.FieldCleared(batchmsg.FieldSuccess) {
  5293. fields = append(fields, batchmsg.FieldSuccess)
  5294. }
  5295. if m.FieldCleared(batchmsg.FieldFail) {
  5296. fields = append(fields, batchmsg.FieldFail)
  5297. }
  5298. if m.FieldCleared(batchmsg.FieldStartTime) {
  5299. fields = append(fields, batchmsg.FieldStartTime)
  5300. }
  5301. if m.FieldCleared(batchmsg.FieldStopTime) {
  5302. fields = append(fields, batchmsg.FieldStopTime)
  5303. }
  5304. if m.FieldCleared(batchmsg.FieldSendTime) {
  5305. fields = append(fields, batchmsg.FieldSendTime)
  5306. }
  5307. if m.FieldCleared(batchmsg.FieldType) {
  5308. fields = append(fields, batchmsg.FieldType)
  5309. }
  5310. return fields
  5311. }
  5312. // FieldCleared returns a boolean indicating if a field with the given name was
  5313. // cleared in this mutation.
  5314. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  5315. _, ok := m.clearedFields[name]
  5316. return ok
  5317. }
  5318. // ClearField clears the value of the field with the given name. It returns an
  5319. // error if the field is not defined in the schema.
  5320. func (m *BatchMsgMutation) ClearField(name string) error {
  5321. switch name {
  5322. case batchmsg.FieldDeletedAt:
  5323. m.ClearDeletedAt()
  5324. return nil
  5325. case batchmsg.FieldStatus:
  5326. m.ClearStatus()
  5327. return nil
  5328. case batchmsg.FieldBatchNo:
  5329. m.ClearBatchNo()
  5330. return nil
  5331. case batchmsg.FieldTaskName:
  5332. m.ClearTaskName()
  5333. return nil
  5334. case batchmsg.FieldFromwxid:
  5335. m.ClearFromwxid()
  5336. return nil
  5337. case batchmsg.FieldMsg:
  5338. m.ClearMsg()
  5339. return nil
  5340. case batchmsg.FieldTag:
  5341. m.ClearTag()
  5342. return nil
  5343. case batchmsg.FieldTagids:
  5344. m.ClearTagids()
  5345. return nil
  5346. case batchmsg.FieldTotal:
  5347. m.ClearTotal()
  5348. return nil
  5349. case batchmsg.FieldSuccess:
  5350. m.ClearSuccess()
  5351. return nil
  5352. case batchmsg.FieldFail:
  5353. m.ClearFail()
  5354. return nil
  5355. case batchmsg.FieldStartTime:
  5356. m.ClearStartTime()
  5357. return nil
  5358. case batchmsg.FieldStopTime:
  5359. m.ClearStopTime()
  5360. return nil
  5361. case batchmsg.FieldSendTime:
  5362. m.ClearSendTime()
  5363. return nil
  5364. case batchmsg.FieldType:
  5365. m.ClearType()
  5366. return nil
  5367. }
  5368. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  5369. }
  5370. // ResetField resets all changes in the mutation for the field with the given name.
  5371. // It returns an error if the field is not defined in the schema.
  5372. func (m *BatchMsgMutation) ResetField(name string) error {
  5373. switch name {
  5374. case batchmsg.FieldCreatedAt:
  5375. m.ResetCreatedAt()
  5376. return nil
  5377. case batchmsg.FieldUpdatedAt:
  5378. m.ResetUpdatedAt()
  5379. return nil
  5380. case batchmsg.FieldDeletedAt:
  5381. m.ResetDeletedAt()
  5382. return nil
  5383. case batchmsg.FieldStatus:
  5384. m.ResetStatus()
  5385. return nil
  5386. case batchmsg.FieldBatchNo:
  5387. m.ResetBatchNo()
  5388. return nil
  5389. case batchmsg.FieldTaskName:
  5390. m.ResetTaskName()
  5391. return nil
  5392. case batchmsg.FieldFromwxid:
  5393. m.ResetFromwxid()
  5394. return nil
  5395. case batchmsg.FieldMsg:
  5396. m.ResetMsg()
  5397. return nil
  5398. case batchmsg.FieldTag:
  5399. m.ResetTag()
  5400. return nil
  5401. case batchmsg.FieldTagids:
  5402. m.ResetTagids()
  5403. return nil
  5404. case batchmsg.FieldTotal:
  5405. m.ResetTotal()
  5406. return nil
  5407. case batchmsg.FieldSuccess:
  5408. m.ResetSuccess()
  5409. return nil
  5410. case batchmsg.FieldFail:
  5411. m.ResetFail()
  5412. return nil
  5413. case batchmsg.FieldStartTime:
  5414. m.ResetStartTime()
  5415. return nil
  5416. case batchmsg.FieldStopTime:
  5417. m.ResetStopTime()
  5418. return nil
  5419. case batchmsg.FieldSendTime:
  5420. m.ResetSendTime()
  5421. return nil
  5422. case batchmsg.FieldType:
  5423. m.ResetType()
  5424. return nil
  5425. case batchmsg.FieldOrganizationID:
  5426. m.ResetOrganizationID()
  5427. return nil
  5428. }
  5429. return fmt.Errorf("unknown BatchMsg field %s", name)
  5430. }
  5431. // AddedEdges returns all edge names that were set/added in this mutation.
  5432. func (m *BatchMsgMutation) AddedEdges() []string {
  5433. edges := make([]string, 0, 0)
  5434. return edges
  5435. }
  5436. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5437. // name in this mutation.
  5438. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  5439. return nil
  5440. }
  5441. // RemovedEdges returns all edge names that were removed in this mutation.
  5442. func (m *BatchMsgMutation) RemovedEdges() []string {
  5443. edges := make([]string, 0, 0)
  5444. return edges
  5445. }
  5446. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5447. // the given name in this mutation.
  5448. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  5449. return nil
  5450. }
  5451. // ClearedEdges returns all edge names that were cleared in this mutation.
  5452. func (m *BatchMsgMutation) ClearedEdges() []string {
  5453. edges := make([]string, 0, 0)
  5454. return edges
  5455. }
  5456. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5457. // was cleared in this mutation.
  5458. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  5459. return false
  5460. }
  5461. // ClearEdge clears the value of the edge with the given name. It returns an error
  5462. // if that edge is not defined in the schema.
  5463. func (m *BatchMsgMutation) ClearEdge(name string) error {
  5464. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  5465. }
  5466. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5467. // It returns an error if the edge is not defined in the schema.
  5468. func (m *BatchMsgMutation) ResetEdge(name string) error {
  5469. return fmt.Errorf("unknown BatchMsg edge %s", name)
  5470. }
  5471. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  5472. type CategoryMutation struct {
  5473. config
  5474. op Op
  5475. typ string
  5476. id *uint64
  5477. created_at *time.Time
  5478. updated_at *time.Time
  5479. deleted_at *time.Time
  5480. name *string
  5481. organization_id *uint64
  5482. addorganization_id *int64
  5483. clearedFields map[string]struct{}
  5484. done bool
  5485. oldValue func(context.Context) (*Category, error)
  5486. predicates []predicate.Category
  5487. }
  5488. var _ ent.Mutation = (*CategoryMutation)(nil)
  5489. // categoryOption allows management of the mutation configuration using functional options.
  5490. type categoryOption func(*CategoryMutation)
  5491. // newCategoryMutation creates new mutation for the Category entity.
  5492. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  5493. m := &CategoryMutation{
  5494. config: c,
  5495. op: op,
  5496. typ: TypeCategory,
  5497. clearedFields: make(map[string]struct{}),
  5498. }
  5499. for _, opt := range opts {
  5500. opt(m)
  5501. }
  5502. return m
  5503. }
  5504. // withCategoryID sets the ID field of the mutation.
  5505. func withCategoryID(id uint64) categoryOption {
  5506. return func(m *CategoryMutation) {
  5507. var (
  5508. err error
  5509. once sync.Once
  5510. value *Category
  5511. )
  5512. m.oldValue = func(ctx context.Context) (*Category, error) {
  5513. once.Do(func() {
  5514. if m.done {
  5515. err = errors.New("querying old values post mutation is not allowed")
  5516. } else {
  5517. value, err = m.Client().Category.Get(ctx, id)
  5518. }
  5519. })
  5520. return value, err
  5521. }
  5522. m.id = &id
  5523. }
  5524. }
  5525. // withCategory sets the old Category of the mutation.
  5526. func withCategory(node *Category) categoryOption {
  5527. return func(m *CategoryMutation) {
  5528. m.oldValue = func(context.Context) (*Category, error) {
  5529. return node, nil
  5530. }
  5531. m.id = &node.ID
  5532. }
  5533. }
  5534. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5535. // executed in a transaction (ent.Tx), a transactional client is returned.
  5536. func (m CategoryMutation) Client() *Client {
  5537. client := &Client{config: m.config}
  5538. client.init()
  5539. return client
  5540. }
  5541. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5542. // it returns an error otherwise.
  5543. func (m CategoryMutation) Tx() (*Tx, error) {
  5544. if _, ok := m.driver.(*txDriver); !ok {
  5545. return nil, errors.New("ent: mutation is not running in a transaction")
  5546. }
  5547. tx := &Tx{config: m.config}
  5548. tx.init()
  5549. return tx, nil
  5550. }
  5551. // SetID sets the value of the id field. Note that this
  5552. // operation is only accepted on creation of Category entities.
  5553. func (m *CategoryMutation) SetID(id uint64) {
  5554. m.id = &id
  5555. }
  5556. // ID returns the ID value in the mutation. Note that the ID is only available
  5557. // if it was provided to the builder or after it was returned from the database.
  5558. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  5559. if m.id == nil {
  5560. return
  5561. }
  5562. return *m.id, true
  5563. }
  5564. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5565. // That means, if the mutation is applied within a transaction with an isolation level such
  5566. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5567. // or updated by the mutation.
  5568. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  5569. switch {
  5570. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5571. id, exists := m.ID()
  5572. if exists {
  5573. return []uint64{id}, nil
  5574. }
  5575. fallthrough
  5576. case m.op.Is(OpUpdate | OpDelete):
  5577. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  5578. default:
  5579. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5580. }
  5581. }
  5582. // SetCreatedAt sets the "created_at" field.
  5583. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  5584. m.created_at = &t
  5585. }
  5586. // CreatedAt returns the value of the "created_at" field in the mutation.
  5587. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  5588. v := m.created_at
  5589. if v == nil {
  5590. return
  5591. }
  5592. return *v, true
  5593. }
  5594. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  5595. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5596. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5597. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5598. if !m.op.Is(OpUpdateOne) {
  5599. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5600. }
  5601. if m.id == nil || m.oldValue == nil {
  5602. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5603. }
  5604. oldValue, err := m.oldValue(ctx)
  5605. if err != nil {
  5606. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5607. }
  5608. return oldValue.CreatedAt, nil
  5609. }
  5610. // ResetCreatedAt resets all changes to the "created_at" field.
  5611. func (m *CategoryMutation) ResetCreatedAt() {
  5612. m.created_at = nil
  5613. }
  5614. // SetUpdatedAt sets the "updated_at" field.
  5615. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  5616. m.updated_at = &t
  5617. }
  5618. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5619. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  5620. v := m.updated_at
  5621. if v == nil {
  5622. return
  5623. }
  5624. return *v, true
  5625. }
  5626. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  5627. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5629. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5630. if !m.op.Is(OpUpdateOne) {
  5631. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5632. }
  5633. if m.id == nil || m.oldValue == nil {
  5634. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5635. }
  5636. oldValue, err := m.oldValue(ctx)
  5637. if err != nil {
  5638. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5639. }
  5640. return oldValue.UpdatedAt, nil
  5641. }
  5642. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5643. func (m *CategoryMutation) ResetUpdatedAt() {
  5644. m.updated_at = nil
  5645. }
  5646. // SetDeletedAt sets the "deleted_at" field.
  5647. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  5648. m.deleted_at = &t
  5649. }
  5650. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5651. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  5652. v := m.deleted_at
  5653. if v == nil {
  5654. return
  5655. }
  5656. return *v, true
  5657. }
  5658. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  5659. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5660. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5661. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5662. if !m.op.Is(OpUpdateOne) {
  5663. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5664. }
  5665. if m.id == nil || m.oldValue == nil {
  5666. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5667. }
  5668. oldValue, err := m.oldValue(ctx)
  5669. if err != nil {
  5670. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5671. }
  5672. return oldValue.DeletedAt, nil
  5673. }
  5674. // ClearDeletedAt clears the value of the "deleted_at" field.
  5675. func (m *CategoryMutation) ClearDeletedAt() {
  5676. m.deleted_at = nil
  5677. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  5678. }
  5679. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5680. func (m *CategoryMutation) DeletedAtCleared() bool {
  5681. _, ok := m.clearedFields[category.FieldDeletedAt]
  5682. return ok
  5683. }
  5684. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5685. func (m *CategoryMutation) ResetDeletedAt() {
  5686. m.deleted_at = nil
  5687. delete(m.clearedFields, category.FieldDeletedAt)
  5688. }
  5689. // SetName sets the "name" field.
  5690. func (m *CategoryMutation) SetName(s string) {
  5691. m.name = &s
  5692. }
  5693. // Name returns the value of the "name" field in the mutation.
  5694. func (m *CategoryMutation) Name() (r string, exists bool) {
  5695. v := m.name
  5696. if v == nil {
  5697. return
  5698. }
  5699. return *v, true
  5700. }
  5701. // OldName returns the old "name" field's value of the Category entity.
  5702. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5704. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  5705. if !m.op.Is(OpUpdateOne) {
  5706. return v, errors.New("OldName is only allowed on UpdateOne operations")
  5707. }
  5708. if m.id == nil || m.oldValue == nil {
  5709. return v, errors.New("OldName requires an ID field in the mutation")
  5710. }
  5711. oldValue, err := m.oldValue(ctx)
  5712. if err != nil {
  5713. return v, fmt.Errorf("querying old value for OldName: %w", err)
  5714. }
  5715. return oldValue.Name, nil
  5716. }
  5717. // ResetName resets all changes to the "name" field.
  5718. func (m *CategoryMutation) ResetName() {
  5719. m.name = nil
  5720. }
  5721. // SetOrganizationID sets the "organization_id" field.
  5722. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  5723. m.organization_id = &u
  5724. m.addorganization_id = nil
  5725. }
  5726. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5727. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  5728. v := m.organization_id
  5729. if v == nil {
  5730. return
  5731. }
  5732. return *v, true
  5733. }
  5734. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  5735. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5736. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5737. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5738. if !m.op.Is(OpUpdateOne) {
  5739. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5740. }
  5741. if m.id == nil || m.oldValue == nil {
  5742. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5743. }
  5744. oldValue, err := m.oldValue(ctx)
  5745. if err != nil {
  5746. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5747. }
  5748. return oldValue.OrganizationID, nil
  5749. }
  5750. // AddOrganizationID adds u to the "organization_id" field.
  5751. func (m *CategoryMutation) AddOrganizationID(u int64) {
  5752. if m.addorganization_id != nil {
  5753. *m.addorganization_id += u
  5754. } else {
  5755. m.addorganization_id = &u
  5756. }
  5757. }
  5758. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5759. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  5760. v := m.addorganization_id
  5761. if v == nil {
  5762. return
  5763. }
  5764. return *v, true
  5765. }
  5766. // ResetOrganizationID resets all changes to the "organization_id" field.
  5767. func (m *CategoryMutation) ResetOrganizationID() {
  5768. m.organization_id = nil
  5769. m.addorganization_id = nil
  5770. }
  5771. // Where appends a list predicates to the CategoryMutation builder.
  5772. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  5773. m.predicates = append(m.predicates, ps...)
  5774. }
  5775. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  5776. // users can use type-assertion to append predicates that do not depend on any generated package.
  5777. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  5778. p := make([]predicate.Category, len(ps))
  5779. for i := range ps {
  5780. p[i] = ps[i]
  5781. }
  5782. m.Where(p...)
  5783. }
  5784. // Op returns the operation name.
  5785. func (m *CategoryMutation) Op() Op {
  5786. return m.op
  5787. }
  5788. // SetOp allows setting the mutation operation.
  5789. func (m *CategoryMutation) SetOp(op Op) {
  5790. m.op = op
  5791. }
  5792. // Type returns the node type of this mutation (Category).
  5793. func (m *CategoryMutation) Type() string {
  5794. return m.typ
  5795. }
  5796. // Fields returns all fields that were changed during this mutation. Note that in
  5797. // order to get all numeric fields that were incremented/decremented, call
  5798. // AddedFields().
  5799. func (m *CategoryMutation) Fields() []string {
  5800. fields := make([]string, 0, 5)
  5801. if m.created_at != nil {
  5802. fields = append(fields, category.FieldCreatedAt)
  5803. }
  5804. if m.updated_at != nil {
  5805. fields = append(fields, category.FieldUpdatedAt)
  5806. }
  5807. if m.deleted_at != nil {
  5808. fields = append(fields, category.FieldDeletedAt)
  5809. }
  5810. if m.name != nil {
  5811. fields = append(fields, category.FieldName)
  5812. }
  5813. if m.organization_id != nil {
  5814. fields = append(fields, category.FieldOrganizationID)
  5815. }
  5816. return fields
  5817. }
  5818. // Field returns the value of a field with the given name. The second boolean
  5819. // return value indicates that this field was not set, or was not defined in the
  5820. // schema.
  5821. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  5822. switch name {
  5823. case category.FieldCreatedAt:
  5824. return m.CreatedAt()
  5825. case category.FieldUpdatedAt:
  5826. return m.UpdatedAt()
  5827. case category.FieldDeletedAt:
  5828. return m.DeletedAt()
  5829. case category.FieldName:
  5830. return m.Name()
  5831. case category.FieldOrganizationID:
  5832. return m.OrganizationID()
  5833. }
  5834. return nil, false
  5835. }
  5836. // OldField returns the old value of the field from the database. An error is
  5837. // returned if the mutation operation is not UpdateOne, or the query to the
  5838. // database failed.
  5839. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5840. switch name {
  5841. case category.FieldCreatedAt:
  5842. return m.OldCreatedAt(ctx)
  5843. case category.FieldUpdatedAt:
  5844. return m.OldUpdatedAt(ctx)
  5845. case category.FieldDeletedAt:
  5846. return m.OldDeletedAt(ctx)
  5847. case category.FieldName:
  5848. return m.OldName(ctx)
  5849. case category.FieldOrganizationID:
  5850. return m.OldOrganizationID(ctx)
  5851. }
  5852. return nil, fmt.Errorf("unknown Category field %s", name)
  5853. }
  5854. // SetField sets the value of a field with the given name. It returns an error if
  5855. // the field is not defined in the schema, or if the type mismatched the field
  5856. // type.
  5857. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  5858. switch name {
  5859. case category.FieldCreatedAt:
  5860. v, ok := value.(time.Time)
  5861. if !ok {
  5862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5863. }
  5864. m.SetCreatedAt(v)
  5865. return nil
  5866. case category.FieldUpdatedAt:
  5867. v, ok := value.(time.Time)
  5868. if !ok {
  5869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5870. }
  5871. m.SetUpdatedAt(v)
  5872. return nil
  5873. case category.FieldDeletedAt:
  5874. v, ok := value.(time.Time)
  5875. if !ok {
  5876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5877. }
  5878. m.SetDeletedAt(v)
  5879. return nil
  5880. case category.FieldName:
  5881. v, ok := value.(string)
  5882. if !ok {
  5883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5884. }
  5885. m.SetName(v)
  5886. return nil
  5887. case category.FieldOrganizationID:
  5888. v, ok := value.(uint64)
  5889. if !ok {
  5890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5891. }
  5892. m.SetOrganizationID(v)
  5893. return nil
  5894. }
  5895. return fmt.Errorf("unknown Category field %s", name)
  5896. }
  5897. // AddedFields returns all numeric fields that were incremented/decremented during
  5898. // this mutation.
  5899. func (m *CategoryMutation) AddedFields() []string {
  5900. var fields []string
  5901. if m.addorganization_id != nil {
  5902. fields = append(fields, category.FieldOrganizationID)
  5903. }
  5904. return fields
  5905. }
  5906. // AddedField returns the numeric value that was incremented/decremented on a field
  5907. // with the given name. The second boolean return value indicates that this field
  5908. // was not set, or was not defined in the schema.
  5909. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  5910. switch name {
  5911. case category.FieldOrganizationID:
  5912. return m.AddedOrganizationID()
  5913. }
  5914. return nil, false
  5915. }
  5916. // AddField adds the value to the field with the given name. It returns an error if
  5917. // the field is not defined in the schema, or if the type mismatched the field
  5918. // type.
  5919. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  5920. switch name {
  5921. case category.FieldOrganizationID:
  5922. v, ok := value.(int64)
  5923. if !ok {
  5924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5925. }
  5926. m.AddOrganizationID(v)
  5927. return nil
  5928. }
  5929. return fmt.Errorf("unknown Category numeric field %s", name)
  5930. }
  5931. // ClearedFields returns all nullable fields that were cleared during this
  5932. // mutation.
  5933. func (m *CategoryMutation) ClearedFields() []string {
  5934. var fields []string
  5935. if m.FieldCleared(category.FieldDeletedAt) {
  5936. fields = append(fields, category.FieldDeletedAt)
  5937. }
  5938. return fields
  5939. }
  5940. // FieldCleared returns a boolean indicating if a field with the given name was
  5941. // cleared in this mutation.
  5942. func (m *CategoryMutation) FieldCleared(name string) bool {
  5943. _, ok := m.clearedFields[name]
  5944. return ok
  5945. }
  5946. // ClearField clears the value of the field with the given name. It returns an
  5947. // error if the field is not defined in the schema.
  5948. func (m *CategoryMutation) ClearField(name string) error {
  5949. switch name {
  5950. case category.FieldDeletedAt:
  5951. m.ClearDeletedAt()
  5952. return nil
  5953. }
  5954. return fmt.Errorf("unknown Category nullable field %s", name)
  5955. }
  5956. // ResetField resets all changes in the mutation for the field with the given name.
  5957. // It returns an error if the field is not defined in the schema.
  5958. func (m *CategoryMutation) ResetField(name string) error {
  5959. switch name {
  5960. case category.FieldCreatedAt:
  5961. m.ResetCreatedAt()
  5962. return nil
  5963. case category.FieldUpdatedAt:
  5964. m.ResetUpdatedAt()
  5965. return nil
  5966. case category.FieldDeletedAt:
  5967. m.ResetDeletedAt()
  5968. return nil
  5969. case category.FieldName:
  5970. m.ResetName()
  5971. return nil
  5972. case category.FieldOrganizationID:
  5973. m.ResetOrganizationID()
  5974. return nil
  5975. }
  5976. return fmt.Errorf("unknown Category field %s", name)
  5977. }
  5978. // AddedEdges returns all edge names that were set/added in this mutation.
  5979. func (m *CategoryMutation) AddedEdges() []string {
  5980. edges := make([]string, 0, 0)
  5981. return edges
  5982. }
  5983. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5984. // name in this mutation.
  5985. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  5986. return nil
  5987. }
  5988. // RemovedEdges returns all edge names that were removed in this mutation.
  5989. func (m *CategoryMutation) RemovedEdges() []string {
  5990. edges := make([]string, 0, 0)
  5991. return edges
  5992. }
  5993. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5994. // the given name in this mutation.
  5995. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  5996. return nil
  5997. }
  5998. // ClearedEdges returns all edge names that were cleared in this mutation.
  5999. func (m *CategoryMutation) ClearedEdges() []string {
  6000. edges := make([]string, 0, 0)
  6001. return edges
  6002. }
  6003. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6004. // was cleared in this mutation.
  6005. func (m *CategoryMutation) EdgeCleared(name string) bool {
  6006. return false
  6007. }
  6008. // ClearEdge clears the value of the edge with the given name. It returns an error
  6009. // if that edge is not defined in the schema.
  6010. func (m *CategoryMutation) ClearEdge(name string) error {
  6011. return fmt.Errorf("unknown Category unique edge %s", name)
  6012. }
  6013. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6014. // It returns an error if the edge is not defined in the schema.
  6015. func (m *CategoryMutation) ResetEdge(name string) error {
  6016. return fmt.Errorf("unknown Category edge %s", name)
  6017. }
  6018. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  6019. type ChatRecordsMutation struct {
  6020. config
  6021. op Op
  6022. typ string
  6023. id *uint64
  6024. created_at *time.Time
  6025. updated_at *time.Time
  6026. deleted_at *time.Time
  6027. content *string
  6028. content_type *uint8
  6029. addcontent_type *int8
  6030. session_id *uint64
  6031. addsession_id *int64
  6032. user_id *uint64
  6033. adduser_id *int64
  6034. bot_id *uint64
  6035. addbot_id *int64
  6036. bot_type *uint8
  6037. addbot_type *int8
  6038. clearedFields map[string]struct{}
  6039. done bool
  6040. oldValue func(context.Context) (*ChatRecords, error)
  6041. predicates []predicate.ChatRecords
  6042. }
  6043. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  6044. // chatrecordsOption allows management of the mutation configuration using functional options.
  6045. type chatrecordsOption func(*ChatRecordsMutation)
  6046. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  6047. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  6048. m := &ChatRecordsMutation{
  6049. config: c,
  6050. op: op,
  6051. typ: TypeChatRecords,
  6052. clearedFields: make(map[string]struct{}),
  6053. }
  6054. for _, opt := range opts {
  6055. opt(m)
  6056. }
  6057. return m
  6058. }
  6059. // withChatRecordsID sets the ID field of the mutation.
  6060. func withChatRecordsID(id uint64) chatrecordsOption {
  6061. return func(m *ChatRecordsMutation) {
  6062. var (
  6063. err error
  6064. once sync.Once
  6065. value *ChatRecords
  6066. )
  6067. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  6068. once.Do(func() {
  6069. if m.done {
  6070. err = errors.New("querying old values post mutation is not allowed")
  6071. } else {
  6072. value, err = m.Client().ChatRecords.Get(ctx, id)
  6073. }
  6074. })
  6075. return value, err
  6076. }
  6077. m.id = &id
  6078. }
  6079. }
  6080. // withChatRecords sets the old ChatRecords of the mutation.
  6081. func withChatRecords(node *ChatRecords) chatrecordsOption {
  6082. return func(m *ChatRecordsMutation) {
  6083. m.oldValue = func(context.Context) (*ChatRecords, error) {
  6084. return node, nil
  6085. }
  6086. m.id = &node.ID
  6087. }
  6088. }
  6089. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6090. // executed in a transaction (ent.Tx), a transactional client is returned.
  6091. func (m ChatRecordsMutation) Client() *Client {
  6092. client := &Client{config: m.config}
  6093. client.init()
  6094. return client
  6095. }
  6096. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6097. // it returns an error otherwise.
  6098. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  6099. if _, ok := m.driver.(*txDriver); !ok {
  6100. return nil, errors.New("ent: mutation is not running in a transaction")
  6101. }
  6102. tx := &Tx{config: m.config}
  6103. tx.init()
  6104. return tx, nil
  6105. }
  6106. // SetID sets the value of the id field. Note that this
  6107. // operation is only accepted on creation of ChatRecords entities.
  6108. func (m *ChatRecordsMutation) SetID(id uint64) {
  6109. m.id = &id
  6110. }
  6111. // ID returns the ID value in the mutation. Note that the ID is only available
  6112. // if it was provided to the builder or after it was returned from the database.
  6113. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  6114. if m.id == nil {
  6115. return
  6116. }
  6117. return *m.id, true
  6118. }
  6119. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6120. // That means, if the mutation is applied within a transaction with an isolation level such
  6121. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6122. // or updated by the mutation.
  6123. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  6124. switch {
  6125. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6126. id, exists := m.ID()
  6127. if exists {
  6128. return []uint64{id}, nil
  6129. }
  6130. fallthrough
  6131. case m.op.Is(OpUpdate | OpDelete):
  6132. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  6133. default:
  6134. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6135. }
  6136. }
  6137. // SetCreatedAt sets the "created_at" field.
  6138. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  6139. m.created_at = &t
  6140. }
  6141. // CreatedAt returns the value of the "created_at" field in the mutation.
  6142. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  6143. v := m.created_at
  6144. if v == nil {
  6145. return
  6146. }
  6147. return *v, true
  6148. }
  6149. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  6150. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6151. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6152. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6153. if !m.op.Is(OpUpdateOne) {
  6154. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6155. }
  6156. if m.id == nil || m.oldValue == nil {
  6157. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6158. }
  6159. oldValue, err := m.oldValue(ctx)
  6160. if err != nil {
  6161. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6162. }
  6163. return oldValue.CreatedAt, nil
  6164. }
  6165. // ResetCreatedAt resets all changes to the "created_at" field.
  6166. func (m *ChatRecordsMutation) ResetCreatedAt() {
  6167. m.created_at = nil
  6168. }
  6169. // SetUpdatedAt sets the "updated_at" field.
  6170. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  6171. m.updated_at = &t
  6172. }
  6173. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6174. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  6175. v := m.updated_at
  6176. if v == nil {
  6177. return
  6178. }
  6179. return *v, true
  6180. }
  6181. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  6182. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6184. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6185. if !m.op.Is(OpUpdateOne) {
  6186. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6187. }
  6188. if m.id == nil || m.oldValue == nil {
  6189. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6190. }
  6191. oldValue, err := m.oldValue(ctx)
  6192. if err != nil {
  6193. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6194. }
  6195. return oldValue.UpdatedAt, nil
  6196. }
  6197. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6198. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  6199. m.updated_at = nil
  6200. }
  6201. // SetDeletedAt sets the "deleted_at" field.
  6202. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  6203. m.deleted_at = &t
  6204. }
  6205. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6206. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  6207. v := m.deleted_at
  6208. if v == nil {
  6209. return
  6210. }
  6211. return *v, true
  6212. }
  6213. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  6214. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6215. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6216. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6217. if !m.op.Is(OpUpdateOne) {
  6218. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6219. }
  6220. if m.id == nil || m.oldValue == nil {
  6221. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6222. }
  6223. oldValue, err := m.oldValue(ctx)
  6224. if err != nil {
  6225. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6226. }
  6227. return oldValue.DeletedAt, nil
  6228. }
  6229. // ClearDeletedAt clears the value of the "deleted_at" field.
  6230. func (m *ChatRecordsMutation) ClearDeletedAt() {
  6231. m.deleted_at = nil
  6232. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  6233. }
  6234. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6235. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  6236. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  6237. return ok
  6238. }
  6239. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6240. func (m *ChatRecordsMutation) ResetDeletedAt() {
  6241. m.deleted_at = nil
  6242. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  6243. }
  6244. // SetContent sets the "content" field.
  6245. func (m *ChatRecordsMutation) SetContent(s string) {
  6246. m.content = &s
  6247. }
  6248. // Content returns the value of the "content" field in the mutation.
  6249. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  6250. v := m.content
  6251. if v == nil {
  6252. return
  6253. }
  6254. return *v, true
  6255. }
  6256. // OldContent returns the old "content" field's value of the ChatRecords entity.
  6257. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6259. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  6260. if !m.op.Is(OpUpdateOne) {
  6261. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6262. }
  6263. if m.id == nil || m.oldValue == nil {
  6264. return v, errors.New("OldContent requires an ID field in the mutation")
  6265. }
  6266. oldValue, err := m.oldValue(ctx)
  6267. if err != nil {
  6268. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  6269. }
  6270. return oldValue.Content, nil
  6271. }
  6272. // ResetContent resets all changes to the "content" field.
  6273. func (m *ChatRecordsMutation) ResetContent() {
  6274. m.content = nil
  6275. }
  6276. // SetContentType sets the "content_type" field.
  6277. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  6278. m.content_type = &u
  6279. m.addcontent_type = nil
  6280. }
  6281. // ContentType returns the value of the "content_type" field in the mutation.
  6282. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  6283. v := m.content_type
  6284. if v == nil {
  6285. return
  6286. }
  6287. return *v, true
  6288. }
  6289. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  6290. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6292. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  6293. if !m.op.Is(OpUpdateOne) {
  6294. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  6295. }
  6296. if m.id == nil || m.oldValue == nil {
  6297. return v, errors.New("OldContentType requires an ID field in the mutation")
  6298. }
  6299. oldValue, err := m.oldValue(ctx)
  6300. if err != nil {
  6301. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  6302. }
  6303. return oldValue.ContentType, nil
  6304. }
  6305. // AddContentType adds u to the "content_type" field.
  6306. func (m *ChatRecordsMutation) AddContentType(u int8) {
  6307. if m.addcontent_type != nil {
  6308. *m.addcontent_type += u
  6309. } else {
  6310. m.addcontent_type = &u
  6311. }
  6312. }
  6313. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  6314. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  6315. v := m.addcontent_type
  6316. if v == nil {
  6317. return
  6318. }
  6319. return *v, true
  6320. }
  6321. // ResetContentType resets all changes to the "content_type" field.
  6322. func (m *ChatRecordsMutation) ResetContentType() {
  6323. m.content_type = nil
  6324. m.addcontent_type = nil
  6325. }
  6326. // SetSessionID sets the "session_id" field.
  6327. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  6328. m.session_id = &u
  6329. m.addsession_id = nil
  6330. }
  6331. // SessionID returns the value of the "session_id" field in the mutation.
  6332. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  6333. v := m.session_id
  6334. if v == nil {
  6335. return
  6336. }
  6337. return *v, true
  6338. }
  6339. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  6340. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6342. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  6343. if !m.op.Is(OpUpdateOne) {
  6344. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  6345. }
  6346. if m.id == nil || m.oldValue == nil {
  6347. return v, errors.New("OldSessionID requires an ID field in the mutation")
  6348. }
  6349. oldValue, err := m.oldValue(ctx)
  6350. if err != nil {
  6351. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  6352. }
  6353. return oldValue.SessionID, nil
  6354. }
  6355. // AddSessionID adds u to the "session_id" field.
  6356. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  6357. if m.addsession_id != nil {
  6358. *m.addsession_id += u
  6359. } else {
  6360. m.addsession_id = &u
  6361. }
  6362. }
  6363. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  6364. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  6365. v := m.addsession_id
  6366. if v == nil {
  6367. return
  6368. }
  6369. return *v, true
  6370. }
  6371. // ResetSessionID resets all changes to the "session_id" field.
  6372. func (m *ChatRecordsMutation) ResetSessionID() {
  6373. m.session_id = nil
  6374. m.addsession_id = nil
  6375. }
  6376. // SetUserID sets the "user_id" field.
  6377. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  6378. m.user_id = &u
  6379. m.adduser_id = nil
  6380. }
  6381. // UserID returns the value of the "user_id" field in the mutation.
  6382. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  6383. v := m.user_id
  6384. if v == nil {
  6385. return
  6386. }
  6387. return *v, true
  6388. }
  6389. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  6390. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6392. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6393. if !m.op.Is(OpUpdateOne) {
  6394. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6395. }
  6396. if m.id == nil || m.oldValue == nil {
  6397. return v, errors.New("OldUserID requires an ID field in the mutation")
  6398. }
  6399. oldValue, err := m.oldValue(ctx)
  6400. if err != nil {
  6401. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6402. }
  6403. return oldValue.UserID, nil
  6404. }
  6405. // AddUserID adds u to the "user_id" field.
  6406. func (m *ChatRecordsMutation) AddUserID(u int64) {
  6407. if m.adduser_id != nil {
  6408. *m.adduser_id += u
  6409. } else {
  6410. m.adduser_id = &u
  6411. }
  6412. }
  6413. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6414. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  6415. v := m.adduser_id
  6416. if v == nil {
  6417. return
  6418. }
  6419. return *v, true
  6420. }
  6421. // ResetUserID resets all changes to the "user_id" field.
  6422. func (m *ChatRecordsMutation) ResetUserID() {
  6423. m.user_id = nil
  6424. m.adduser_id = nil
  6425. }
  6426. // SetBotID sets the "bot_id" field.
  6427. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  6428. m.bot_id = &u
  6429. m.addbot_id = nil
  6430. }
  6431. // BotID returns the value of the "bot_id" field in the mutation.
  6432. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  6433. v := m.bot_id
  6434. if v == nil {
  6435. return
  6436. }
  6437. return *v, true
  6438. }
  6439. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  6440. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6442. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6443. if !m.op.Is(OpUpdateOne) {
  6444. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6445. }
  6446. if m.id == nil || m.oldValue == nil {
  6447. return v, errors.New("OldBotID requires an ID field in the mutation")
  6448. }
  6449. oldValue, err := m.oldValue(ctx)
  6450. if err != nil {
  6451. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6452. }
  6453. return oldValue.BotID, nil
  6454. }
  6455. // AddBotID adds u to the "bot_id" field.
  6456. func (m *ChatRecordsMutation) AddBotID(u int64) {
  6457. if m.addbot_id != nil {
  6458. *m.addbot_id += u
  6459. } else {
  6460. m.addbot_id = &u
  6461. }
  6462. }
  6463. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6464. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  6465. v := m.addbot_id
  6466. if v == nil {
  6467. return
  6468. }
  6469. return *v, true
  6470. }
  6471. // ResetBotID resets all changes to the "bot_id" field.
  6472. func (m *ChatRecordsMutation) ResetBotID() {
  6473. m.bot_id = nil
  6474. m.addbot_id = nil
  6475. }
  6476. // SetBotType sets the "bot_type" field.
  6477. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  6478. m.bot_type = &u
  6479. m.addbot_type = nil
  6480. }
  6481. // BotType returns the value of the "bot_type" field in the mutation.
  6482. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  6483. v := m.bot_type
  6484. if v == nil {
  6485. return
  6486. }
  6487. return *v, true
  6488. }
  6489. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  6490. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6492. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6493. if !m.op.Is(OpUpdateOne) {
  6494. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6495. }
  6496. if m.id == nil || m.oldValue == nil {
  6497. return v, errors.New("OldBotType requires an ID field in the mutation")
  6498. }
  6499. oldValue, err := m.oldValue(ctx)
  6500. if err != nil {
  6501. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  6502. }
  6503. return oldValue.BotType, nil
  6504. }
  6505. // AddBotType adds u to the "bot_type" field.
  6506. func (m *ChatRecordsMutation) AddBotType(u int8) {
  6507. if m.addbot_type != nil {
  6508. *m.addbot_type += u
  6509. } else {
  6510. m.addbot_type = &u
  6511. }
  6512. }
  6513. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  6514. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  6515. v := m.addbot_type
  6516. if v == nil {
  6517. return
  6518. }
  6519. return *v, true
  6520. }
  6521. // ResetBotType resets all changes to the "bot_type" field.
  6522. func (m *ChatRecordsMutation) ResetBotType() {
  6523. m.bot_type = nil
  6524. m.addbot_type = nil
  6525. }
  6526. // Where appends a list predicates to the ChatRecordsMutation builder.
  6527. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  6528. m.predicates = append(m.predicates, ps...)
  6529. }
  6530. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  6531. // users can use type-assertion to append predicates that do not depend on any generated package.
  6532. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  6533. p := make([]predicate.ChatRecords, len(ps))
  6534. for i := range ps {
  6535. p[i] = ps[i]
  6536. }
  6537. m.Where(p...)
  6538. }
  6539. // Op returns the operation name.
  6540. func (m *ChatRecordsMutation) Op() Op {
  6541. return m.op
  6542. }
  6543. // SetOp allows setting the mutation operation.
  6544. func (m *ChatRecordsMutation) SetOp(op Op) {
  6545. m.op = op
  6546. }
  6547. // Type returns the node type of this mutation (ChatRecords).
  6548. func (m *ChatRecordsMutation) Type() string {
  6549. return m.typ
  6550. }
  6551. // Fields returns all fields that were changed during this mutation. Note that in
  6552. // order to get all numeric fields that were incremented/decremented, call
  6553. // AddedFields().
  6554. func (m *ChatRecordsMutation) Fields() []string {
  6555. fields := make([]string, 0, 9)
  6556. if m.created_at != nil {
  6557. fields = append(fields, chatrecords.FieldCreatedAt)
  6558. }
  6559. if m.updated_at != nil {
  6560. fields = append(fields, chatrecords.FieldUpdatedAt)
  6561. }
  6562. if m.deleted_at != nil {
  6563. fields = append(fields, chatrecords.FieldDeletedAt)
  6564. }
  6565. if m.content != nil {
  6566. fields = append(fields, chatrecords.FieldContent)
  6567. }
  6568. if m.content_type != nil {
  6569. fields = append(fields, chatrecords.FieldContentType)
  6570. }
  6571. if m.session_id != nil {
  6572. fields = append(fields, chatrecords.FieldSessionID)
  6573. }
  6574. if m.user_id != nil {
  6575. fields = append(fields, chatrecords.FieldUserID)
  6576. }
  6577. if m.bot_id != nil {
  6578. fields = append(fields, chatrecords.FieldBotID)
  6579. }
  6580. if m.bot_type != nil {
  6581. fields = append(fields, chatrecords.FieldBotType)
  6582. }
  6583. return fields
  6584. }
  6585. // Field returns the value of a field with the given name. The second boolean
  6586. // return value indicates that this field was not set, or was not defined in the
  6587. // schema.
  6588. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  6589. switch name {
  6590. case chatrecords.FieldCreatedAt:
  6591. return m.CreatedAt()
  6592. case chatrecords.FieldUpdatedAt:
  6593. return m.UpdatedAt()
  6594. case chatrecords.FieldDeletedAt:
  6595. return m.DeletedAt()
  6596. case chatrecords.FieldContent:
  6597. return m.Content()
  6598. case chatrecords.FieldContentType:
  6599. return m.ContentType()
  6600. case chatrecords.FieldSessionID:
  6601. return m.SessionID()
  6602. case chatrecords.FieldUserID:
  6603. return m.UserID()
  6604. case chatrecords.FieldBotID:
  6605. return m.BotID()
  6606. case chatrecords.FieldBotType:
  6607. return m.BotType()
  6608. }
  6609. return nil, false
  6610. }
  6611. // OldField returns the old value of the field from the database. An error is
  6612. // returned if the mutation operation is not UpdateOne, or the query to the
  6613. // database failed.
  6614. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6615. switch name {
  6616. case chatrecords.FieldCreatedAt:
  6617. return m.OldCreatedAt(ctx)
  6618. case chatrecords.FieldUpdatedAt:
  6619. return m.OldUpdatedAt(ctx)
  6620. case chatrecords.FieldDeletedAt:
  6621. return m.OldDeletedAt(ctx)
  6622. case chatrecords.FieldContent:
  6623. return m.OldContent(ctx)
  6624. case chatrecords.FieldContentType:
  6625. return m.OldContentType(ctx)
  6626. case chatrecords.FieldSessionID:
  6627. return m.OldSessionID(ctx)
  6628. case chatrecords.FieldUserID:
  6629. return m.OldUserID(ctx)
  6630. case chatrecords.FieldBotID:
  6631. return m.OldBotID(ctx)
  6632. case chatrecords.FieldBotType:
  6633. return m.OldBotType(ctx)
  6634. }
  6635. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  6636. }
  6637. // SetField sets the value of a field with the given name. It returns an error if
  6638. // the field is not defined in the schema, or if the type mismatched the field
  6639. // type.
  6640. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  6641. switch name {
  6642. case chatrecords.FieldCreatedAt:
  6643. v, ok := value.(time.Time)
  6644. if !ok {
  6645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6646. }
  6647. m.SetCreatedAt(v)
  6648. return nil
  6649. case chatrecords.FieldUpdatedAt:
  6650. v, ok := value.(time.Time)
  6651. if !ok {
  6652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6653. }
  6654. m.SetUpdatedAt(v)
  6655. return nil
  6656. case chatrecords.FieldDeletedAt:
  6657. v, ok := value.(time.Time)
  6658. if !ok {
  6659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6660. }
  6661. m.SetDeletedAt(v)
  6662. return nil
  6663. case chatrecords.FieldContent:
  6664. v, ok := value.(string)
  6665. if !ok {
  6666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6667. }
  6668. m.SetContent(v)
  6669. return nil
  6670. case chatrecords.FieldContentType:
  6671. v, ok := value.(uint8)
  6672. if !ok {
  6673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6674. }
  6675. m.SetContentType(v)
  6676. return nil
  6677. case chatrecords.FieldSessionID:
  6678. v, ok := value.(uint64)
  6679. if !ok {
  6680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6681. }
  6682. m.SetSessionID(v)
  6683. return nil
  6684. case chatrecords.FieldUserID:
  6685. v, ok := value.(uint64)
  6686. if !ok {
  6687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6688. }
  6689. m.SetUserID(v)
  6690. return nil
  6691. case chatrecords.FieldBotID:
  6692. v, ok := value.(uint64)
  6693. if !ok {
  6694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6695. }
  6696. m.SetBotID(v)
  6697. return nil
  6698. case chatrecords.FieldBotType:
  6699. v, ok := value.(uint8)
  6700. if !ok {
  6701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6702. }
  6703. m.SetBotType(v)
  6704. return nil
  6705. }
  6706. return fmt.Errorf("unknown ChatRecords field %s", name)
  6707. }
  6708. // AddedFields returns all numeric fields that were incremented/decremented during
  6709. // this mutation.
  6710. func (m *ChatRecordsMutation) AddedFields() []string {
  6711. var fields []string
  6712. if m.addcontent_type != nil {
  6713. fields = append(fields, chatrecords.FieldContentType)
  6714. }
  6715. if m.addsession_id != nil {
  6716. fields = append(fields, chatrecords.FieldSessionID)
  6717. }
  6718. if m.adduser_id != nil {
  6719. fields = append(fields, chatrecords.FieldUserID)
  6720. }
  6721. if m.addbot_id != nil {
  6722. fields = append(fields, chatrecords.FieldBotID)
  6723. }
  6724. if m.addbot_type != nil {
  6725. fields = append(fields, chatrecords.FieldBotType)
  6726. }
  6727. return fields
  6728. }
  6729. // AddedField returns the numeric value that was incremented/decremented on a field
  6730. // with the given name. The second boolean return value indicates that this field
  6731. // was not set, or was not defined in the schema.
  6732. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  6733. switch name {
  6734. case chatrecords.FieldContentType:
  6735. return m.AddedContentType()
  6736. case chatrecords.FieldSessionID:
  6737. return m.AddedSessionID()
  6738. case chatrecords.FieldUserID:
  6739. return m.AddedUserID()
  6740. case chatrecords.FieldBotID:
  6741. return m.AddedBotID()
  6742. case chatrecords.FieldBotType:
  6743. return m.AddedBotType()
  6744. }
  6745. return nil, false
  6746. }
  6747. // AddField adds the value to the field with the given name. It returns an error if
  6748. // the field is not defined in the schema, or if the type mismatched the field
  6749. // type.
  6750. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  6751. switch name {
  6752. case chatrecords.FieldContentType:
  6753. v, ok := value.(int8)
  6754. if !ok {
  6755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6756. }
  6757. m.AddContentType(v)
  6758. return nil
  6759. case chatrecords.FieldSessionID:
  6760. v, ok := value.(int64)
  6761. if !ok {
  6762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6763. }
  6764. m.AddSessionID(v)
  6765. return nil
  6766. case chatrecords.FieldUserID:
  6767. v, ok := value.(int64)
  6768. if !ok {
  6769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6770. }
  6771. m.AddUserID(v)
  6772. return nil
  6773. case chatrecords.FieldBotID:
  6774. v, ok := value.(int64)
  6775. if !ok {
  6776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6777. }
  6778. m.AddBotID(v)
  6779. return nil
  6780. case chatrecords.FieldBotType:
  6781. v, ok := value.(int8)
  6782. if !ok {
  6783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6784. }
  6785. m.AddBotType(v)
  6786. return nil
  6787. }
  6788. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  6789. }
  6790. // ClearedFields returns all nullable fields that were cleared during this
  6791. // mutation.
  6792. func (m *ChatRecordsMutation) ClearedFields() []string {
  6793. var fields []string
  6794. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  6795. fields = append(fields, chatrecords.FieldDeletedAt)
  6796. }
  6797. return fields
  6798. }
  6799. // FieldCleared returns a boolean indicating if a field with the given name was
  6800. // cleared in this mutation.
  6801. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  6802. _, ok := m.clearedFields[name]
  6803. return ok
  6804. }
  6805. // ClearField clears the value of the field with the given name. It returns an
  6806. // error if the field is not defined in the schema.
  6807. func (m *ChatRecordsMutation) ClearField(name string) error {
  6808. switch name {
  6809. case chatrecords.FieldDeletedAt:
  6810. m.ClearDeletedAt()
  6811. return nil
  6812. }
  6813. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  6814. }
  6815. // ResetField resets all changes in the mutation for the field with the given name.
  6816. // It returns an error if the field is not defined in the schema.
  6817. func (m *ChatRecordsMutation) ResetField(name string) error {
  6818. switch name {
  6819. case chatrecords.FieldCreatedAt:
  6820. m.ResetCreatedAt()
  6821. return nil
  6822. case chatrecords.FieldUpdatedAt:
  6823. m.ResetUpdatedAt()
  6824. return nil
  6825. case chatrecords.FieldDeletedAt:
  6826. m.ResetDeletedAt()
  6827. return nil
  6828. case chatrecords.FieldContent:
  6829. m.ResetContent()
  6830. return nil
  6831. case chatrecords.FieldContentType:
  6832. m.ResetContentType()
  6833. return nil
  6834. case chatrecords.FieldSessionID:
  6835. m.ResetSessionID()
  6836. return nil
  6837. case chatrecords.FieldUserID:
  6838. m.ResetUserID()
  6839. return nil
  6840. case chatrecords.FieldBotID:
  6841. m.ResetBotID()
  6842. return nil
  6843. case chatrecords.FieldBotType:
  6844. m.ResetBotType()
  6845. return nil
  6846. }
  6847. return fmt.Errorf("unknown ChatRecords field %s", name)
  6848. }
  6849. // AddedEdges returns all edge names that were set/added in this mutation.
  6850. func (m *ChatRecordsMutation) AddedEdges() []string {
  6851. edges := make([]string, 0, 0)
  6852. return edges
  6853. }
  6854. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6855. // name in this mutation.
  6856. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  6857. return nil
  6858. }
  6859. // RemovedEdges returns all edge names that were removed in this mutation.
  6860. func (m *ChatRecordsMutation) RemovedEdges() []string {
  6861. edges := make([]string, 0, 0)
  6862. return edges
  6863. }
  6864. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6865. // the given name in this mutation.
  6866. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  6867. return nil
  6868. }
  6869. // ClearedEdges returns all edge names that were cleared in this mutation.
  6870. func (m *ChatRecordsMutation) ClearedEdges() []string {
  6871. edges := make([]string, 0, 0)
  6872. return edges
  6873. }
  6874. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6875. // was cleared in this mutation.
  6876. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  6877. return false
  6878. }
  6879. // ClearEdge clears the value of the edge with the given name. It returns an error
  6880. // if that edge is not defined in the schema.
  6881. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  6882. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  6883. }
  6884. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6885. // It returns an error if the edge is not defined in the schema.
  6886. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  6887. return fmt.Errorf("unknown ChatRecords edge %s", name)
  6888. }
  6889. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  6890. type ChatSessionMutation struct {
  6891. config
  6892. op Op
  6893. typ string
  6894. id *uint64
  6895. created_at *time.Time
  6896. updated_at *time.Time
  6897. deleted_at *time.Time
  6898. name *string
  6899. user_id *uint64
  6900. adduser_id *int64
  6901. bot_id *uint64
  6902. addbot_id *int64
  6903. bot_type *uint8
  6904. addbot_type *int8
  6905. clearedFields map[string]struct{}
  6906. done bool
  6907. oldValue func(context.Context) (*ChatSession, error)
  6908. predicates []predicate.ChatSession
  6909. }
  6910. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  6911. // chatsessionOption allows management of the mutation configuration using functional options.
  6912. type chatsessionOption func(*ChatSessionMutation)
  6913. // newChatSessionMutation creates new mutation for the ChatSession entity.
  6914. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  6915. m := &ChatSessionMutation{
  6916. config: c,
  6917. op: op,
  6918. typ: TypeChatSession,
  6919. clearedFields: make(map[string]struct{}),
  6920. }
  6921. for _, opt := range opts {
  6922. opt(m)
  6923. }
  6924. return m
  6925. }
  6926. // withChatSessionID sets the ID field of the mutation.
  6927. func withChatSessionID(id uint64) chatsessionOption {
  6928. return func(m *ChatSessionMutation) {
  6929. var (
  6930. err error
  6931. once sync.Once
  6932. value *ChatSession
  6933. )
  6934. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  6935. once.Do(func() {
  6936. if m.done {
  6937. err = errors.New("querying old values post mutation is not allowed")
  6938. } else {
  6939. value, err = m.Client().ChatSession.Get(ctx, id)
  6940. }
  6941. })
  6942. return value, err
  6943. }
  6944. m.id = &id
  6945. }
  6946. }
  6947. // withChatSession sets the old ChatSession of the mutation.
  6948. func withChatSession(node *ChatSession) chatsessionOption {
  6949. return func(m *ChatSessionMutation) {
  6950. m.oldValue = func(context.Context) (*ChatSession, error) {
  6951. return node, nil
  6952. }
  6953. m.id = &node.ID
  6954. }
  6955. }
  6956. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6957. // executed in a transaction (ent.Tx), a transactional client is returned.
  6958. func (m ChatSessionMutation) Client() *Client {
  6959. client := &Client{config: m.config}
  6960. client.init()
  6961. return client
  6962. }
  6963. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6964. // it returns an error otherwise.
  6965. func (m ChatSessionMutation) Tx() (*Tx, error) {
  6966. if _, ok := m.driver.(*txDriver); !ok {
  6967. return nil, errors.New("ent: mutation is not running in a transaction")
  6968. }
  6969. tx := &Tx{config: m.config}
  6970. tx.init()
  6971. return tx, nil
  6972. }
  6973. // SetID sets the value of the id field. Note that this
  6974. // operation is only accepted on creation of ChatSession entities.
  6975. func (m *ChatSessionMutation) SetID(id uint64) {
  6976. m.id = &id
  6977. }
  6978. // ID returns the ID value in the mutation. Note that the ID is only available
  6979. // if it was provided to the builder or after it was returned from the database.
  6980. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  6981. if m.id == nil {
  6982. return
  6983. }
  6984. return *m.id, true
  6985. }
  6986. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6987. // That means, if the mutation is applied within a transaction with an isolation level such
  6988. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6989. // or updated by the mutation.
  6990. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  6991. switch {
  6992. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6993. id, exists := m.ID()
  6994. if exists {
  6995. return []uint64{id}, nil
  6996. }
  6997. fallthrough
  6998. case m.op.Is(OpUpdate | OpDelete):
  6999. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  7000. default:
  7001. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7002. }
  7003. }
  7004. // SetCreatedAt sets the "created_at" field.
  7005. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  7006. m.created_at = &t
  7007. }
  7008. // CreatedAt returns the value of the "created_at" field in the mutation.
  7009. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  7010. v := m.created_at
  7011. if v == nil {
  7012. return
  7013. }
  7014. return *v, true
  7015. }
  7016. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  7017. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7019. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7020. if !m.op.Is(OpUpdateOne) {
  7021. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7022. }
  7023. if m.id == nil || m.oldValue == nil {
  7024. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7025. }
  7026. oldValue, err := m.oldValue(ctx)
  7027. if err != nil {
  7028. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7029. }
  7030. return oldValue.CreatedAt, nil
  7031. }
  7032. // ResetCreatedAt resets all changes to the "created_at" field.
  7033. func (m *ChatSessionMutation) ResetCreatedAt() {
  7034. m.created_at = nil
  7035. }
  7036. // SetUpdatedAt sets the "updated_at" field.
  7037. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  7038. m.updated_at = &t
  7039. }
  7040. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7041. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  7042. v := m.updated_at
  7043. if v == nil {
  7044. return
  7045. }
  7046. return *v, true
  7047. }
  7048. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  7049. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7051. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7052. if !m.op.Is(OpUpdateOne) {
  7053. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7054. }
  7055. if m.id == nil || m.oldValue == nil {
  7056. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7057. }
  7058. oldValue, err := m.oldValue(ctx)
  7059. if err != nil {
  7060. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7061. }
  7062. return oldValue.UpdatedAt, nil
  7063. }
  7064. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7065. func (m *ChatSessionMutation) ResetUpdatedAt() {
  7066. m.updated_at = nil
  7067. }
  7068. // SetDeletedAt sets the "deleted_at" field.
  7069. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  7070. m.deleted_at = &t
  7071. }
  7072. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7073. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  7074. v := m.deleted_at
  7075. if v == nil {
  7076. return
  7077. }
  7078. return *v, true
  7079. }
  7080. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  7081. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7083. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7084. if !m.op.Is(OpUpdateOne) {
  7085. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7086. }
  7087. if m.id == nil || m.oldValue == nil {
  7088. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7089. }
  7090. oldValue, err := m.oldValue(ctx)
  7091. if err != nil {
  7092. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7093. }
  7094. return oldValue.DeletedAt, nil
  7095. }
  7096. // ClearDeletedAt clears the value of the "deleted_at" field.
  7097. func (m *ChatSessionMutation) ClearDeletedAt() {
  7098. m.deleted_at = nil
  7099. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  7100. }
  7101. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7102. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  7103. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  7104. return ok
  7105. }
  7106. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7107. func (m *ChatSessionMutation) ResetDeletedAt() {
  7108. m.deleted_at = nil
  7109. delete(m.clearedFields, chatsession.FieldDeletedAt)
  7110. }
  7111. // SetName sets the "name" field.
  7112. func (m *ChatSessionMutation) SetName(s string) {
  7113. m.name = &s
  7114. }
  7115. // Name returns the value of the "name" field in the mutation.
  7116. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  7117. v := m.name
  7118. if v == nil {
  7119. return
  7120. }
  7121. return *v, true
  7122. }
  7123. // OldName returns the old "name" field's value of the ChatSession entity.
  7124. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7125. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7126. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  7127. if !m.op.Is(OpUpdateOne) {
  7128. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7129. }
  7130. if m.id == nil || m.oldValue == nil {
  7131. return v, errors.New("OldName requires an ID field in the mutation")
  7132. }
  7133. oldValue, err := m.oldValue(ctx)
  7134. if err != nil {
  7135. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7136. }
  7137. return oldValue.Name, nil
  7138. }
  7139. // ResetName resets all changes to the "name" field.
  7140. func (m *ChatSessionMutation) ResetName() {
  7141. m.name = nil
  7142. }
  7143. // SetUserID sets the "user_id" field.
  7144. func (m *ChatSessionMutation) SetUserID(u uint64) {
  7145. m.user_id = &u
  7146. m.adduser_id = nil
  7147. }
  7148. // UserID returns the value of the "user_id" field in the mutation.
  7149. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  7150. v := m.user_id
  7151. if v == nil {
  7152. return
  7153. }
  7154. return *v, true
  7155. }
  7156. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  7157. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7159. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  7160. if !m.op.Is(OpUpdateOne) {
  7161. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  7162. }
  7163. if m.id == nil || m.oldValue == nil {
  7164. return v, errors.New("OldUserID requires an ID field in the mutation")
  7165. }
  7166. oldValue, err := m.oldValue(ctx)
  7167. if err != nil {
  7168. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  7169. }
  7170. return oldValue.UserID, nil
  7171. }
  7172. // AddUserID adds u to the "user_id" field.
  7173. func (m *ChatSessionMutation) AddUserID(u int64) {
  7174. if m.adduser_id != nil {
  7175. *m.adduser_id += u
  7176. } else {
  7177. m.adduser_id = &u
  7178. }
  7179. }
  7180. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  7181. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  7182. v := m.adduser_id
  7183. if v == nil {
  7184. return
  7185. }
  7186. return *v, true
  7187. }
  7188. // ResetUserID resets all changes to the "user_id" field.
  7189. func (m *ChatSessionMutation) ResetUserID() {
  7190. m.user_id = nil
  7191. m.adduser_id = nil
  7192. }
  7193. // SetBotID sets the "bot_id" field.
  7194. func (m *ChatSessionMutation) SetBotID(u uint64) {
  7195. m.bot_id = &u
  7196. m.addbot_id = nil
  7197. }
  7198. // BotID returns the value of the "bot_id" field in the mutation.
  7199. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  7200. v := m.bot_id
  7201. if v == nil {
  7202. return
  7203. }
  7204. return *v, true
  7205. }
  7206. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  7207. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7208. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7209. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  7210. if !m.op.Is(OpUpdateOne) {
  7211. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  7212. }
  7213. if m.id == nil || m.oldValue == nil {
  7214. return v, errors.New("OldBotID requires an ID field in the mutation")
  7215. }
  7216. oldValue, err := m.oldValue(ctx)
  7217. if err != nil {
  7218. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  7219. }
  7220. return oldValue.BotID, nil
  7221. }
  7222. // AddBotID adds u to the "bot_id" field.
  7223. func (m *ChatSessionMutation) AddBotID(u int64) {
  7224. if m.addbot_id != nil {
  7225. *m.addbot_id += u
  7226. } else {
  7227. m.addbot_id = &u
  7228. }
  7229. }
  7230. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  7231. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  7232. v := m.addbot_id
  7233. if v == nil {
  7234. return
  7235. }
  7236. return *v, true
  7237. }
  7238. // ResetBotID resets all changes to the "bot_id" field.
  7239. func (m *ChatSessionMutation) ResetBotID() {
  7240. m.bot_id = nil
  7241. m.addbot_id = nil
  7242. }
  7243. // SetBotType sets the "bot_type" field.
  7244. func (m *ChatSessionMutation) SetBotType(u uint8) {
  7245. m.bot_type = &u
  7246. m.addbot_type = nil
  7247. }
  7248. // BotType returns the value of the "bot_type" field in the mutation.
  7249. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  7250. v := m.bot_type
  7251. if v == nil {
  7252. return
  7253. }
  7254. return *v, true
  7255. }
  7256. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  7257. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7259. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  7260. if !m.op.Is(OpUpdateOne) {
  7261. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  7262. }
  7263. if m.id == nil || m.oldValue == nil {
  7264. return v, errors.New("OldBotType requires an ID field in the mutation")
  7265. }
  7266. oldValue, err := m.oldValue(ctx)
  7267. if err != nil {
  7268. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  7269. }
  7270. return oldValue.BotType, nil
  7271. }
  7272. // AddBotType adds u to the "bot_type" field.
  7273. func (m *ChatSessionMutation) AddBotType(u int8) {
  7274. if m.addbot_type != nil {
  7275. *m.addbot_type += u
  7276. } else {
  7277. m.addbot_type = &u
  7278. }
  7279. }
  7280. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  7281. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  7282. v := m.addbot_type
  7283. if v == nil {
  7284. return
  7285. }
  7286. return *v, true
  7287. }
  7288. // ResetBotType resets all changes to the "bot_type" field.
  7289. func (m *ChatSessionMutation) ResetBotType() {
  7290. m.bot_type = nil
  7291. m.addbot_type = nil
  7292. }
  7293. // Where appends a list predicates to the ChatSessionMutation builder.
  7294. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  7295. m.predicates = append(m.predicates, ps...)
  7296. }
  7297. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  7298. // users can use type-assertion to append predicates that do not depend on any generated package.
  7299. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  7300. p := make([]predicate.ChatSession, len(ps))
  7301. for i := range ps {
  7302. p[i] = ps[i]
  7303. }
  7304. m.Where(p...)
  7305. }
  7306. // Op returns the operation name.
  7307. func (m *ChatSessionMutation) Op() Op {
  7308. return m.op
  7309. }
  7310. // SetOp allows setting the mutation operation.
  7311. func (m *ChatSessionMutation) SetOp(op Op) {
  7312. m.op = op
  7313. }
  7314. // Type returns the node type of this mutation (ChatSession).
  7315. func (m *ChatSessionMutation) Type() string {
  7316. return m.typ
  7317. }
  7318. // Fields returns all fields that were changed during this mutation. Note that in
  7319. // order to get all numeric fields that were incremented/decremented, call
  7320. // AddedFields().
  7321. func (m *ChatSessionMutation) Fields() []string {
  7322. fields := make([]string, 0, 7)
  7323. if m.created_at != nil {
  7324. fields = append(fields, chatsession.FieldCreatedAt)
  7325. }
  7326. if m.updated_at != nil {
  7327. fields = append(fields, chatsession.FieldUpdatedAt)
  7328. }
  7329. if m.deleted_at != nil {
  7330. fields = append(fields, chatsession.FieldDeletedAt)
  7331. }
  7332. if m.name != nil {
  7333. fields = append(fields, chatsession.FieldName)
  7334. }
  7335. if m.user_id != nil {
  7336. fields = append(fields, chatsession.FieldUserID)
  7337. }
  7338. if m.bot_id != nil {
  7339. fields = append(fields, chatsession.FieldBotID)
  7340. }
  7341. if m.bot_type != nil {
  7342. fields = append(fields, chatsession.FieldBotType)
  7343. }
  7344. return fields
  7345. }
  7346. // Field returns the value of a field with the given name. The second boolean
  7347. // return value indicates that this field was not set, or was not defined in the
  7348. // schema.
  7349. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  7350. switch name {
  7351. case chatsession.FieldCreatedAt:
  7352. return m.CreatedAt()
  7353. case chatsession.FieldUpdatedAt:
  7354. return m.UpdatedAt()
  7355. case chatsession.FieldDeletedAt:
  7356. return m.DeletedAt()
  7357. case chatsession.FieldName:
  7358. return m.Name()
  7359. case chatsession.FieldUserID:
  7360. return m.UserID()
  7361. case chatsession.FieldBotID:
  7362. return m.BotID()
  7363. case chatsession.FieldBotType:
  7364. return m.BotType()
  7365. }
  7366. return nil, false
  7367. }
  7368. // OldField returns the old value of the field from the database. An error is
  7369. // returned if the mutation operation is not UpdateOne, or the query to the
  7370. // database failed.
  7371. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7372. switch name {
  7373. case chatsession.FieldCreatedAt:
  7374. return m.OldCreatedAt(ctx)
  7375. case chatsession.FieldUpdatedAt:
  7376. return m.OldUpdatedAt(ctx)
  7377. case chatsession.FieldDeletedAt:
  7378. return m.OldDeletedAt(ctx)
  7379. case chatsession.FieldName:
  7380. return m.OldName(ctx)
  7381. case chatsession.FieldUserID:
  7382. return m.OldUserID(ctx)
  7383. case chatsession.FieldBotID:
  7384. return m.OldBotID(ctx)
  7385. case chatsession.FieldBotType:
  7386. return m.OldBotType(ctx)
  7387. }
  7388. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  7389. }
  7390. // SetField sets the value of a field with the given name. It returns an error if
  7391. // the field is not defined in the schema, or if the type mismatched the field
  7392. // type.
  7393. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  7394. switch name {
  7395. case chatsession.FieldCreatedAt:
  7396. v, ok := value.(time.Time)
  7397. if !ok {
  7398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7399. }
  7400. m.SetCreatedAt(v)
  7401. return nil
  7402. case chatsession.FieldUpdatedAt:
  7403. v, ok := value.(time.Time)
  7404. if !ok {
  7405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7406. }
  7407. m.SetUpdatedAt(v)
  7408. return nil
  7409. case chatsession.FieldDeletedAt:
  7410. v, ok := value.(time.Time)
  7411. if !ok {
  7412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7413. }
  7414. m.SetDeletedAt(v)
  7415. return nil
  7416. case chatsession.FieldName:
  7417. v, ok := value.(string)
  7418. if !ok {
  7419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7420. }
  7421. m.SetName(v)
  7422. return nil
  7423. case chatsession.FieldUserID:
  7424. v, ok := value.(uint64)
  7425. if !ok {
  7426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7427. }
  7428. m.SetUserID(v)
  7429. return nil
  7430. case chatsession.FieldBotID:
  7431. v, ok := value.(uint64)
  7432. if !ok {
  7433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7434. }
  7435. m.SetBotID(v)
  7436. return nil
  7437. case chatsession.FieldBotType:
  7438. v, ok := value.(uint8)
  7439. if !ok {
  7440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7441. }
  7442. m.SetBotType(v)
  7443. return nil
  7444. }
  7445. return fmt.Errorf("unknown ChatSession field %s", name)
  7446. }
  7447. // AddedFields returns all numeric fields that were incremented/decremented during
  7448. // this mutation.
  7449. func (m *ChatSessionMutation) AddedFields() []string {
  7450. var fields []string
  7451. if m.adduser_id != nil {
  7452. fields = append(fields, chatsession.FieldUserID)
  7453. }
  7454. if m.addbot_id != nil {
  7455. fields = append(fields, chatsession.FieldBotID)
  7456. }
  7457. if m.addbot_type != nil {
  7458. fields = append(fields, chatsession.FieldBotType)
  7459. }
  7460. return fields
  7461. }
  7462. // AddedField returns the numeric value that was incremented/decremented on a field
  7463. // with the given name. The second boolean return value indicates that this field
  7464. // was not set, or was not defined in the schema.
  7465. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  7466. switch name {
  7467. case chatsession.FieldUserID:
  7468. return m.AddedUserID()
  7469. case chatsession.FieldBotID:
  7470. return m.AddedBotID()
  7471. case chatsession.FieldBotType:
  7472. return m.AddedBotType()
  7473. }
  7474. return nil, false
  7475. }
  7476. // AddField adds the value to the field with the given name. It returns an error if
  7477. // the field is not defined in the schema, or if the type mismatched the field
  7478. // type.
  7479. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  7480. switch name {
  7481. case chatsession.FieldUserID:
  7482. v, ok := value.(int64)
  7483. if !ok {
  7484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7485. }
  7486. m.AddUserID(v)
  7487. return nil
  7488. case chatsession.FieldBotID:
  7489. v, ok := value.(int64)
  7490. if !ok {
  7491. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7492. }
  7493. m.AddBotID(v)
  7494. return nil
  7495. case chatsession.FieldBotType:
  7496. v, ok := value.(int8)
  7497. if !ok {
  7498. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7499. }
  7500. m.AddBotType(v)
  7501. return nil
  7502. }
  7503. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  7504. }
  7505. // ClearedFields returns all nullable fields that were cleared during this
  7506. // mutation.
  7507. func (m *ChatSessionMutation) ClearedFields() []string {
  7508. var fields []string
  7509. if m.FieldCleared(chatsession.FieldDeletedAt) {
  7510. fields = append(fields, chatsession.FieldDeletedAt)
  7511. }
  7512. return fields
  7513. }
  7514. // FieldCleared returns a boolean indicating if a field with the given name was
  7515. // cleared in this mutation.
  7516. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  7517. _, ok := m.clearedFields[name]
  7518. return ok
  7519. }
  7520. // ClearField clears the value of the field with the given name. It returns an
  7521. // error if the field is not defined in the schema.
  7522. func (m *ChatSessionMutation) ClearField(name string) error {
  7523. switch name {
  7524. case chatsession.FieldDeletedAt:
  7525. m.ClearDeletedAt()
  7526. return nil
  7527. }
  7528. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  7529. }
  7530. // ResetField resets all changes in the mutation for the field with the given name.
  7531. // It returns an error if the field is not defined in the schema.
  7532. func (m *ChatSessionMutation) ResetField(name string) error {
  7533. switch name {
  7534. case chatsession.FieldCreatedAt:
  7535. m.ResetCreatedAt()
  7536. return nil
  7537. case chatsession.FieldUpdatedAt:
  7538. m.ResetUpdatedAt()
  7539. return nil
  7540. case chatsession.FieldDeletedAt:
  7541. m.ResetDeletedAt()
  7542. return nil
  7543. case chatsession.FieldName:
  7544. m.ResetName()
  7545. return nil
  7546. case chatsession.FieldUserID:
  7547. m.ResetUserID()
  7548. return nil
  7549. case chatsession.FieldBotID:
  7550. m.ResetBotID()
  7551. return nil
  7552. case chatsession.FieldBotType:
  7553. m.ResetBotType()
  7554. return nil
  7555. }
  7556. return fmt.Errorf("unknown ChatSession field %s", name)
  7557. }
  7558. // AddedEdges returns all edge names that were set/added in this mutation.
  7559. func (m *ChatSessionMutation) AddedEdges() []string {
  7560. edges := make([]string, 0, 0)
  7561. return edges
  7562. }
  7563. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7564. // name in this mutation.
  7565. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  7566. return nil
  7567. }
  7568. // RemovedEdges returns all edge names that were removed in this mutation.
  7569. func (m *ChatSessionMutation) RemovedEdges() []string {
  7570. edges := make([]string, 0, 0)
  7571. return edges
  7572. }
  7573. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7574. // the given name in this mutation.
  7575. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  7576. return nil
  7577. }
  7578. // ClearedEdges returns all edge names that were cleared in this mutation.
  7579. func (m *ChatSessionMutation) ClearedEdges() []string {
  7580. edges := make([]string, 0, 0)
  7581. return edges
  7582. }
  7583. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7584. // was cleared in this mutation.
  7585. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  7586. return false
  7587. }
  7588. // ClearEdge clears the value of the edge with the given name. It returns an error
  7589. // if that edge is not defined in the schema.
  7590. func (m *ChatSessionMutation) ClearEdge(name string) error {
  7591. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  7592. }
  7593. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7594. // It returns an error if the edge is not defined in the schema.
  7595. func (m *ChatSessionMutation) ResetEdge(name string) error {
  7596. return fmt.Errorf("unknown ChatSession edge %s", name)
  7597. }
  7598. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  7599. type ContactMutation struct {
  7600. config
  7601. op Op
  7602. typ string
  7603. id *uint64
  7604. created_at *time.Time
  7605. updated_at *time.Time
  7606. status *uint8
  7607. addstatus *int8
  7608. deleted_at *time.Time
  7609. wx_wxid *string
  7610. _type *int
  7611. add_type *int
  7612. wxid *string
  7613. account *string
  7614. nickname *string
  7615. markname *string
  7616. headimg *string
  7617. sex *int
  7618. addsex *int
  7619. starrole *string
  7620. dontseeit *int
  7621. adddontseeit *int
  7622. dontseeme *int
  7623. adddontseeme *int
  7624. lag *string
  7625. gid *string
  7626. gname *string
  7627. v3 *string
  7628. organization_id *uint64
  7629. addorganization_id *int64
  7630. clearedFields map[string]struct{}
  7631. contact_relationships map[uint64]struct{}
  7632. removedcontact_relationships map[uint64]struct{}
  7633. clearedcontact_relationships bool
  7634. contact_messages map[uint64]struct{}
  7635. removedcontact_messages map[uint64]struct{}
  7636. clearedcontact_messages bool
  7637. done bool
  7638. oldValue func(context.Context) (*Contact, error)
  7639. predicates []predicate.Contact
  7640. }
  7641. var _ ent.Mutation = (*ContactMutation)(nil)
  7642. // contactOption allows management of the mutation configuration using functional options.
  7643. type contactOption func(*ContactMutation)
  7644. // newContactMutation creates new mutation for the Contact entity.
  7645. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  7646. m := &ContactMutation{
  7647. config: c,
  7648. op: op,
  7649. typ: TypeContact,
  7650. clearedFields: make(map[string]struct{}),
  7651. }
  7652. for _, opt := range opts {
  7653. opt(m)
  7654. }
  7655. return m
  7656. }
  7657. // withContactID sets the ID field of the mutation.
  7658. func withContactID(id uint64) contactOption {
  7659. return func(m *ContactMutation) {
  7660. var (
  7661. err error
  7662. once sync.Once
  7663. value *Contact
  7664. )
  7665. m.oldValue = func(ctx context.Context) (*Contact, error) {
  7666. once.Do(func() {
  7667. if m.done {
  7668. err = errors.New("querying old values post mutation is not allowed")
  7669. } else {
  7670. value, err = m.Client().Contact.Get(ctx, id)
  7671. }
  7672. })
  7673. return value, err
  7674. }
  7675. m.id = &id
  7676. }
  7677. }
  7678. // withContact sets the old Contact of the mutation.
  7679. func withContact(node *Contact) contactOption {
  7680. return func(m *ContactMutation) {
  7681. m.oldValue = func(context.Context) (*Contact, error) {
  7682. return node, nil
  7683. }
  7684. m.id = &node.ID
  7685. }
  7686. }
  7687. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7688. // executed in a transaction (ent.Tx), a transactional client is returned.
  7689. func (m ContactMutation) Client() *Client {
  7690. client := &Client{config: m.config}
  7691. client.init()
  7692. return client
  7693. }
  7694. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7695. // it returns an error otherwise.
  7696. func (m ContactMutation) Tx() (*Tx, error) {
  7697. if _, ok := m.driver.(*txDriver); !ok {
  7698. return nil, errors.New("ent: mutation is not running in a transaction")
  7699. }
  7700. tx := &Tx{config: m.config}
  7701. tx.init()
  7702. return tx, nil
  7703. }
  7704. // SetID sets the value of the id field. Note that this
  7705. // operation is only accepted on creation of Contact entities.
  7706. func (m *ContactMutation) SetID(id uint64) {
  7707. m.id = &id
  7708. }
  7709. // ID returns the ID value in the mutation. Note that the ID is only available
  7710. // if it was provided to the builder or after it was returned from the database.
  7711. func (m *ContactMutation) ID() (id uint64, exists bool) {
  7712. if m.id == nil {
  7713. return
  7714. }
  7715. return *m.id, true
  7716. }
  7717. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7718. // That means, if the mutation is applied within a transaction with an isolation level such
  7719. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7720. // or updated by the mutation.
  7721. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  7722. switch {
  7723. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7724. id, exists := m.ID()
  7725. if exists {
  7726. return []uint64{id}, nil
  7727. }
  7728. fallthrough
  7729. case m.op.Is(OpUpdate | OpDelete):
  7730. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  7731. default:
  7732. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7733. }
  7734. }
  7735. // SetCreatedAt sets the "created_at" field.
  7736. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  7737. m.created_at = &t
  7738. }
  7739. // CreatedAt returns the value of the "created_at" field in the mutation.
  7740. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  7741. v := m.created_at
  7742. if v == nil {
  7743. return
  7744. }
  7745. return *v, true
  7746. }
  7747. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  7748. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7750. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7751. if !m.op.Is(OpUpdateOne) {
  7752. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7753. }
  7754. if m.id == nil || m.oldValue == nil {
  7755. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7756. }
  7757. oldValue, err := m.oldValue(ctx)
  7758. if err != nil {
  7759. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7760. }
  7761. return oldValue.CreatedAt, nil
  7762. }
  7763. // ResetCreatedAt resets all changes to the "created_at" field.
  7764. func (m *ContactMutation) ResetCreatedAt() {
  7765. m.created_at = nil
  7766. }
  7767. // SetUpdatedAt sets the "updated_at" field.
  7768. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  7769. m.updated_at = &t
  7770. }
  7771. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7772. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  7773. v := m.updated_at
  7774. if v == nil {
  7775. return
  7776. }
  7777. return *v, true
  7778. }
  7779. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  7780. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7782. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7783. if !m.op.Is(OpUpdateOne) {
  7784. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7785. }
  7786. if m.id == nil || m.oldValue == nil {
  7787. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7788. }
  7789. oldValue, err := m.oldValue(ctx)
  7790. if err != nil {
  7791. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7792. }
  7793. return oldValue.UpdatedAt, nil
  7794. }
  7795. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7796. func (m *ContactMutation) ResetUpdatedAt() {
  7797. m.updated_at = nil
  7798. }
  7799. // SetStatus sets the "status" field.
  7800. func (m *ContactMutation) SetStatus(u uint8) {
  7801. m.status = &u
  7802. m.addstatus = nil
  7803. }
  7804. // Status returns the value of the "status" field in the mutation.
  7805. func (m *ContactMutation) Status() (r uint8, exists bool) {
  7806. v := m.status
  7807. if v == nil {
  7808. return
  7809. }
  7810. return *v, true
  7811. }
  7812. // OldStatus returns the old "status" field's value of the Contact entity.
  7813. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7815. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7816. if !m.op.Is(OpUpdateOne) {
  7817. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7818. }
  7819. if m.id == nil || m.oldValue == nil {
  7820. return v, errors.New("OldStatus requires an ID field in the mutation")
  7821. }
  7822. oldValue, err := m.oldValue(ctx)
  7823. if err != nil {
  7824. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7825. }
  7826. return oldValue.Status, nil
  7827. }
  7828. // AddStatus adds u to the "status" field.
  7829. func (m *ContactMutation) AddStatus(u int8) {
  7830. if m.addstatus != nil {
  7831. *m.addstatus += u
  7832. } else {
  7833. m.addstatus = &u
  7834. }
  7835. }
  7836. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7837. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  7838. v := m.addstatus
  7839. if v == nil {
  7840. return
  7841. }
  7842. return *v, true
  7843. }
  7844. // ClearStatus clears the value of the "status" field.
  7845. func (m *ContactMutation) ClearStatus() {
  7846. m.status = nil
  7847. m.addstatus = nil
  7848. m.clearedFields[contact.FieldStatus] = struct{}{}
  7849. }
  7850. // StatusCleared returns if the "status" field was cleared in this mutation.
  7851. func (m *ContactMutation) StatusCleared() bool {
  7852. _, ok := m.clearedFields[contact.FieldStatus]
  7853. return ok
  7854. }
  7855. // ResetStatus resets all changes to the "status" field.
  7856. func (m *ContactMutation) ResetStatus() {
  7857. m.status = nil
  7858. m.addstatus = nil
  7859. delete(m.clearedFields, contact.FieldStatus)
  7860. }
  7861. // SetDeletedAt sets the "deleted_at" field.
  7862. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  7863. m.deleted_at = &t
  7864. }
  7865. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7866. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  7867. v := m.deleted_at
  7868. if v == nil {
  7869. return
  7870. }
  7871. return *v, true
  7872. }
  7873. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  7874. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7876. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7877. if !m.op.Is(OpUpdateOne) {
  7878. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7879. }
  7880. if m.id == nil || m.oldValue == nil {
  7881. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7882. }
  7883. oldValue, err := m.oldValue(ctx)
  7884. if err != nil {
  7885. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7886. }
  7887. return oldValue.DeletedAt, nil
  7888. }
  7889. // ClearDeletedAt clears the value of the "deleted_at" field.
  7890. func (m *ContactMutation) ClearDeletedAt() {
  7891. m.deleted_at = nil
  7892. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  7893. }
  7894. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7895. func (m *ContactMutation) DeletedAtCleared() bool {
  7896. _, ok := m.clearedFields[contact.FieldDeletedAt]
  7897. return ok
  7898. }
  7899. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7900. func (m *ContactMutation) ResetDeletedAt() {
  7901. m.deleted_at = nil
  7902. delete(m.clearedFields, contact.FieldDeletedAt)
  7903. }
  7904. // SetWxWxid sets the "wx_wxid" field.
  7905. func (m *ContactMutation) SetWxWxid(s string) {
  7906. m.wx_wxid = &s
  7907. }
  7908. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7909. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  7910. v := m.wx_wxid
  7911. if v == nil {
  7912. return
  7913. }
  7914. return *v, true
  7915. }
  7916. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  7917. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7919. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  7920. if !m.op.Is(OpUpdateOne) {
  7921. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  7922. }
  7923. if m.id == nil || m.oldValue == nil {
  7924. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  7925. }
  7926. oldValue, err := m.oldValue(ctx)
  7927. if err != nil {
  7928. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  7929. }
  7930. return oldValue.WxWxid, nil
  7931. }
  7932. // ResetWxWxid resets all changes to the "wx_wxid" field.
  7933. func (m *ContactMutation) ResetWxWxid() {
  7934. m.wx_wxid = nil
  7935. }
  7936. // SetType sets the "type" field.
  7937. func (m *ContactMutation) SetType(i int) {
  7938. m._type = &i
  7939. m.add_type = nil
  7940. }
  7941. // GetType returns the value of the "type" field in the mutation.
  7942. func (m *ContactMutation) GetType() (r int, exists bool) {
  7943. v := m._type
  7944. if v == nil {
  7945. return
  7946. }
  7947. return *v, true
  7948. }
  7949. // OldType returns the old "type" field's value of the Contact entity.
  7950. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7951. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7952. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  7953. if !m.op.Is(OpUpdateOne) {
  7954. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7955. }
  7956. if m.id == nil || m.oldValue == nil {
  7957. return v, errors.New("OldType requires an ID field in the mutation")
  7958. }
  7959. oldValue, err := m.oldValue(ctx)
  7960. if err != nil {
  7961. return v, fmt.Errorf("querying old value for OldType: %w", err)
  7962. }
  7963. return oldValue.Type, nil
  7964. }
  7965. // AddType adds i to the "type" field.
  7966. func (m *ContactMutation) AddType(i int) {
  7967. if m.add_type != nil {
  7968. *m.add_type += i
  7969. } else {
  7970. m.add_type = &i
  7971. }
  7972. }
  7973. // AddedType returns the value that was added to the "type" field in this mutation.
  7974. func (m *ContactMutation) AddedType() (r int, exists bool) {
  7975. v := m.add_type
  7976. if v == nil {
  7977. return
  7978. }
  7979. return *v, true
  7980. }
  7981. // ClearType clears the value of the "type" field.
  7982. func (m *ContactMutation) ClearType() {
  7983. m._type = nil
  7984. m.add_type = nil
  7985. m.clearedFields[contact.FieldType] = struct{}{}
  7986. }
  7987. // TypeCleared returns if the "type" field was cleared in this mutation.
  7988. func (m *ContactMutation) TypeCleared() bool {
  7989. _, ok := m.clearedFields[contact.FieldType]
  7990. return ok
  7991. }
  7992. // ResetType resets all changes to the "type" field.
  7993. func (m *ContactMutation) ResetType() {
  7994. m._type = nil
  7995. m.add_type = nil
  7996. delete(m.clearedFields, contact.FieldType)
  7997. }
  7998. // SetWxid sets the "wxid" field.
  7999. func (m *ContactMutation) SetWxid(s string) {
  8000. m.wxid = &s
  8001. }
  8002. // Wxid returns the value of the "wxid" field in the mutation.
  8003. func (m *ContactMutation) Wxid() (r string, exists bool) {
  8004. v := m.wxid
  8005. if v == nil {
  8006. return
  8007. }
  8008. return *v, true
  8009. }
  8010. // OldWxid returns the old "wxid" field's value of the Contact entity.
  8011. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8013. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  8014. if !m.op.Is(OpUpdateOne) {
  8015. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  8016. }
  8017. if m.id == nil || m.oldValue == nil {
  8018. return v, errors.New("OldWxid requires an ID field in the mutation")
  8019. }
  8020. oldValue, err := m.oldValue(ctx)
  8021. if err != nil {
  8022. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  8023. }
  8024. return oldValue.Wxid, nil
  8025. }
  8026. // ResetWxid resets all changes to the "wxid" field.
  8027. func (m *ContactMutation) ResetWxid() {
  8028. m.wxid = nil
  8029. }
  8030. // SetAccount sets the "account" field.
  8031. func (m *ContactMutation) SetAccount(s string) {
  8032. m.account = &s
  8033. }
  8034. // Account returns the value of the "account" field in the mutation.
  8035. func (m *ContactMutation) Account() (r string, exists bool) {
  8036. v := m.account
  8037. if v == nil {
  8038. return
  8039. }
  8040. return *v, true
  8041. }
  8042. // OldAccount returns the old "account" field's value of the Contact entity.
  8043. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8045. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  8046. if !m.op.Is(OpUpdateOne) {
  8047. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  8048. }
  8049. if m.id == nil || m.oldValue == nil {
  8050. return v, errors.New("OldAccount requires an ID field in the mutation")
  8051. }
  8052. oldValue, err := m.oldValue(ctx)
  8053. if err != nil {
  8054. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  8055. }
  8056. return oldValue.Account, nil
  8057. }
  8058. // ResetAccount resets all changes to the "account" field.
  8059. func (m *ContactMutation) ResetAccount() {
  8060. m.account = nil
  8061. }
  8062. // SetNickname sets the "nickname" field.
  8063. func (m *ContactMutation) SetNickname(s string) {
  8064. m.nickname = &s
  8065. }
  8066. // Nickname returns the value of the "nickname" field in the mutation.
  8067. func (m *ContactMutation) Nickname() (r string, exists bool) {
  8068. v := m.nickname
  8069. if v == nil {
  8070. return
  8071. }
  8072. return *v, true
  8073. }
  8074. // OldNickname returns the old "nickname" field's value of the Contact entity.
  8075. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8077. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  8078. if !m.op.Is(OpUpdateOne) {
  8079. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  8080. }
  8081. if m.id == nil || m.oldValue == nil {
  8082. return v, errors.New("OldNickname requires an ID field in the mutation")
  8083. }
  8084. oldValue, err := m.oldValue(ctx)
  8085. if err != nil {
  8086. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  8087. }
  8088. return oldValue.Nickname, nil
  8089. }
  8090. // ResetNickname resets all changes to the "nickname" field.
  8091. func (m *ContactMutation) ResetNickname() {
  8092. m.nickname = nil
  8093. }
  8094. // SetMarkname sets the "markname" field.
  8095. func (m *ContactMutation) SetMarkname(s string) {
  8096. m.markname = &s
  8097. }
  8098. // Markname returns the value of the "markname" field in the mutation.
  8099. func (m *ContactMutation) Markname() (r string, exists bool) {
  8100. v := m.markname
  8101. if v == nil {
  8102. return
  8103. }
  8104. return *v, true
  8105. }
  8106. // OldMarkname returns the old "markname" field's value of the Contact entity.
  8107. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8109. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  8110. if !m.op.Is(OpUpdateOne) {
  8111. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  8112. }
  8113. if m.id == nil || m.oldValue == nil {
  8114. return v, errors.New("OldMarkname requires an ID field in the mutation")
  8115. }
  8116. oldValue, err := m.oldValue(ctx)
  8117. if err != nil {
  8118. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  8119. }
  8120. return oldValue.Markname, nil
  8121. }
  8122. // ResetMarkname resets all changes to the "markname" field.
  8123. func (m *ContactMutation) ResetMarkname() {
  8124. m.markname = nil
  8125. }
  8126. // SetHeadimg sets the "headimg" field.
  8127. func (m *ContactMutation) SetHeadimg(s string) {
  8128. m.headimg = &s
  8129. }
  8130. // Headimg returns the value of the "headimg" field in the mutation.
  8131. func (m *ContactMutation) Headimg() (r string, exists bool) {
  8132. v := m.headimg
  8133. if v == nil {
  8134. return
  8135. }
  8136. return *v, true
  8137. }
  8138. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  8139. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8140. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8141. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  8142. if !m.op.Is(OpUpdateOne) {
  8143. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  8144. }
  8145. if m.id == nil || m.oldValue == nil {
  8146. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  8147. }
  8148. oldValue, err := m.oldValue(ctx)
  8149. if err != nil {
  8150. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  8151. }
  8152. return oldValue.Headimg, nil
  8153. }
  8154. // ResetHeadimg resets all changes to the "headimg" field.
  8155. func (m *ContactMutation) ResetHeadimg() {
  8156. m.headimg = nil
  8157. }
  8158. // SetSex sets the "sex" field.
  8159. func (m *ContactMutation) SetSex(i int) {
  8160. m.sex = &i
  8161. m.addsex = nil
  8162. }
  8163. // Sex returns the value of the "sex" field in the mutation.
  8164. func (m *ContactMutation) Sex() (r int, exists bool) {
  8165. v := m.sex
  8166. if v == nil {
  8167. return
  8168. }
  8169. return *v, true
  8170. }
  8171. // OldSex returns the old "sex" field's value of the Contact entity.
  8172. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8174. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  8175. if !m.op.Is(OpUpdateOne) {
  8176. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  8177. }
  8178. if m.id == nil || m.oldValue == nil {
  8179. return v, errors.New("OldSex requires an ID field in the mutation")
  8180. }
  8181. oldValue, err := m.oldValue(ctx)
  8182. if err != nil {
  8183. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  8184. }
  8185. return oldValue.Sex, nil
  8186. }
  8187. // AddSex adds i to the "sex" field.
  8188. func (m *ContactMutation) AddSex(i int) {
  8189. if m.addsex != nil {
  8190. *m.addsex += i
  8191. } else {
  8192. m.addsex = &i
  8193. }
  8194. }
  8195. // AddedSex returns the value that was added to the "sex" field in this mutation.
  8196. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  8197. v := m.addsex
  8198. if v == nil {
  8199. return
  8200. }
  8201. return *v, true
  8202. }
  8203. // ResetSex resets all changes to the "sex" field.
  8204. func (m *ContactMutation) ResetSex() {
  8205. m.sex = nil
  8206. m.addsex = nil
  8207. }
  8208. // SetStarrole sets the "starrole" field.
  8209. func (m *ContactMutation) SetStarrole(s string) {
  8210. m.starrole = &s
  8211. }
  8212. // Starrole returns the value of the "starrole" field in the mutation.
  8213. func (m *ContactMutation) Starrole() (r string, exists bool) {
  8214. v := m.starrole
  8215. if v == nil {
  8216. return
  8217. }
  8218. return *v, true
  8219. }
  8220. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  8221. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8223. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  8224. if !m.op.Is(OpUpdateOne) {
  8225. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  8226. }
  8227. if m.id == nil || m.oldValue == nil {
  8228. return v, errors.New("OldStarrole requires an ID field in the mutation")
  8229. }
  8230. oldValue, err := m.oldValue(ctx)
  8231. if err != nil {
  8232. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  8233. }
  8234. return oldValue.Starrole, nil
  8235. }
  8236. // ResetStarrole resets all changes to the "starrole" field.
  8237. func (m *ContactMutation) ResetStarrole() {
  8238. m.starrole = nil
  8239. }
  8240. // SetDontseeit sets the "dontseeit" field.
  8241. func (m *ContactMutation) SetDontseeit(i int) {
  8242. m.dontseeit = &i
  8243. m.adddontseeit = nil
  8244. }
  8245. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  8246. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  8247. v := m.dontseeit
  8248. if v == nil {
  8249. return
  8250. }
  8251. return *v, true
  8252. }
  8253. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  8254. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8256. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  8257. if !m.op.Is(OpUpdateOne) {
  8258. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  8259. }
  8260. if m.id == nil || m.oldValue == nil {
  8261. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  8262. }
  8263. oldValue, err := m.oldValue(ctx)
  8264. if err != nil {
  8265. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  8266. }
  8267. return oldValue.Dontseeit, nil
  8268. }
  8269. // AddDontseeit adds i to the "dontseeit" field.
  8270. func (m *ContactMutation) AddDontseeit(i int) {
  8271. if m.adddontseeit != nil {
  8272. *m.adddontseeit += i
  8273. } else {
  8274. m.adddontseeit = &i
  8275. }
  8276. }
  8277. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  8278. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  8279. v := m.adddontseeit
  8280. if v == nil {
  8281. return
  8282. }
  8283. return *v, true
  8284. }
  8285. // ResetDontseeit resets all changes to the "dontseeit" field.
  8286. func (m *ContactMutation) ResetDontseeit() {
  8287. m.dontseeit = nil
  8288. m.adddontseeit = nil
  8289. }
  8290. // SetDontseeme sets the "dontseeme" field.
  8291. func (m *ContactMutation) SetDontseeme(i int) {
  8292. m.dontseeme = &i
  8293. m.adddontseeme = nil
  8294. }
  8295. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  8296. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  8297. v := m.dontseeme
  8298. if v == nil {
  8299. return
  8300. }
  8301. return *v, true
  8302. }
  8303. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  8304. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8306. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  8307. if !m.op.Is(OpUpdateOne) {
  8308. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  8309. }
  8310. if m.id == nil || m.oldValue == nil {
  8311. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  8312. }
  8313. oldValue, err := m.oldValue(ctx)
  8314. if err != nil {
  8315. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  8316. }
  8317. return oldValue.Dontseeme, nil
  8318. }
  8319. // AddDontseeme adds i to the "dontseeme" field.
  8320. func (m *ContactMutation) AddDontseeme(i int) {
  8321. if m.adddontseeme != nil {
  8322. *m.adddontseeme += i
  8323. } else {
  8324. m.adddontseeme = &i
  8325. }
  8326. }
  8327. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  8328. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  8329. v := m.adddontseeme
  8330. if v == nil {
  8331. return
  8332. }
  8333. return *v, true
  8334. }
  8335. // ResetDontseeme resets all changes to the "dontseeme" field.
  8336. func (m *ContactMutation) ResetDontseeme() {
  8337. m.dontseeme = nil
  8338. m.adddontseeme = nil
  8339. }
  8340. // SetLag sets the "lag" field.
  8341. func (m *ContactMutation) SetLag(s string) {
  8342. m.lag = &s
  8343. }
  8344. // Lag returns the value of the "lag" field in the mutation.
  8345. func (m *ContactMutation) Lag() (r string, exists bool) {
  8346. v := m.lag
  8347. if v == nil {
  8348. return
  8349. }
  8350. return *v, true
  8351. }
  8352. // OldLag returns the old "lag" field's value of the Contact entity.
  8353. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8355. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  8356. if !m.op.Is(OpUpdateOne) {
  8357. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  8358. }
  8359. if m.id == nil || m.oldValue == nil {
  8360. return v, errors.New("OldLag requires an ID field in the mutation")
  8361. }
  8362. oldValue, err := m.oldValue(ctx)
  8363. if err != nil {
  8364. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  8365. }
  8366. return oldValue.Lag, nil
  8367. }
  8368. // ResetLag resets all changes to the "lag" field.
  8369. func (m *ContactMutation) ResetLag() {
  8370. m.lag = nil
  8371. }
  8372. // SetGid sets the "gid" field.
  8373. func (m *ContactMutation) SetGid(s string) {
  8374. m.gid = &s
  8375. }
  8376. // Gid returns the value of the "gid" field in the mutation.
  8377. func (m *ContactMutation) Gid() (r string, exists bool) {
  8378. v := m.gid
  8379. if v == nil {
  8380. return
  8381. }
  8382. return *v, true
  8383. }
  8384. // OldGid returns the old "gid" field's value of the Contact entity.
  8385. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8386. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8387. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  8388. if !m.op.Is(OpUpdateOne) {
  8389. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  8390. }
  8391. if m.id == nil || m.oldValue == nil {
  8392. return v, errors.New("OldGid requires an ID field in the mutation")
  8393. }
  8394. oldValue, err := m.oldValue(ctx)
  8395. if err != nil {
  8396. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  8397. }
  8398. return oldValue.Gid, nil
  8399. }
  8400. // ResetGid resets all changes to the "gid" field.
  8401. func (m *ContactMutation) ResetGid() {
  8402. m.gid = nil
  8403. }
  8404. // SetGname sets the "gname" field.
  8405. func (m *ContactMutation) SetGname(s string) {
  8406. m.gname = &s
  8407. }
  8408. // Gname returns the value of the "gname" field in the mutation.
  8409. func (m *ContactMutation) Gname() (r string, exists bool) {
  8410. v := m.gname
  8411. if v == nil {
  8412. return
  8413. }
  8414. return *v, true
  8415. }
  8416. // OldGname returns the old "gname" field's value of the Contact entity.
  8417. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8419. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  8420. if !m.op.Is(OpUpdateOne) {
  8421. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  8422. }
  8423. if m.id == nil || m.oldValue == nil {
  8424. return v, errors.New("OldGname requires an ID field in the mutation")
  8425. }
  8426. oldValue, err := m.oldValue(ctx)
  8427. if err != nil {
  8428. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  8429. }
  8430. return oldValue.Gname, nil
  8431. }
  8432. // ResetGname resets all changes to the "gname" field.
  8433. func (m *ContactMutation) ResetGname() {
  8434. m.gname = nil
  8435. }
  8436. // SetV3 sets the "v3" field.
  8437. func (m *ContactMutation) SetV3(s string) {
  8438. m.v3 = &s
  8439. }
  8440. // V3 returns the value of the "v3" field in the mutation.
  8441. func (m *ContactMutation) V3() (r string, exists bool) {
  8442. v := m.v3
  8443. if v == nil {
  8444. return
  8445. }
  8446. return *v, true
  8447. }
  8448. // OldV3 returns the old "v3" field's value of the Contact entity.
  8449. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8451. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  8452. if !m.op.Is(OpUpdateOne) {
  8453. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  8454. }
  8455. if m.id == nil || m.oldValue == nil {
  8456. return v, errors.New("OldV3 requires an ID field in the mutation")
  8457. }
  8458. oldValue, err := m.oldValue(ctx)
  8459. if err != nil {
  8460. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  8461. }
  8462. return oldValue.V3, nil
  8463. }
  8464. // ResetV3 resets all changes to the "v3" field.
  8465. func (m *ContactMutation) ResetV3() {
  8466. m.v3 = nil
  8467. }
  8468. // SetOrganizationID sets the "organization_id" field.
  8469. func (m *ContactMutation) SetOrganizationID(u uint64) {
  8470. m.organization_id = &u
  8471. m.addorganization_id = nil
  8472. }
  8473. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8474. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  8475. v := m.organization_id
  8476. if v == nil {
  8477. return
  8478. }
  8479. return *v, true
  8480. }
  8481. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  8482. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8483. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8484. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8485. if !m.op.Is(OpUpdateOne) {
  8486. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8487. }
  8488. if m.id == nil || m.oldValue == nil {
  8489. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8490. }
  8491. oldValue, err := m.oldValue(ctx)
  8492. if err != nil {
  8493. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8494. }
  8495. return oldValue.OrganizationID, nil
  8496. }
  8497. // AddOrganizationID adds u to the "organization_id" field.
  8498. func (m *ContactMutation) AddOrganizationID(u int64) {
  8499. if m.addorganization_id != nil {
  8500. *m.addorganization_id += u
  8501. } else {
  8502. m.addorganization_id = &u
  8503. }
  8504. }
  8505. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8506. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  8507. v := m.addorganization_id
  8508. if v == nil {
  8509. return
  8510. }
  8511. return *v, true
  8512. }
  8513. // ClearOrganizationID clears the value of the "organization_id" field.
  8514. func (m *ContactMutation) ClearOrganizationID() {
  8515. m.organization_id = nil
  8516. m.addorganization_id = nil
  8517. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  8518. }
  8519. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  8520. func (m *ContactMutation) OrganizationIDCleared() bool {
  8521. _, ok := m.clearedFields[contact.FieldOrganizationID]
  8522. return ok
  8523. }
  8524. // ResetOrganizationID resets all changes to the "organization_id" field.
  8525. func (m *ContactMutation) ResetOrganizationID() {
  8526. m.organization_id = nil
  8527. m.addorganization_id = nil
  8528. delete(m.clearedFields, contact.FieldOrganizationID)
  8529. }
  8530. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  8531. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  8532. if m.contact_relationships == nil {
  8533. m.contact_relationships = make(map[uint64]struct{})
  8534. }
  8535. for i := range ids {
  8536. m.contact_relationships[ids[i]] = struct{}{}
  8537. }
  8538. }
  8539. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  8540. func (m *ContactMutation) ClearContactRelationships() {
  8541. m.clearedcontact_relationships = true
  8542. }
  8543. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  8544. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  8545. return m.clearedcontact_relationships
  8546. }
  8547. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  8548. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  8549. if m.removedcontact_relationships == nil {
  8550. m.removedcontact_relationships = make(map[uint64]struct{})
  8551. }
  8552. for i := range ids {
  8553. delete(m.contact_relationships, ids[i])
  8554. m.removedcontact_relationships[ids[i]] = struct{}{}
  8555. }
  8556. }
  8557. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  8558. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  8559. for id := range m.removedcontact_relationships {
  8560. ids = append(ids, id)
  8561. }
  8562. return
  8563. }
  8564. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  8565. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  8566. for id := range m.contact_relationships {
  8567. ids = append(ids, id)
  8568. }
  8569. return
  8570. }
  8571. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  8572. func (m *ContactMutation) ResetContactRelationships() {
  8573. m.contact_relationships = nil
  8574. m.clearedcontact_relationships = false
  8575. m.removedcontact_relationships = nil
  8576. }
  8577. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  8578. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  8579. if m.contact_messages == nil {
  8580. m.contact_messages = make(map[uint64]struct{})
  8581. }
  8582. for i := range ids {
  8583. m.contact_messages[ids[i]] = struct{}{}
  8584. }
  8585. }
  8586. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  8587. func (m *ContactMutation) ClearContactMessages() {
  8588. m.clearedcontact_messages = true
  8589. }
  8590. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  8591. func (m *ContactMutation) ContactMessagesCleared() bool {
  8592. return m.clearedcontact_messages
  8593. }
  8594. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  8595. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  8596. if m.removedcontact_messages == nil {
  8597. m.removedcontact_messages = make(map[uint64]struct{})
  8598. }
  8599. for i := range ids {
  8600. delete(m.contact_messages, ids[i])
  8601. m.removedcontact_messages[ids[i]] = struct{}{}
  8602. }
  8603. }
  8604. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  8605. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  8606. for id := range m.removedcontact_messages {
  8607. ids = append(ids, id)
  8608. }
  8609. return
  8610. }
  8611. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  8612. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  8613. for id := range m.contact_messages {
  8614. ids = append(ids, id)
  8615. }
  8616. return
  8617. }
  8618. // ResetContactMessages resets all changes to the "contact_messages" edge.
  8619. func (m *ContactMutation) ResetContactMessages() {
  8620. m.contact_messages = nil
  8621. m.clearedcontact_messages = false
  8622. m.removedcontact_messages = nil
  8623. }
  8624. // Where appends a list predicates to the ContactMutation builder.
  8625. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  8626. m.predicates = append(m.predicates, ps...)
  8627. }
  8628. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  8629. // users can use type-assertion to append predicates that do not depend on any generated package.
  8630. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  8631. p := make([]predicate.Contact, len(ps))
  8632. for i := range ps {
  8633. p[i] = ps[i]
  8634. }
  8635. m.Where(p...)
  8636. }
  8637. // Op returns the operation name.
  8638. func (m *ContactMutation) Op() Op {
  8639. return m.op
  8640. }
  8641. // SetOp allows setting the mutation operation.
  8642. func (m *ContactMutation) SetOp(op Op) {
  8643. m.op = op
  8644. }
  8645. // Type returns the node type of this mutation (Contact).
  8646. func (m *ContactMutation) Type() string {
  8647. return m.typ
  8648. }
  8649. // Fields returns all fields that were changed during this mutation. Note that in
  8650. // order to get all numeric fields that were incremented/decremented, call
  8651. // AddedFields().
  8652. func (m *ContactMutation) Fields() []string {
  8653. fields := make([]string, 0, 20)
  8654. if m.created_at != nil {
  8655. fields = append(fields, contact.FieldCreatedAt)
  8656. }
  8657. if m.updated_at != nil {
  8658. fields = append(fields, contact.FieldUpdatedAt)
  8659. }
  8660. if m.status != nil {
  8661. fields = append(fields, contact.FieldStatus)
  8662. }
  8663. if m.deleted_at != nil {
  8664. fields = append(fields, contact.FieldDeletedAt)
  8665. }
  8666. if m.wx_wxid != nil {
  8667. fields = append(fields, contact.FieldWxWxid)
  8668. }
  8669. if m._type != nil {
  8670. fields = append(fields, contact.FieldType)
  8671. }
  8672. if m.wxid != nil {
  8673. fields = append(fields, contact.FieldWxid)
  8674. }
  8675. if m.account != nil {
  8676. fields = append(fields, contact.FieldAccount)
  8677. }
  8678. if m.nickname != nil {
  8679. fields = append(fields, contact.FieldNickname)
  8680. }
  8681. if m.markname != nil {
  8682. fields = append(fields, contact.FieldMarkname)
  8683. }
  8684. if m.headimg != nil {
  8685. fields = append(fields, contact.FieldHeadimg)
  8686. }
  8687. if m.sex != nil {
  8688. fields = append(fields, contact.FieldSex)
  8689. }
  8690. if m.starrole != nil {
  8691. fields = append(fields, contact.FieldStarrole)
  8692. }
  8693. if m.dontseeit != nil {
  8694. fields = append(fields, contact.FieldDontseeit)
  8695. }
  8696. if m.dontseeme != nil {
  8697. fields = append(fields, contact.FieldDontseeme)
  8698. }
  8699. if m.lag != nil {
  8700. fields = append(fields, contact.FieldLag)
  8701. }
  8702. if m.gid != nil {
  8703. fields = append(fields, contact.FieldGid)
  8704. }
  8705. if m.gname != nil {
  8706. fields = append(fields, contact.FieldGname)
  8707. }
  8708. if m.v3 != nil {
  8709. fields = append(fields, contact.FieldV3)
  8710. }
  8711. if m.organization_id != nil {
  8712. fields = append(fields, contact.FieldOrganizationID)
  8713. }
  8714. return fields
  8715. }
  8716. // Field returns the value of a field with the given name. The second boolean
  8717. // return value indicates that this field was not set, or was not defined in the
  8718. // schema.
  8719. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  8720. switch name {
  8721. case contact.FieldCreatedAt:
  8722. return m.CreatedAt()
  8723. case contact.FieldUpdatedAt:
  8724. return m.UpdatedAt()
  8725. case contact.FieldStatus:
  8726. return m.Status()
  8727. case contact.FieldDeletedAt:
  8728. return m.DeletedAt()
  8729. case contact.FieldWxWxid:
  8730. return m.WxWxid()
  8731. case contact.FieldType:
  8732. return m.GetType()
  8733. case contact.FieldWxid:
  8734. return m.Wxid()
  8735. case contact.FieldAccount:
  8736. return m.Account()
  8737. case contact.FieldNickname:
  8738. return m.Nickname()
  8739. case contact.FieldMarkname:
  8740. return m.Markname()
  8741. case contact.FieldHeadimg:
  8742. return m.Headimg()
  8743. case contact.FieldSex:
  8744. return m.Sex()
  8745. case contact.FieldStarrole:
  8746. return m.Starrole()
  8747. case contact.FieldDontseeit:
  8748. return m.Dontseeit()
  8749. case contact.FieldDontseeme:
  8750. return m.Dontseeme()
  8751. case contact.FieldLag:
  8752. return m.Lag()
  8753. case contact.FieldGid:
  8754. return m.Gid()
  8755. case contact.FieldGname:
  8756. return m.Gname()
  8757. case contact.FieldV3:
  8758. return m.V3()
  8759. case contact.FieldOrganizationID:
  8760. return m.OrganizationID()
  8761. }
  8762. return nil, false
  8763. }
  8764. // OldField returns the old value of the field from the database. An error is
  8765. // returned if the mutation operation is not UpdateOne, or the query to the
  8766. // database failed.
  8767. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8768. switch name {
  8769. case contact.FieldCreatedAt:
  8770. return m.OldCreatedAt(ctx)
  8771. case contact.FieldUpdatedAt:
  8772. return m.OldUpdatedAt(ctx)
  8773. case contact.FieldStatus:
  8774. return m.OldStatus(ctx)
  8775. case contact.FieldDeletedAt:
  8776. return m.OldDeletedAt(ctx)
  8777. case contact.FieldWxWxid:
  8778. return m.OldWxWxid(ctx)
  8779. case contact.FieldType:
  8780. return m.OldType(ctx)
  8781. case contact.FieldWxid:
  8782. return m.OldWxid(ctx)
  8783. case contact.FieldAccount:
  8784. return m.OldAccount(ctx)
  8785. case contact.FieldNickname:
  8786. return m.OldNickname(ctx)
  8787. case contact.FieldMarkname:
  8788. return m.OldMarkname(ctx)
  8789. case contact.FieldHeadimg:
  8790. return m.OldHeadimg(ctx)
  8791. case contact.FieldSex:
  8792. return m.OldSex(ctx)
  8793. case contact.FieldStarrole:
  8794. return m.OldStarrole(ctx)
  8795. case contact.FieldDontseeit:
  8796. return m.OldDontseeit(ctx)
  8797. case contact.FieldDontseeme:
  8798. return m.OldDontseeme(ctx)
  8799. case contact.FieldLag:
  8800. return m.OldLag(ctx)
  8801. case contact.FieldGid:
  8802. return m.OldGid(ctx)
  8803. case contact.FieldGname:
  8804. return m.OldGname(ctx)
  8805. case contact.FieldV3:
  8806. return m.OldV3(ctx)
  8807. case contact.FieldOrganizationID:
  8808. return m.OldOrganizationID(ctx)
  8809. }
  8810. return nil, fmt.Errorf("unknown Contact field %s", name)
  8811. }
  8812. // SetField sets the value of a field with the given name. It returns an error if
  8813. // the field is not defined in the schema, or if the type mismatched the field
  8814. // type.
  8815. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  8816. switch name {
  8817. case contact.FieldCreatedAt:
  8818. v, ok := value.(time.Time)
  8819. if !ok {
  8820. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8821. }
  8822. m.SetCreatedAt(v)
  8823. return nil
  8824. case contact.FieldUpdatedAt:
  8825. v, ok := value.(time.Time)
  8826. if !ok {
  8827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8828. }
  8829. m.SetUpdatedAt(v)
  8830. return nil
  8831. case contact.FieldStatus:
  8832. v, ok := value.(uint8)
  8833. if !ok {
  8834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8835. }
  8836. m.SetStatus(v)
  8837. return nil
  8838. case contact.FieldDeletedAt:
  8839. v, ok := value.(time.Time)
  8840. if !ok {
  8841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8842. }
  8843. m.SetDeletedAt(v)
  8844. return nil
  8845. case contact.FieldWxWxid:
  8846. v, ok := value.(string)
  8847. if !ok {
  8848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8849. }
  8850. m.SetWxWxid(v)
  8851. return nil
  8852. case contact.FieldType:
  8853. v, ok := value.(int)
  8854. if !ok {
  8855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8856. }
  8857. m.SetType(v)
  8858. return nil
  8859. case contact.FieldWxid:
  8860. v, ok := value.(string)
  8861. if !ok {
  8862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8863. }
  8864. m.SetWxid(v)
  8865. return nil
  8866. case contact.FieldAccount:
  8867. v, ok := value.(string)
  8868. if !ok {
  8869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8870. }
  8871. m.SetAccount(v)
  8872. return nil
  8873. case contact.FieldNickname:
  8874. v, ok := value.(string)
  8875. if !ok {
  8876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8877. }
  8878. m.SetNickname(v)
  8879. return nil
  8880. case contact.FieldMarkname:
  8881. v, ok := value.(string)
  8882. if !ok {
  8883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8884. }
  8885. m.SetMarkname(v)
  8886. return nil
  8887. case contact.FieldHeadimg:
  8888. v, ok := value.(string)
  8889. if !ok {
  8890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8891. }
  8892. m.SetHeadimg(v)
  8893. return nil
  8894. case contact.FieldSex:
  8895. v, ok := value.(int)
  8896. if !ok {
  8897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8898. }
  8899. m.SetSex(v)
  8900. return nil
  8901. case contact.FieldStarrole:
  8902. v, ok := value.(string)
  8903. if !ok {
  8904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8905. }
  8906. m.SetStarrole(v)
  8907. return nil
  8908. case contact.FieldDontseeit:
  8909. v, ok := value.(int)
  8910. if !ok {
  8911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8912. }
  8913. m.SetDontseeit(v)
  8914. return nil
  8915. case contact.FieldDontseeme:
  8916. v, ok := value.(int)
  8917. if !ok {
  8918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8919. }
  8920. m.SetDontseeme(v)
  8921. return nil
  8922. case contact.FieldLag:
  8923. v, ok := value.(string)
  8924. if !ok {
  8925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8926. }
  8927. m.SetLag(v)
  8928. return nil
  8929. case contact.FieldGid:
  8930. v, ok := value.(string)
  8931. if !ok {
  8932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8933. }
  8934. m.SetGid(v)
  8935. return nil
  8936. case contact.FieldGname:
  8937. v, ok := value.(string)
  8938. if !ok {
  8939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8940. }
  8941. m.SetGname(v)
  8942. return nil
  8943. case contact.FieldV3:
  8944. v, ok := value.(string)
  8945. if !ok {
  8946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8947. }
  8948. m.SetV3(v)
  8949. return nil
  8950. case contact.FieldOrganizationID:
  8951. v, ok := value.(uint64)
  8952. if !ok {
  8953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8954. }
  8955. m.SetOrganizationID(v)
  8956. return nil
  8957. }
  8958. return fmt.Errorf("unknown Contact field %s", name)
  8959. }
  8960. // AddedFields returns all numeric fields that were incremented/decremented during
  8961. // this mutation.
  8962. func (m *ContactMutation) AddedFields() []string {
  8963. var fields []string
  8964. if m.addstatus != nil {
  8965. fields = append(fields, contact.FieldStatus)
  8966. }
  8967. if m.add_type != nil {
  8968. fields = append(fields, contact.FieldType)
  8969. }
  8970. if m.addsex != nil {
  8971. fields = append(fields, contact.FieldSex)
  8972. }
  8973. if m.adddontseeit != nil {
  8974. fields = append(fields, contact.FieldDontseeit)
  8975. }
  8976. if m.adddontseeme != nil {
  8977. fields = append(fields, contact.FieldDontseeme)
  8978. }
  8979. if m.addorganization_id != nil {
  8980. fields = append(fields, contact.FieldOrganizationID)
  8981. }
  8982. return fields
  8983. }
  8984. // AddedField returns the numeric value that was incremented/decremented on a field
  8985. // with the given name. The second boolean return value indicates that this field
  8986. // was not set, or was not defined in the schema.
  8987. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  8988. switch name {
  8989. case contact.FieldStatus:
  8990. return m.AddedStatus()
  8991. case contact.FieldType:
  8992. return m.AddedType()
  8993. case contact.FieldSex:
  8994. return m.AddedSex()
  8995. case contact.FieldDontseeit:
  8996. return m.AddedDontseeit()
  8997. case contact.FieldDontseeme:
  8998. return m.AddedDontseeme()
  8999. case contact.FieldOrganizationID:
  9000. return m.AddedOrganizationID()
  9001. }
  9002. return nil, false
  9003. }
  9004. // AddField adds the value to the field with the given name. It returns an error if
  9005. // the field is not defined in the schema, or if the type mismatched the field
  9006. // type.
  9007. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  9008. switch name {
  9009. case contact.FieldStatus:
  9010. v, ok := value.(int8)
  9011. if !ok {
  9012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9013. }
  9014. m.AddStatus(v)
  9015. return nil
  9016. case contact.FieldType:
  9017. v, ok := value.(int)
  9018. if !ok {
  9019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9020. }
  9021. m.AddType(v)
  9022. return nil
  9023. case contact.FieldSex:
  9024. v, ok := value.(int)
  9025. if !ok {
  9026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9027. }
  9028. m.AddSex(v)
  9029. return nil
  9030. case contact.FieldDontseeit:
  9031. v, ok := value.(int)
  9032. if !ok {
  9033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9034. }
  9035. m.AddDontseeit(v)
  9036. return nil
  9037. case contact.FieldDontseeme:
  9038. v, ok := value.(int)
  9039. if !ok {
  9040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9041. }
  9042. m.AddDontseeme(v)
  9043. return nil
  9044. case contact.FieldOrganizationID:
  9045. v, ok := value.(int64)
  9046. if !ok {
  9047. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9048. }
  9049. m.AddOrganizationID(v)
  9050. return nil
  9051. }
  9052. return fmt.Errorf("unknown Contact numeric field %s", name)
  9053. }
  9054. // ClearedFields returns all nullable fields that were cleared during this
  9055. // mutation.
  9056. func (m *ContactMutation) ClearedFields() []string {
  9057. var fields []string
  9058. if m.FieldCleared(contact.FieldStatus) {
  9059. fields = append(fields, contact.FieldStatus)
  9060. }
  9061. if m.FieldCleared(contact.FieldDeletedAt) {
  9062. fields = append(fields, contact.FieldDeletedAt)
  9063. }
  9064. if m.FieldCleared(contact.FieldType) {
  9065. fields = append(fields, contact.FieldType)
  9066. }
  9067. if m.FieldCleared(contact.FieldOrganizationID) {
  9068. fields = append(fields, contact.FieldOrganizationID)
  9069. }
  9070. return fields
  9071. }
  9072. // FieldCleared returns a boolean indicating if a field with the given name was
  9073. // cleared in this mutation.
  9074. func (m *ContactMutation) FieldCleared(name string) bool {
  9075. _, ok := m.clearedFields[name]
  9076. return ok
  9077. }
  9078. // ClearField clears the value of the field with the given name. It returns an
  9079. // error if the field is not defined in the schema.
  9080. func (m *ContactMutation) ClearField(name string) error {
  9081. switch name {
  9082. case contact.FieldStatus:
  9083. m.ClearStatus()
  9084. return nil
  9085. case contact.FieldDeletedAt:
  9086. m.ClearDeletedAt()
  9087. return nil
  9088. case contact.FieldType:
  9089. m.ClearType()
  9090. return nil
  9091. case contact.FieldOrganizationID:
  9092. m.ClearOrganizationID()
  9093. return nil
  9094. }
  9095. return fmt.Errorf("unknown Contact nullable field %s", name)
  9096. }
  9097. // ResetField resets all changes in the mutation for the field with the given name.
  9098. // It returns an error if the field is not defined in the schema.
  9099. func (m *ContactMutation) ResetField(name string) error {
  9100. switch name {
  9101. case contact.FieldCreatedAt:
  9102. m.ResetCreatedAt()
  9103. return nil
  9104. case contact.FieldUpdatedAt:
  9105. m.ResetUpdatedAt()
  9106. return nil
  9107. case contact.FieldStatus:
  9108. m.ResetStatus()
  9109. return nil
  9110. case contact.FieldDeletedAt:
  9111. m.ResetDeletedAt()
  9112. return nil
  9113. case contact.FieldWxWxid:
  9114. m.ResetWxWxid()
  9115. return nil
  9116. case contact.FieldType:
  9117. m.ResetType()
  9118. return nil
  9119. case contact.FieldWxid:
  9120. m.ResetWxid()
  9121. return nil
  9122. case contact.FieldAccount:
  9123. m.ResetAccount()
  9124. return nil
  9125. case contact.FieldNickname:
  9126. m.ResetNickname()
  9127. return nil
  9128. case contact.FieldMarkname:
  9129. m.ResetMarkname()
  9130. return nil
  9131. case contact.FieldHeadimg:
  9132. m.ResetHeadimg()
  9133. return nil
  9134. case contact.FieldSex:
  9135. m.ResetSex()
  9136. return nil
  9137. case contact.FieldStarrole:
  9138. m.ResetStarrole()
  9139. return nil
  9140. case contact.FieldDontseeit:
  9141. m.ResetDontseeit()
  9142. return nil
  9143. case contact.FieldDontseeme:
  9144. m.ResetDontseeme()
  9145. return nil
  9146. case contact.FieldLag:
  9147. m.ResetLag()
  9148. return nil
  9149. case contact.FieldGid:
  9150. m.ResetGid()
  9151. return nil
  9152. case contact.FieldGname:
  9153. m.ResetGname()
  9154. return nil
  9155. case contact.FieldV3:
  9156. m.ResetV3()
  9157. return nil
  9158. case contact.FieldOrganizationID:
  9159. m.ResetOrganizationID()
  9160. return nil
  9161. }
  9162. return fmt.Errorf("unknown Contact field %s", name)
  9163. }
  9164. // AddedEdges returns all edge names that were set/added in this mutation.
  9165. func (m *ContactMutation) AddedEdges() []string {
  9166. edges := make([]string, 0, 2)
  9167. if m.contact_relationships != nil {
  9168. edges = append(edges, contact.EdgeContactRelationships)
  9169. }
  9170. if m.contact_messages != nil {
  9171. edges = append(edges, contact.EdgeContactMessages)
  9172. }
  9173. return edges
  9174. }
  9175. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9176. // name in this mutation.
  9177. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  9178. switch name {
  9179. case contact.EdgeContactRelationships:
  9180. ids := make([]ent.Value, 0, len(m.contact_relationships))
  9181. for id := range m.contact_relationships {
  9182. ids = append(ids, id)
  9183. }
  9184. return ids
  9185. case contact.EdgeContactMessages:
  9186. ids := make([]ent.Value, 0, len(m.contact_messages))
  9187. for id := range m.contact_messages {
  9188. ids = append(ids, id)
  9189. }
  9190. return ids
  9191. }
  9192. return nil
  9193. }
  9194. // RemovedEdges returns all edge names that were removed in this mutation.
  9195. func (m *ContactMutation) RemovedEdges() []string {
  9196. edges := make([]string, 0, 2)
  9197. if m.removedcontact_relationships != nil {
  9198. edges = append(edges, contact.EdgeContactRelationships)
  9199. }
  9200. if m.removedcontact_messages != nil {
  9201. edges = append(edges, contact.EdgeContactMessages)
  9202. }
  9203. return edges
  9204. }
  9205. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9206. // the given name in this mutation.
  9207. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  9208. switch name {
  9209. case contact.EdgeContactRelationships:
  9210. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  9211. for id := range m.removedcontact_relationships {
  9212. ids = append(ids, id)
  9213. }
  9214. return ids
  9215. case contact.EdgeContactMessages:
  9216. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  9217. for id := range m.removedcontact_messages {
  9218. ids = append(ids, id)
  9219. }
  9220. return ids
  9221. }
  9222. return nil
  9223. }
  9224. // ClearedEdges returns all edge names that were cleared in this mutation.
  9225. func (m *ContactMutation) ClearedEdges() []string {
  9226. edges := make([]string, 0, 2)
  9227. if m.clearedcontact_relationships {
  9228. edges = append(edges, contact.EdgeContactRelationships)
  9229. }
  9230. if m.clearedcontact_messages {
  9231. edges = append(edges, contact.EdgeContactMessages)
  9232. }
  9233. return edges
  9234. }
  9235. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9236. // was cleared in this mutation.
  9237. func (m *ContactMutation) EdgeCleared(name string) bool {
  9238. switch name {
  9239. case contact.EdgeContactRelationships:
  9240. return m.clearedcontact_relationships
  9241. case contact.EdgeContactMessages:
  9242. return m.clearedcontact_messages
  9243. }
  9244. return false
  9245. }
  9246. // ClearEdge clears the value of the edge with the given name. It returns an error
  9247. // if that edge is not defined in the schema.
  9248. func (m *ContactMutation) ClearEdge(name string) error {
  9249. switch name {
  9250. }
  9251. return fmt.Errorf("unknown Contact unique edge %s", name)
  9252. }
  9253. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9254. // It returns an error if the edge is not defined in the schema.
  9255. func (m *ContactMutation) ResetEdge(name string) error {
  9256. switch name {
  9257. case contact.EdgeContactRelationships:
  9258. m.ResetContactRelationships()
  9259. return nil
  9260. case contact.EdgeContactMessages:
  9261. m.ResetContactMessages()
  9262. return nil
  9263. }
  9264. return fmt.Errorf("unknown Contact edge %s", name)
  9265. }
  9266. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  9267. type CreditBalanceMutation struct {
  9268. config
  9269. op Op
  9270. typ string
  9271. id *uint64
  9272. created_at *time.Time
  9273. updated_at *time.Time
  9274. deleted_at *time.Time
  9275. user_id *string
  9276. balance *float32
  9277. addbalance *float32
  9278. status *int
  9279. addstatus *int
  9280. organization_id *uint64
  9281. addorganization_id *int64
  9282. clearedFields map[string]struct{}
  9283. done bool
  9284. oldValue func(context.Context) (*CreditBalance, error)
  9285. predicates []predicate.CreditBalance
  9286. }
  9287. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  9288. // creditbalanceOption allows management of the mutation configuration using functional options.
  9289. type creditbalanceOption func(*CreditBalanceMutation)
  9290. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  9291. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  9292. m := &CreditBalanceMutation{
  9293. config: c,
  9294. op: op,
  9295. typ: TypeCreditBalance,
  9296. clearedFields: make(map[string]struct{}),
  9297. }
  9298. for _, opt := range opts {
  9299. opt(m)
  9300. }
  9301. return m
  9302. }
  9303. // withCreditBalanceID sets the ID field of the mutation.
  9304. func withCreditBalanceID(id uint64) creditbalanceOption {
  9305. return func(m *CreditBalanceMutation) {
  9306. var (
  9307. err error
  9308. once sync.Once
  9309. value *CreditBalance
  9310. )
  9311. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  9312. once.Do(func() {
  9313. if m.done {
  9314. err = errors.New("querying old values post mutation is not allowed")
  9315. } else {
  9316. value, err = m.Client().CreditBalance.Get(ctx, id)
  9317. }
  9318. })
  9319. return value, err
  9320. }
  9321. m.id = &id
  9322. }
  9323. }
  9324. // withCreditBalance sets the old CreditBalance of the mutation.
  9325. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  9326. return func(m *CreditBalanceMutation) {
  9327. m.oldValue = func(context.Context) (*CreditBalance, error) {
  9328. return node, nil
  9329. }
  9330. m.id = &node.ID
  9331. }
  9332. }
  9333. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9334. // executed in a transaction (ent.Tx), a transactional client is returned.
  9335. func (m CreditBalanceMutation) Client() *Client {
  9336. client := &Client{config: m.config}
  9337. client.init()
  9338. return client
  9339. }
  9340. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9341. // it returns an error otherwise.
  9342. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  9343. if _, ok := m.driver.(*txDriver); !ok {
  9344. return nil, errors.New("ent: mutation is not running in a transaction")
  9345. }
  9346. tx := &Tx{config: m.config}
  9347. tx.init()
  9348. return tx, nil
  9349. }
  9350. // SetID sets the value of the id field. Note that this
  9351. // operation is only accepted on creation of CreditBalance entities.
  9352. func (m *CreditBalanceMutation) SetID(id uint64) {
  9353. m.id = &id
  9354. }
  9355. // ID returns the ID value in the mutation. Note that the ID is only available
  9356. // if it was provided to the builder or after it was returned from the database.
  9357. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  9358. if m.id == nil {
  9359. return
  9360. }
  9361. return *m.id, true
  9362. }
  9363. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9364. // That means, if the mutation is applied within a transaction with an isolation level such
  9365. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9366. // or updated by the mutation.
  9367. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  9368. switch {
  9369. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9370. id, exists := m.ID()
  9371. if exists {
  9372. return []uint64{id}, nil
  9373. }
  9374. fallthrough
  9375. case m.op.Is(OpUpdate | OpDelete):
  9376. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  9377. default:
  9378. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9379. }
  9380. }
  9381. // SetCreatedAt sets the "created_at" field.
  9382. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  9383. m.created_at = &t
  9384. }
  9385. // CreatedAt returns the value of the "created_at" field in the mutation.
  9386. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  9387. v := m.created_at
  9388. if v == nil {
  9389. return
  9390. }
  9391. return *v, true
  9392. }
  9393. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  9394. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9396. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9397. if !m.op.Is(OpUpdateOne) {
  9398. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9399. }
  9400. if m.id == nil || m.oldValue == nil {
  9401. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9402. }
  9403. oldValue, err := m.oldValue(ctx)
  9404. if err != nil {
  9405. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9406. }
  9407. return oldValue.CreatedAt, nil
  9408. }
  9409. // ResetCreatedAt resets all changes to the "created_at" field.
  9410. func (m *CreditBalanceMutation) ResetCreatedAt() {
  9411. m.created_at = nil
  9412. }
  9413. // SetUpdatedAt sets the "updated_at" field.
  9414. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  9415. m.updated_at = &t
  9416. }
  9417. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9418. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  9419. v := m.updated_at
  9420. if v == nil {
  9421. return
  9422. }
  9423. return *v, true
  9424. }
  9425. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  9426. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9428. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9429. if !m.op.Is(OpUpdateOne) {
  9430. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9431. }
  9432. if m.id == nil || m.oldValue == nil {
  9433. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9434. }
  9435. oldValue, err := m.oldValue(ctx)
  9436. if err != nil {
  9437. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9438. }
  9439. return oldValue.UpdatedAt, nil
  9440. }
  9441. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9442. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  9443. m.updated_at = nil
  9444. }
  9445. // SetDeletedAt sets the "deleted_at" field.
  9446. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  9447. m.deleted_at = &t
  9448. }
  9449. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9450. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  9451. v := m.deleted_at
  9452. if v == nil {
  9453. return
  9454. }
  9455. return *v, true
  9456. }
  9457. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  9458. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9460. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9461. if !m.op.Is(OpUpdateOne) {
  9462. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9463. }
  9464. if m.id == nil || m.oldValue == nil {
  9465. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9466. }
  9467. oldValue, err := m.oldValue(ctx)
  9468. if err != nil {
  9469. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9470. }
  9471. return oldValue.DeletedAt, nil
  9472. }
  9473. // ClearDeletedAt clears the value of the "deleted_at" field.
  9474. func (m *CreditBalanceMutation) ClearDeletedAt() {
  9475. m.deleted_at = nil
  9476. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  9477. }
  9478. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9479. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  9480. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  9481. return ok
  9482. }
  9483. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9484. func (m *CreditBalanceMutation) ResetDeletedAt() {
  9485. m.deleted_at = nil
  9486. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  9487. }
  9488. // SetUserID sets the "user_id" field.
  9489. func (m *CreditBalanceMutation) SetUserID(s string) {
  9490. m.user_id = &s
  9491. }
  9492. // UserID returns the value of the "user_id" field in the mutation.
  9493. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  9494. v := m.user_id
  9495. if v == nil {
  9496. return
  9497. }
  9498. return *v, true
  9499. }
  9500. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  9501. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9503. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  9504. if !m.op.Is(OpUpdateOne) {
  9505. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  9506. }
  9507. if m.id == nil || m.oldValue == nil {
  9508. return v, errors.New("OldUserID requires an ID field in the mutation")
  9509. }
  9510. oldValue, err := m.oldValue(ctx)
  9511. if err != nil {
  9512. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  9513. }
  9514. return oldValue.UserID, nil
  9515. }
  9516. // ResetUserID resets all changes to the "user_id" field.
  9517. func (m *CreditBalanceMutation) ResetUserID() {
  9518. m.user_id = nil
  9519. }
  9520. // SetBalance sets the "balance" field.
  9521. func (m *CreditBalanceMutation) SetBalance(f float32) {
  9522. m.balance = &f
  9523. m.addbalance = nil
  9524. }
  9525. // Balance returns the value of the "balance" field in the mutation.
  9526. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  9527. v := m.balance
  9528. if v == nil {
  9529. return
  9530. }
  9531. return *v, true
  9532. }
  9533. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  9534. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9536. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  9537. if !m.op.Is(OpUpdateOne) {
  9538. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  9539. }
  9540. if m.id == nil || m.oldValue == nil {
  9541. return v, errors.New("OldBalance requires an ID field in the mutation")
  9542. }
  9543. oldValue, err := m.oldValue(ctx)
  9544. if err != nil {
  9545. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  9546. }
  9547. return oldValue.Balance, nil
  9548. }
  9549. // AddBalance adds f to the "balance" field.
  9550. func (m *CreditBalanceMutation) AddBalance(f float32) {
  9551. if m.addbalance != nil {
  9552. *m.addbalance += f
  9553. } else {
  9554. m.addbalance = &f
  9555. }
  9556. }
  9557. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  9558. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  9559. v := m.addbalance
  9560. if v == nil {
  9561. return
  9562. }
  9563. return *v, true
  9564. }
  9565. // ResetBalance resets all changes to the "balance" field.
  9566. func (m *CreditBalanceMutation) ResetBalance() {
  9567. m.balance = nil
  9568. m.addbalance = nil
  9569. }
  9570. // SetStatus sets the "status" field.
  9571. func (m *CreditBalanceMutation) SetStatus(i int) {
  9572. m.status = &i
  9573. m.addstatus = nil
  9574. }
  9575. // Status returns the value of the "status" field in the mutation.
  9576. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  9577. v := m.status
  9578. if v == nil {
  9579. return
  9580. }
  9581. return *v, true
  9582. }
  9583. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  9584. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9586. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  9587. if !m.op.Is(OpUpdateOne) {
  9588. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9589. }
  9590. if m.id == nil || m.oldValue == nil {
  9591. return v, errors.New("OldStatus requires an ID field in the mutation")
  9592. }
  9593. oldValue, err := m.oldValue(ctx)
  9594. if err != nil {
  9595. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9596. }
  9597. return oldValue.Status, nil
  9598. }
  9599. // AddStatus adds i to the "status" field.
  9600. func (m *CreditBalanceMutation) AddStatus(i int) {
  9601. if m.addstatus != nil {
  9602. *m.addstatus += i
  9603. } else {
  9604. m.addstatus = &i
  9605. }
  9606. }
  9607. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9608. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  9609. v := m.addstatus
  9610. if v == nil {
  9611. return
  9612. }
  9613. return *v, true
  9614. }
  9615. // ClearStatus clears the value of the "status" field.
  9616. func (m *CreditBalanceMutation) ClearStatus() {
  9617. m.status = nil
  9618. m.addstatus = nil
  9619. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  9620. }
  9621. // StatusCleared returns if the "status" field was cleared in this mutation.
  9622. func (m *CreditBalanceMutation) StatusCleared() bool {
  9623. _, ok := m.clearedFields[creditbalance.FieldStatus]
  9624. return ok
  9625. }
  9626. // ResetStatus resets all changes to the "status" field.
  9627. func (m *CreditBalanceMutation) ResetStatus() {
  9628. m.status = nil
  9629. m.addstatus = nil
  9630. delete(m.clearedFields, creditbalance.FieldStatus)
  9631. }
  9632. // SetOrganizationID sets the "organization_id" field.
  9633. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  9634. m.organization_id = &u
  9635. m.addorganization_id = nil
  9636. }
  9637. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9638. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  9639. v := m.organization_id
  9640. if v == nil {
  9641. return
  9642. }
  9643. return *v, true
  9644. }
  9645. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  9646. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9647. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9648. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9649. if !m.op.Is(OpUpdateOne) {
  9650. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9651. }
  9652. if m.id == nil || m.oldValue == nil {
  9653. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9654. }
  9655. oldValue, err := m.oldValue(ctx)
  9656. if err != nil {
  9657. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9658. }
  9659. return oldValue.OrganizationID, nil
  9660. }
  9661. // AddOrganizationID adds u to the "organization_id" field.
  9662. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  9663. if m.addorganization_id != nil {
  9664. *m.addorganization_id += u
  9665. } else {
  9666. m.addorganization_id = &u
  9667. }
  9668. }
  9669. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9670. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  9671. v := m.addorganization_id
  9672. if v == nil {
  9673. return
  9674. }
  9675. return *v, true
  9676. }
  9677. // ResetOrganizationID resets all changes to the "organization_id" field.
  9678. func (m *CreditBalanceMutation) ResetOrganizationID() {
  9679. m.organization_id = nil
  9680. m.addorganization_id = nil
  9681. }
  9682. // Where appends a list predicates to the CreditBalanceMutation builder.
  9683. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  9684. m.predicates = append(m.predicates, ps...)
  9685. }
  9686. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  9687. // users can use type-assertion to append predicates that do not depend on any generated package.
  9688. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  9689. p := make([]predicate.CreditBalance, len(ps))
  9690. for i := range ps {
  9691. p[i] = ps[i]
  9692. }
  9693. m.Where(p...)
  9694. }
  9695. // Op returns the operation name.
  9696. func (m *CreditBalanceMutation) Op() Op {
  9697. return m.op
  9698. }
  9699. // SetOp allows setting the mutation operation.
  9700. func (m *CreditBalanceMutation) SetOp(op Op) {
  9701. m.op = op
  9702. }
  9703. // Type returns the node type of this mutation (CreditBalance).
  9704. func (m *CreditBalanceMutation) Type() string {
  9705. return m.typ
  9706. }
  9707. // Fields returns all fields that were changed during this mutation. Note that in
  9708. // order to get all numeric fields that were incremented/decremented, call
  9709. // AddedFields().
  9710. func (m *CreditBalanceMutation) Fields() []string {
  9711. fields := make([]string, 0, 7)
  9712. if m.created_at != nil {
  9713. fields = append(fields, creditbalance.FieldCreatedAt)
  9714. }
  9715. if m.updated_at != nil {
  9716. fields = append(fields, creditbalance.FieldUpdatedAt)
  9717. }
  9718. if m.deleted_at != nil {
  9719. fields = append(fields, creditbalance.FieldDeletedAt)
  9720. }
  9721. if m.user_id != nil {
  9722. fields = append(fields, creditbalance.FieldUserID)
  9723. }
  9724. if m.balance != nil {
  9725. fields = append(fields, creditbalance.FieldBalance)
  9726. }
  9727. if m.status != nil {
  9728. fields = append(fields, creditbalance.FieldStatus)
  9729. }
  9730. if m.organization_id != nil {
  9731. fields = append(fields, creditbalance.FieldOrganizationID)
  9732. }
  9733. return fields
  9734. }
  9735. // Field returns the value of a field with the given name. The second boolean
  9736. // return value indicates that this field was not set, or was not defined in the
  9737. // schema.
  9738. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  9739. switch name {
  9740. case creditbalance.FieldCreatedAt:
  9741. return m.CreatedAt()
  9742. case creditbalance.FieldUpdatedAt:
  9743. return m.UpdatedAt()
  9744. case creditbalance.FieldDeletedAt:
  9745. return m.DeletedAt()
  9746. case creditbalance.FieldUserID:
  9747. return m.UserID()
  9748. case creditbalance.FieldBalance:
  9749. return m.Balance()
  9750. case creditbalance.FieldStatus:
  9751. return m.Status()
  9752. case creditbalance.FieldOrganizationID:
  9753. return m.OrganizationID()
  9754. }
  9755. return nil, false
  9756. }
  9757. // OldField returns the old value of the field from the database. An error is
  9758. // returned if the mutation operation is not UpdateOne, or the query to the
  9759. // database failed.
  9760. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9761. switch name {
  9762. case creditbalance.FieldCreatedAt:
  9763. return m.OldCreatedAt(ctx)
  9764. case creditbalance.FieldUpdatedAt:
  9765. return m.OldUpdatedAt(ctx)
  9766. case creditbalance.FieldDeletedAt:
  9767. return m.OldDeletedAt(ctx)
  9768. case creditbalance.FieldUserID:
  9769. return m.OldUserID(ctx)
  9770. case creditbalance.FieldBalance:
  9771. return m.OldBalance(ctx)
  9772. case creditbalance.FieldStatus:
  9773. return m.OldStatus(ctx)
  9774. case creditbalance.FieldOrganizationID:
  9775. return m.OldOrganizationID(ctx)
  9776. }
  9777. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  9778. }
  9779. // SetField sets the value of a field with the given name. It returns an error if
  9780. // the field is not defined in the schema, or if the type mismatched the field
  9781. // type.
  9782. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  9783. switch name {
  9784. case creditbalance.FieldCreatedAt:
  9785. v, ok := value.(time.Time)
  9786. if !ok {
  9787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9788. }
  9789. m.SetCreatedAt(v)
  9790. return nil
  9791. case creditbalance.FieldUpdatedAt:
  9792. v, ok := value.(time.Time)
  9793. if !ok {
  9794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9795. }
  9796. m.SetUpdatedAt(v)
  9797. return nil
  9798. case creditbalance.FieldDeletedAt:
  9799. v, ok := value.(time.Time)
  9800. if !ok {
  9801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9802. }
  9803. m.SetDeletedAt(v)
  9804. return nil
  9805. case creditbalance.FieldUserID:
  9806. v, ok := value.(string)
  9807. if !ok {
  9808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9809. }
  9810. m.SetUserID(v)
  9811. return nil
  9812. case creditbalance.FieldBalance:
  9813. v, ok := value.(float32)
  9814. if !ok {
  9815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9816. }
  9817. m.SetBalance(v)
  9818. return nil
  9819. case creditbalance.FieldStatus:
  9820. v, ok := value.(int)
  9821. if !ok {
  9822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9823. }
  9824. m.SetStatus(v)
  9825. return nil
  9826. case creditbalance.FieldOrganizationID:
  9827. v, ok := value.(uint64)
  9828. if !ok {
  9829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9830. }
  9831. m.SetOrganizationID(v)
  9832. return nil
  9833. }
  9834. return fmt.Errorf("unknown CreditBalance field %s", name)
  9835. }
  9836. // AddedFields returns all numeric fields that were incremented/decremented during
  9837. // this mutation.
  9838. func (m *CreditBalanceMutation) AddedFields() []string {
  9839. var fields []string
  9840. if m.addbalance != nil {
  9841. fields = append(fields, creditbalance.FieldBalance)
  9842. }
  9843. if m.addstatus != nil {
  9844. fields = append(fields, creditbalance.FieldStatus)
  9845. }
  9846. if m.addorganization_id != nil {
  9847. fields = append(fields, creditbalance.FieldOrganizationID)
  9848. }
  9849. return fields
  9850. }
  9851. // AddedField returns the numeric value that was incremented/decremented on a field
  9852. // with the given name. The second boolean return value indicates that this field
  9853. // was not set, or was not defined in the schema.
  9854. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  9855. switch name {
  9856. case creditbalance.FieldBalance:
  9857. return m.AddedBalance()
  9858. case creditbalance.FieldStatus:
  9859. return m.AddedStatus()
  9860. case creditbalance.FieldOrganizationID:
  9861. return m.AddedOrganizationID()
  9862. }
  9863. return nil, false
  9864. }
  9865. // AddField adds the value to the field with the given name. It returns an error if
  9866. // the field is not defined in the schema, or if the type mismatched the field
  9867. // type.
  9868. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  9869. switch name {
  9870. case creditbalance.FieldBalance:
  9871. v, ok := value.(float32)
  9872. if !ok {
  9873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9874. }
  9875. m.AddBalance(v)
  9876. return nil
  9877. case creditbalance.FieldStatus:
  9878. v, ok := value.(int)
  9879. if !ok {
  9880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9881. }
  9882. m.AddStatus(v)
  9883. return nil
  9884. case creditbalance.FieldOrganizationID:
  9885. v, ok := value.(int64)
  9886. if !ok {
  9887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9888. }
  9889. m.AddOrganizationID(v)
  9890. return nil
  9891. }
  9892. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  9893. }
  9894. // ClearedFields returns all nullable fields that were cleared during this
  9895. // mutation.
  9896. func (m *CreditBalanceMutation) ClearedFields() []string {
  9897. var fields []string
  9898. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  9899. fields = append(fields, creditbalance.FieldDeletedAt)
  9900. }
  9901. if m.FieldCleared(creditbalance.FieldStatus) {
  9902. fields = append(fields, creditbalance.FieldStatus)
  9903. }
  9904. return fields
  9905. }
  9906. // FieldCleared returns a boolean indicating if a field with the given name was
  9907. // cleared in this mutation.
  9908. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  9909. _, ok := m.clearedFields[name]
  9910. return ok
  9911. }
  9912. // ClearField clears the value of the field with the given name. It returns an
  9913. // error if the field is not defined in the schema.
  9914. func (m *CreditBalanceMutation) ClearField(name string) error {
  9915. switch name {
  9916. case creditbalance.FieldDeletedAt:
  9917. m.ClearDeletedAt()
  9918. return nil
  9919. case creditbalance.FieldStatus:
  9920. m.ClearStatus()
  9921. return nil
  9922. }
  9923. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  9924. }
  9925. // ResetField resets all changes in the mutation for the field with the given name.
  9926. // It returns an error if the field is not defined in the schema.
  9927. func (m *CreditBalanceMutation) ResetField(name string) error {
  9928. switch name {
  9929. case creditbalance.FieldCreatedAt:
  9930. m.ResetCreatedAt()
  9931. return nil
  9932. case creditbalance.FieldUpdatedAt:
  9933. m.ResetUpdatedAt()
  9934. return nil
  9935. case creditbalance.FieldDeletedAt:
  9936. m.ResetDeletedAt()
  9937. return nil
  9938. case creditbalance.FieldUserID:
  9939. m.ResetUserID()
  9940. return nil
  9941. case creditbalance.FieldBalance:
  9942. m.ResetBalance()
  9943. return nil
  9944. case creditbalance.FieldStatus:
  9945. m.ResetStatus()
  9946. return nil
  9947. case creditbalance.FieldOrganizationID:
  9948. m.ResetOrganizationID()
  9949. return nil
  9950. }
  9951. return fmt.Errorf("unknown CreditBalance field %s", name)
  9952. }
  9953. // AddedEdges returns all edge names that were set/added in this mutation.
  9954. func (m *CreditBalanceMutation) AddedEdges() []string {
  9955. edges := make([]string, 0, 0)
  9956. return edges
  9957. }
  9958. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9959. // name in this mutation.
  9960. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  9961. return nil
  9962. }
  9963. // RemovedEdges returns all edge names that were removed in this mutation.
  9964. func (m *CreditBalanceMutation) RemovedEdges() []string {
  9965. edges := make([]string, 0, 0)
  9966. return edges
  9967. }
  9968. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9969. // the given name in this mutation.
  9970. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  9971. return nil
  9972. }
  9973. // ClearedEdges returns all edge names that were cleared in this mutation.
  9974. func (m *CreditBalanceMutation) ClearedEdges() []string {
  9975. edges := make([]string, 0, 0)
  9976. return edges
  9977. }
  9978. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9979. // was cleared in this mutation.
  9980. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  9981. return false
  9982. }
  9983. // ClearEdge clears the value of the edge with the given name. It returns an error
  9984. // if that edge is not defined in the schema.
  9985. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  9986. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  9987. }
  9988. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9989. // It returns an error if the edge is not defined in the schema.
  9990. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  9991. return fmt.Errorf("unknown CreditBalance edge %s", name)
  9992. }
  9993. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  9994. type CreditUsageMutation struct {
  9995. config
  9996. op Op
  9997. typ string
  9998. id *uint64
  9999. created_at *time.Time
  10000. updated_at *time.Time
  10001. deleted_at *time.Time
  10002. user_id *string
  10003. number *float32
  10004. addnumber *float32
  10005. status *int
  10006. addstatus *int
  10007. ntype *int
  10008. addntype *int
  10009. table *string
  10010. organization_id *uint64
  10011. addorganization_id *int64
  10012. nid *uint64
  10013. addnid *int64
  10014. reason *string
  10015. operator *string
  10016. clearedFields map[string]struct{}
  10017. done bool
  10018. oldValue func(context.Context) (*CreditUsage, error)
  10019. predicates []predicate.CreditUsage
  10020. }
  10021. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  10022. // creditusageOption allows management of the mutation configuration using functional options.
  10023. type creditusageOption func(*CreditUsageMutation)
  10024. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  10025. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  10026. m := &CreditUsageMutation{
  10027. config: c,
  10028. op: op,
  10029. typ: TypeCreditUsage,
  10030. clearedFields: make(map[string]struct{}),
  10031. }
  10032. for _, opt := range opts {
  10033. opt(m)
  10034. }
  10035. return m
  10036. }
  10037. // withCreditUsageID sets the ID field of the mutation.
  10038. func withCreditUsageID(id uint64) creditusageOption {
  10039. return func(m *CreditUsageMutation) {
  10040. var (
  10041. err error
  10042. once sync.Once
  10043. value *CreditUsage
  10044. )
  10045. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  10046. once.Do(func() {
  10047. if m.done {
  10048. err = errors.New("querying old values post mutation is not allowed")
  10049. } else {
  10050. value, err = m.Client().CreditUsage.Get(ctx, id)
  10051. }
  10052. })
  10053. return value, err
  10054. }
  10055. m.id = &id
  10056. }
  10057. }
  10058. // withCreditUsage sets the old CreditUsage of the mutation.
  10059. func withCreditUsage(node *CreditUsage) creditusageOption {
  10060. return func(m *CreditUsageMutation) {
  10061. m.oldValue = func(context.Context) (*CreditUsage, error) {
  10062. return node, nil
  10063. }
  10064. m.id = &node.ID
  10065. }
  10066. }
  10067. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10068. // executed in a transaction (ent.Tx), a transactional client is returned.
  10069. func (m CreditUsageMutation) Client() *Client {
  10070. client := &Client{config: m.config}
  10071. client.init()
  10072. return client
  10073. }
  10074. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10075. // it returns an error otherwise.
  10076. func (m CreditUsageMutation) Tx() (*Tx, error) {
  10077. if _, ok := m.driver.(*txDriver); !ok {
  10078. return nil, errors.New("ent: mutation is not running in a transaction")
  10079. }
  10080. tx := &Tx{config: m.config}
  10081. tx.init()
  10082. return tx, nil
  10083. }
  10084. // SetID sets the value of the id field. Note that this
  10085. // operation is only accepted on creation of CreditUsage entities.
  10086. func (m *CreditUsageMutation) SetID(id uint64) {
  10087. m.id = &id
  10088. }
  10089. // ID returns the ID value in the mutation. Note that the ID is only available
  10090. // if it was provided to the builder or after it was returned from the database.
  10091. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  10092. if m.id == nil {
  10093. return
  10094. }
  10095. return *m.id, true
  10096. }
  10097. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10098. // That means, if the mutation is applied within a transaction with an isolation level such
  10099. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10100. // or updated by the mutation.
  10101. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  10102. switch {
  10103. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10104. id, exists := m.ID()
  10105. if exists {
  10106. return []uint64{id}, nil
  10107. }
  10108. fallthrough
  10109. case m.op.Is(OpUpdate | OpDelete):
  10110. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  10111. default:
  10112. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10113. }
  10114. }
  10115. // SetCreatedAt sets the "created_at" field.
  10116. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  10117. m.created_at = &t
  10118. }
  10119. // CreatedAt returns the value of the "created_at" field in the mutation.
  10120. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  10121. v := m.created_at
  10122. if v == nil {
  10123. return
  10124. }
  10125. return *v, true
  10126. }
  10127. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  10128. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10130. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10131. if !m.op.Is(OpUpdateOne) {
  10132. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10133. }
  10134. if m.id == nil || m.oldValue == nil {
  10135. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10136. }
  10137. oldValue, err := m.oldValue(ctx)
  10138. if err != nil {
  10139. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10140. }
  10141. return oldValue.CreatedAt, nil
  10142. }
  10143. // ResetCreatedAt resets all changes to the "created_at" field.
  10144. func (m *CreditUsageMutation) ResetCreatedAt() {
  10145. m.created_at = nil
  10146. }
  10147. // SetUpdatedAt sets the "updated_at" field.
  10148. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  10149. m.updated_at = &t
  10150. }
  10151. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10152. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  10153. v := m.updated_at
  10154. if v == nil {
  10155. return
  10156. }
  10157. return *v, true
  10158. }
  10159. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  10160. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10162. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10163. if !m.op.Is(OpUpdateOne) {
  10164. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10165. }
  10166. if m.id == nil || m.oldValue == nil {
  10167. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10168. }
  10169. oldValue, err := m.oldValue(ctx)
  10170. if err != nil {
  10171. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10172. }
  10173. return oldValue.UpdatedAt, nil
  10174. }
  10175. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10176. func (m *CreditUsageMutation) ResetUpdatedAt() {
  10177. m.updated_at = nil
  10178. }
  10179. // SetDeletedAt sets the "deleted_at" field.
  10180. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  10181. m.deleted_at = &t
  10182. }
  10183. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10184. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  10185. v := m.deleted_at
  10186. if v == nil {
  10187. return
  10188. }
  10189. return *v, true
  10190. }
  10191. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  10192. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10193. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10194. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10195. if !m.op.Is(OpUpdateOne) {
  10196. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10197. }
  10198. if m.id == nil || m.oldValue == nil {
  10199. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10200. }
  10201. oldValue, err := m.oldValue(ctx)
  10202. if err != nil {
  10203. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10204. }
  10205. return oldValue.DeletedAt, nil
  10206. }
  10207. // ClearDeletedAt clears the value of the "deleted_at" field.
  10208. func (m *CreditUsageMutation) ClearDeletedAt() {
  10209. m.deleted_at = nil
  10210. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  10211. }
  10212. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10213. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  10214. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  10215. return ok
  10216. }
  10217. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10218. func (m *CreditUsageMutation) ResetDeletedAt() {
  10219. m.deleted_at = nil
  10220. delete(m.clearedFields, creditusage.FieldDeletedAt)
  10221. }
  10222. // SetUserID sets the "user_id" field.
  10223. func (m *CreditUsageMutation) SetUserID(s string) {
  10224. m.user_id = &s
  10225. }
  10226. // UserID returns the value of the "user_id" field in the mutation.
  10227. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  10228. v := m.user_id
  10229. if v == nil {
  10230. return
  10231. }
  10232. return *v, true
  10233. }
  10234. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  10235. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10236. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10237. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  10238. if !m.op.Is(OpUpdateOne) {
  10239. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  10240. }
  10241. if m.id == nil || m.oldValue == nil {
  10242. return v, errors.New("OldUserID requires an ID field in the mutation")
  10243. }
  10244. oldValue, err := m.oldValue(ctx)
  10245. if err != nil {
  10246. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  10247. }
  10248. return oldValue.UserID, nil
  10249. }
  10250. // ResetUserID resets all changes to the "user_id" field.
  10251. func (m *CreditUsageMutation) ResetUserID() {
  10252. m.user_id = nil
  10253. }
  10254. // SetNumber sets the "number" field.
  10255. func (m *CreditUsageMutation) SetNumber(f float32) {
  10256. m.number = &f
  10257. m.addnumber = nil
  10258. }
  10259. // Number returns the value of the "number" field in the mutation.
  10260. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  10261. v := m.number
  10262. if v == nil {
  10263. return
  10264. }
  10265. return *v, true
  10266. }
  10267. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  10268. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10270. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  10271. if !m.op.Is(OpUpdateOne) {
  10272. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  10273. }
  10274. if m.id == nil || m.oldValue == nil {
  10275. return v, errors.New("OldNumber requires an ID field in the mutation")
  10276. }
  10277. oldValue, err := m.oldValue(ctx)
  10278. if err != nil {
  10279. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  10280. }
  10281. return oldValue.Number, nil
  10282. }
  10283. // AddNumber adds f to the "number" field.
  10284. func (m *CreditUsageMutation) AddNumber(f float32) {
  10285. if m.addnumber != nil {
  10286. *m.addnumber += f
  10287. } else {
  10288. m.addnumber = &f
  10289. }
  10290. }
  10291. // AddedNumber returns the value that was added to the "number" field in this mutation.
  10292. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  10293. v := m.addnumber
  10294. if v == nil {
  10295. return
  10296. }
  10297. return *v, true
  10298. }
  10299. // ResetNumber resets all changes to the "number" field.
  10300. func (m *CreditUsageMutation) ResetNumber() {
  10301. m.number = nil
  10302. m.addnumber = nil
  10303. }
  10304. // SetStatus sets the "status" field.
  10305. func (m *CreditUsageMutation) SetStatus(i int) {
  10306. m.status = &i
  10307. m.addstatus = nil
  10308. }
  10309. // Status returns the value of the "status" field in the mutation.
  10310. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  10311. v := m.status
  10312. if v == nil {
  10313. return
  10314. }
  10315. return *v, true
  10316. }
  10317. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  10318. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10320. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  10321. if !m.op.Is(OpUpdateOne) {
  10322. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10323. }
  10324. if m.id == nil || m.oldValue == nil {
  10325. return v, errors.New("OldStatus requires an ID field in the mutation")
  10326. }
  10327. oldValue, err := m.oldValue(ctx)
  10328. if err != nil {
  10329. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10330. }
  10331. return oldValue.Status, nil
  10332. }
  10333. // AddStatus adds i to the "status" field.
  10334. func (m *CreditUsageMutation) AddStatus(i int) {
  10335. if m.addstatus != nil {
  10336. *m.addstatus += i
  10337. } else {
  10338. m.addstatus = &i
  10339. }
  10340. }
  10341. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10342. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  10343. v := m.addstatus
  10344. if v == nil {
  10345. return
  10346. }
  10347. return *v, true
  10348. }
  10349. // ClearStatus clears the value of the "status" field.
  10350. func (m *CreditUsageMutation) ClearStatus() {
  10351. m.status = nil
  10352. m.addstatus = nil
  10353. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  10354. }
  10355. // StatusCleared returns if the "status" field was cleared in this mutation.
  10356. func (m *CreditUsageMutation) StatusCleared() bool {
  10357. _, ok := m.clearedFields[creditusage.FieldStatus]
  10358. return ok
  10359. }
  10360. // ResetStatus resets all changes to the "status" field.
  10361. func (m *CreditUsageMutation) ResetStatus() {
  10362. m.status = nil
  10363. m.addstatus = nil
  10364. delete(m.clearedFields, creditusage.FieldStatus)
  10365. }
  10366. // SetNtype sets the "ntype" field.
  10367. func (m *CreditUsageMutation) SetNtype(i int) {
  10368. m.ntype = &i
  10369. m.addntype = nil
  10370. }
  10371. // Ntype returns the value of the "ntype" field in the mutation.
  10372. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  10373. v := m.ntype
  10374. if v == nil {
  10375. return
  10376. }
  10377. return *v, true
  10378. }
  10379. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  10380. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10382. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  10383. if !m.op.Is(OpUpdateOne) {
  10384. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  10385. }
  10386. if m.id == nil || m.oldValue == nil {
  10387. return v, errors.New("OldNtype requires an ID field in the mutation")
  10388. }
  10389. oldValue, err := m.oldValue(ctx)
  10390. if err != nil {
  10391. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  10392. }
  10393. return oldValue.Ntype, nil
  10394. }
  10395. // AddNtype adds i to the "ntype" field.
  10396. func (m *CreditUsageMutation) AddNtype(i int) {
  10397. if m.addntype != nil {
  10398. *m.addntype += i
  10399. } else {
  10400. m.addntype = &i
  10401. }
  10402. }
  10403. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  10404. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  10405. v := m.addntype
  10406. if v == nil {
  10407. return
  10408. }
  10409. return *v, true
  10410. }
  10411. // ResetNtype resets all changes to the "ntype" field.
  10412. func (m *CreditUsageMutation) ResetNtype() {
  10413. m.ntype = nil
  10414. m.addntype = nil
  10415. }
  10416. // SetTable sets the "table" field.
  10417. func (m *CreditUsageMutation) SetTable(s string) {
  10418. m.table = &s
  10419. }
  10420. // Table returns the value of the "table" field in the mutation.
  10421. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  10422. v := m.table
  10423. if v == nil {
  10424. return
  10425. }
  10426. return *v, true
  10427. }
  10428. // OldTable returns the old "table" field's value of the CreditUsage entity.
  10429. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10430. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10431. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  10432. if !m.op.Is(OpUpdateOne) {
  10433. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  10434. }
  10435. if m.id == nil || m.oldValue == nil {
  10436. return v, errors.New("OldTable requires an ID field in the mutation")
  10437. }
  10438. oldValue, err := m.oldValue(ctx)
  10439. if err != nil {
  10440. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  10441. }
  10442. return oldValue.Table, nil
  10443. }
  10444. // ResetTable resets all changes to the "table" field.
  10445. func (m *CreditUsageMutation) ResetTable() {
  10446. m.table = nil
  10447. }
  10448. // SetOrganizationID sets the "organization_id" field.
  10449. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  10450. m.organization_id = &u
  10451. m.addorganization_id = nil
  10452. }
  10453. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10454. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  10455. v := m.organization_id
  10456. if v == nil {
  10457. return
  10458. }
  10459. return *v, true
  10460. }
  10461. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  10462. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10464. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10465. if !m.op.Is(OpUpdateOne) {
  10466. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10467. }
  10468. if m.id == nil || m.oldValue == nil {
  10469. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10470. }
  10471. oldValue, err := m.oldValue(ctx)
  10472. if err != nil {
  10473. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10474. }
  10475. return oldValue.OrganizationID, nil
  10476. }
  10477. // AddOrganizationID adds u to the "organization_id" field.
  10478. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  10479. if m.addorganization_id != nil {
  10480. *m.addorganization_id += u
  10481. } else {
  10482. m.addorganization_id = &u
  10483. }
  10484. }
  10485. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10486. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  10487. v := m.addorganization_id
  10488. if v == nil {
  10489. return
  10490. }
  10491. return *v, true
  10492. }
  10493. // ResetOrganizationID resets all changes to the "organization_id" field.
  10494. func (m *CreditUsageMutation) ResetOrganizationID() {
  10495. m.organization_id = nil
  10496. m.addorganization_id = nil
  10497. }
  10498. // SetNid sets the "nid" field.
  10499. func (m *CreditUsageMutation) SetNid(u uint64) {
  10500. m.nid = &u
  10501. m.addnid = nil
  10502. }
  10503. // Nid returns the value of the "nid" field in the mutation.
  10504. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  10505. v := m.nid
  10506. if v == nil {
  10507. return
  10508. }
  10509. return *v, true
  10510. }
  10511. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  10512. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10514. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  10515. if !m.op.Is(OpUpdateOne) {
  10516. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  10517. }
  10518. if m.id == nil || m.oldValue == nil {
  10519. return v, errors.New("OldNid requires an ID field in the mutation")
  10520. }
  10521. oldValue, err := m.oldValue(ctx)
  10522. if err != nil {
  10523. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  10524. }
  10525. return oldValue.Nid, nil
  10526. }
  10527. // AddNid adds u to the "nid" field.
  10528. func (m *CreditUsageMutation) AddNid(u int64) {
  10529. if m.addnid != nil {
  10530. *m.addnid += u
  10531. } else {
  10532. m.addnid = &u
  10533. }
  10534. }
  10535. // AddedNid returns the value that was added to the "nid" field in this mutation.
  10536. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  10537. v := m.addnid
  10538. if v == nil {
  10539. return
  10540. }
  10541. return *v, true
  10542. }
  10543. // ResetNid resets all changes to the "nid" field.
  10544. func (m *CreditUsageMutation) ResetNid() {
  10545. m.nid = nil
  10546. m.addnid = nil
  10547. }
  10548. // SetReason sets the "reason" field.
  10549. func (m *CreditUsageMutation) SetReason(s string) {
  10550. m.reason = &s
  10551. }
  10552. // Reason returns the value of the "reason" field in the mutation.
  10553. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  10554. v := m.reason
  10555. if v == nil {
  10556. return
  10557. }
  10558. return *v, true
  10559. }
  10560. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  10561. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10563. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  10564. if !m.op.Is(OpUpdateOne) {
  10565. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  10566. }
  10567. if m.id == nil || m.oldValue == nil {
  10568. return v, errors.New("OldReason requires an ID field in the mutation")
  10569. }
  10570. oldValue, err := m.oldValue(ctx)
  10571. if err != nil {
  10572. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  10573. }
  10574. return oldValue.Reason, nil
  10575. }
  10576. // ResetReason resets all changes to the "reason" field.
  10577. func (m *CreditUsageMutation) ResetReason() {
  10578. m.reason = nil
  10579. }
  10580. // SetOperator sets the "operator" field.
  10581. func (m *CreditUsageMutation) SetOperator(s string) {
  10582. m.operator = &s
  10583. }
  10584. // Operator returns the value of the "operator" field in the mutation.
  10585. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  10586. v := m.operator
  10587. if v == nil {
  10588. return
  10589. }
  10590. return *v, true
  10591. }
  10592. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  10593. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10595. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  10596. if !m.op.Is(OpUpdateOne) {
  10597. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  10598. }
  10599. if m.id == nil || m.oldValue == nil {
  10600. return v, errors.New("OldOperator requires an ID field in the mutation")
  10601. }
  10602. oldValue, err := m.oldValue(ctx)
  10603. if err != nil {
  10604. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  10605. }
  10606. return oldValue.Operator, nil
  10607. }
  10608. // ResetOperator resets all changes to the "operator" field.
  10609. func (m *CreditUsageMutation) ResetOperator() {
  10610. m.operator = nil
  10611. }
  10612. // Where appends a list predicates to the CreditUsageMutation builder.
  10613. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  10614. m.predicates = append(m.predicates, ps...)
  10615. }
  10616. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  10617. // users can use type-assertion to append predicates that do not depend on any generated package.
  10618. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  10619. p := make([]predicate.CreditUsage, len(ps))
  10620. for i := range ps {
  10621. p[i] = ps[i]
  10622. }
  10623. m.Where(p...)
  10624. }
  10625. // Op returns the operation name.
  10626. func (m *CreditUsageMutation) Op() Op {
  10627. return m.op
  10628. }
  10629. // SetOp allows setting the mutation operation.
  10630. func (m *CreditUsageMutation) SetOp(op Op) {
  10631. m.op = op
  10632. }
  10633. // Type returns the node type of this mutation (CreditUsage).
  10634. func (m *CreditUsageMutation) Type() string {
  10635. return m.typ
  10636. }
  10637. // Fields returns all fields that were changed during this mutation. Note that in
  10638. // order to get all numeric fields that were incremented/decremented, call
  10639. // AddedFields().
  10640. func (m *CreditUsageMutation) Fields() []string {
  10641. fields := make([]string, 0, 12)
  10642. if m.created_at != nil {
  10643. fields = append(fields, creditusage.FieldCreatedAt)
  10644. }
  10645. if m.updated_at != nil {
  10646. fields = append(fields, creditusage.FieldUpdatedAt)
  10647. }
  10648. if m.deleted_at != nil {
  10649. fields = append(fields, creditusage.FieldDeletedAt)
  10650. }
  10651. if m.user_id != nil {
  10652. fields = append(fields, creditusage.FieldUserID)
  10653. }
  10654. if m.number != nil {
  10655. fields = append(fields, creditusage.FieldNumber)
  10656. }
  10657. if m.status != nil {
  10658. fields = append(fields, creditusage.FieldStatus)
  10659. }
  10660. if m.ntype != nil {
  10661. fields = append(fields, creditusage.FieldNtype)
  10662. }
  10663. if m.table != nil {
  10664. fields = append(fields, creditusage.FieldTable)
  10665. }
  10666. if m.organization_id != nil {
  10667. fields = append(fields, creditusage.FieldOrganizationID)
  10668. }
  10669. if m.nid != nil {
  10670. fields = append(fields, creditusage.FieldNid)
  10671. }
  10672. if m.reason != nil {
  10673. fields = append(fields, creditusage.FieldReason)
  10674. }
  10675. if m.operator != nil {
  10676. fields = append(fields, creditusage.FieldOperator)
  10677. }
  10678. return fields
  10679. }
  10680. // Field returns the value of a field with the given name. The second boolean
  10681. // return value indicates that this field was not set, or was not defined in the
  10682. // schema.
  10683. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  10684. switch name {
  10685. case creditusage.FieldCreatedAt:
  10686. return m.CreatedAt()
  10687. case creditusage.FieldUpdatedAt:
  10688. return m.UpdatedAt()
  10689. case creditusage.FieldDeletedAt:
  10690. return m.DeletedAt()
  10691. case creditusage.FieldUserID:
  10692. return m.UserID()
  10693. case creditusage.FieldNumber:
  10694. return m.Number()
  10695. case creditusage.FieldStatus:
  10696. return m.Status()
  10697. case creditusage.FieldNtype:
  10698. return m.Ntype()
  10699. case creditusage.FieldTable:
  10700. return m.Table()
  10701. case creditusage.FieldOrganizationID:
  10702. return m.OrganizationID()
  10703. case creditusage.FieldNid:
  10704. return m.Nid()
  10705. case creditusage.FieldReason:
  10706. return m.Reason()
  10707. case creditusage.FieldOperator:
  10708. return m.Operator()
  10709. }
  10710. return nil, false
  10711. }
  10712. // OldField returns the old value of the field from the database. An error is
  10713. // returned if the mutation operation is not UpdateOne, or the query to the
  10714. // database failed.
  10715. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10716. switch name {
  10717. case creditusage.FieldCreatedAt:
  10718. return m.OldCreatedAt(ctx)
  10719. case creditusage.FieldUpdatedAt:
  10720. return m.OldUpdatedAt(ctx)
  10721. case creditusage.FieldDeletedAt:
  10722. return m.OldDeletedAt(ctx)
  10723. case creditusage.FieldUserID:
  10724. return m.OldUserID(ctx)
  10725. case creditusage.FieldNumber:
  10726. return m.OldNumber(ctx)
  10727. case creditusage.FieldStatus:
  10728. return m.OldStatus(ctx)
  10729. case creditusage.FieldNtype:
  10730. return m.OldNtype(ctx)
  10731. case creditusage.FieldTable:
  10732. return m.OldTable(ctx)
  10733. case creditusage.FieldOrganizationID:
  10734. return m.OldOrganizationID(ctx)
  10735. case creditusage.FieldNid:
  10736. return m.OldNid(ctx)
  10737. case creditusage.FieldReason:
  10738. return m.OldReason(ctx)
  10739. case creditusage.FieldOperator:
  10740. return m.OldOperator(ctx)
  10741. }
  10742. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  10743. }
  10744. // SetField sets the value of a field with the given name. It returns an error if
  10745. // the field is not defined in the schema, or if the type mismatched the field
  10746. // type.
  10747. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  10748. switch name {
  10749. case creditusage.FieldCreatedAt:
  10750. v, ok := value.(time.Time)
  10751. if !ok {
  10752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10753. }
  10754. m.SetCreatedAt(v)
  10755. return nil
  10756. case creditusage.FieldUpdatedAt:
  10757. v, ok := value.(time.Time)
  10758. if !ok {
  10759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10760. }
  10761. m.SetUpdatedAt(v)
  10762. return nil
  10763. case creditusage.FieldDeletedAt:
  10764. v, ok := value.(time.Time)
  10765. if !ok {
  10766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10767. }
  10768. m.SetDeletedAt(v)
  10769. return nil
  10770. case creditusage.FieldUserID:
  10771. v, ok := value.(string)
  10772. if !ok {
  10773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10774. }
  10775. m.SetUserID(v)
  10776. return nil
  10777. case creditusage.FieldNumber:
  10778. v, ok := value.(float32)
  10779. if !ok {
  10780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10781. }
  10782. m.SetNumber(v)
  10783. return nil
  10784. case creditusage.FieldStatus:
  10785. v, ok := value.(int)
  10786. if !ok {
  10787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10788. }
  10789. m.SetStatus(v)
  10790. return nil
  10791. case creditusage.FieldNtype:
  10792. v, ok := value.(int)
  10793. if !ok {
  10794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10795. }
  10796. m.SetNtype(v)
  10797. return nil
  10798. case creditusage.FieldTable:
  10799. v, ok := value.(string)
  10800. if !ok {
  10801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10802. }
  10803. m.SetTable(v)
  10804. return nil
  10805. case creditusage.FieldOrganizationID:
  10806. v, ok := value.(uint64)
  10807. if !ok {
  10808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10809. }
  10810. m.SetOrganizationID(v)
  10811. return nil
  10812. case creditusage.FieldNid:
  10813. v, ok := value.(uint64)
  10814. if !ok {
  10815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10816. }
  10817. m.SetNid(v)
  10818. return nil
  10819. case creditusage.FieldReason:
  10820. v, ok := value.(string)
  10821. if !ok {
  10822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10823. }
  10824. m.SetReason(v)
  10825. return nil
  10826. case creditusage.FieldOperator:
  10827. v, ok := value.(string)
  10828. if !ok {
  10829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10830. }
  10831. m.SetOperator(v)
  10832. return nil
  10833. }
  10834. return fmt.Errorf("unknown CreditUsage field %s", name)
  10835. }
  10836. // AddedFields returns all numeric fields that were incremented/decremented during
  10837. // this mutation.
  10838. func (m *CreditUsageMutation) AddedFields() []string {
  10839. var fields []string
  10840. if m.addnumber != nil {
  10841. fields = append(fields, creditusage.FieldNumber)
  10842. }
  10843. if m.addstatus != nil {
  10844. fields = append(fields, creditusage.FieldStatus)
  10845. }
  10846. if m.addntype != nil {
  10847. fields = append(fields, creditusage.FieldNtype)
  10848. }
  10849. if m.addorganization_id != nil {
  10850. fields = append(fields, creditusage.FieldOrganizationID)
  10851. }
  10852. if m.addnid != nil {
  10853. fields = append(fields, creditusage.FieldNid)
  10854. }
  10855. return fields
  10856. }
  10857. // AddedField returns the numeric value that was incremented/decremented on a field
  10858. // with the given name. The second boolean return value indicates that this field
  10859. // was not set, or was not defined in the schema.
  10860. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  10861. switch name {
  10862. case creditusage.FieldNumber:
  10863. return m.AddedNumber()
  10864. case creditusage.FieldStatus:
  10865. return m.AddedStatus()
  10866. case creditusage.FieldNtype:
  10867. return m.AddedNtype()
  10868. case creditusage.FieldOrganizationID:
  10869. return m.AddedOrganizationID()
  10870. case creditusage.FieldNid:
  10871. return m.AddedNid()
  10872. }
  10873. return nil, false
  10874. }
  10875. // AddField adds the value to the field with the given name. It returns an error if
  10876. // the field is not defined in the schema, or if the type mismatched the field
  10877. // type.
  10878. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  10879. switch name {
  10880. case creditusage.FieldNumber:
  10881. v, ok := value.(float32)
  10882. if !ok {
  10883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10884. }
  10885. m.AddNumber(v)
  10886. return nil
  10887. case creditusage.FieldStatus:
  10888. v, ok := value.(int)
  10889. if !ok {
  10890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10891. }
  10892. m.AddStatus(v)
  10893. return nil
  10894. case creditusage.FieldNtype:
  10895. v, ok := value.(int)
  10896. if !ok {
  10897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10898. }
  10899. m.AddNtype(v)
  10900. return nil
  10901. case creditusage.FieldOrganizationID:
  10902. v, ok := value.(int64)
  10903. if !ok {
  10904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10905. }
  10906. m.AddOrganizationID(v)
  10907. return nil
  10908. case creditusage.FieldNid:
  10909. v, ok := value.(int64)
  10910. if !ok {
  10911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10912. }
  10913. m.AddNid(v)
  10914. return nil
  10915. }
  10916. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  10917. }
  10918. // ClearedFields returns all nullable fields that were cleared during this
  10919. // mutation.
  10920. func (m *CreditUsageMutation) ClearedFields() []string {
  10921. var fields []string
  10922. if m.FieldCleared(creditusage.FieldDeletedAt) {
  10923. fields = append(fields, creditusage.FieldDeletedAt)
  10924. }
  10925. if m.FieldCleared(creditusage.FieldStatus) {
  10926. fields = append(fields, creditusage.FieldStatus)
  10927. }
  10928. return fields
  10929. }
  10930. // FieldCleared returns a boolean indicating if a field with the given name was
  10931. // cleared in this mutation.
  10932. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  10933. _, ok := m.clearedFields[name]
  10934. return ok
  10935. }
  10936. // ClearField clears the value of the field with the given name. It returns an
  10937. // error if the field is not defined in the schema.
  10938. func (m *CreditUsageMutation) ClearField(name string) error {
  10939. switch name {
  10940. case creditusage.FieldDeletedAt:
  10941. m.ClearDeletedAt()
  10942. return nil
  10943. case creditusage.FieldStatus:
  10944. m.ClearStatus()
  10945. return nil
  10946. }
  10947. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  10948. }
  10949. // ResetField resets all changes in the mutation for the field with the given name.
  10950. // It returns an error if the field is not defined in the schema.
  10951. func (m *CreditUsageMutation) ResetField(name string) error {
  10952. switch name {
  10953. case creditusage.FieldCreatedAt:
  10954. m.ResetCreatedAt()
  10955. return nil
  10956. case creditusage.FieldUpdatedAt:
  10957. m.ResetUpdatedAt()
  10958. return nil
  10959. case creditusage.FieldDeletedAt:
  10960. m.ResetDeletedAt()
  10961. return nil
  10962. case creditusage.FieldUserID:
  10963. m.ResetUserID()
  10964. return nil
  10965. case creditusage.FieldNumber:
  10966. m.ResetNumber()
  10967. return nil
  10968. case creditusage.FieldStatus:
  10969. m.ResetStatus()
  10970. return nil
  10971. case creditusage.FieldNtype:
  10972. m.ResetNtype()
  10973. return nil
  10974. case creditusage.FieldTable:
  10975. m.ResetTable()
  10976. return nil
  10977. case creditusage.FieldOrganizationID:
  10978. m.ResetOrganizationID()
  10979. return nil
  10980. case creditusage.FieldNid:
  10981. m.ResetNid()
  10982. return nil
  10983. case creditusage.FieldReason:
  10984. m.ResetReason()
  10985. return nil
  10986. case creditusage.FieldOperator:
  10987. m.ResetOperator()
  10988. return nil
  10989. }
  10990. return fmt.Errorf("unknown CreditUsage field %s", name)
  10991. }
  10992. // AddedEdges returns all edge names that were set/added in this mutation.
  10993. func (m *CreditUsageMutation) AddedEdges() []string {
  10994. edges := make([]string, 0, 0)
  10995. return edges
  10996. }
  10997. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10998. // name in this mutation.
  10999. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  11000. return nil
  11001. }
  11002. // RemovedEdges returns all edge names that were removed in this mutation.
  11003. func (m *CreditUsageMutation) RemovedEdges() []string {
  11004. edges := make([]string, 0, 0)
  11005. return edges
  11006. }
  11007. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11008. // the given name in this mutation.
  11009. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  11010. return nil
  11011. }
  11012. // ClearedEdges returns all edge names that were cleared in this mutation.
  11013. func (m *CreditUsageMutation) ClearedEdges() []string {
  11014. edges := make([]string, 0, 0)
  11015. return edges
  11016. }
  11017. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11018. // was cleared in this mutation.
  11019. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  11020. return false
  11021. }
  11022. // ClearEdge clears the value of the edge with the given name. It returns an error
  11023. // if that edge is not defined in the schema.
  11024. func (m *CreditUsageMutation) ClearEdge(name string) error {
  11025. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  11026. }
  11027. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11028. // It returns an error if the edge is not defined in the schema.
  11029. func (m *CreditUsageMutation) ResetEdge(name string) error {
  11030. return fmt.Errorf("unknown CreditUsage edge %s", name)
  11031. }
  11032. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  11033. type EmployeeMutation struct {
  11034. config
  11035. op Op
  11036. typ string
  11037. id *uint64
  11038. created_at *time.Time
  11039. updated_at *time.Time
  11040. deleted_at *time.Time
  11041. title *string
  11042. avatar *string
  11043. tags *string
  11044. hire_count *int
  11045. addhire_count *int
  11046. service_count *int
  11047. addservice_count *int
  11048. achievement_count *int
  11049. addachievement_count *int
  11050. intro *string
  11051. estimate *string
  11052. skill *string
  11053. ability_type *string
  11054. scene *string
  11055. switch_in *string
  11056. video_url *string
  11057. organization_id *uint64
  11058. addorganization_id *int64
  11059. category_id *uint64
  11060. addcategory_id *int64
  11061. api_base *string
  11062. api_key *string
  11063. ai_info *string
  11064. is_vip *int
  11065. addis_vip *int
  11066. chat_url *string
  11067. clearedFields map[string]struct{}
  11068. em_work_experiences map[uint64]struct{}
  11069. removedem_work_experiences map[uint64]struct{}
  11070. clearedem_work_experiences bool
  11071. em_tutorial map[uint64]struct{}
  11072. removedem_tutorial map[uint64]struct{}
  11073. clearedem_tutorial bool
  11074. done bool
  11075. oldValue func(context.Context) (*Employee, error)
  11076. predicates []predicate.Employee
  11077. }
  11078. var _ ent.Mutation = (*EmployeeMutation)(nil)
  11079. // employeeOption allows management of the mutation configuration using functional options.
  11080. type employeeOption func(*EmployeeMutation)
  11081. // newEmployeeMutation creates new mutation for the Employee entity.
  11082. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  11083. m := &EmployeeMutation{
  11084. config: c,
  11085. op: op,
  11086. typ: TypeEmployee,
  11087. clearedFields: make(map[string]struct{}),
  11088. }
  11089. for _, opt := range opts {
  11090. opt(m)
  11091. }
  11092. return m
  11093. }
  11094. // withEmployeeID sets the ID field of the mutation.
  11095. func withEmployeeID(id uint64) employeeOption {
  11096. return func(m *EmployeeMutation) {
  11097. var (
  11098. err error
  11099. once sync.Once
  11100. value *Employee
  11101. )
  11102. m.oldValue = func(ctx context.Context) (*Employee, error) {
  11103. once.Do(func() {
  11104. if m.done {
  11105. err = errors.New("querying old values post mutation is not allowed")
  11106. } else {
  11107. value, err = m.Client().Employee.Get(ctx, id)
  11108. }
  11109. })
  11110. return value, err
  11111. }
  11112. m.id = &id
  11113. }
  11114. }
  11115. // withEmployee sets the old Employee of the mutation.
  11116. func withEmployee(node *Employee) employeeOption {
  11117. return func(m *EmployeeMutation) {
  11118. m.oldValue = func(context.Context) (*Employee, error) {
  11119. return node, nil
  11120. }
  11121. m.id = &node.ID
  11122. }
  11123. }
  11124. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11125. // executed in a transaction (ent.Tx), a transactional client is returned.
  11126. func (m EmployeeMutation) Client() *Client {
  11127. client := &Client{config: m.config}
  11128. client.init()
  11129. return client
  11130. }
  11131. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11132. // it returns an error otherwise.
  11133. func (m EmployeeMutation) Tx() (*Tx, error) {
  11134. if _, ok := m.driver.(*txDriver); !ok {
  11135. return nil, errors.New("ent: mutation is not running in a transaction")
  11136. }
  11137. tx := &Tx{config: m.config}
  11138. tx.init()
  11139. return tx, nil
  11140. }
  11141. // SetID sets the value of the id field. Note that this
  11142. // operation is only accepted on creation of Employee entities.
  11143. func (m *EmployeeMutation) SetID(id uint64) {
  11144. m.id = &id
  11145. }
  11146. // ID returns the ID value in the mutation. Note that the ID is only available
  11147. // if it was provided to the builder or after it was returned from the database.
  11148. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  11149. if m.id == nil {
  11150. return
  11151. }
  11152. return *m.id, true
  11153. }
  11154. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11155. // That means, if the mutation is applied within a transaction with an isolation level such
  11156. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11157. // or updated by the mutation.
  11158. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  11159. switch {
  11160. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11161. id, exists := m.ID()
  11162. if exists {
  11163. return []uint64{id}, nil
  11164. }
  11165. fallthrough
  11166. case m.op.Is(OpUpdate | OpDelete):
  11167. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  11168. default:
  11169. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11170. }
  11171. }
  11172. // SetCreatedAt sets the "created_at" field.
  11173. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  11174. m.created_at = &t
  11175. }
  11176. // CreatedAt returns the value of the "created_at" field in the mutation.
  11177. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  11178. v := m.created_at
  11179. if v == nil {
  11180. return
  11181. }
  11182. return *v, true
  11183. }
  11184. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  11185. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11187. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11188. if !m.op.Is(OpUpdateOne) {
  11189. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11190. }
  11191. if m.id == nil || m.oldValue == nil {
  11192. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11193. }
  11194. oldValue, err := m.oldValue(ctx)
  11195. if err != nil {
  11196. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11197. }
  11198. return oldValue.CreatedAt, nil
  11199. }
  11200. // ResetCreatedAt resets all changes to the "created_at" field.
  11201. func (m *EmployeeMutation) ResetCreatedAt() {
  11202. m.created_at = nil
  11203. }
  11204. // SetUpdatedAt sets the "updated_at" field.
  11205. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  11206. m.updated_at = &t
  11207. }
  11208. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11209. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  11210. v := m.updated_at
  11211. if v == nil {
  11212. return
  11213. }
  11214. return *v, true
  11215. }
  11216. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  11217. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11219. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11220. if !m.op.Is(OpUpdateOne) {
  11221. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11222. }
  11223. if m.id == nil || m.oldValue == nil {
  11224. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11225. }
  11226. oldValue, err := m.oldValue(ctx)
  11227. if err != nil {
  11228. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11229. }
  11230. return oldValue.UpdatedAt, nil
  11231. }
  11232. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11233. func (m *EmployeeMutation) ResetUpdatedAt() {
  11234. m.updated_at = nil
  11235. }
  11236. // SetDeletedAt sets the "deleted_at" field.
  11237. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  11238. m.deleted_at = &t
  11239. }
  11240. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11241. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  11242. v := m.deleted_at
  11243. if v == nil {
  11244. return
  11245. }
  11246. return *v, true
  11247. }
  11248. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  11249. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11250. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11251. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11252. if !m.op.Is(OpUpdateOne) {
  11253. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11254. }
  11255. if m.id == nil || m.oldValue == nil {
  11256. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11257. }
  11258. oldValue, err := m.oldValue(ctx)
  11259. if err != nil {
  11260. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11261. }
  11262. return oldValue.DeletedAt, nil
  11263. }
  11264. // ClearDeletedAt clears the value of the "deleted_at" field.
  11265. func (m *EmployeeMutation) ClearDeletedAt() {
  11266. m.deleted_at = nil
  11267. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  11268. }
  11269. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11270. func (m *EmployeeMutation) DeletedAtCleared() bool {
  11271. _, ok := m.clearedFields[employee.FieldDeletedAt]
  11272. return ok
  11273. }
  11274. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11275. func (m *EmployeeMutation) ResetDeletedAt() {
  11276. m.deleted_at = nil
  11277. delete(m.clearedFields, employee.FieldDeletedAt)
  11278. }
  11279. // SetTitle sets the "title" field.
  11280. func (m *EmployeeMutation) SetTitle(s string) {
  11281. m.title = &s
  11282. }
  11283. // Title returns the value of the "title" field in the mutation.
  11284. func (m *EmployeeMutation) Title() (r string, exists bool) {
  11285. v := m.title
  11286. if v == nil {
  11287. return
  11288. }
  11289. return *v, true
  11290. }
  11291. // OldTitle returns the old "title" field's value of the Employee entity.
  11292. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11294. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  11295. if !m.op.Is(OpUpdateOne) {
  11296. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  11297. }
  11298. if m.id == nil || m.oldValue == nil {
  11299. return v, errors.New("OldTitle requires an ID field in the mutation")
  11300. }
  11301. oldValue, err := m.oldValue(ctx)
  11302. if err != nil {
  11303. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  11304. }
  11305. return oldValue.Title, nil
  11306. }
  11307. // ResetTitle resets all changes to the "title" field.
  11308. func (m *EmployeeMutation) ResetTitle() {
  11309. m.title = nil
  11310. }
  11311. // SetAvatar sets the "avatar" field.
  11312. func (m *EmployeeMutation) SetAvatar(s string) {
  11313. m.avatar = &s
  11314. }
  11315. // Avatar returns the value of the "avatar" field in the mutation.
  11316. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  11317. v := m.avatar
  11318. if v == nil {
  11319. return
  11320. }
  11321. return *v, true
  11322. }
  11323. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  11324. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11326. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  11327. if !m.op.Is(OpUpdateOne) {
  11328. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  11329. }
  11330. if m.id == nil || m.oldValue == nil {
  11331. return v, errors.New("OldAvatar requires an ID field in the mutation")
  11332. }
  11333. oldValue, err := m.oldValue(ctx)
  11334. if err != nil {
  11335. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  11336. }
  11337. return oldValue.Avatar, nil
  11338. }
  11339. // ResetAvatar resets all changes to the "avatar" field.
  11340. func (m *EmployeeMutation) ResetAvatar() {
  11341. m.avatar = nil
  11342. }
  11343. // SetTags sets the "tags" field.
  11344. func (m *EmployeeMutation) SetTags(s string) {
  11345. m.tags = &s
  11346. }
  11347. // Tags returns the value of the "tags" field in the mutation.
  11348. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  11349. v := m.tags
  11350. if v == nil {
  11351. return
  11352. }
  11353. return *v, true
  11354. }
  11355. // OldTags returns the old "tags" field's value of the Employee entity.
  11356. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11357. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11358. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  11359. if !m.op.Is(OpUpdateOne) {
  11360. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  11361. }
  11362. if m.id == nil || m.oldValue == nil {
  11363. return v, errors.New("OldTags requires an ID field in the mutation")
  11364. }
  11365. oldValue, err := m.oldValue(ctx)
  11366. if err != nil {
  11367. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  11368. }
  11369. return oldValue.Tags, nil
  11370. }
  11371. // ResetTags resets all changes to the "tags" field.
  11372. func (m *EmployeeMutation) ResetTags() {
  11373. m.tags = nil
  11374. }
  11375. // SetHireCount sets the "hire_count" field.
  11376. func (m *EmployeeMutation) SetHireCount(i int) {
  11377. m.hire_count = &i
  11378. m.addhire_count = nil
  11379. }
  11380. // HireCount returns the value of the "hire_count" field in the mutation.
  11381. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  11382. v := m.hire_count
  11383. if v == nil {
  11384. return
  11385. }
  11386. return *v, true
  11387. }
  11388. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  11389. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11391. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  11392. if !m.op.Is(OpUpdateOne) {
  11393. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  11394. }
  11395. if m.id == nil || m.oldValue == nil {
  11396. return v, errors.New("OldHireCount requires an ID field in the mutation")
  11397. }
  11398. oldValue, err := m.oldValue(ctx)
  11399. if err != nil {
  11400. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  11401. }
  11402. return oldValue.HireCount, nil
  11403. }
  11404. // AddHireCount adds i to the "hire_count" field.
  11405. func (m *EmployeeMutation) AddHireCount(i int) {
  11406. if m.addhire_count != nil {
  11407. *m.addhire_count += i
  11408. } else {
  11409. m.addhire_count = &i
  11410. }
  11411. }
  11412. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  11413. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  11414. v := m.addhire_count
  11415. if v == nil {
  11416. return
  11417. }
  11418. return *v, true
  11419. }
  11420. // ResetHireCount resets all changes to the "hire_count" field.
  11421. func (m *EmployeeMutation) ResetHireCount() {
  11422. m.hire_count = nil
  11423. m.addhire_count = nil
  11424. }
  11425. // SetServiceCount sets the "service_count" field.
  11426. func (m *EmployeeMutation) SetServiceCount(i int) {
  11427. m.service_count = &i
  11428. m.addservice_count = nil
  11429. }
  11430. // ServiceCount returns the value of the "service_count" field in the mutation.
  11431. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  11432. v := m.service_count
  11433. if v == nil {
  11434. return
  11435. }
  11436. return *v, true
  11437. }
  11438. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  11439. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11440. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11441. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  11442. if !m.op.Is(OpUpdateOne) {
  11443. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  11444. }
  11445. if m.id == nil || m.oldValue == nil {
  11446. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  11447. }
  11448. oldValue, err := m.oldValue(ctx)
  11449. if err != nil {
  11450. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  11451. }
  11452. return oldValue.ServiceCount, nil
  11453. }
  11454. // AddServiceCount adds i to the "service_count" field.
  11455. func (m *EmployeeMutation) AddServiceCount(i int) {
  11456. if m.addservice_count != nil {
  11457. *m.addservice_count += i
  11458. } else {
  11459. m.addservice_count = &i
  11460. }
  11461. }
  11462. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  11463. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  11464. v := m.addservice_count
  11465. if v == nil {
  11466. return
  11467. }
  11468. return *v, true
  11469. }
  11470. // ResetServiceCount resets all changes to the "service_count" field.
  11471. func (m *EmployeeMutation) ResetServiceCount() {
  11472. m.service_count = nil
  11473. m.addservice_count = nil
  11474. }
  11475. // SetAchievementCount sets the "achievement_count" field.
  11476. func (m *EmployeeMutation) SetAchievementCount(i int) {
  11477. m.achievement_count = &i
  11478. m.addachievement_count = nil
  11479. }
  11480. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  11481. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  11482. v := m.achievement_count
  11483. if v == nil {
  11484. return
  11485. }
  11486. return *v, true
  11487. }
  11488. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  11489. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11491. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  11492. if !m.op.Is(OpUpdateOne) {
  11493. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  11494. }
  11495. if m.id == nil || m.oldValue == nil {
  11496. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  11497. }
  11498. oldValue, err := m.oldValue(ctx)
  11499. if err != nil {
  11500. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  11501. }
  11502. return oldValue.AchievementCount, nil
  11503. }
  11504. // AddAchievementCount adds i to the "achievement_count" field.
  11505. func (m *EmployeeMutation) AddAchievementCount(i int) {
  11506. if m.addachievement_count != nil {
  11507. *m.addachievement_count += i
  11508. } else {
  11509. m.addachievement_count = &i
  11510. }
  11511. }
  11512. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  11513. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  11514. v := m.addachievement_count
  11515. if v == nil {
  11516. return
  11517. }
  11518. return *v, true
  11519. }
  11520. // ResetAchievementCount resets all changes to the "achievement_count" field.
  11521. func (m *EmployeeMutation) ResetAchievementCount() {
  11522. m.achievement_count = nil
  11523. m.addachievement_count = nil
  11524. }
  11525. // SetIntro sets the "intro" field.
  11526. func (m *EmployeeMutation) SetIntro(s string) {
  11527. m.intro = &s
  11528. }
  11529. // Intro returns the value of the "intro" field in the mutation.
  11530. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  11531. v := m.intro
  11532. if v == nil {
  11533. return
  11534. }
  11535. return *v, true
  11536. }
  11537. // OldIntro returns the old "intro" field's value of the Employee entity.
  11538. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11540. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  11541. if !m.op.Is(OpUpdateOne) {
  11542. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  11543. }
  11544. if m.id == nil || m.oldValue == nil {
  11545. return v, errors.New("OldIntro requires an ID field in the mutation")
  11546. }
  11547. oldValue, err := m.oldValue(ctx)
  11548. if err != nil {
  11549. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  11550. }
  11551. return oldValue.Intro, nil
  11552. }
  11553. // ResetIntro resets all changes to the "intro" field.
  11554. func (m *EmployeeMutation) ResetIntro() {
  11555. m.intro = nil
  11556. }
  11557. // SetEstimate sets the "estimate" field.
  11558. func (m *EmployeeMutation) SetEstimate(s string) {
  11559. m.estimate = &s
  11560. }
  11561. // Estimate returns the value of the "estimate" field in the mutation.
  11562. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  11563. v := m.estimate
  11564. if v == nil {
  11565. return
  11566. }
  11567. return *v, true
  11568. }
  11569. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  11570. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11572. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  11573. if !m.op.Is(OpUpdateOne) {
  11574. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  11575. }
  11576. if m.id == nil || m.oldValue == nil {
  11577. return v, errors.New("OldEstimate requires an ID field in the mutation")
  11578. }
  11579. oldValue, err := m.oldValue(ctx)
  11580. if err != nil {
  11581. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  11582. }
  11583. return oldValue.Estimate, nil
  11584. }
  11585. // ResetEstimate resets all changes to the "estimate" field.
  11586. func (m *EmployeeMutation) ResetEstimate() {
  11587. m.estimate = nil
  11588. }
  11589. // SetSkill sets the "skill" field.
  11590. func (m *EmployeeMutation) SetSkill(s string) {
  11591. m.skill = &s
  11592. }
  11593. // Skill returns the value of the "skill" field in the mutation.
  11594. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  11595. v := m.skill
  11596. if v == nil {
  11597. return
  11598. }
  11599. return *v, true
  11600. }
  11601. // OldSkill returns the old "skill" field's value of the Employee entity.
  11602. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11604. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  11605. if !m.op.Is(OpUpdateOne) {
  11606. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  11607. }
  11608. if m.id == nil || m.oldValue == nil {
  11609. return v, errors.New("OldSkill requires an ID field in the mutation")
  11610. }
  11611. oldValue, err := m.oldValue(ctx)
  11612. if err != nil {
  11613. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  11614. }
  11615. return oldValue.Skill, nil
  11616. }
  11617. // ResetSkill resets all changes to the "skill" field.
  11618. func (m *EmployeeMutation) ResetSkill() {
  11619. m.skill = nil
  11620. }
  11621. // SetAbilityType sets the "ability_type" field.
  11622. func (m *EmployeeMutation) SetAbilityType(s string) {
  11623. m.ability_type = &s
  11624. }
  11625. // AbilityType returns the value of the "ability_type" field in the mutation.
  11626. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  11627. v := m.ability_type
  11628. if v == nil {
  11629. return
  11630. }
  11631. return *v, true
  11632. }
  11633. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  11634. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11636. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  11637. if !m.op.Is(OpUpdateOne) {
  11638. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  11639. }
  11640. if m.id == nil || m.oldValue == nil {
  11641. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  11642. }
  11643. oldValue, err := m.oldValue(ctx)
  11644. if err != nil {
  11645. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  11646. }
  11647. return oldValue.AbilityType, nil
  11648. }
  11649. // ResetAbilityType resets all changes to the "ability_type" field.
  11650. func (m *EmployeeMutation) ResetAbilityType() {
  11651. m.ability_type = nil
  11652. }
  11653. // SetScene sets the "scene" field.
  11654. func (m *EmployeeMutation) SetScene(s string) {
  11655. m.scene = &s
  11656. }
  11657. // Scene returns the value of the "scene" field in the mutation.
  11658. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  11659. v := m.scene
  11660. if v == nil {
  11661. return
  11662. }
  11663. return *v, true
  11664. }
  11665. // OldScene returns the old "scene" field's value of the Employee entity.
  11666. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11668. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  11669. if !m.op.Is(OpUpdateOne) {
  11670. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  11671. }
  11672. if m.id == nil || m.oldValue == nil {
  11673. return v, errors.New("OldScene requires an ID field in the mutation")
  11674. }
  11675. oldValue, err := m.oldValue(ctx)
  11676. if err != nil {
  11677. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  11678. }
  11679. return oldValue.Scene, nil
  11680. }
  11681. // ResetScene resets all changes to the "scene" field.
  11682. func (m *EmployeeMutation) ResetScene() {
  11683. m.scene = nil
  11684. }
  11685. // SetSwitchIn sets the "switch_in" field.
  11686. func (m *EmployeeMutation) SetSwitchIn(s string) {
  11687. m.switch_in = &s
  11688. }
  11689. // SwitchIn returns the value of the "switch_in" field in the mutation.
  11690. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  11691. v := m.switch_in
  11692. if v == nil {
  11693. return
  11694. }
  11695. return *v, true
  11696. }
  11697. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  11698. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11700. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  11701. if !m.op.Is(OpUpdateOne) {
  11702. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  11703. }
  11704. if m.id == nil || m.oldValue == nil {
  11705. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  11706. }
  11707. oldValue, err := m.oldValue(ctx)
  11708. if err != nil {
  11709. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  11710. }
  11711. return oldValue.SwitchIn, nil
  11712. }
  11713. // ResetSwitchIn resets all changes to the "switch_in" field.
  11714. func (m *EmployeeMutation) ResetSwitchIn() {
  11715. m.switch_in = nil
  11716. }
  11717. // SetVideoURL sets the "video_url" field.
  11718. func (m *EmployeeMutation) SetVideoURL(s string) {
  11719. m.video_url = &s
  11720. }
  11721. // VideoURL returns the value of the "video_url" field in the mutation.
  11722. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  11723. v := m.video_url
  11724. if v == nil {
  11725. return
  11726. }
  11727. return *v, true
  11728. }
  11729. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  11730. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11732. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  11733. if !m.op.Is(OpUpdateOne) {
  11734. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  11735. }
  11736. if m.id == nil || m.oldValue == nil {
  11737. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  11738. }
  11739. oldValue, err := m.oldValue(ctx)
  11740. if err != nil {
  11741. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  11742. }
  11743. return oldValue.VideoURL, nil
  11744. }
  11745. // ResetVideoURL resets all changes to the "video_url" field.
  11746. func (m *EmployeeMutation) ResetVideoURL() {
  11747. m.video_url = nil
  11748. }
  11749. // SetOrganizationID sets the "organization_id" field.
  11750. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  11751. m.organization_id = &u
  11752. m.addorganization_id = nil
  11753. }
  11754. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11755. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  11756. v := m.organization_id
  11757. if v == nil {
  11758. return
  11759. }
  11760. return *v, true
  11761. }
  11762. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  11763. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11764. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11765. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11766. if !m.op.Is(OpUpdateOne) {
  11767. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11768. }
  11769. if m.id == nil || m.oldValue == nil {
  11770. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11771. }
  11772. oldValue, err := m.oldValue(ctx)
  11773. if err != nil {
  11774. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11775. }
  11776. return oldValue.OrganizationID, nil
  11777. }
  11778. // AddOrganizationID adds u to the "organization_id" field.
  11779. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  11780. if m.addorganization_id != nil {
  11781. *m.addorganization_id += u
  11782. } else {
  11783. m.addorganization_id = &u
  11784. }
  11785. }
  11786. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11787. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  11788. v := m.addorganization_id
  11789. if v == nil {
  11790. return
  11791. }
  11792. return *v, true
  11793. }
  11794. // ResetOrganizationID resets all changes to the "organization_id" field.
  11795. func (m *EmployeeMutation) ResetOrganizationID() {
  11796. m.organization_id = nil
  11797. m.addorganization_id = nil
  11798. }
  11799. // SetCategoryID sets the "category_id" field.
  11800. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  11801. m.category_id = &u
  11802. m.addcategory_id = nil
  11803. }
  11804. // CategoryID returns the value of the "category_id" field in the mutation.
  11805. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  11806. v := m.category_id
  11807. if v == nil {
  11808. return
  11809. }
  11810. return *v, true
  11811. }
  11812. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  11813. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11815. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  11816. if !m.op.Is(OpUpdateOne) {
  11817. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  11818. }
  11819. if m.id == nil || m.oldValue == nil {
  11820. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  11821. }
  11822. oldValue, err := m.oldValue(ctx)
  11823. if err != nil {
  11824. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  11825. }
  11826. return oldValue.CategoryID, nil
  11827. }
  11828. // AddCategoryID adds u to the "category_id" field.
  11829. func (m *EmployeeMutation) AddCategoryID(u int64) {
  11830. if m.addcategory_id != nil {
  11831. *m.addcategory_id += u
  11832. } else {
  11833. m.addcategory_id = &u
  11834. }
  11835. }
  11836. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  11837. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  11838. v := m.addcategory_id
  11839. if v == nil {
  11840. return
  11841. }
  11842. return *v, true
  11843. }
  11844. // ResetCategoryID resets all changes to the "category_id" field.
  11845. func (m *EmployeeMutation) ResetCategoryID() {
  11846. m.category_id = nil
  11847. m.addcategory_id = nil
  11848. }
  11849. // SetAPIBase sets the "api_base" field.
  11850. func (m *EmployeeMutation) SetAPIBase(s string) {
  11851. m.api_base = &s
  11852. }
  11853. // APIBase returns the value of the "api_base" field in the mutation.
  11854. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  11855. v := m.api_base
  11856. if v == nil {
  11857. return
  11858. }
  11859. return *v, true
  11860. }
  11861. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  11862. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11864. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  11865. if !m.op.Is(OpUpdateOne) {
  11866. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  11867. }
  11868. if m.id == nil || m.oldValue == nil {
  11869. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  11870. }
  11871. oldValue, err := m.oldValue(ctx)
  11872. if err != nil {
  11873. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  11874. }
  11875. return oldValue.APIBase, nil
  11876. }
  11877. // ResetAPIBase resets all changes to the "api_base" field.
  11878. func (m *EmployeeMutation) ResetAPIBase() {
  11879. m.api_base = nil
  11880. }
  11881. // SetAPIKey sets the "api_key" field.
  11882. func (m *EmployeeMutation) SetAPIKey(s string) {
  11883. m.api_key = &s
  11884. }
  11885. // APIKey returns the value of the "api_key" field in the mutation.
  11886. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  11887. v := m.api_key
  11888. if v == nil {
  11889. return
  11890. }
  11891. return *v, true
  11892. }
  11893. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  11894. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11895. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11896. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  11897. if !m.op.Is(OpUpdateOne) {
  11898. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  11899. }
  11900. if m.id == nil || m.oldValue == nil {
  11901. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  11902. }
  11903. oldValue, err := m.oldValue(ctx)
  11904. if err != nil {
  11905. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  11906. }
  11907. return oldValue.APIKey, nil
  11908. }
  11909. // ResetAPIKey resets all changes to the "api_key" field.
  11910. func (m *EmployeeMutation) ResetAPIKey() {
  11911. m.api_key = nil
  11912. }
  11913. // SetAiInfo sets the "ai_info" field.
  11914. func (m *EmployeeMutation) SetAiInfo(s string) {
  11915. m.ai_info = &s
  11916. }
  11917. // AiInfo returns the value of the "ai_info" field in the mutation.
  11918. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  11919. v := m.ai_info
  11920. if v == nil {
  11921. return
  11922. }
  11923. return *v, true
  11924. }
  11925. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  11926. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11927. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11928. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  11929. if !m.op.Is(OpUpdateOne) {
  11930. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  11931. }
  11932. if m.id == nil || m.oldValue == nil {
  11933. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  11934. }
  11935. oldValue, err := m.oldValue(ctx)
  11936. if err != nil {
  11937. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  11938. }
  11939. return oldValue.AiInfo, nil
  11940. }
  11941. // ClearAiInfo clears the value of the "ai_info" field.
  11942. func (m *EmployeeMutation) ClearAiInfo() {
  11943. m.ai_info = nil
  11944. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  11945. }
  11946. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  11947. func (m *EmployeeMutation) AiInfoCleared() bool {
  11948. _, ok := m.clearedFields[employee.FieldAiInfo]
  11949. return ok
  11950. }
  11951. // ResetAiInfo resets all changes to the "ai_info" field.
  11952. func (m *EmployeeMutation) ResetAiInfo() {
  11953. m.ai_info = nil
  11954. delete(m.clearedFields, employee.FieldAiInfo)
  11955. }
  11956. // SetIsVip sets the "is_vip" field.
  11957. func (m *EmployeeMutation) SetIsVip(i int) {
  11958. m.is_vip = &i
  11959. m.addis_vip = nil
  11960. }
  11961. // IsVip returns the value of the "is_vip" field in the mutation.
  11962. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  11963. v := m.is_vip
  11964. if v == nil {
  11965. return
  11966. }
  11967. return *v, true
  11968. }
  11969. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  11970. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11971. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11972. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  11973. if !m.op.Is(OpUpdateOne) {
  11974. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  11975. }
  11976. if m.id == nil || m.oldValue == nil {
  11977. return v, errors.New("OldIsVip requires an ID field in the mutation")
  11978. }
  11979. oldValue, err := m.oldValue(ctx)
  11980. if err != nil {
  11981. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  11982. }
  11983. return oldValue.IsVip, nil
  11984. }
  11985. // AddIsVip adds i to the "is_vip" field.
  11986. func (m *EmployeeMutation) AddIsVip(i int) {
  11987. if m.addis_vip != nil {
  11988. *m.addis_vip += i
  11989. } else {
  11990. m.addis_vip = &i
  11991. }
  11992. }
  11993. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  11994. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  11995. v := m.addis_vip
  11996. if v == nil {
  11997. return
  11998. }
  11999. return *v, true
  12000. }
  12001. // ResetIsVip resets all changes to the "is_vip" field.
  12002. func (m *EmployeeMutation) ResetIsVip() {
  12003. m.is_vip = nil
  12004. m.addis_vip = nil
  12005. }
  12006. // SetChatURL sets the "chat_url" field.
  12007. func (m *EmployeeMutation) SetChatURL(s string) {
  12008. m.chat_url = &s
  12009. }
  12010. // ChatURL returns the value of the "chat_url" field in the mutation.
  12011. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  12012. v := m.chat_url
  12013. if v == nil {
  12014. return
  12015. }
  12016. return *v, true
  12017. }
  12018. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  12019. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12021. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  12022. if !m.op.Is(OpUpdateOne) {
  12023. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  12024. }
  12025. if m.id == nil || m.oldValue == nil {
  12026. return v, errors.New("OldChatURL requires an ID field in the mutation")
  12027. }
  12028. oldValue, err := m.oldValue(ctx)
  12029. if err != nil {
  12030. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  12031. }
  12032. return oldValue.ChatURL, nil
  12033. }
  12034. // ResetChatURL resets all changes to the "chat_url" field.
  12035. func (m *EmployeeMutation) ResetChatURL() {
  12036. m.chat_url = nil
  12037. }
  12038. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  12039. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  12040. if m.em_work_experiences == nil {
  12041. m.em_work_experiences = make(map[uint64]struct{})
  12042. }
  12043. for i := range ids {
  12044. m.em_work_experiences[ids[i]] = struct{}{}
  12045. }
  12046. }
  12047. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  12048. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  12049. m.clearedem_work_experiences = true
  12050. }
  12051. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  12052. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  12053. return m.clearedem_work_experiences
  12054. }
  12055. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  12056. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  12057. if m.removedem_work_experiences == nil {
  12058. m.removedem_work_experiences = make(map[uint64]struct{})
  12059. }
  12060. for i := range ids {
  12061. delete(m.em_work_experiences, ids[i])
  12062. m.removedem_work_experiences[ids[i]] = struct{}{}
  12063. }
  12064. }
  12065. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  12066. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  12067. for id := range m.removedem_work_experiences {
  12068. ids = append(ids, id)
  12069. }
  12070. return
  12071. }
  12072. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  12073. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  12074. for id := range m.em_work_experiences {
  12075. ids = append(ids, id)
  12076. }
  12077. return
  12078. }
  12079. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  12080. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  12081. m.em_work_experiences = nil
  12082. m.clearedem_work_experiences = false
  12083. m.removedem_work_experiences = nil
  12084. }
  12085. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  12086. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  12087. if m.em_tutorial == nil {
  12088. m.em_tutorial = make(map[uint64]struct{})
  12089. }
  12090. for i := range ids {
  12091. m.em_tutorial[ids[i]] = struct{}{}
  12092. }
  12093. }
  12094. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  12095. func (m *EmployeeMutation) ClearEmTutorial() {
  12096. m.clearedem_tutorial = true
  12097. }
  12098. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  12099. func (m *EmployeeMutation) EmTutorialCleared() bool {
  12100. return m.clearedem_tutorial
  12101. }
  12102. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  12103. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  12104. if m.removedem_tutorial == nil {
  12105. m.removedem_tutorial = make(map[uint64]struct{})
  12106. }
  12107. for i := range ids {
  12108. delete(m.em_tutorial, ids[i])
  12109. m.removedem_tutorial[ids[i]] = struct{}{}
  12110. }
  12111. }
  12112. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  12113. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  12114. for id := range m.removedem_tutorial {
  12115. ids = append(ids, id)
  12116. }
  12117. return
  12118. }
  12119. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  12120. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  12121. for id := range m.em_tutorial {
  12122. ids = append(ids, id)
  12123. }
  12124. return
  12125. }
  12126. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  12127. func (m *EmployeeMutation) ResetEmTutorial() {
  12128. m.em_tutorial = nil
  12129. m.clearedem_tutorial = false
  12130. m.removedem_tutorial = nil
  12131. }
  12132. // Where appends a list predicates to the EmployeeMutation builder.
  12133. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  12134. m.predicates = append(m.predicates, ps...)
  12135. }
  12136. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  12137. // users can use type-assertion to append predicates that do not depend on any generated package.
  12138. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  12139. p := make([]predicate.Employee, len(ps))
  12140. for i := range ps {
  12141. p[i] = ps[i]
  12142. }
  12143. m.Where(p...)
  12144. }
  12145. // Op returns the operation name.
  12146. func (m *EmployeeMutation) Op() Op {
  12147. return m.op
  12148. }
  12149. // SetOp allows setting the mutation operation.
  12150. func (m *EmployeeMutation) SetOp(op Op) {
  12151. m.op = op
  12152. }
  12153. // Type returns the node type of this mutation (Employee).
  12154. func (m *EmployeeMutation) Type() string {
  12155. return m.typ
  12156. }
  12157. // Fields returns all fields that were changed during this mutation. Note that in
  12158. // order to get all numeric fields that were incremented/decremented, call
  12159. // AddedFields().
  12160. func (m *EmployeeMutation) Fields() []string {
  12161. fields := make([]string, 0, 23)
  12162. if m.created_at != nil {
  12163. fields = append(fields, employee.FieldCreatedAt)
  12164. }
  12165. if m.updated_at != nil {
  12166. fields = append(fields, employee.FieldUpdatedAt)
  12167. }
  12168. if m.deleted_at != nil {
  12169. fields = append(fields, employee.FieldDeletedAt)
  12170. }
  12171. if m.title != nil {
  12172. fields = append(fields, employee.FieldTitle)
  12173. }
  12174. if m.avatar != nil {
  12175. fields = append(fields, employee.FieldAvatar)
  12176. }
  12177. if m.tags != nil {
  12178. fields = append(fields, employee.FieldTags)
  12179. }
  12180. if m.hire_count != nil {
  12181. fields = append(fields, employee.FieldHireCount)
  12182. }
  12183. if m.service_count != nil {
  12184. fields = append(fields, employee.FieldServiceCount)
  12185. }
  12186. if m.achievement_count != nil {
  12187. fields = append(fields, employee.FieldAchievementCount)
  12188. }
  12189. if m.intro != nil {
  12190. fields = append(fields, employee.FieldIntro)
  12191. }
  12192. if m.estimate != nil {
  12193. fields = append(fields, employee.FieldEstimate)
  12194. }
  12195. if m.skill != nil {
  12196. fields = append(fields, employee.FieldSkill)
  12197. }
  12198. if m.ability_type != nil {
  12199. fields = append(fields, employee.FieldAbilityType)
  12200. }
  12201. if m.scene != nil {
  12202. fields = append(fields, employee.FieldScene)
  12203. }
  12204. if m.switch_in != nil {
  12205. fields = append(fields, employee.FieldSwitchIn)
  12206. }
  12207. if m.video_url != nil {
  12208. fields = append(fields, employee.FieldVideoURL)
  12209. }
  12210. if m.organization_id != nil {
  12211. fields = append(fields, employee.FieldOrganizationID)
  12212. }
  12213. if m.category_id != nil {
  12214. fields = append(fields, employee.FieldCategoryID)
  12215. }
  12216. if m.api_base != nil {
  12217. fields = append(fields, employee.FieldAPIBase)
  12218. }
  12219. if m.api_key != nil {
  12220. fields = append(fields, employee.FieldAPIKey)
  12221. }
  12222. if m.ai_info != nil {
  12223. fields = append(fields, employee.FieldAiInfo)
  12224. }
  12225. if m.is_vip != nil {
  12226. fields = append(fields, employee.FieldIsVip)
  12227. }
  12228. if m.chat_url != nil {
  12229. fields = append(fields, employee.FieldChatURL)
  12230. }
  12231. return fields
  12232. }
  12233. // Field returns the value of a field with the given name. The second boolean
  12234. // return value indicates that this field was not set, or was not defined in the
  12235. // schema.
  12236. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  12237. switch name {
  12238. case employee.FieldCreatedAt:
  12239. return m.CreatedAt()
  12240. case employee.FieldUpdatedAt:
  12241. return m.UpdatedAt()
  12242. case employee.FieldDeletedAt:
  12243. return m.DeletedAt()
  12244. case employee.FieldTitle:
  12245. return m.Title()
  12246. case employee.FieldAvatar:
  12247. return m.Avatar()
  12248. case employee.FieldTags:
  12249. return m.Tags()
  12250. case employee.FieldHireCount:
  12251. return m.HireCount()
  12252. case employee.FieldServiceCount:
  12253. return m.ServiceCount()
  12254. case employee.FieldAchievementCount:
  12255. return m.AchievementCount()
  12256. case employee.FieldIntro:
  12257. return m.Intro()
  12258. case employee.FieldEstimate:
  12259. return m.Estimate()
  12260. case employee.FieldSkill:
  12261. return m.Skill()
  12262. case employee.FieldAbilityType:
  12263. return m.AbilityType()
  12264. case employee.FieldScene:
  12265. return m.Scene()
  12266. case employee.FieldSwitchIn:
  12267. return m.SwitchIn()
  12268. case employee.FieldVideoURL:
  12269. return m.VideoURL()
  12270. case employee.FieldOrganizationID:
  12271. return m.OrganizationID()
  12272. case employee.FieldCategoryID:
  12273. return m.CategoryID()
  12274. case employee.FieldAPIBase:
  12275. return m.APIBase()
  12276. case employee.FieldAPIKey:
  12277. return m.APIKey()
  12278. case employee.FieldAiInfo:
  12279. return m.AiInfo()
  12280. case employee.FieldIsVip:
  12281. return m.IsVip()
  12282. case employee.FieldChatURL:
  12283. return m.ChatURL()
  12284. }
  12285. return nil, false
  12286. }
  12287. // OldField returns the old value of the field from the database. An error is
  12288. // returned if the mutation operation is not UpdateOne, or the query to the
  12289. // database failed.
  12290. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12291. switch name {
  12292. case employee.FieldCreatedAt:
  12293. return m.OldCreatedAt(ctx)
  12294. case employee.FieldUpdatedAt:
  12295. return m.OldUpdatedAt(ctx)
  12296. case employee.FieldDeletedAt:
  12297. return m.OldDeletedAt(ctx)
  12298. case employee.FieldTitle:
  12299. return m.OldTitle(ctx)
  12300. case employee.FieldAvatar:
  12301. return m.OldAvatar(ctx)
  12302. case employee.FieldTags:
  12303. return m.OldTags(ctx)
  12304. case employee.FieldHireCount:
  12305. return m.OldHireCount(ctx)
  12306. case employee.FieldServiceCount:
  12307. return m.OldServiceCount(ctx)
  12308. case employee.FieldAchievementCount:
  12309. return m.OldAchievementCount(ctx)
  12310. case employee.FieldIntro:
  12311. return m.OldIntro(ctx)
  12312. case employee.FieldEstimate:
  12313. return m.OldEstimate(ctx)
  12314. case employee.FieldSkill:
  12315. return m.OldSkill(ctx)
  12316. case employee.FieldAbilityType:
  12317. return m.OldAbilityType(ctx)
  12318. case employee.FieldScene:
  12319. return m.OldScene(ctx)
  12320. case employee.FieldSwitchIn:
  12321. return m.OldSwitchIn(ctx)
  12322. case employee.FieldVideoURL:
  12323. return m.OldVideoURL(ctx)
  12324. case employee.FieldOrganizationID:
  12325. return m.OldOrganizationID(ctx)
  12326. case employee.FieldCategoryID:
  12327. return m.OldCategoryID(ctx)
  12328. case employee.FieldAPIBase:
  12329. return m.OldAPIBase(ctx)
  12330. case employee.FieldAPIKey:
  12331. return m.OldAPIKey(ctx)
  12332. case employee.FieldAiInfo:
  12333. return m.OldAiInfo(ctx)
  12334. case employee.FieldIsVip:
  12335. return m.OldIsVip(ctx)
  12336. case employee.FieldChatURL:
  12337. return m.OldChatURL(ctx)
  12338. }
  12339. return nil, fmt.Errorf("unknown Employee field %s", name)
  12340. }
  12341. // SetField sets the value of a field with the given name. It returns an error if
  12342. // the field is not defined in the schema, or if the type mismatched the field
  12343. // type.
  12344. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  12345. switch name {
  12346. case employee.FieldCreatedAt:
  12347. v, ok := value.(time.Time)
  12348. if !ok {
  12349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12350. }
  12351. m.SetCreatedAt(v)
  12352. return nil
  12353. case employee.FieldUpdatedAt:
  12354. v, ok := value.(time.Time)
  12355. if !ok {
  12356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12357. }
  12358. m.SetUpdatedAt(v)
  12359. return nil
  12360. case employee.FieldDeletedAt:
  12361. v, ok := value.(time.Time)
  12362. if !ok {
  12363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12364. }
  12365. m.SetDeletedAt(v)
  12366. return nil
  12367. case employee.FieldTitle:
  12368. v, ok := value.(string)
  12369. if !ok {
  12370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12371. }
  12372. m.SetTitle(v)
  12373. return nil
  12374. case employee.FieldAvatar:
  12375. v, ok := value.(string)
  12376. if !ok {
  12377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12378. }
  12379. m.SetAvatar(v)
  12380. return nil
  12381. case employee.FieldTags:
  12382. v, ok := value.(string)
  12383. if !ok {
  12384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12385. }
  12386. m.SetTags(v)
  12387. return nil
  12388. case employee.FieldHireCount:
  12389. v, ok := value.(int)
  12390. if !ok {
  12391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12392. }
  12393. m.SetHireCount(v)
  12394. return nil
  12395. case employee.FieldServiceCount:
  12396. v, ok := value.(int)
  12397. if !ok {
  12398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12399. }
  12400. m.SetServiceCount(v)
  12401. return nil
  12402. case employee.FieldAchievementCount:
  12403. v, ok := value.(int)
  12404. if !ok {
  12405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12406. }
  12407. m.SetAchievementCount(v)
  12408. return nil
  12409. case employee.FieldIntro:
  12410. v, ok := value.(string)
  12411. if !ok {
  12412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12413. }
  12414. m.SetIntro(v)
  12415. return nil
  12416. case employee.FieldEstimate:
  12417. v, ok := value.(string)
  12418. if !ok {
  12419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12420. }
  12421. m.SetEstimate(v)
  12422. return nil
  12423. case employee.FieldSkill:
  12424. v, ok := value.(string)
  12425. if !ok {
  12426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12427. }
  12428. m.SetSkill(v)
  12429. return nil
  12430. case employee.FieldAbilityType:
  12431. v, ok := value.(string)
  12432. if !ok {
  12433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12434. }
  12435. m.SetAbilityType(v)
  12436. return nil
  12437. case employee.FieldScene:
  12438. v, ok := value.(string)
  12439. if !ok {
  12440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12441. }
  12442. m.SetScene(v)
  12443. return nil
  12444. case employee.FieldSwitchIn:
  12445. v, ok := value.(string)
  12446. if !ok {
  12447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12448. }
  12449. m.SetSwitchIn(v)
  12450. return nil
  12451. case employee.FieldVideoURL:
  12452. v, ok := value.(string)
  12453. if !ok {
  12454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12455. }
  12456. m.SetVideoURL(v)
  12457. return nil
  12458. case employee.FieldOrganizationID:
  12459. v, ok := value.(uint64)
  12460. if !ok {
  12461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12462. }
  12463. m.SetOrganizationID(v)
  12464. return nil
  12465. case employee.FieldCategoryID:
  12466. v, ok := value.(uint64)
  12467. if !ok {
  12468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12469. }
  12470. m.SetCategoryID(v)
  12471. return nil
  12472. case employee.FieldAPIBase:
  12473. v, ok := value.(string)
  12474. if !ok {
  12475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12476. }
  12477. m.SetAPIBase(v)
  12478. return nil
  12479. case employee.FieldAPIKey:
  12480. v, ok := value.(string)
  12481. if !ok {
  12482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12483. }
  12484. m.SetAPIKey(v)
  12485. return nil
  12486. case employee.FieldAiInfo:
  12487. v, ok := value.(string)
  12488. if !ok {
  12489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12490. }
  12491. m.SetAiInfo(v)
  12492. return nil
  12493. case employee.FieldIsVip:
  12494. v, ok := value.(int)
  12495. if !ok {
  12496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12497. }
  12498. m.SetIsVip(v)
  12499. return nil
  12500. case employee.FieldChatURL:
  12501. v, ok := value.(string)
  12502. if !ok {
  12503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12504. }
  12505. m.SetChatURL(v)
  12506. return nil
  12507. }
  12508. return fmt.Errorf("unknown Employee field %s", name)
  12509. }
  12510. // AddedFields returns all numeric fields that were incremented/decremented during
  12511. // this mutation.
  12512. func (m *EmployeeMutation) AddedFields() []string {
  12513. var fields []string
  12514. if m.addhire_count != nil {
  12515. fields = append(fields, employee.FieldHireCount)
  12516. }
  12517. if m.addservice_count != nil {
  12518. fields = append(fields, employee.FieldServiceCount)
  12519. }
  12520. if m.addachievement_count != nil {
  12521. fields = append(fields, employee.FieldAchievementCount)
  12522. }
  12523. if m.addorganization_id != nil {
  12524. fields = append(fields, employee.FieldOrganizationID)
  12525. }
  12526. if m.addcategory_id != nil {
  12527. fields = append(fields, employee.FieldCategoryID)
  12528. }
  12529. if m.addis_vip != nil {
  12530. fields = append(fields, employee.FieldIsVip)
  12531. }
  12532. return fields
  12533. }
  12534. // AddedField returns the numeric value that was incremented/decremented on a field
  12535. // with the given name. The second boolean return value indicates that this field
  12536. // was not set, or was not defined in the schema.
  12537. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  12538. switch name {
  12539. case employee.FieldHireCount:
  12540. return m.AddedHireCount()
  12541. case employee.FieldServiceCount:
  12542. return m.AddedServiceCount()
  12543. case employee.FieldAchievementCount:
  12544. return m.AddedAchievementCount()
  12545. case employee.FieldOrganizationID:
  12546. return m.AddedOrganizationID()
  12547. case employee.FieldCategoryID:
  12548. return m.AddedCategoryID()
  12549. case employee.FieldIsVip:
  12550. return m.AddedIsVip()
  12551. }
  12552. return nil, false
  12553. }
  12554. // AddField adds the value to the field with the given name. It returns an error if
  12555. // the field is not defined in the schema, or if the type mismatched the field
  12556. // type.
  12557. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  12558. switch name {
  12559. case employee.FieldHireCount:
  12560. v, ok := value.(int)
  12561. if !ok {
  12562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12563. }
  12564. m.AddHireCount(v)
  12565. return nil
  12566. case employee.FieldServiceCount:
  12567. v, ok := value.(int)
  12568. if !ok {
  12569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12570. }
  12571. m.AddServiceCount(v)
  12572. return nil
  12573. case employee.FieldAchievementCount:
  12574. v, ok := value.(int)
  12575. if !ok {
  12576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12577. }
  12578. m.AddAchievementCount(v)
  12579. return nil
  12580. case employee.FieldOrganizationID:
  12581. v, ok := value.(int64)
  12582. if !ok {
  12583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12584. }
  12585. m.AddOrganizationID(v)
  12586. return nil
  12587. case employee.FieldCategoryID:
  12588. v, ok := value.(int64)
  12589. if !ok {
  12590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12591. }
  12592. m.AddCategoryID(v)
  12593. return nil
  12594. case employee.FieldIsVip:
  12595. v, ok := value.(int)
  12596. if !ok {
  12597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12598. }
  12599. m.AddIsVip(v)
  12600. return nil
  12601. }
  12602. return fmt.Errorf("unknown Employee numeric field %s", name)
  12603. }
  12604. // ClearedFields returns all nullable fields that were cleared during this
  12605. // mutation.
  12606. func (m *EmployeeMutation) ClearedFields() []string {
  12607. var fields []string
  12608. if m.FieldCleared(employee.FieldDeletedAt) {
  12609. fields = append(fields, employee.FieldDeletedAt)
  12610. }
  12611. if m.FieldCleared(employee.FieldAiInfo) {
  12612. fields = append(fields, employee.FieldAiInfo)
  12613. }
  12614. return fields
  12615. }
  12616. // FieldCleared returns a boolean indicating if a field with the given name was
  12617. // cleared in this mutation.
  12618. func (m *EmployeeMutation) FieldCleared(name string) bool {
  12619. _, ok := m.clearedFields[name]
  12620. return ok
  12621. }
  12622. // ClearField clears the value of the field with the given name. It returns an
  12623. // error if the field is not defined in the schema.
  12624. func (m *EmployeeMutation) ClearField(name string) error {
  12625. switch name {
  12626. case employee.FieldDeletedAt:
  12627. m.ClearDeletedAt()
  12628. return nil
  12629. case employee.FieldAiInfo:
  12630. m.ClearAiInfo()
  12631. return nil
  12632. }
  12633. return fmt.Errorf("unknown Employee nullable field %s", name)
  12634. }
  12635. // ResetField resets all changes in the mutation for the field with the given name.
  12636. // It returns an error if the field is not defined in the schema.
  12637. func (m *EmployeeMutation) ResetField(name string) error {
  12638. switch name {
  12639. case employee.FieldCreatedAt:
  12640. m.ResetCreatedAt()
  12641. return nil
  12642. case employee.FieldUpdatedAt:
  12643. m.ResetUpdatedAt()
  12644. return nil
  12645. case employee.FieldDeletedAt:
  12646. m.ResetDeletedAt()
  12647. return nil
  12648. case employee.FieldTitle:
  12649. m.ResetTitle()
  12650. return nil
  12651. case employee.FieldAvatar:
  12652. m.ResetAvatar()
  12653. return nil
  12654. case employee.FieldTags:
  12655. m.ResetTags()
  12656. return nil
  12657. case employee.FieldHireCount:
  12658. m.ResetHireCount()
  12659. return nil
  12660. case employee.FieldServiceCount:
  12661. m.ResetServiceCount()
  12662. return nil
  12663. case employee.FieldAchievementCount:
  12664. m.ResetAchievementCount()
  12665. return nil
  12666. case employee.FieldIntro:
  12667. m.ResetIntro()
  12668. return nil
  12669. case employee.FieldEstimate:
  12670. m.ResetEstimate()
  12671. return nil
  12672. case employee.FieldSkill:
  12673. m.ResetSkill()
  12674. return nil
  12675. case employee.FieldAbilityType:
  12676. m.ResetAbilityType()
  12677. return nil
  12678. case employee.FieldScene:
  12679. m.ResetScene()
  12680. return nil
  12681. case employee.FieldSwitchIn:
  12682. m.ResetSwitchIn()
  12683. return nil
  12684. case employee.FieldVideoURL:
  12685. m.ResetVideoURL()
  12686. return nil
  12687. case employee.FieldOrganizationID:
  12688. m.ResetOrganizationID()
  12689. return nil
  12690. case employee.FieldCategoryID:
  12691. m.ResetCategoryID()
  12692. return nil
  12693. case employee.FieldAPIBase:
  12694. m.ResetAPIBase()
  12695. return nil
  12696. case employee.FieldAPIKey:
  12697. m.ResetAPIKey()
  12698. return nil
  12699. case employee.FieldAiInfo:
  12700. m.ResetAiInfo()
  12701. return nil
  12702. case employee.FieldIsVip:
  12703. m.ResetIsVip()
  12704. return nil
  12705. case employee.FieldChatURL:
  12706. m.ResetChatURL()
  12707. return nil
  12708. }
  12709. return fmt.Errorf("unknown Employee field %s", name)
  12710. }
  12711. // AddedEdges returns all edge names that were set/added in this mutation.
  12712. func (m *EmployeeMutation) AddedEdges() []string {
  12713. edges := make([]string, 0, 2)
  12714. if m.em_work_experiences != nil {
  12715. edges = append(edges, employee.EdgeEmWorkExperiences)
  12716. }
  12717. if m.em_tutorial != nil {
  12718. edges = append(edges, employee.EdgeEmTutorial)
  12719. }
  12720. return edges
  12721. }
  12722. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12723. // name in this mutation.
  12724. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  12725. switch name {
  12726. case employee.EdgeEmWorkExperiences:
  12727. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  12728. for id := range m.em_work_experiences {
  12729. ids = append(ids, id)
  12730. }
  12731. return ids
  12732. case employee.EdgeEmTutorial:
  12733. ids := make([]ent.Value, 0, len(m.em_tutorial))
  12734. for id := range m.em_tutorial {
  12735. ids = append(ids, id)
  12736. }
  12737. return ids
  12738. }
  12739. return nil
  12740. }
  12741. // RemovedEdges returns all edge names that were removed in this mutation.
  12742. func (m *EmployeeMutation) RemovedEdges() []string {
  12743. edges := make([]string, 0, 2)
  12744. if m.removedem_work_experiences != nil {
  12745. edges = append(edges, employee.EdgeEmWorkExperiences)
  12746. }
  12747. if m.removedem_tutorial != nil {
  12748. edges = append(edges, employee.EdgeEmTutorial)
  12749. }
  12750. return edges
  12751. }
  12752. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12753. // the given name in this mutation.
  12754. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  12755. switch name {
  12756. case employee.EdgeEmWorkExperiences:
  12757. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  12758. for id := range m.removedem_work_experiences {
  12759. ids = append(ids, id)
  12760. }
  12761. return ids
  12762. case employee.EdgeEmTutorial:
  12763. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  12764. for id := range m.removedem_tutorial {
  12765. ids = append(ids, id)
  12766. }
  12767. return ids
  12768. }
  12769. return nil
  12770. }
  12771. // ClearedEdges returns all edge names that were cleared in this mutation.
  12772. func (m *EmployeeMutation) ClearedEdges() []string {
  12773. edges := make([]string, 0, 2)
  12774. if m.clearedem_work_experiences {
  12775. edges = append(edges, employee.EdgeEmWorkExperiences)
  12776. }
  12777. if m.clearedem_tutorial {
  12778. edges = append(edges, employee.EdgeEmTutorial)
  12779. }
  12780. return edges
  12781. }
  12782. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12783. // was cleared in this mutation.
  12784. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  12785. switch name {
  12786. case employee.EdgeEmWorkExperiences:
  12787. return m.clearedem_work_experiences
  12788. case employee.EdgeEmTutorial:
  12789. return m.clearedem_tutorial
  12790. }
  12791. return false
  12792. }
  12793. // ClearEdge clears the value of the edge with the given name. It returns an error
  12794. // if that edge is not defined in the schema.
  12795. func (m *EmployeeMutation) ClearEdge(name string) error {
  12796. switch name {
  12797. }
  12798. return fmt.Errorf("unknown Employee unique edge %s", name)
  12799. }
  12800. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12801. // It returns an error if the edge is not defined in the schema.
  12802. func (m *EmployeeMutation) ResetEdge(name string) error {
  12803. switch name {
  12804. case employee.EdgeEmWorkExperiences:
  12805. m.ResetEmWorkExperiences()
  12806. return nil
  12807. case employee.EdgeEmTutorial:
  12808. m.ResetEmTutorial()
  12809. return nil
  12810. }
  12811. return fmt.Errorf("unknown Employee edge %s", name)
  12812. }
  12813. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  12814. type EmployeeConfigMutation struct {
  12815. config
  12816. op Op
  12817. typ string
  12818. id *uint64
  12819. created_at *time.Time
  12820. updated_at *time.Time
  12821. deleted_at *time.Time
  12822. stype *string
  12823. title *string
  12824. photo *string
  12825. organization_id *uint64
  12826. addorganization_id *int64
  12827. clearedFields map[string]struct{}
  12828. done bool
  12829. oldValue func(context.Context) (*EmployeeConfig, error)
  12830. predicates []predicate.EmployeeConfig
  12831. }
  12832. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  12833. // employeeconfigOption allows management of the mutation configuration using functional options.
  12834. type employeeconfigOption func(*EmployeeConfigMutation)
  12835. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  12836. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  12837. m := &EmployeeConfigMutation{
  12838. config: c,
  12839. op: op,
  12840. typ: TypeEmployeeConfig,
  12841. clearedFields: make(map[string]struct{}),
  12842. }
  12843. for _, opt := range opts {
  12844. opt(m)
  12845. }
  12846. return m
  12847. }
  12848. // withEmployeeConfigID sets the ID field of the mutation.
  12849. func withEmployeeConfigID(id uint64) employeeconfigOption {
  12850. return func(m *EmployeeConfigMutation) {
  12851. var (
  12852. err error
  12853. once sync.Once
  12854. value *EmployeeConfig
  12855. )
  12856. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  12857. once.Do(func() {
  12858. if m.done {
  12859. err = errors.New("querying old values post mutation is not allowed")
  12860. } else {
  12861. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  12862. }
  12863. })
  12864. return value, err
  12865. }
  12866. m.id = &id
  12867. }
  12868. }
  12869. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  12870. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  12871. return func(m *EmployeeConfigMutation) {
  12872. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  12873. return node, nil
  12874. }
  12875. m.id = &node.ID
  12876. }
  12877. }
  12878. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12879. // executed in a transaction (ent.Tx), a transactional client is returned.
  12880. func (m EmployeeConfigMutation) Client() *Client {
  12881. client := &Client{config: m.config}
  12882. client.init()
  12883. return client
  12884. }
  12885. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12886. // it returns an error otherwise.
  12887. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  12888. if _, ok := m.driver.(*txDriver); !ok {
  12889. return nil, errors.New("ent: mutation is not running in a transaction")
  12890. }
  12891. tx := &Tx{config: m.config}
  12892. tx.init()
  12893. return tx, nil
  12894. }
  12895. // SetID sets the value of the id field. Note that this
  12896. // operation is only accepted on creation of EmployeeConfig entities.
  12897. func (m *EmployeeConfigMutation) SetID(id uint64) {
  12898. m.id = &id
  12899. }
  12900. // ID returns the ID value in the mutation. Note that the ID is only available
  12901. // if it was provided to the builder or after it was returned from the database.
  12902. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  12903. if m.id == nil {
  12904. return
  12905. }
  12906. return *m.id, true
  12907. }
  12908. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12909. // That means, if the mutation is applied within a transaction with an isolation level such
  12910. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12911. // or updated by the mutation.
  12912. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  12913. switch {
  12914. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12915. id, exists := m.ID()
  12916. if exists {
  12917. return []uint64{id}, nil
  12918. }
  12919. fallthrough
  12920. case m.op.Is(OpUpdate | OpDelete):
  12921. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  12922. default:
  12923. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12924. }
  12925. }
  12926. // SetCreatedAt sets the "created_at" field.
  12927. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  12928. m.created_at = &t
  12929. }
  12930. // CreatedAt returns the value of the "created_at" field in the mutation.
  12931. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  12932. v := m.created_at
  12933. if v == nil {
  12934. return
  12935. }
  12936. return *v, true
  12937. }
  12938. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  12939. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  12940. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12941. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12942. if !m.op.Is(OpUpdateOne) {
  12943. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12944. }
  12945. if m.id == nil || m.oldValue == nil {
  12946. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12947. }
  12948. oldValue, err := m.oldValue(ctx)
  12949. if err != nil {
  12950. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12951. }
  12952. return oldValue.CreatedAt, nil
  12953. }
  12954. // ResetCreatedAt resets all changes to the "created_at" field.
  12955. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  12956. m.created_at = nil
  12957. }
  12958. // SetUpdatedAt sets the "updated_at" field.
  12959. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  12960. m.updated_at = &t
  12961. }
  12962. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12963. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  12964. v := m.updated_at
  12965. if v == nil {
  12966. return
  12967. }
  12968. return *v, true
  12969. }
  12970. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  12971. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  12972. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12973. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12974. if !m.op.Is(OpUpdateOne) {
  12975. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12976. }
  12977. if m.id == nil || m.oldValue == nil {
  12978. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12979. }
  12980. oldValue, err := m.oldValue(ctx)
  12981. if err != nil {
  12982. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12983. }
  12984. return oldValue.UpdatedAt, nil
  12985. }
  12986. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12987. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  12988. m.updated_at = nil
  12989. }
  12990. // SetDeletedAt sets the "deleted_at" field.
  12991. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  12992. m.deleted_at = &t
  12993. }
  12994. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12995. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  12996. v := m.deleted_at
  12997. if v == nil {
  12998. return
  12999. }
  13000. return *v, true
  13001. }
  13002. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  13003. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13004. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13005. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13006. if !m.op.Is(OpUpdateOne) {
  13007. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13008. }
  13009. if m.id == nil || m.oldValue == nil {
  13010. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13011. }
  13012. oldValue, err := m.oldValue(ctx)
  13013. if err != nil {
  13014. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13015. }
  13016. return oldValue.DeletedAt, nil
  13017. }
  13018. // ClearDeletedAt clears the value of the "deleted_at" field.
  13019. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  13020. m.deleted_at = nil
  13021. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  13022. }
  13023. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13024. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  13025. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  13026. return ok
  13027. }
  13028. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13029. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  13030. m.deleted_at = nil
  13031. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  13032. }
  13033. // SetStype sets the "stype" field.
  13034. func (m *EmployeeConfigMutation) SetStype(s string) {
  13035. m.stype = &s
  13036. }
  13037. // Stype returns the value of the "stype" field in the mutation.
  13038. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  13039. v := m.stype
  13040. if v == nil {
  13041. return
  13042. }
  13043. return *v, true
  13044. }
  13045. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  13046. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13048. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  13049. if !m.op.Is(OpUpdateOne) {
  13050. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  13051. }
  13052. if m.id == nil || m.oldValue == nil {
  13053. return v, errors.New("OldStype requires an ID field in the mutation")
  13054. }
  13055. oldValue, err := m.oldValue(ctx)
  13056. if err != nil {
  13057. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  13058. }
  13059. return oldValue.Stype, nil
  13060. }
  13061. // ResetStype resets all changes to the "stype" field.
  13062. func (m *EmployeeConfigMutation) ResetStype() {
  13063. m.stype = nil
  13064. }
  13065. // SetTitle sets the "title" field.
  13066. func (m *EmployeeConfigMutation) SetTitle(s string) {
  13067. m.title = &s
  13068. }
  13069. // Title returns the value of the "title" field in the mutation.
  13070. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  13071. v := m.title
  13072. if v == nil {
  13073. return
  13074. }
  13075. return *v, true
  13076. }
  13077. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  13078. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13080. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  13081. if !m.op.Is(OpUpdateOne) {
  13082. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  13083. }
  13084. if m.id == nil || m.oldValue == nil {
  13085. return v, errors.New("OldTitle requires an ID field in the mutation")
  13086. }
  13087. oldValue, err := m.oldValue(ctx)
  13088. if err != nil {
  13089. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  13090. }
  13091. return oldValue.Title, nil
  13092. }
  13093. // ResetTitle resets all changes to the "title" field.
  13094. func (m *EmployeeConfigMutation) ResetTitle() {
  13095. m.title = nil
  13096. }
  13097. // SetPhoto sets the "photo" field.
  13098. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  13099. m.photo = &s
  13100. }
  13101. // Photo returns the value of the "photo" field in the mutation.
  13102. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  13103. v := m.photo
  13104. if v == nil {
  13105. return
  13106. }
  13107. return *v, true
  13108. }
  13109. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  13110. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13111. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13112. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  13113. if !m.op.Is(OpUpdateOne) {
  13114. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  13115. }
  13116. if m.id == nil || m.oldValue == nil {
  13117. return v, errors.New("OldPhoto requires an ID field in the mutation")
  13118. }
  13119. oldValue, err := m.oldValue(ctx)
  13120. if err != nil {
  13121. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  13122. }
  13123. return oldValue.Photo, nil
  13124. }
  13125. // ResetPhoto resets all changes to the "photo" field.
  13126. func (m *EmployeeConfigMutation) ResetPhoto() {
  13127. m.photo = nil
  13128. }
  13129. // SetOrganizationID sets the "organization_id" field.
  13130. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  13131. m.organization_id = &u
  13132. m.addorganization_id = nil
  13133. }
  13134. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13135. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  13136. v := m.organization_id
  13137. if v == nil {
  13138. return
  13139. }
  13140. return *v, true
  13141. }
  13142. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  13143. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13145. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13146. if !m.op.Is(OpUpdateOne) {
  13147. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13148. }
  13149. if m.id == nil || m.oldValue == nil {
  13150. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13151. }
  13152. oldValue, err := m.oldValue(ctx)
  13153. if err != nil {
  13154. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13155. }
  13156. return oldValue.OrganizationID, nil
  13157. }
  13158. // AddOrganizationID adds u to the "organization_id" field.
  13159. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  13160. if m.addorganization_id != nil {
  13161. *m.addorganization_id += u
  13162. } else {
  13163. m.addorganization_id = &u
  13164. }
  13165. }
  13166. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13167. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  13168. v := m.addorganization_id
  13169. if v == nil {
  13170. return
  13171. }
  13172. return *v, true
  13173. }
  13174. // ClearOrganizationID clears the value of the "organization_id" field.
  13175. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  13176. m.organization_id = nil
  13177. m.addorganization_id = nil
  13178. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  13179. }
  13180. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13181. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  13182. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  13183. return ok
  13184. }
  13185. // ResetOrganizationID resets all changes to the "organization_id" field.
  13186. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  13187. m.organization_id = nil
  13188. m.addorganization_id = nil
  13189. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  13190. }
  13191. // Where appends a list predicates to the EmployeeConfigMutation builder.
  13192. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  13193. m.predicates = append(m.predicates, ps...)
  13194. }
  13195. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  13196. // users can use type-assertion to append predicates that do not depend on any generated package.
  13197. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  13198. p := make([]predicate.EmployeeConfig, len(ps))
  13199. for i := range ps {
  13200. p[i] = ps[i]
  13201. }
  13202. m.Where(p...)
  13203. }
  13204. // Op returns the operation name.
  13205. func (m *EmployeeConfigMutation) Op() Op {
  13206. return m.op
  13207. }
  13208. // SetOp allows setting the mutation operation.
  13209. func (m *EmployeeConfigMutation) SetOp(op Op) {
  13210. m.op = op
  13211. }
  13212. // Type returns the node type of this mutation (EmployeeConfig).
  13213. func (m *EmployeeConfigMutation) Type() string {
  13214. return m.typ
  13215. }
  13216. // Fields returns all fields that were changed during this mutation. Note that in
  13217. // order to get all numeric fields that were incremented/decremented, call
  13218. // AddedFields().
  13219. func (m *EmployeeConfigMutation) Fields() []string {
  13220. fields := make([]string, 0, 7)
  13221. if m.created_at != nil {
  13222. fields = append(fields, employeeconfig.FieldCreatedAt)
  13223. }
  13224. if m.updated_at != nil {
  13225. fields = append(fields, employeeconfig.FieldUpdatedAt)
  13226. }
  13227. if m.deleted_at != nil {
  13228. fields = append(fields, employeeconfig.FieldDeletedAt)
  13229. }
  13230. if m.stype != nil {
  13231. fields = append(fields, employeeconfig.FieldStype)
  13232. }
  13233. if m.title != nil {
  13234. fields = append(fields, employeeconfig.FieldTitle)
  13235. }
  13236. if m.photo != nil {
  13237. fields = append(fields, employeeconfig.FieldPhoto)
  13238. }
  13239. if m.organization_id != nil {
  13240. fields = append(fields, employeeconfig.FieldOrganizationID)
  13241. }
  13242. return fields
  13243. }
  13244. // Field returns the value of a field with the given name. The second boolean
  13245. // return value indicates that this field was not set, or was not defined in the
  13246. // schema.
  13247. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  13248. switch name {
  13249. case employeeconfig.FieldCreatedAt:
  13250. return m.CreatedAt()
  13251. case employeeconfig.FieldUpdatedAt:
  13252. return m.UpdatedAt()
  13253. case employeeconfig.FieldDeletedAt:
  13254. return m.DeletedAt()
  13255. case employeeconfig.FieldStype:
  13256. return m.Stype()
  13257. case employeeconfig.FieldTitle:
  13258. return m.Title()
  13259. case employeeconfig.FieldPhoto:
  13260. return m.Photo()
  13261. case employeeconfig.FieldOrganizationID:
  13262. return m.OrganizationID()
  13263. }
  13264. return nil, false
  13265. }
  13266. // OldField returns the old value of the field from the database. An error is
  13267. // returned if the mutation operation is not UpdateOne, or the query to the
  13268. // database failed.
  13269. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13270. switch name {
  13271. case employeeconfig.FieldCreatedAt:
  13272. return m.OldCreatedAt(ctx)
  13273. case employeeconfig.FieldUpdatedAt:
  13274. return m.OldUpdatedAt(ctx)
  13275. case employeeconfig.FieldDeletedAt:
  13276. return m.OldDeletedAt(ctx)
  13277. case employeeconfig.FieldStype:
  13278. return m.OldStype(ctx)
  13279. case employeeconfig.FieldTitle:
  13280. return m.OldTitle(ctx)
  13281. case employeeconfig.FieldPhoto:
  13282. return m.OldPhoto(ctx)
  13283. case employeeconfig.FieldOrganizationID:
  13284. return m.OldOrganizationID(ctx)
  13285. }
  13286. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  13287. }
  13288. // SetField sets the value of a field with the given name. It returns an error if
  13289. // the field is not defined in the schema, or if the type mismatched the field
  13290. // type.
  13291. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  13292. switch name {
  13293. case employeeconfig.FieldCreatedAt:
  13294. v, ok := value.(time.Time)
  13295. if !ok {
  13296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13297. }
  13298. m.SetCreatedAt(v)
  13299. return nil
  13300. case employeeconfig.FieldUpdatedAt:
  13301. v, ok := value.(time.Time)
  13302. if !ok {
  13303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13304. }
  13305. m.SetUpdatedAt(v)
  13306. return nil
  13307. case employeeconfig.FieldDeletedAt:
  13308. v, ok := value.(time.Time)
  13309. if !ok {
  13310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13311. }
  13312. m.SetDeletedAt(v)
  13313. return nil
  13314. case employeeconfig.FieldStype:
  13315. v, ok := value.(string)
  13316. if !ok {
  13317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13318. }
  13319. m.SetStype(v)
  13320. return nil
  13321. case employeeconfig.FieldTitle:
  13322. v, ok := value.(string)
  13323. if !ok {
  13324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13325. }
  13326. m.SetTitle(v)
  13327. return nil
  13328. case employeeconfig.FieldPhoto:
  13329. v, ok := value.(string)
  13330. if !ok {
  13331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13332. }
  13333. m.SetPhoto(v)
  13334. return nil
  13335. case employeeconfig.FieldOrganizationID:
  13336. v, ok := value.(uint64)
  13337. if !ok {
  13338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13339. }
  13340. m.SetOrganizationID(v)
  13341. return nil
  13342. }
  13343. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  13344. }
  13345. // AddedFields returns all numeric fields that were incremented/decremented during
  13346. // this mutation.
  13347. func (m *EmployeeConfigMutation) AddedFields() []string {
  13348. var fields []string
  13349. if m.addorganization_id != nil {
  13350. fields = append(fields, employeeconfig.FieldOrganizationID)
  13351. }
  13352. return fields
  13353. }
  13354. // AddedField returns the numeric value that was incremented/decremented on a field
  13355. // with the given name. The second boolean return value indicates that this field
  13356. // was not set, or was not defined in the schema.
  13357. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  13358. switch name {
  13359. case employeeconfig.FieldOrganizationID:
  13360. return m.AddedOrganizationID()
  13361. }
  13362. return nil, false
  13363. }
  13364. // AddField adds the value to the field with the given name. It returns an error if
  13365. // the field is not defined in the schema, or if the type mismatched the field
  13366. // type.
  13367. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  13368. switch name {
  13369. case employeeconfig.FieldOrganizationID:
  13370. v, ok := value.(int64)
  13371. if !ok {
  13372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13373. }
  13374. m.AddOrganizationID(v)
  13375. return nil
  13376. }
  13377. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  13378. }
  13379. // ClearedFields returns all nullable fields that were cleared during this
  13380. // mutation.
  13381. func (m *EmployeeConfigMutation) ClearedFields() []string {
  13382. var fields []string
  13383. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  13384. fields = append(fields, employeeconfig.FieldDeletedAt)
  13385. }
  13386. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  13387. fields = append(fields, employeeconfig.FieldOrganizationID)
  13388. }
  13389. return fields
  13390. }
  13391. // FieldCleared returns a boolean indicating if a field with the given name was
  13392. // cleared in this mutation.
  13393. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  13394. _, ok := m.clearedFields[name]
  13395. return ok
  13396. }
  13397. // ClearField clears the value of the field with the given name. It returns an
  13398. // error if the field is not defined in the schema.
  13399. func (m *EmployeeConfigMutation) ClearField(name string) error {
  13400. switch name {
  13401. case employeeconfig.FieldDeletedAt:
  13402. m.ClearDeletedAt()
  13403. return nil
  13404. case employeeconfig.FieldOrganizationID:
  13405. m.ClearOrganizationID()
  13406. return nil
  13407. }
  13408. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  13409. }
  13410. // ResetField resets all changes in the mutation for the field with the given name.
  13411. // It returns an error if the field is not defined in the schema.
  13412. func (m *EmployeeConfigMutation) ResetField(name string) error {
  13413. switch name {
  13414. case employeeconfig.FieldCreatedAt:
  13415. m.ResetCreatedAt()
  13416. return nil
  13417. case employeeconfig.FieldUpdatedAt:
  13418. m.ResetUpdatedAt()
  13419. return nil
  13420. case employeeconfig.FieldDeletedAt:
  13421. m.ResetDeletedAt()
  13422. return nil
  13423. case employeeconfig.FieldStype:
  13424. m.ResetStype()
  13425. return nil
  13426. case employeeconfig.FieldTitle:
  13427. m.ResetTitle()
  13428. return nil
  13429. case employeeconfig.FieldPhoto:
  13430. m.ResetPhoto()
  13431. return nil
  13432. case employeeconfig.FieldOrganizationID:
  13433. m.ResetOrganizationID()
  13434. return nil
  13435. }
  13436. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  13437. }
  13438. // AddedEdges returns all edge names that were set/added in this mutation.
  13439. func (m *EmployeeConfigMutation) AddedEdges() []string {
  13440. edges := make([]string, 0, 0)
  13441. return edges
  13442. }
  13443. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13444. // name in this mutation.
  13445. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  13446. return nil
  13447. }
  13448. // RemovedEdges returns all edge names that were removed in this mutation.
  13449. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  13450. edges := make([]string, 0, 0)
  13451. return edges
  13452. }
  13453. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13454. // the given name in this mutation.
  13455. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  13456. return nil
  13457. }
  13458. // ClearedEdges returns all edge names that were cleared in this mutation.
  13459. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  13460. edges := make([]string, 0, 0)
  13461. return edges
  13462. }
  13463. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13464. // was cleared in this mutation.
  13465. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  13466. return false
  13467. }
  13468. // ClearEdge clears the value of the edge with the given name. It returns an error
  13469. // if that edge is not defined in the schema.
  13470. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  13471. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  13472. }
  13473. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13474. // It returns an error if the edge is not defined in the schema.
  13475. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  13476. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  13477. }
  13478. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  13479. type LabelMutation struct {
  13480. config
  13481. op Op
  13482. typ string
  13483. id *uint64
  13484. created_at *time.Time
  13485. updated_at *time.Time
  13486. status *uint8
  13487. addstatus *int8
  13488. _type *int
  13489. add_type *int
  13490. name *string
  13491. from *int
  13492. addfrom *int
  13493. mode *int
  13494. addmode *int
  13495. conditions *string
  13496. organization_id *uint64
  13497. addorganization_id *int64
  13498. clearedFields map[string]struct{}
  13499. label_relationships map[uint64]struct{}
  13500. removedlabel_relationships map[uint64]struct{}
  13501. clearedlabel_relationships bool
  13502. done bool
  13503. oldValue func(context.Context) (*Label, error)
  13504. predicates []predicate.Label
  13505. }
  13506. var _ ent.Mutation = (*LabelMutation)(nil)
  13507. // labelOption allows management of the mutation configuration using functional options.
  13508. type labelOption func(*LabelMutation)
  13509. // newLabelMutation creates new mutation for the Label entity.
  13510. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  13511. m := &LabelMutation{
  13512. config: c,
  13513. op: op,
  13514. typ: TypeLabel,
  13515. clearedFields: make(map[string]struct{}),
  13516. }
  13517. for _, opt := range opts {
  13518. opt(m)
  13519. }
  13520. return m
  13521. }
  13522. // withLabelID sets the ID field of the mutation.
  13523. func withLabelID(id uint64) labelOption {
  13524. return func(m *LabelMutation) {
  13525. var (
  13526. err error
  13527. once sync.Once
  13528. value *Label
  13529. )
  13530. m.oldValue = func(ctx context.Context) (*Label, error) {
  13531. once.Do(func() {
  13532. if m.done {
  13533. err = errors.New("querying old values post mutation is not allowed")
  13534. } else {
  13535. value, err = m.Client().Label.Get(ctx, id)
  13536. }
  13537. })
  13538. return value, err
  13539. }
  13540. m.id = &id
  13541. }
  13542. }
  13543. // withLabel sets the old Label of the mutation.
  13544. func withLabel(node *Label) labelOption {
  13545. return func(m *LabelMutation) {
  13546. m.oldValue = func(context.Context) (*Label, error) {
  13547. return node, nil
  13548. }
  13549. m.id = &node.ID
  13550. }
  13551. }
  13552. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13553. // executed in a transaction (ent.Tx), a transactional client is returned.
  13554. func (m LabelMutation) Client() *Client {
  13555. client := &Client{config: m.config}
  13556. client.init()
  13557. return client
  13558. }
  13559. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13560. // it returns an error otherwise.
  13561. func (m LabelMutation) Tx() (*Tx, error) {
  13562. if _, ok := m.driver.(*txDriver); !ok {
  13563. return nil, errors.New("ent: mutation is not running in a transaction")
  13564. }
  13565. tx := &Tx{config: m.config}
  13566. tx.init()
  13567. return tx, nil
  13568. }
  13569. // SetID sets the value of the id field. Note that this
  13570. // operation is only accepted on creation of Label entities.
  13571. func (m *LabelMutation) SetID(id uint64) {
  13572. m.id = &id
  13573. }
  13574. // ID returns the ID value in the mutation. Note that the ID is only available
  13575. // if it was provided to the builder or after it was returned from the database.
  13576. func (m *LabelMutation) ID() (id uint64, exists bool) {
  13577. if m.id == nil {
  13578. return
  13579. }
  13580. return *m.id, true
  13581. }
  13582. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13583. // That means, if the mutation is applied within a transaction with an isolation level such
  13584. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13585. // or updated by the mutation.
  13586. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  13587. switch {
  13588. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13589. id, exists := m.ID()
  13590. if exists {
  13591. return []uint64{id}, nil
  13592. }
  13593. fallthrough
  13594. case m.op.Is(OpUpdate | OpDelete):
  13595. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  13596. default:
  13597. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13598. }
  13599. }
  13600. // SetCreatedAt sets the "created_at" field.
  13601. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  13602. m.created_at = &t
  13603. }
  13604. // CreatedAt returns the value of the "created_at" field in the mutation.
  13605. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  13606. v := m.created_at
  13607. if v == nil {
  13608. return
  13609. }
  13610. return *v, true
  13611. }
  13612. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  13613. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13615. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13616. if !m.op.Is(OpUpdateOne) {
  13617. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13618. }
  13619. if m.id == nil || m.oldValue == nil {
  13620. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13621. }
  13622. oldValue, err := m.oldValue(ctx)
  13623. if err != nil {
  13624. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13625. }
  13626. return oldValue.CreatedAt, nil
  13627. }
  13628. // ResetCreatedAt resets all changes to the "created_at" field.
  13629. func (m *LabelMutation) ResetCreatedAt() {
  13630. m.created_at = nil
  13631. }
  13632. // SetUpdatedAt sets the "updated_at" field.
  13633. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  13634. m.updated_at = &t
  13635. }
  13636. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13637. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  13638. v := m.updated_at
  13639. if v == nil {
  13640. return
  13641. }
  13642. return *v, true
  13643. }
  13644. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  13645. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13647. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13648. if !m.op.Is(OpUpdateOne) {
  13649. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13650. }
  13651. if m.id == nil || m.oldValue == nil {
  13652. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13653. }
  13654. oldValue, err := m.oldValue(ctx)
  13655. if err != nil {
  13656. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13657. }
  13658. return oldValue.UpdatedAt, nil
  13659. }
  13660. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13661. func (m *LabelMutation) ResetUpdatedAt() {
  13662. m.updated_at = nil
  13663. }
  13664. // SetStatus sets the "status" field.
  13665. func (m *LabelMutation) SetStatus(u uint8) {
  13666. m.status = &u
  13667. m.addstatus = nil
  13668. }
  13669. // Status returns the value of the "status" field in the mutation.
  13670. func (m *LabelMutation) Status() (r uint8, exists bool) {
  13671. v := m.status
  13672. if v == nil {
  13673. return
  13674. }
  13675. return *v, true
  13676. }
  13677. // OldStatus returns the old "status" field's value of the Label entity.
  13678. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13680. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13681. if !m.op.Is(OpUpdateOne) {
  13682. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13683. }
  13684. if m.id == nil || m.oldValue == nil {
  13685. return v, errors.New("OldStatus requires an ID field in the mutation")
  13686. }
  13687. oldValue, err := m.oldValue(ctx)
  13688. if err != nil {
  13689. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13690. }
  13691. return oldValue.Status, nil
  13692. }
  13693. // AddStatus adds u to the "status" field.
  13694. func (m *LabelMutation) AddStatus(u int8) {
  13695. if m.addstatus != nil {
  13696. *m.addstatus += u
  13697. } else {
  13698. m.addstatus = &u
  13699. }
  13700. }
  13701. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13702. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  13703. v := m.addstatus
  13704. if v == nil {
  13705. return
  13706. }
  13707. return *v, true
  13708. }
  13709. // ClearStatus clears the value of the "status" field.
  13710. func (m *LabelMutation) ClearStatus() {
  13711. m.status = nil
  13712. m.addstatus = nil
  13713. m.clearedFields[label.FieldStatus] = struct{}{}
  13714. }
  13715. // StatusCleared returns if the "status" field was cleared in this mutation.
  13716. func (m *LabelMutation) StatusCleared() bool {
  13717. _, ok := m.clearedFields[label.FieldStatus]
  13718. return ok
  13719. }
  13720. // ResetStatus resets all changes to the "status" field.
  13721. func (m *LabelMutation) ResetStatus() {
  13722. m.status = nil
  13723. m.addstatus = nil
  13724. delete(m.clearedFields, label.FieldStatus)
  13725. }
  13726. // SetType sets the "type" field.
  13727. func (m *LabelMutation) SetType(i int) {
  13728. m._type = &i
  13729. m.add_type = nil
  13730. }
  13731. // GetType returns the value of the "type" field in the mutation.
  13732. func (m *LabelMutation) GetType() (r int, exists bool) {
  13733. v := m._type
  13734. if v == nil {
  13735. return
  13736. }
  13737. return *v, true
  13738. }
  13739. // OldType returns the old "type" field's value of the Label entity.
  13740. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13742. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  13743. if !m.op.Is(OpUpdateOne) {
  13744. return v, errors.New("OldType is only allowed on UpdateOne operations")
  13745. }
  13746. if m.id == nil || m.oldValue == nil {
  13747. return v, errors.New("OldType requires an ID field in the mutation")
  13748. }
  13749. oldValue, err := m.oldValue(ctx)
  13750. if err != nil {
  13751. return v, fmt.Errorf("querying old value for OldType: %w", err)
  13752. }
  13753. return oldValue.Type, nil
  13754. }
  13755. // AddType adds i to the "type" field.
  13756. func (m *LabelMutation) AddType(i int) {
  13757. if m.add_type != nil {
  13758. *m.add_type += i
  13759. } else {
  13760. m.add_type = &i
  13761. }
  13762. }
  13763. // AddedType returns the value that was added to the "type" field in this mutation.
  13764. func (m *LabelMutation) AddedType() (r int, exists bool) {
  13765. v := m.add_type
  13766. if v == nil {
  13767. return
  13768. }
  13769. return *v, true
  13770. }
  13771. // ResetType resets all changes to the "type" field.
  13772. func (m *LabelMutation) ResetType() {
  13773. m._type = nil
  13774. m.add_type = nil
  13775. }
  13776. // SetName sets the "name" field.
  13777. func (m *LabelMutation) SetName(s string) {
  13778. m.name = &s
  13779. }
  13780. // Name returns the value of the "name" field in the mutation.
  13781. func (m *LabelMutation) Name() (r string, exists bool) {
  13782. v := m.name
  13783. if v == nil {
  13784. return
  13785. }
  13786. return *v, true
  13787. }
  13788. // OldName returns the old "name" field's value of the Label entity.
  13789. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13790. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13791. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  13792. if !m.op.Is(OpUpdateOne) {
  13793. return v, errors.New("OldName is only allowed on UpdateOne operations")
  13794. }
  13795. if m.id == nil || m.oldValue == nil {
  13796. return v, errors.New("OldName requires an ID field in the mutation")
  13797. }
  13798. oldValue, err := m.oldValue(ctx)
  13799. if err != nil {
  13800. return v, fmt.Errorf("querying old value for OldName: %w", err)
  13801. }
  13802. return oldValue.Name, nil
  13803. }
  13804. // ResetName resets all changes to the "name" field.
  13805. func (m *LabelMutation) ResetName() {
  13806. m.name = nil
  13807. }
  13808. // SetFrom sets the "from" field.
  13809. func (m *LabelMutation) SetFrom(i int) {
  13810. m.from = &i
  13811. m.addfrom = nil
  13812. }
  13813. // From returns the value of the "from" field in the mutation.
  13814. func (m *LabelMutation) From() (r int, exists bool) {
  13815. v := m.from
  13816. if v == nil {
  13817. return
  13818. }
  13819. return *v, true
  13820. }
  13821. // OldFrom returns the old "from" field's value of the Label entity.
  13822. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13823. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13824. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  13825. if !m.op.Is(OpUpdateOne) {
  13826. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  13827. }
  13828. if m.id == nil || m.oldValue == nil {
  13829. return v, errors.New("OldFrom requires an ID field in the mutation")
  13830. }
  13831. oldValue, err := m.oldValue(ctx)
  13832. if err != nil {
  13833. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  13834. }
  13835. return oldValue.From, nil
  13836. }
  13837. // AddFrom adds i to the "from" field.
  13838. func (m *LabelMutation) AddFrom(i int) {
  13839. if m.addfrom != nil {
  13840. *m.addfrom += i
  13841. } else {
  13842. m.addfrom = &i
  13843. }
  13844. }
  13845. // AddedFrom returns the value that was added to the "from" field in this mutation.
  13846. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  13847. v := m.addfrom
  13848. if v == nil {
  13849. return
  13850. }
  13851. return *v, true
  13852. }
  13853. // ResetFrom resets all changes to the "from" field.
  13854. func (m *LabelMutation) ResetFrom() {
  13855. m.from = nil
  13856. m.addfrom = nil
  13857. }
  13858. // SetMode sets the "mode" field.
  13859. func (m *LabelMutation) SetMode(i int) {
  13860. m.mode = &i
  13861. m.addmode = nil
  13862. }
  13863. // Mode returns the value of the "mode" field in the mutation.
  13864. func (m *LabelMutation) Mode() (r int, exists bool) {
  13865. v := m.mode
  13866. if v == nil {
  13867. return
  13868. }
  13869. return *v, true
  13870. }
  13871. // OldMode returns the old "mode" field's value of the Label entity.
  13872. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13874. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  13875. if !m.op.Is(OpUpdateOne) {
  13876. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  13877. }
  13878. if m.id == nil || m.oldValue == nil {
  13879. return v, errors.New("OldMode requires an ID field in the mutation")
  13880. }
  13881. oldValue, err := m.oldValue(ctx)
  13882. if err != nil {
  13883. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  13884. }
  13885. return oldValue.Mode, nil
  13886. }
  13887. // AddMode adds i to the "mode" field.
  13888. func (m *LabelMutation) AddMode(i int) {
  13889. if m.addmode != nil {
  13890. *m.addmode += i
  13891. } else {
  13892. m.addmode = &i
  13893. }
  13894. }
  13895. // AddedMode returns the value that was added to the "mode" field in this mutation.
  13896. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  13897. v := m.addmode
  13898. if v == nil {
  13899. return
  13900. }
  13901. return *v, true
  13902. }
  13903. // ResetMode resets all changes to the "mode" field.
  13904. func (m *LabelMutation) ResetMode() {
  13905. m.mode = nil
  13906. m.addmode = nil
  13907. }
  13908. // SetConditions sets the "conditions" field.
  13909. func (m *LabelMutation) SetConditions(s string) {
  13910. m.conditions = &s
  13911. }
  13912. // Conditions returns the value of the "conditions" field in the mutation.
  13913. func (m *LabelMutation) Conditions() (r string, exists bool) {
  13914. v := m.conditions
  13915. if v == nil {
  13916. return
  13917. }
  13918. return *v, true
  13919. }
  13920. // OldConditions returns the old "conditions" field's value of the Label entity.
  13921. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13923. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  13924. if !m.op.Is(OpUpdateOne) {
  13925. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  13926. }
  13927. if m.id == nil || m.oldValue == nil {
  13928. return v, errors.New("OldConditions requires an ID field in the mutation")
  13929. }
  13930. oldValue, err := m.oldValue(ctx)
  13931. if err != nil {
  13932. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  13933. }
  13934. return oldValue.Conditions, nil
  13935. }
  13936. // ClearConditions clears the value of the "conditions" field.
  13937. func (m *LabelMutation) ClearConditions() {
  13938. m.conditions = nil
  13939. m.clearedFields[label.FieldConditions] = struct{}{}
  13940. }
  13941. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  13942. func (m *LabelMutation) ConditionsCleared() bool {
  13943. _, ok := m.clearedFields[label.FieldConditions]
  13944. return ok
  13945. }
  13946. // ResetConditions resets all changes to the "conditions" field.
  13947. func (m *LabelMutation) ResetConditions() {
  13948. m.conditions = nil
  13949. delete(m.clearedFields, label.FieldConditions)
  13950. }
  13951. // SetOrganizationID sets the "organization_id" field.
  13952. func (m *LabelMutation) SetOrganizationID(u uint64) {
  13953. m.organization_id = &u
  13954. m.addorganization_id = nil
  13955. }
  13956. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13957. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  13958. v := m.organization_id
  13959. if v == nil {
  13960. return
  13961. }
  13962. return *v, true
  13963. }
  13964. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  13965. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13967. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13968. if !m.op.Is(OpUpdateOne) {
  13969. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13970. }
  13971. if m.id == nil || m.oldValue == nil {
  13972. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13973. }
  13974. oldValue, err := m.oldValue(ctx)
  13975. if err != nil {
  13976. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13977. }
  13978. return oldValue.OrganizationID, nil
  13979. }
  13980. // AddOrganizationID adds u to the "organization_id" field.
  13981. func (m *LabelMutation) AddOrganizationID(u int64) {
  13982. if m.addorganization_id != nil {
  13983. *m.addorganization_id += u
  13984. } else {
  13985. m.addorganization_id = &u
  13986. }
  13987. }
  13988. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13989. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  13990. v := m.addorganization_id
  13991. if v == nil {
  13992. return
  13993. }
  13994. return *v, true
  13995. }
  13996. // ClearOrganizationID clears the value of the "organization_id" field.
  13997. func (m *LabelMutation) ClearOrganizationID() {
  13998. m.organization_id = nil
  13999. m.addorganization_id = nil
  14000. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  14001. }
  14002. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14003. func (m *LabelMutation) OrganizationIDCleared() bool {
  14004. _, ok := m.clearedFields[label.FieldOrganizationID]
  14005. return ok
  14006. }
  14007. // ResetOrganizationID resets all changes to the "organization_id" field.
  14008. func (m *LabelMutation) ResetOrganizationID() {
  14009. m.organization_id = nil
  14010. m.addorganization_id = nil
  14011. delete(m.clearedFields, label.FieldOrganizationID)
  14012. }
  14013. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  14014. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  14015. if m.label_relationships == nil {
  14016. m.label_relationships = make(map[uint64]struct{})
  14017. }
  14018. for i := range ids {
  14019. m.label_relationships[ids[i]] = struct{}{}
  14020. }
  14021. }
  14022. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  14023. func (m *LabelMutation) ClearLabelRelationships() {
  14024. m.clearedlabel_relationships = true
  14025. }
  14026. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  14027. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  14028. return m.clearedlabel_relationships
  14029. }
  14030. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  14031. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  14032. if m.removedlabel_relationships == nil {
  14033. m.removedlabel_relationships = make(map[uint64]struct{})
  14034. }
  14035. for i := range ids {
  14036. delete(m.label_relationships, ids[i])
  14037. m.removedlabel_relationships[ids[i]] = struct{}{}
  14038. }
  14039. }
  14040. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  14041. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  14042. for id := range m.removedlabel_relationships {
  14043. ids = append(ids, id)
  14044. }
  14045. return
  14046. }
  14047. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  14048. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  14049. for id := range m.label_relationships {
  14050. ids = append(ids, id)
  14051. }
  14052. return
  14053. }
  14054. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  14055. func (m *LabelMutation) ResetLabelRelationships() {
  14056. m.label_relationships = nil
  14057. m.clearedlabel_relationships = false
  14058. m.removedlabel_relationships = nil
  14059. }
  14060. // Where appends a list predicates to the LabelMutation builder.
  14061. func (m *LabelMutation) Where(ps ...predicate.Label) {
  14062. m.predicates = append(m.predicates, ps...)
  14063. }
  14064. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  14065. // users can use type-assertion to append predicates that do not depend on any generated package.
  14066. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  14067. p := make([]predicate.Label, len(ps))
  14068. for i := range ps {
  14069. p[i] = ps[i]
  14070. }
  14071. m.Where(p...)
  14072. }
  14073. // Op returns the operation name.
  14074. func (m *LabelMutation) Op() Op {
  14075. return m.op
  14076. }
  14077. // SetOp allows setting the mutation operation.
  14078. func (m *LabelMutation) SetOp(op Op) {
  14079. m.op = op
  14080. }
  14081. // Type returns the node type of this mutation (Label).
  14082. func (m *LabelMutation) Type() string {
  14083. return m.typ
  14084. }
  14085. // Fields returns all fields that were changed during this mutation. Note that in
  14086. // order to get all numeric fields that were incremented/decremented, call
  14087. // AddedFields().
  14088. func (m *LabelMutation) Fields() []string {
  14089. fields := make([]string, 0, 9)
  14090. if m.created_at != nil {
  14091. fields = append(fields, label.FieldCreatedAt)
  14092. }
  14093. if m.updated_at != nil {
  14094. fields = append(fields, label.FieldUpdatedAt)
  14095. }
  14096. if m.status != nil {
  14097. fields = append(fields, label.FieldStatus)
  14098. }
  14099. if m._type != nil {
  14100. fields = append(fields, label.FieldType)
  14101. }
  14102. if m.name != nil {
  14103. fields = append(fields, label.FieldName)
  14104. }
  14105. if m.from != nil {
  14106. fields = append(fields, label.FieldFrom)
  14107. }
  14108. if m.mode != nil {
  14109. fields = append(fields, label.FieldMode)
  14110. }
  14111. if m.conditions != nil {
  14112. fields = append(fields, label.FieldConditions)
  14113. }
  14114. if m.organization_id != nil {
  14115. fields = append(fields, label.FieldOrganizationID)
  14116. }
  14117. return fields
  14118. }
  14119. // Field returns the value of a field with the given name. The second boolean
  14120. // return value indicates that this field was not set, or was not defined in the
  14121. // schema.
  14122. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  14123. switch name {
  14124. case label.FieldCreatedAt:
  14125. return m.CreatedAt()
  14126. case label.FieldUpdatedAt:
  14127. return m.UpdatedAt()
  14128. case label.FieldStatus:
  14129. return m.Status()
  14130. case label.FieldType:
  14131. return m.GetType()
  14132. case label.FieldName:
  14133. return m.Name()
  14134. case label.FieldFrom:
  14135. return m.From()
  14136. case label.FieldMode:
  14137. return m.Mode()
  14138. case label.FieldConditions:
  14139. return m.Conditions()
  14140. case label.FieldOrganizationID:
  14141. return m.OrganizationID()
  14142. }
  14143. return nil, false
  14144. }
  14145. // OldField returns the old value of the field from the database. An error is
  14146. // returned if the mutation operation is not UpdateOne, or the query to the
  14147. // database failed.
  14148. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14149. switch name {
  14150. case label.FieldCreatedAt:
  14151. return m.OldCreatedAt(ctx)
  14152. case label.FieldUpdatedAt:
  14153. return m.OldUpdatedAt(ctx)
  14154. case label.FieldStatus:
  14155. return m.OldStatus(ctx)
  14156. case label.FieldType:
  14157. return m.OldType(ctx)
  14158. case label.FieldName:
  14159. return m.OldName(ctx)
  14160. case label.FieldFrom:
  14161. return m.OldFrom(ctx)
  14162. case label.FieldMode:
  14163. return m.OldMode(ctx)
  14164. case label.FieldConditions:
  14165. return m.OldConditions(ctx)
  14166. case label.FieldOrganizationID:
  14167. return m.OldOrganizationID(ctx)
  14168. }
  14169. return nil, fmt.Errorf("unknown Label field %s", name)
  14170. }
  14171. // SetField sets the value of a field with the given name. It returns an error if
  14172. // the field is not defined in the schema, or if the type mismatched the field
  14173. // type.
  14174. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  14175. switch name {
  14176. case label.FieldCreatedAt:
  14177. v, ok := value.(time.Time)
  14178. if !ok {
  14179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14180. }
  14181. m.SetCreatedAt(v)
  14182. return nil
  14183. case label.FieldUpdatedAt:
  14184. v, ok := value.(time.Time)
  14185. if !ok {
  14186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14187. }
  14188. m.SetUpdatedAt(v)
  14189. return nil
  14190. case label.FieldStatus:
  14191. v, ok := value.(uint8)
  14192. if !ok {
  14193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14194. }
  14195. m.SetStatus(v)
  14196. return nil
  14197. case label.FieldType:
  14198. v, ok := value.(int)
  14199. if !ok {
  14200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14201. }
  14202. m.SetType(v)
  14203. return nil
  14204. case label.FieldName:
  14205. v, ok := value.(string)
  14206. if !ok {
  14207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14208. }
  14209. m.SetName(v)
  14210. return nil
  14211. case label.FieldFrom:
  14212. v, ok := value.(int)
  14213. if !ok {
  14214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14215. }
  14216. m.SetFrom(v)
  14217. return nil
  14218. case label.FieldMode:
  14219. v, ok := value.(int)
  14220. if !ok {
  14221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14222. }
  14223. m.SetMode(v)
  14224. return nil
  14225. case label.FieldConditions:
  14226. v, ok := value.(string)
  14227. if !ok {
  14228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14229. }
  14230. m.SetConditions(v)
  14231. return nil
  14232. case label.FieldOrganizationID:
  14233. v, ok := value.(uint64)
  14234. if !ok {
  14235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14236. }
  14237. m.SetOrganizationID(v)
  14238. return nil
  14239. }
  14240. return fmt.Errorf("unknown Label field %s", name)
  14241. }
  14242. // AddedFields returns all numeric fields that were incremented/decremented during
  14243. // this mutation.
  14244. func (m *LabelMutation) AddedFields() []string {
  14245. var fields []string
  14246. if m.addstatus != nil {
  14247. fields = append(fields, label.FieldStatus)
  14248. }
  14249. if m.add_type != nil {
  14250. fields = append(fields, label.FieldType)
  14251. }
  14252. if m.addfrom != nil {
  14253. fields = append(fields, label.FieldFrom)
  14254. }
  14255. if m.addmode != nil {
  14256. fields = append(fields, label.FieldMode)
  14257. }
  14258. if m.addorganization_id != nil {
  14259. fields = append(fields, label.FieldOrganizationID)
  14260. }
  14261. return fields
  14262. }
  14263. // AddedField returns the numeric value that was incremented/decremented on a field
  14264. // with the given name. The second boolean return value indicates that this field
  14265. // was not set, or was not defined in the schema.
  14266. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  14267. switch name {
  14268. case label.FieldStatus:
  14269. return m.AddedStatus()
  14270. case label.FieldType:
  14271. return m.AddedType()
  14272. case label.FieldFrom:
  14273. return m.AddedFrom()
  14274. case label.FieldMode:
  14275. return m.AddedMode()
  14276. case label.FieldOrganizationID:
  14277. return m.AddedOrganizationID()
  14278. }
  14279. return nil, false
  14280. }
  14281. // AddField adds the value to the field with the given name. It returns an error if
  14282. // the field is not defined in the schema, or if the type mismatched the field
  14283. // type.
  14284. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  14285. switch name {
  14286. case label.FieldStatus:
  14287. v, ok := value.(int8)
  14288. if !ok {
  14289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14290. }
  14291. m.AddStatus(v)
  14292. return nil
  14293. case label.FieldType:
  14294. v, ok := value.(int)
  14295. if !ok {
  14296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14297. }
  14298. m.AddType(v)
  14299. return nil
  14300. case label.FieldFrom:
  14301. v, ok := value.(int)
  14302. if !ok {
  14303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14304. }
  14305. m.AddFrom(v)
  14306. return nil
  14307. case label.FieldMode:
  14308. v, ok := value.(int)
  14309. if !ok {
  14310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14311. }
  14312. m.AddMode(v)
  14313. return nil
  14314. case label.FieldOrganizationID:
  14315. v, ok := value.(int64)
  14316. if !ok {
  14317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14318. }
  14319. m.AddOrganizationID(v)
  14320. return nil
  14321. }
  14322. return fmt.Errorf("unknown Label numeric field %s", name)
  14323. }
  14324. // ClearedFields returns all nullable fields that were cleared during this
  14325. // mutation.
  14326. func (m *LabelMutation) ClearedFields() []string {
  14327. var fields []string
  14328. if m.FieldCleared(label.FieldStatus) {
  14329. fields = append(fields, label.FieldStatus)
  14330. }
  14331. if m.FieldCleared(label.FieldConditions) {
  14332. fields = append(fields, label.FieldConditions)
  14333. }
  14334. if m.FieldCleared(label.FieldOrganizationID) {
  14335. fields = append(fields, label.FieldOrganizationID)
  14336. }
  14337. return fields
  14338. }
  14339. // FieldCleared returns a boolean indicating if a field with the given name was
  14340. // cleared in this mutation.
  14341. func (m *LabelMutation) FieldCleared(name string) bool {
  14342. _, ok := m.clearedFields[name]
  14343. return ok
  14344. }
  14345. // ClearField clears the value of the field with the given name. It returns an
  14346. // error if the field is not defined in the schema.
  14347. func (m *LabelMutation) ClearField(name string) error {
  14348. switch name {
  14349. case label.FieldStatus:
  14350. m.ClearStatus()
  14351. return nil
  14352. case label.FieldConditions:
  14353. m.ClearConditions()
  14354. return nil
  14355. case label.FieldOrganizationID:
  14356. m.ClearOrganizationID()
  14357. return nil
  14358. }
  14359. return fmt.Errorf("unknown Label nullable field %s", name)
  14360. }
  14361. // ResetField resets all changes in the mutation for the field with the given name.
  14362. // It returns an error if the field is not defined in the schema.
  14363. func (m *LabelMutation) ResetField(name string) error {
  14364. switch name {
  14365. case label.FieldCreatedAt:
  14366. m.ResetCreatedAt()
  14367. return nil
  14368. case label.FieldUpdatedAt:
  14369. m.ResetUpdatedAt()
  14370. return nil
  14371. case label.FieldStatus:
  14372. m.ResetStatus()
  14373. return nil
  14374. case label.FieldType:
  14375. m.ResetType()
  14376. return nil
  14377. case label.FieldName:
  14378. m.ResetName()
  14379. return nil
  14380. case label.FieldFrom:
  14381. m.ResetFrom()
  14382. return nil
  14383. case label.FieldMode:
  14384. m.ResetMode()
  14385. return nil
  14386. case label.FieldConditions:
  14387. m.ResetConditions()
  14388. return nil
  14389. case label.FieldOrganizationID:
  14390. m.ResetOrganizationID()
  14391. return nil
  14392. }
  14393. return fmt.Errorf("unknown Label field %s", name)
  14394. }
  14395. // AddedEdges returns all edge names that were set/added in this mutation.
  14396. func (m *LabelMutation) AddedEdges() []string {
  14397. edges := make([]string, 0, 1)
  14398. if m.label_relationships != nil {
  14399. edges = append(edges, label.EdgeLabelRelationships)
  14400. }
  14401. return edges
  14402. }
  14403. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14404. // name in this mutation.
  14405. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  14406. switch name {
  14407. case label.EdgeLabelRelationships:
  14408. ids := make([]ent.Value, 0, len(m.label_relationships))
  14409. for id := range m.label_relationships {
  14410. ids = append(ids, id)
  14411. }
  14412. return ids
  14413. }
  14414. return nil
  14415. }
  14416. // RemovedEdges returns all edge names that were removed in this mutation.
  14417. func (m *LabelMutation) RemovedEdges() []string {
  14418. edges := make([]string, 0, 1)
  14419. if m.removedlabel_relationships != nil {
  14420. edges = append(edges, label.EdgeLabelRelationships)
  14421. }
  14422. return edges
  14423. }
  14424. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14425. // the given name in this mutation.
  14426. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  14427. switch name {
  14428. case label.EdgeLabelRelationships:
  14429. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  14430. for id := range m.removedlabel_relationships {
  14431. ids = append(ids, id)
  14432. }
  14433. return ids
  14434. }
  14435. return nil
  14436. }
  14437. // ClearedEdges returns all edge names that were cleared in this mutation.
  14438. func (m *LabelMutation) ClearedEdges() []string {
  14439. edges := make([]string, 0, 1)
  14440. if m.clearedlabel_relationships {
  14441. edges = append(edges, label.EdgeLabelRelationships)
  14442. }
  14443. return edges
  14444. }
  14445. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14446. // was cleared in this mutation.
  14447. func (m *LabelMutation) EdgeCleared(name string) bool {
  14448. switch name {
  14449. case label.EdgeLabelRelationships:
  14450. return m.clearedlabel_relationships
  14451. }
  14452. return false
  14453. }
  14454. // ClearEdge clears the value of the edge with the given name. It returns an error
  14455. // if that edge is not defined in the schema.
  14456. func (m *LabelMutation) ClearEdge(name string) error {
  14457. switch name {
  14458. }
  14459. return fmt.Errorf("unknown Label unique edge %s", name)
  14460. }
  14461. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14462. // It returns an error if the edge is not defined in the schema.
  14463. func (m *LabelMutation) ResetEdge(name string) error {
  14464. switch name {
  14465. case label.EdgeLabelRelationships:
  14466. m.ResetLabelRelationships()
  14467. return nil
  14468. }
  14469. return fmt.Errorf("unknown Label edge %s", name)
  14470. }
  14471. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  14472. type LabelRelationshipMutation struct {
  14473. config
  14474. op Op
  14475. typ string
  14476. id *uint64
  14477. created_at *time.Time
  14478. updated_at *time.Time
  14479. status *uint8
  14480. addstatus *int8
  14481. deleted_at *time.Time
  14482. organization_id *uint64
  14483. addorganization_id *int64
  14484. clearedFields map[string]struct{}
  14485. contacts *uint64
  14486. clearedcontacts bool
  14487. labels *uint64
  14488. clearedlabels bool
  14489. done bool
  14490. oldValue func(context.Context) (*LabelRelationship, error)
  14491. predicates []predicate.LabelRelationship
  14492. }
  14493. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  14494. // labelrelationshipOption allows management of the mutation configuration using functional options.
  14495. type labelrelationshipOption func(*LabelRelationshipMutation)
  14496. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  14497. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  14498. m := &LabelRelationshipMutation{
  14499. config: c,
  14500. op: op,
  14501. typ: TypeLabelRelationship,
  14502. clearedFields: make(map[string]struct{}),
  14503. }
  14504. for _, opt := range opts {
  14505. opt(m)
  14506. }
  14507. return m
  14508. }
  14509. // withLabelRelationshipID sets the ID field of the mutation.
  14510. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  14511. return func(m *LabelRelationshipMutation) {
  14512. var (
  14513. err error
  14514. once sync.Once
  14515. value *LabelRelationship
  14516. )
  14517. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  14518. once.Do(func() {
  14519. if m.done {
  14520. err = errors.New("querying old values post mutation is not allowed")
  14521. } else {
  14522. value, err = m.Client().LabelRelationship.Get(ctx, id)
  14523. }
  14524. })
  14525. return value, err
  14526. }
  14527. m.id = &id
  14528. }
  14529. }
  14530. // withLabelRelationship sets the old LabelRelationship of the mutation.
  14531. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  14532. return func(m *LabelRelationshipMutation) {
  14533. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  14534. return node, nil
  14535. }
  14536. m.id = &node.ID
  14537. }
  14538. }
  14539. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14540. // executed in a transaction (ent.Tx), a transactional client is returned.
  14541. func (m LabelRelationshipMutation) Client() *Client {
  14542. client := &Client{config: m.config}
  14543. client.init()
  14544. return client
  14545. }
  14546. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14547. // it returns an error otherwise.
  14548. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  14549. if _, ok := m.driver.(*txDriver); !ok {
  14550. return nil, errors.New("ent: mutation is not running in a transaction")
  14551. }
  14552. tx := &Tx{config: m.config}
  14553. tx.init()
  14554. return tx, nil
  14555. }
  14556. // SetID sets the value of the id field. Note that this
  14557. // operation is only accepted on creation of LabelRelationship entities.
  14558. func (m *LabelRelationshipMutation) SetID(id uint64) {
  14559. m.id = &id
  14560. }
  14561. // ID returns the ID value in the mutation. Note that the ID is only available
  14562. // if it was provided to the builder or after it was returned from the database.
  14563. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  14564. if m.id == nil {
  14565. return
  14566. }
  14567. return *m.id, true
  14568. }
  14569. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14570. // That means, if the mutation is applied within a transaction with an isolation level such
  14571. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14572. // or updated by the mutation.
  14573. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  14574. switch {
  14575. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14576. id, exists := m.ID()
  14577. if exists {
  14578. return []uint64{id}, nil
  14579. }
  14580. fallthrough
  14581. case m.op.Is(OpUpdate | OpDelete):
  14582. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  14583. default:
  14584. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14585. }
  14586. }
  14587. // SetCreatedAt sets the "created_at" field.
  14588. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  14589. m.created_at = &t
  14590. }
  14591. // CreatedAt returns the value of the "created_at" field in the mutation.
  14592. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  14593. v := m.created_at
  14594. if v == nil {
  14595. return
  14596. }
  14597. return *v, true
  14598. }
  14599. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  14600. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14602. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14603. if !m.op.Is(OpUpdateOne) {
  14604. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14605. }
  14606. if m.id == nil || m.oldValue == nil {
  14607. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14608. }
  14609. oldValue, err := m.oldValue(ctx)
  14610. if err != nil {
  14611. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14612. }
  14613. return oldValue.CreatedAt, nil
  14614. }
  14615. // ResetCreatedAt resets all changes to the "created_at" field.
  14616. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  14617. m.created_at = nil
  14618. }
  14619. // SetUpdatedAt sets the "updated_at" field.
  14620. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  14621. m.updated_at = &t
  14622. }
  14623. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14624. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  14625. v := m.updated_at
  14626. if v == nil {
  14627. return
  14628. }
  14629. return *v, true
  14630. }
  14631. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  14632. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14633. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14634. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14635. if !m.op.Is(OpUpdateOne) {
  14636. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14637. }
  14638. if m.id == nil || m.oldValue == nil {
  14639. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14640. }
  14641. oldValue, err := m.oldValue(ctx)
  14642. if err != nil {
  14643. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14644. }
  14645. return oldValue.UpdatedAt, nil
  14646. }
  14647. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14648. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  14649. m.updated_at = nil
  14650. }
  14651. // SetStatus sets the "status" field.
  14652. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  14653. m.status = &u
  14654. m.addstatus = nil
  14655. }
  14656. // Status returns the value of the "status" field in the mutation.
  14657. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  14658. v := m.status
  14659. if v == nil {
  14660. return
  14661. }
  14662. return *v, true
  14663. }
  14664. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  14665. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14666. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14667. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14668. if !m.op.Is(OpUpdateOne) {
  14669. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14670. }
  14671. if m.id == nil || m.oldValue == nil {
  14672. return v, errors.New("OldStatus requires an ID field in the mutation")
  14673. }
  14674. oldValue, err := m.oldValue(ctx)
  14675. if err != nil {
  14676. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14677. }
  14678. return oldValue.Status, nil
  14679. }
  14680. // AddStatus adds u to the "status" field.
  14681. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  14682. if m.addstatus != nil {
  14683. *m.addstatus += u
  14684. } else {
  14685. m.addstatus = &u
  14686. }
  14687. }
  14688. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14689. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  14690. v := m.addstatus
  14691. if v == nil {
  14692. return
  14693. }
  14694. return *v, true
  14695. }
  14696. // ClearStatus clears the value of the "status" field.
  14697. func (m *LabelRelationshipMutation) ClearStatus() {
  14698. m.status = nil
  14699. m.addstatus = nil
  14700. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  14701. }
  14702. // StatusCleared returns if the "status" field was cleared in this mutation.
  14703. func (m *LabelRelationshipMutation) StatusCleared() bool {
  14704. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  14705. return ok
  14706. }
  14707. // ResetStatus resets all changes to the "status" field.
  14708. func (m *LabelRelationshipMutation) ResetStatus() {
  14709. m.status = nil
  14710. m.addstatus = nil
  14711. delete(m.clearedFields, labelrelationship.FieldStatus)
  14712. }
  14713. // SetDeletedAt sets the "deleted_at" field.
  14714. func (m *LabelRelationshipMutation) SetDeletedAt(t time.Time) {
  14715. m.deleted_at = &t
  14716. }
  14717. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  14718. func (m *LabelRelationshipMutation) DeletedAt() (r time.Time, exists bool) {
  14719. v := m.deleted_at
  14720. if v == nil {
  14721. return
  14722. }
  14723. return *v, true
  14724. }
  14725. // OldDeletedAt returns the old "deleted_at" field's value of the LabelRelationship entity.
  14726. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14728. func (m *LabelRelationshipMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  14729. if !m.op.Is(OpUpdateOne) {
  14730. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  14731. }
  14732. if m.id == nil || m.oldValue == nil {
  14733. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  14734. }
  14735. oldValue, err := m.oldValue(ctx)
  14736. if err != nil {
  14737. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  14738. }
  14739. return oldValue.DeletedAt, nil
  14740. }
  14741. // ClearDeletedAt clears the value of the "deleted_at" field.
  14742. func (m *LabelRelationshipMutation) ClearDeletedAt() {
  14743. m.deleted_at = nil
  14744. m.clearedFields[labelrelationship.FieldDeletedAt] = struct{}{}
  14745. }
  14746. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  14747. func (m *LabelRelationshipMutation) DeletedAtCleared() bool {
  14748. _, ok := m.clearedFields[labelrelationship.FieldDeletedAt]
  14749. return ok
  14750. }
  14751. // ResetDeletedAt resets all changes to the "deleted_at" field.
  14752. func (m *LabelRelationshipMutation) ResetDeletedAt() {
  14753. m.deleted_at = nil
  14754. delete(m.clearedFields, labelrelationship.FieldDeletedAt)
  14755. }
  14756. // SetLabelID sets the "label_id" field.
  14757. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  14758. m.labels = &u
  14759. }
  14760. // LabelID returns the value of the "label_id" field in the mutation.
  14761. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  14762. v := m.labels
  14763. if v == nil {
  14764. return
  14765. }
  14766. return *v, true
  14767. }
  14768. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  14769. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14770. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14771. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  14772. if !m.op.Is(OpUpdateOne) {
  14773. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  14774. }
  14775. if m.id == nil || m.oldValue == nil {
  14776. return v, errors.New("OldLabelID requires an ID field in the mutation")
  14777. }
  14778. oldValue, err := m.oldValue(ctx)
  14779. if err != nil {
  14780. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  14781. }
  14782. return oldValue.LabelID, nil
  14783. }
  14784. // ResetLabelID resets all changes to the "label_id" field.
  14785. func (m *LabelRelationshipMutation) ResetLabelID() {
  14786. m.labels = nil
  14787. }
  14788. // SetContactID sets the "contact_id" field.
  14789. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  14790. m.contacts = &u
  14791. }
  14792. // ContactID returns the value of the "contact_id" field in the mutation.
  14793. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  14794. v := m.contacts
  14795. if v == nil {
  14796. return
  14797. }
  14798. return *v, true
  14799. }
  14800. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  14801. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14802. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14803. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  14804. if !m.op.Is(OpUpdateOne) {
  14805. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  14806. }
  14807. if m.id == nil || m.oldValue == nil {
  14808. return v, errors.New("OldContactID requires an ID field in the mutation")
  14809. }
  14810. oldValue, err := m.oldValue(ctx)
  14811. if err != nil {
  14812. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  14813. }
  14814. return oldValue.ContactID, nil
  14815. }
  14816. // ResetContactID resets all changes to the "contact_id" field.
  14817. func (m *LabelRelationshipMutation) ResetContactID() {
  14818. m.contacts = nil
  14819. }
  14820. // SetOrganizationID sets the "organization_id" field.
  14821. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  14822. m.organization_id = &u
  14823. m.addorganization_id = nil
  14824. }
  14825. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14826. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  14827. v := m.organization_id
  14828. if v == nil {
  14829. return
  14830. }
  14831. return *v, true
  14832. }
  14833. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  14834. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14835. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14836. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14837. if !m.op.Is(OpUpdateOne) {
  14838. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14839. }
  14840. if m.id == nil || m.oldValue == nil {
  14841. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14842. }
  14843. oldValue, err := m.oldValue(ctx)
  14844. if err != nil {
  14845. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14846. }
  14847. return oldValue.OrganizationID, nil
  14848. }
  14849. // AddOrganizationID adds u to the "organization_id" field.
  14850. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  14851. if m.addorganization_id != nil {
  14852. *m.addorganization_id += u
  14853. } else {
  14854. m.addorganization_id = &u
  14855. }
  14856. }
  14857. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14858. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  14859. v := m.addorganization_id
  14860. if v == nil {
  14861. return
  14862. }
  14863. return *v, true
  14864. }
  14865. // ClearOrganizationID clears the value of the "organization_id" field.
  14866. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  14867. m.organization_id = nil
  14868. m.addorganization_id = nil
  14869. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  14870. }
  14871. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14872. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  14873. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  14874. return ok
  14875. }
  14876. // ResetOrganizationID resets all changes to the "organization_id" field.
  14877. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  14878. m.organization_id = nil
  14879. m.addorganization_id = nil
  14880. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  14881. }
  14882. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  14883. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  14884. m.contacts = &id
  14885. }
  14886. // ClearContacts clears the "contacts" edge to the Contact entity.
  14887. func (m *LabelRelationshipMutation) ClearContacts() {
  14888. m.clearedcontacts = true
  14889. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  14890. }
  14891. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  14892. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  14893. return m.clearedcontacts
  14894. }
  14895. // ContactsID returns the "contacts" edge ID in the mutation.
  14896. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  14897. if m.contacts != nil {
  14898. return *m.contacts, true
  14899. }
  14900. return
  14901. }
  14902. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  14903. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14904. // ContactsID instead. It exists only for internal usage by the builders.
  14905. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  14906. if id := m.contacts; id != nil {
  14907. ids = append(ids, *id)
  14908. }
  14909. return
  14910. }
  14911. // ResetContacts resets all changes to the "contacts" edge.
  14912. func (m *LabelRelationshipMutation) ResetContacts() {
  14913. m.contacts = nil
  14914. m.clearedcontacts = false
  14915. }
  14916. // SetLabelsID sets the "labels" edge to the Label entity by id.
  14917. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  14918. m.labels = &id
  14919. }
  14920. // ClearLabels clears the "labels" edge to the Label entity.
  14921. func (m *LabelRelationshipMutation) ClearLabels() {
  14922. m.clearedlabels = true
  14923. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  14924. }
  14925. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  14926. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  14927. return m.clearedlabels
  14928. }
  14929. // LabelsID returns the "labels" edge ID in the mutation.
  14930. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  14931. if m.labels != nil {
  14932. return *m.labels, true
  14933. }
  14934. return
  14935. }
  14936. // LabelsIDs returns the "labels" edge IDs in the mutation.
  14937. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14938. // LabelsID instead. It exists only for internal usage by the builders.
  14939. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  14940. if id := m.labels; id != nil {
  14941. ids = append(ids, *id)
  14942. }
  14943. return
  14944. }
  14945. // ResetLabels resets all changes to the "labels" edge.
  14946. func (m *LabelRelationshipMutation) ResetLabels() {
  14947. m.labels = nil
  14948. m.clearedlabels = false
  14949. }
  14950. // Where appends a list predicates to the LabelRelationshipMutation builder.
  14951. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  14952. m.predicates = append(m.predicates, ps...)
  14953. }
  14954. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  14955. // users can use type-assertion to append predicates that do not depend on any generated package.
  14956. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  14957. p := make([]predicate.LabelRelationship, len(ps))
  14958. for i := range ps {
  14959. p[i] = ps[i]
  14960. }
  14961. m.Where(p...)
  14962. }
  14963. // Op returns the operation name.
  14964. func (m *LabelRelationshipMutation) Op() Op {
  14965. return m.op
  14966. }
  14967. // SetOp allows setting the mutation operation.
  14968. func (m *LabelRelationshipMutation) SetOp(op Op) {
  14969. m.op = op
  14970. }
  14971. // Type returns the node type of this mutation (LabelRelationship).
  14972. func (m *LabelRelationshipMutation) Type() string {
  14973. return m.typ
  14974. }
  14975. // Fields returns all fields that were changed during this mutation. Note that in
  14976. // order to get all numeric fields that were incremented/decremented, call
  14977. // AddedFields().
  14978. func (m *LabelRelationshipMutation) Fields() []string {
  14979. fields := make([]string, 0, 7)
  14980. if m.created_at != nil {
  14981. fields = append(fields, labelrelationship.FieldCreatedAt)
  14982. }
  14983. if m.updated_at != nil {
  14984. fields = append(fields, labelrelationship.FieldUpdatedAt)
  14985. }
  14986. if m.status != nil {
  14987. fields = append(fields, labelrelationship.FieldStatus)
  14988. }
  14989. if m.deleted_at != nil {
  14990. fields = append(fields, labelrelationship.FieldDeletedAt)
  14991. }
  14992. if m.labels != nil {
  14993. fields = append(fields, labelrelationship.FieldLabelID)
  14994. }
  14995. if m.contacts != nil {
  14996. fields = append(fields, labelrelationship.FieldContactID)
  14997. }
  14998. if m.organization_id != nil {
  14999. fields = append(fields, labelrelationship.FieldOrganizationID)
  15000. }
  15001. return fields
  15002. }
  15003. // Field returns the value of a field with the given name. The second boolean
  15004. // return value indicates that this field was not set, or was not defined in the
  15005. // schema.
  15006. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  15007. switch name {
  15008. case labelrelationship.FieldCreatedAt:
  15009. return m.CreatedAt()
  15010. case labelrelationship.FieldUpdatedAt:
  15011. return m.UpdatedAt()
  15012. case labelrelationship.FieldStatus:
  15013. return m.Status()
  15014. case labelrelationship.FieldDeletedAt:
  15015. return m.DeletedAt()
  15016. case labelrelationship.FieldLabelID:
  15017. return m.LabelID()
  15018. case labelrelationship.FieldContactID:
  15019. return m.ContactID()
  15020. case labelrelationship.FieldOrganizationID:
  15021. return m.OrganizationID()
  15022. }
  15023. return nil, false
  15024. }
  15025. // OldField returns the old value of the field from the database. An error is
  15026. // returned if the mutation operation is not UpdateOne, or the query to the
  15027. // database failed.
  15028. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15029. switch name {
  15030. case labelrelationship.FieldCreatedAt:
  15031. return m.OldCreatedAt(ctx)
  15032. case labelrelationship.FieldUpdatedAt:
  15033. return m.OldUpdatedAt(ctx)
  15034. case labelrelationship.FieldStatus:
  15035. return m.OldStatus(ctx)
  15036. case labelrelationship.FieldDeletedAt:
  15037. return m.OldDeletedAt(ctx)
  15038. case labelrelationship.FieldLabelID:
  15039. return m.OldLabelID(ctx)
  15040. case labelrelationship.FieldContactID:
  15041. return m.OldContactID(ctx)
  15042. case labelrelationship.FieldOrganizationID:
  15043. return m.OldOrganizationID(ctx)
  15044. }
  15045. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  15046. }
  15047. // SetField sets the value of a field with the given name. It returns an error if
  15048. // the field is not defined in the schema, or if the type mismatched the field
  15049. // type.
  15050. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  15051. switch name {
  15052. case labelrelationship.FieldCreatedAt:
  15053. v, ok := value.(time.Time)
  15054. if !ok {
  15055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15056. }
  15057. m.SetCreatedAt(v)
  15058. return nil
  15059. case labelrelationship.FieldUpdatedAt:
  15060. v, ok := value.(time.Time)
  15061. if !ok {
  15062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15063. }
  15064. m.SetUpdatedAt(v)
  15065. return nil
  15066. case labelrelationship.FieldStatus:
  15067. v, ok := value.(uint8)
  15068. if !ok {
  15069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15070. }
  15071. m.SetStatus(v)
  15072. return nil
  15073. case labelrelationship.FieldDeletedAt:
  15074. v, ok := value.(time.Time)
  15075. if !ok {
  15076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15077. }
  15078. m.SetDeletedAt(v)
  15079. return nil
  15080. case labelrelationship.FieldLabelID:
  15081. v, ok := value.(uint64)
  15082. if !ok {
  15083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15084. }
  15085. m.SetLabelID(v)
  15086. return nil
  15087. case labelrelationship.FieldContactID:
  15088. v, ok := value.(uint64)
  15089. if !ok {
  15090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15091. }
  15092. m.SetContactID(v)
  15093. return nil
  15094. case labelrelationship.FieldOrganizationID:
  15095. v, ok := value.(uint64)
  15096. if !ok {
  15097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15098. }
  15099. m.SetOrganizationID(v)
  15100. return nil
  15101. }
  15102. return fmt.Errorf("unknown LabelRelationship field %s", name)
  15103. }
  15104. // AddedFields returns all numeric fields that were incremented/decremented during
  15105. // this mutation.
  15106. func (m *LabelRelationshipMutation) AddedFields() []string {
  15107. var fields []string
  15108. if m.addstatus != nil {
  15109. fields = append(fields, labelrelationship.FieldStatus)
  15110. }
  15111. if m.addorganization_id != nil {
  15112. fields = append(fields, labelrelationship.FieldOrganizationID)
  15113. }
  15114. return fields
  15115. }
  15116. // AddedField returns the numeric value that was incremented/decremented on a field
  15117. // with the given name. The second boolean return value indicates that this field
  15118. // was not set, or was not defined in the schema.
  15119. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  15120. switch name {
  15121. case labelrelationship.FieldStatus:
  15122. return m.AddedStatus()
  15123. case labelrelationship.FieldOrganizationID:
  15124. return m.AddedOrganizationID()
  15125. }
  15126. return nil, false
  15127. }
  15128. // AddField adds the value to the field with the given name. It returns an error if
  15129. // the field is not defined in the schema, or if the type mismatched the field
  15130. // type.
  15131. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  15132. switch name {
  15133. case labelrelationship.FieldStatus:
  15134. v, ok := value.(int8)
  15135. if !ok {
  15136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15137. }
  15138. m.AddStatus(v)
  15139. return nil
  15140. case labelrelationship.FieldOrganizationID:
  15141. v, ok := value.(int64)
  15142. if !ok {
  15143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15144. }
  15145. m.AddOrganizationID(v)
  15146. return nil
  15147. }
  15148. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  15149. }
  15150. // ClearedFields returns all nullable fields that were cleared during this
  15151. // mutation.
  15152. func (m *LabelRelationshipMutation) ClearedFields() []string {
  15153. var fields []string
  15154. if m.FieldCleared(labelrelationship.FieldStatus) {
  15155. fields = append(fields, labelrelationship.FieldStatus)
  15156. }
  15157. if m.FieldCleared(labelrelationship.FieldDeletedAt) {
  15158. fields = append(fields, labelrelationship.FieldDeletedAt)
  15159. }
  15160. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  15161. fields = append(fields, labelrelationship.FieldOrganizationID)
  15162. }
  15163. return fields
  15164. }
  15165. // FieldCleared returns a boolean indicating if a field with the given name was
  15166. // cleared in this mutation.
  15167. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  15168. _, ok := m.clearedFields[name]
  15169. return ok
  15170. }
  15171. // ClearField clears the value of the field with the given name. It returns an
  15172. // error if the field is not defined in the schema.
  15173. func (m *LabelRelationshipMutation) ClearField(name string) error {
  15174. switch name {
  15175. case labelrelationship.FieldStatus:
  15176. m.ClearStatus()
  15177. return nil
  15178. case labelrelationship.FieldDeletedAt:
  15179. m.ClearDeletedAt()
  15180. return nil
  15181. case labelrelationship.FieldOrganizationID:
  15182. m.ClearOrganizationID()
  15183. return nil
  15184. }
  15185. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  15186. }
  15187. // ResetField resets all changes in the mutation for the field with the given name.
  15188. // It returns an error if the field is not defined in the schema.
  15189. func (m *LabelRelationshipMutation) ResetField(name string) error {
  15190. switch name {
  15191. case labelrelationship.FieldCreatedAt:
  15192. m.ResetCreatedAt()
  15193. return nil
  15194. case labelrelationship.FieldUpdatedAt:
  15195. m.ResetUpdatedAt()
  15196. return nil
  15197. case labelrelationship.FieldStatus:
  15198. m.ResetStatus()
  15199. return nil
  15200. case labelrelationship.FieldDeletedAt:
  15201. m.ResetDeletedAt()
  15202. return nil
  15203. case labelrelationship.FieldLabelID:
  15204. m.ResetLabelID()
  15205. return nil
  15206. case labelrelationship.FieldContactID:
  15207. m.ResetContactID()
  15208. return nil
  15209. case labelrelationship.FieldOrganizationID:
  15210. m.ResetOrganizationID()
  15211. return nil
  15212. }
  15213. return fmt.Errorf("unknown LabelRelationship field %s", name)
  15214. }
  15215. // AddedEdges returns all edge names that were set/added in this mutation.
  15216. func (m *LabelRelationshipMutation) AddedEdges() []string {
  15217. edges := make([]string, 0, 2)
  15218. if m.contacts != nil {
  15219. edges = append(edges, labelrelationship.EdgeContacts)
  15220. }
  15221. if m.labels != nil {
  15222. edges = append(edges, labelrelationship.EdgeLabels)
  15223. }
  15224. return edges
  15225. }
  15226. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15227. // name in this mutation.
  15228. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  15229. switch name {
  15230. case labelrelationship.EdgeContacts:
  15231. if id := m.contacts; id != nil {
  15232. return []ent.Value{*id}
  15233. }
  15234. case labelrelationship.EdgeLabels:
  15235. if id := m.labels; id != nil {
  15236. return []ent.Value{*id}
  15237. }
  15238. }
  15239. return nil
  15240. }
  15241. // RemovedEdges returns all edge names that were removed in this mutation.
  15242. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  15243. edges := make([]string, 0, 2)
  15244. return edges
  15245. }
  15246. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15247. // the given name in this mutation.
  15248. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  15249. return nil
  15250. }
  15251. // ClearedEdges returns all edge names that were cleared in this mutation.
  15252. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  15253. edges := make([]string, 0, 2)
  15254. if m.clearedcontacts {
  15255. edges = append(edges, labelrelationship.EdgeContacts)
  15256. }
  15257. if m.clearedlabels {
  15258. edges = append(edges, labelrelationship.EdgeLabels)
  15259. }
  15260. return edges
  15261. }
  15262. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15263. // was cleared in this mutation.
  15264. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  15265. switch name {
  15266. case labelrelationship.EdgeContacts:
  15267. return m.clearedcontacts
  15268. case labelrelationship.EdgeLabels:
  15269. return m.clearedlabels
  15270. }
  15271. return false
  15272. }
  15273. // ClearEdge clears the value of the edge with the given name. It returns an error
  15274. // if that edge is not defined in the schema.
  15275. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  15276. switch name {
  15277. case labelrelationship.EdgeContacts:
  15278. m.ClearContacts()
  15279. return nil
  15280. case labelrelationship.EdgeLabels:
  15281. m.ClearLabels()
  15282. return nil
  15283. }
  15284. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  15285. }
  15286. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15287. // It returns an error if the edge is not defined in the schema.
  15288. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  15289. switch name {
  15290. case labelrelationship.EdgeContacts:
  15291. m.ResetContacts()
  15292. return nil
  15293. case labelrelationship.EdgeLabels:
  15294. m.ResetLabels()
  15295. return nil
  15296. }
  15297. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  15298. }
  15299. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  15300. type MessageMutation struct {
  15301. config
  15302. op Op
  15303. typ string
  15304. id *int
  15305. wx_wxid *string
  15306. wxid *string
  15307. content *string
  15308. clearedFields map[string]struct{}
  15309. done bool
  15310. oldValue func(context.Context) (*Message, error)
  15311. predicates []predicate.Message
  15312. }
  15313. var _ ent.Mutation = (*MessageMutation)(nil)
  15314. // messageOption allows management of the mutation configuration using functional options.
  15315. type messageOption func(*MessageMutation)
  15316. // newMessageMutation creates new mutation for the Message entity.
  15317. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  15318. m := &MessageMutation{
  15319. config: c,
  15320. op: op,
  15321. typ: TypeMessage,
  15322. clearedFields: make(map[string]struct{}),
  15323. }
  15324. for _, opt := range opts {
  15325. opt(m)
  15326. }
  15327. return m
  15328. }
  15329. // withMessageID sets the ID field of the mutation.
  15330. func withMessageID(id int) messageOption {
  15331. return func(m *MessageMutation) {
  15332. var (
  15333. err error
  15334. once sync.Once
  15335. value *Message
  15336. )
  15337. m.oldValue = func(ctx context.Context) (*Message, error) {
  15338. once.Do(func() {
  15339. if m.done {
  15340. err = errors.New("querying old values post mutation is not allowed")
  15341. } else {
  15342. value, err = m.Client().Message.Get(ctx, id)
  15343. }
  15344. })
  15345. return value, err
  15346. }
  15347. m.id = &id
  15348. }
  15349. }
  15350. // withMessage sets the old Message of the mutation.
  15351. func withMessage(node *Message) messageOption {
  15352. return func(m *MessageMutation) {
  15353. m.oldValue = func(context.Context) (*Message, error) {
  15354. return node, nil
  15355. }
  15356. m.id = &node.ID
  15357. }
  15358. }
  15359. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15360. // executed in a transaction (ent.Tx), a transactional client is returned.
  15361. func (m MessageMutation) Client() *Client {
  15362. client := &Client{config: m.config}
  15363. client.init()
  15364. return client
  15365. }
  15366. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15367. // it returns an error otherwise.
  15368. func (m MessageMutation) Tx() (*Tx, error) {
  15369. if _, ok := m.driver.(*txDriver); !ok {
  15370. return nil, errors.New("ent: mutation is not running in a transaction")
  15371. }
  15372. tx := &Tx{config: m.config}
  15373. tx.init()
  15374. return tx, nil
  15375. }
  15376. // ID returns the ID value in the mutation. Note that the ID is only available
  15377. // if it was provided to the builder or after it was returned from the database.
  15378. func (m *MessageMutation) ID() (id int, exists bool) {
  15379. if m.id == nil {
  15380. return
  15381. }
  15382. return *m.id, true
  15383. }
  15384. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15385. // That means, if the mutation is applied within a transaction with an isolation level such
  15386. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15387. // or updated by the mutation.
  15388. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  15389. switch {
  15390. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15391. id, exists := m.ID()
  15392. if exists {
  15393. return []int{id}, nil
  15394. }
  15395. fallthrough
  15396. case m.op.Is(OpUpdate | OpDelete):
  15397. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  15398. default:
  15399. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15400. }
  15401. }
  15402. // SetWxWxid sets the "wx_wxid" field.
  15403. func (m *MessageMutation) SetWxWxid(s string) {
  15404. m.wx_wxid = &s
  15405. }
  15406. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  15407. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  15408. v := m.wx_wxid
  15409. if v == nil {
  15410. return
  15411. }
  15412. return *v, true
  15413. }
  15414. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  15415. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  15416. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15417. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  15418. if !m.op.Is(OpUpdateOne) {
  15419. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  15420. }
  15421. if m.id == nil || m.oldValue == nil {
  15422. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  15423. }
  15424. oldValue, err := m.oldValue(ctx)
  15425. if err != nil {
  15426. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  15427. }
  15428. return oldValue.WxWxid, nil
  15429. }
  15430. // ClearWxWxid clears the value of the "wx_wxid" field.
  15431. func (m *MessageMutation) ClearWxWxid() {
  15432. m.wx_wxid = nil
  15433. m.clearedFields[message.FieldWxWxid] = struct{}{}
  15434. }
  15435. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  15436. func (m *MessageMutation) WxWxidCleared() bool {
  15437. _, ok := m.clearedFields[message.FieldWxWxid]
  15438. return ok
  15439. }
  15440. // ResetWxWxid resets all changes to the "wx_wxid" field.
  15441. func (m *MessageMutation) ResetWxWxid() {
  15442. m.wx_wxid = nil
  15443. delete(m.clearedFields, message.FieldWxWxid)
  15444. }
  15445. // SetWxid sets the "wxid" field.
  15446. func (m *MessageMutation) SetWxid(s string) {
  15447. m.wxid = &s
  15448. }
  15449. // Wxid returns the value of the "wxid" field in the mutation.
  15450. func (m *MessageMutation) Wxid() (r string, exists bool) {
  15451. v := m.wxid
  15452. if v == nil {
  15453. return
  15454. }
  15455. return *v, true
  15456. }
  15457. // OldWxid returns the old "wxid" field's value of the Message entity.
  15458. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  15459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15460. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  15461. if !m.op.Is(OpUpdateOne) {
  15462. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  15463. }
  15464. if m.id == nil || m.oldValue == nil {
  15465. return v, errors.New("OldWxid requires an ID field in the mutation")
  15466. }
  15467. oldValue, err := m.oldValue(ctx)
  15468. if err != nil {
  15469. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  15470. }
  15471. return oldValue.Wxid, nil
  15472. }
  15473. // ResetWxid resets all changes to the "wxid" field.
  15474. func (m *MessageMutation) ResetWxid() {
  15475. m.wxid = nil
  15476. }
  15477. // SetContent sets the "content" field.
  15478. func (m *MessageMutation) SetContent(s string) {
  15479. m.content = &s
  15480. }
  15481. // Content returns the value of the "content" field in the mutation.
  15482. func (m *MessageMutation) Content() (r string, exists bool) {
  15483. v := m.content
  15484. if v == nil {
  15485. return
  15486. }
  15487. return *v, true
  15488. }
  15489. // OldContent returns the old "content" field's value of the Message entity.
  15490. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  15491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15492. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  15493. if !m.op.Is(OpUpdateOne) {
  15494. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  15495. }
  15496. if m.id == nil || m.oldValue == nil {
  15497. return v, errors.New("OldContent requires an ID field in the mutation")
  15498. }
  15499. oldValue, err := m.oldValue(ctx)
  15500. if err != nil {
  15501. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  15502. }
  15503. return oldValue.Content, nil
  15504. }
  15505. // ResetContent resets all changes to the "content" field.
  15506. func (m *MessageMutation) ResetContent() {
  15507. m.content = nil
  15508. }
  15509. // Where appends a list predicates to the MessageMutation builder.
  15510. func (m *MessageMutation) Where(ps ...predicate.Message) {
  15511. m.predicates = append(m.predicates, ps...)
  15512. }
  15513. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  15514. // users can use type-assertion to append predicates that do not depend on any generated package.
  15515. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  15516. p := make([]predicate.Message, len(ps))
  15517. for i := range ps {
  15518. p[i] = ps[i]
  15519. }
  15520. m.Where(p...)
  15521. }
  15522. // Op returns the operation name.
  15523. func (m *MessageMutation) Op() Op {
  15524. return m.op
  15525. }
  15526. // SetOp allows setting the mutation operation.
  15527. func (m *MessageMutation) SetOp(op Op) {
  15528. m.op = op
  15529. }
  15530. // Type returns the node type of this mutation (Message).
  15531. func (m *MessageMutation) Type() string {
  15532. return m.typ
  15533. }
  15534. // Fields returns all fields that were changed during this mutation. Note that in
  15535. // order to get all numeric fields that were incremented/decremented, call
  15536. // AddedFields().
  15537. func (m *MessageMutation) Fields() []string {
  15538. fields := make([]string, 0, 3)
  15539. if m.wx_wxid != nil {
  15540. fields = append(fields, message.FieldWxWxid)
  15541. }
  15542. if m.wxid != nil {
  15543. fields = append(fields, message.FieldWxid)
  15544. }
  15545. if m.content != nil {
  15546. fields = append(fields, message.FieldContent)
  15547. }
  15548. return fields
  15549. }
  15550. // Field returns the value of a field with the given name. The second boolean
  15551. // return value indicates that this field was not set, or was not defined in the
  15552. // schema.
  15553. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  15554. switch name {
  15555. case message.FieldWxWxid:
  15556. return m.WxWxid()
  15557. case message.FieldWxid:
  15558. return m.Wxid()
  15559. case message.FieldContent:
  15560. return m.Content()
  15561. }
  15562. return nil, false
  15563. }
  15564. // OldField returns the old value of the field from the database. An error is
  15565. // returned if the mutation operation is not UpdateOne, or the query to the
  15566. // database failed.
  15567. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15568. switch name {
  15569. case message.FieldWxWxid:
  15570. return m.OldWxWxid(ctx)
  15571. case message.FieldWxid:
  15572. return m.OldWxid(ctx)
  15573. case message.FieldContent:
  15574. return m.OldContent(ctx)
  15575. }
  15576. return nil, fmt.Errorf("unknown Message field %s", name)
  15577. }
  15578. // SetField sets the value of a field with the given name. It returns an error if
  15579. // the field is not defined in the schema, or if the type mismatched the field
  15580. // type.
  15581. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  15582. switch name {
  15583. case message.FieldWxWxid:
  15584. v, ok := value.(string)
  15585. if !ok {
  15586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15587. }
  15588. m.SetWxWxid(v)
  15589. return nil
  15590. case message.FieldWxid:
  15591. v, ok := value.(string)
  15592. if !ok {
  15593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15594. }
  15595. m.SetWxid(v)
  15596. return nil
  15597. case message.FieldContent:
  15598. v, ok := value.(string)
  15599. if !ok {
  15600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15601. }
  15602. m.SetContent(v)
  15603. return nil
  15604. }
  15605. return fmt.Errorf("unknown Message field %s", name)
  15606. }
  15607. // AddedFields returns all numeric fields that were incremented/decremented during
  15608. // this mutation.
  15609. func (m *MessageMutation) AddedFields() []string {
  15610. return nil
  15611. }
  15612. // AddedField returns the numeric value that was incremented/decremented on a field
  15613. // with the given name. The second boolean return value indicates that this field
  15614. // was not set, or was not defined in the schema.
  15615. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  15616. return nil, false
  15617. }
  15618. // AddField adds the value to the field with the given name. It returns an error if
  15619. // the field is not defined in the schema, or if the type mismatched the field
  15620. // type.
  15621. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  15622. switch name {
  15623. }
  15624. return fmt.Errorf("unknown Message numeric field %s", name)
  15625. }
  15626. // ClearedFields returns all nullable fields that were cleared during this
  15627. // mutation.
  15628. func (m *MessageMutation) ClearedFields() []string {
  15629. var fields []string
  15630. if m.FieldCleared(message.FieldWxWxid) {
  15631. fields = append(fields, message.FieldWxWxid)
  15632. }
  15633. return fields
  15634. }
  15635. // FieldCleared returns a boolean indicating if a field with the given name was
  15636. // cleared in this mutation.
  15637. func (m *MessageMutation) FieldCleared(name string) bool {
  15638. _, ok := m.clearedFields[name]
  15639. return ok
  15640. }
  15641. // ClearField clears the value of the field with the given name. It returns an
  15642. // error if the field is not defined in the schema.
  15643. func (m *MessageMutation) ClearField(name string) error {
  15644. switch name {
  15645. case message.FieldWxWxid:
  15646. m.ClearWxWxid()
  15647. return nil
  15648. }
  15649. return fmt.Errorf("unknown Message nullable field %s", name)
  15650. }
  15651. // ResetField resets all changes in the mutation for the field with the given name.
  15652. // It returns an error if the field is not defined in the schema.
  15653. func (m *MessageMutation) ResetField(name string) error {
  15654. switch name {
  15655. case message.FieldWxWxid:
  15656. m.ResetWxWxid()
  15657. return nil
  15658. case message.FieldWxid:
  15659. m.ResetWxid()
  15660. return nil
  15661. case message.FieldContent:
  15662. m.ResetContent()
  15663. return nil
  15664. }
  15665. return fmt.Errorf("unknown Message field %s", name)
  15666. }
  15667. // AddedEdges returns all edge names that were set/added in this mutation.
  15668. func (m *MessageMutation) AddedEdges() []string {
  15669. edges := make([]string, 0, 0)
  15670. return edges
  15671. }
  15672. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15673. // name in this mutation.
  15674. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  15675. return nil
  15676. }
  15677. // RemovedEdges returns all edge names that were removed in this mutation.
  15678. func (m *MessageMutation) RemovedEdges() []string {
  15679. edges := make([]string, 0, 0)
  15680. return edges
  15681. }
  15682. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15683. // the given name in this mutation.
  15684. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  15685. return nil
  15686. }
  15687. // ClearedEdges returns all edge names that were cleared in this mutation.
  15688. func (m *MessageMutation) ClearedEdges() []string {
  15689. edges := make([]string, 0, 0)
  15690. return edges
  15691. }
  15692. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15693. // was cleared in this mutation.
  15694. func (m *MessageMutation) EdgeCleared(name string) bool {
  15695. return false
  15696. }
  15697. // ClearEdge clears the value of the edge with the given name. It returns an error
  15698. // if that edge is not defined in the schema.
  15699. func (m *MessageMutation) ClearEdge(name string) error {
  15700. return fmt.Errorf("unknown Message unique edge %s", name)
  15701. }
  15702. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15703. // It returns an error if the edge is not defined in the schema.
  15704. func (m *MessageMutation) ResetEdge(name string) error {
  15705. return fmt.Errorf("unknown Message edge %s", name)
  15706. }
  15707. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  15708. type MessageRecordsMutation struct {
  15709. config
  15710. op Op
  15711. typ string
  15712. id *uint64
  15713. created_at *time.Time
  15714. updated_at *time.Time
  15715. status *uint8
  15716. addstatus *int8
  15717. bot_wxid *string
  15718. contact_type *int
  15719. addcontact_type *int
  15720. contact_wxid *string
  15721. content_type *int
  15722. addcontent_type *int
  15723. content *string
  15724. meta *custom_types.Meta
  15725. error_detail *string
  15726. send_time *time.Time
  15727. source_type *int
  15728. addsource_type *int
  15729. organization_id *uint64
  15730. addorganization_id *int64
  15731. clearedFields map[string]struct{}
  15732. sop_stage *uint64
  15733. clearedsop_stage bool
  15734. sop_node *uint64
  15735. clearedsop_node bool
  15736. message_contact *uint64
  15737. clearedmessage_contact bool
  15738. done bool
  15739. oldValue func(context.Context) (*MessageRecords, error)
  15740. predicates []predicate.MessageRecords
  15741. }
  15742. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  15743. // messagerecordsOption allows management of the mutation configuration using functional options.
  15744. type messagerecordsOption func(*MessageRecordsMutation)
  15745. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  15746. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  15747. m := &MessageRecordsMutation{
  15748. config: c,
  15749. op: op,
  15750. typ: TypeMessageRecords,
  15751. clearedFields: make(map[string]struct{}),
  15752. }
  15753. for _, opt := range opts {
  15754. opt(m)
  15755. }
  15756. return m
  15757. }
  15758. // withMessageRecordsID sets the ID field of the mutation.
  15759. func withMessageRecordsID(id uint64) messagerecordsOption {
  15760. return func(m *MessageRecordsMutation) {
  15761. var (
  15762. err error
  15763. once sync.Once
  15764. value *MessageRecords
  15765. )
  15766. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  15767. once.Do(func() {
  15768. if m.done {
  15769. err = errors.New("querying old values post mutation is not allowed")
  15770. } else {
  15771. value, err = m.Client().MessageRecords.Get(ctx, id)
  15772. }
  15773. })
  15774. return value, err
  15775. }
  15776. m.id = &id
  15777. }
  15778. }
  15779. // withMessageRecords sets the old MessageRecords of the mutation.
  15780. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  15781. return func(m *MessageRecordsMutation) {
  15782. m.oldValue = func(context.Context) (*MessageRecords, error) {
  15783. return node, nil
  15784. }
  15785. m.id = &node.ID
  15786. }
  15787. }
  15788. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15789. // executed in a transaction (ent.Tx), a transactional client is returned.
  15790. func (m MessageRecordsMutation) Client() *Client {
  15791. client := &Client{config: m.config}
  15792. client.init()
  15793. return client
  15794. }
  15795. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15796. // it returns an error otherwise.
  15797. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  15798. if _, ok := m.driver.(*txDriver); !ok {
  15799. return nil, errors.New("ent: mutation is not running in a transaction")
  15800. }
  15801. tx := &Tx{config: m.config}
  15802. tx.init()
  15803. return tx, nil
  15804. }
  15805. // SetID sets the value of the id field. Note that this
  15806. // operation is only accepted on creation of MessageRecords entities.
  15807. func (m *MessageRecordsMutation) SetID(id uint64) {
  15808. m.id = &id
  15809. }
  15810. // ID returns the ID value in the mutation. Note that the ID is only available
  15811. // if it was provided to the builder or after it was returned from the database.
  15812. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  15813. if m.id == nil {
  15814. return
  15815. }
  15816. return *m.id, true
  15817. }
  15818. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15819. // That means, if the mutation is applied within a transaction with an isolation level such
  15820. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15821. // or updated by the mutation.
  15822. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  15823. switch {
  15824. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15825. id, exists := m.ID()
  15826. if exists {
  15827. return []uint64{id}, nil
  15828. }
  15829. fallthrough
  15830. case m.op.Is(OpUpdate | OpDelete):
  15831. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  15832. default:
  15833. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15834. }
  15835. }
  15836. // SetCreatedAt sets the "created_at" field.
  15837. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  15838. m.created_at = &t
  15839. }
  15840. // CreatedAt returns the value of the "created_at" field in the mutation.
  15841. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  15842. v := m.created_at
  15843. if v == nil {
  15844. return
  15845. }
  15846. return *v, true
  15847. }
  15848. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  15849. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15851. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15852. if !m.op.Is(OpUpdateOne) {
  15853. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15854. }
  15855. if m.id == nil || m.oldValue == nil {
  15856. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15857. }
  15858. oldValue, err := m.oldValue(ctx)
  15859. if err != nil {
  15860. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15861. }
  15862. return oldValue.CreatedAt, nil
  15863. }
  15864. // ResetCreatedAt resets all changes to the "created_at" field.
  15865. func (m *MessageRecordsMutation) ResetCreatedAt() {
  15866. m.created_at = nil
  15867. }
  15868. // SetUpdatedAt sets the "updated_at" field.
  15869. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  15870. m.updated_at = &t
  15871. }
  15872. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15873. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  15874. v := m.updated_at
  15875. if v == nil {
  15876. return
  15877. }
  15878. return *v, true
  15879. }
  15880. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  15881. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15882. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15883. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15884. if !m.op.Is(OpUpdateOne) {
  15885. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15886. }
  15887. if m.id == nil || m.oldValue == nil {
  15888. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15889. }
  15890. oldValue, err := m.oldValue(ctx)
  15891. if err != nil {
  15892. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15893. }
  15894. return oldValue.UpdatedAt, nil
  15895. }
  15896. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15897. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  15898. m.updated_at = nil
  15899. }
  15900. // SetStatus sets the "status" field.
  15901. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  15902. m.status = &u
  15903. m.addstatus = nil
  15904. }
  15905. // Status returns the value of the "status" field in the mutation.
  15906. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  15907. v := m.status
  15908. if v == nil {
  15909. return
  15910. }
  15911. return *v, true
  15912. }
  15913. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  15914. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15915. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15916. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15917. if !m.op.Is(OpUpdateOne) {
  15918. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15919. }
  15920. if m.id == nil || m.oldValue == nil {
  15921. return v, errors.New("OldStatus requires an ID field in the mutation")
  15922. }
  15923. oldValue, err := m.oldValue(ctx)
  15924. if err != nil {
  15925. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15926. }
  15927. return oldValue.Status, nil
  15928. }
  15929. // AddStatus adds u to the "status" field.
  15930. func (m *MessageRecordsMutation) AddStatus(u int8) {
  15931. if m.addstatus != nil {
  15932. *m.addstatus += u
  15933. } else {
  15934. m.addstatus = &u
  15935. }
  15936. }
  15937. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15938. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  15939. v := m.addstatus
  15940. if v == nil {
  15941. return
  15942. }
  15943. return *v, true
  15944. }
  15945. // ClearStatus clears the value of the "status" field.
  15946. func (m *MessageRecordsMutation) ClearStatus() {
  15947. m.status = nil
  15948. m.addstatus = nil
  15949. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  15950. }
  15951. // StatusCleared returns if the "status" field was cleared in this mutation.
  15952. func (m *MessageRecordsMutation) StatusCleared() bool {
  15953. _, ok := m.clearedFields[messagerecords.FieldStatus]
  15954. return ok
  15955. }
  15956. // ResetStatus resets all changes to the "status" field.
  15957. func (m *MessageRecordsMutation) ResetStatus() {
  15958. m.status = nil
  15959. m.addstatus = nil
  15960. delete(m.clearedFields, messagerecords.FieldStatus)
  15961. }
  15962. // SetBotWxid sets the "bot_wxid" field.
  15963. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  15964. m.bot_wxid = &s
  15965. }
  15966. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  15967. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  15968. v := m.bot_wxid
  15969. if v == nil {
  15970. return
  15971. }
  15972. return *v, true
  15973. }
  15974. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  15975. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  15976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15977. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  15978. if !m.op.Is(OpUpdateOne) {
  15979. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  15980. }
  15981. if m.id == nil || m.oldValue == nil {
  15982. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  15983. }
  15984. oldValue, err := m.oldValue(ctx)
  15985. if err != nil {
  15986. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  15987. }
  15988. return oldValue.BotWxid, nil
  15989. }
  15990. // ResetBotWxid resets all changes to the "bot_wxid" field.
  15991. func (m *MessageRecordsMutation) ResetBotWxid() {
  15992. m.bot_wxid = nil
  15993. }
  15994. // SetContactID sets the "contact_id" field.
  15995. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  15996. m.message_contact = &u
  15997. }
  15998. // ContactID returns the value of the "contact_id" field in the mutation.
  15999. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  16000. v := m.message_contact
  16001. if v == nil {
  16002. return
  16003. }
  16004. return *v, true
  16005. }
  16006. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  16007. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16009. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  16010. if !m.op.Is(OpUpdateOne) {
  16011. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  16012. }
  16013. if m.id == nil || m.oldValue == nil {
  16014. return v, errors.New("OldContactID requires an ID field in the mutation")
  16015. }
  16016. oldValue, err := m.oldValue(ctx)
  16017. if err != nil {
  16018. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  16019. }
  16020. return oldValue.ContactID, nil
  16021. }
  16022. // ClearContactID clears the value of the "contact_id" field.
  16023. func (m *MessageRecordsMutation) ClearContactID() {
  16024. m.message_contact = nil
  16025. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  16026. }
  16027. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  16028. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  16029. _, ok := m.clearedFields[messagerecords.FieldContactID]
  16030. return ok
  16031. }
  16032. // ResetContactID resets all changes to the "contact_id" field.
  16033. func (m *MessageRecordsMutation) ResetContactID() {
  16034. m.message_contact = nil
  16035. delete(m.clearedFields, messagerecords.FieldContactID)
  16036. }
  16037. // SetContactType sets the "contact_type" field.
  16038. func (m *MessageRecordsMutation) SetContactType(i int) {
  16039. m.contact_type = &i
  16040. m.addcontact_type = nil
  16041. }
  16042. // ContactType returns the value of the "contact_type" field in the mutation.
  16043. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  16044. v := m.contact_type
  16045. if v == nil {
  16046. return
  16047. }
  16048. return *v, true
  16049. }
  16050. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  16051. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16053. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  16054. if !m.op.Is(OpUpdateOne) {
  16055. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  16056. }
  16057. if m.id == nil || m.oldValue == nil {
  16058. return v, errors.New("OldContactType requires an ID field in the mutation")
  16059. }
  16060. oldValue, err := m.oldValue(ctx)
  16061. if err != nil {
  16062. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  16063. }
  16064. return oldValue.ContactType, nil
  16065. }
  16066. // AddContactType adds i to the "contact_type" field.
  16067. func (m *MessageRecordsMutation) AddContactType(i int) {
  16068. if m.addcontact_type != nil {
  16069. *m.addcontact_type += i
  16070. } else {
  16071. m.addcontact_type = &i
  16072. }
  16073. }
  16074. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  16075. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  16076. v := m.addcontact_type
  16077. if v == nil {
  16078. return
  16079. }
  16080. return *v, true
  16081. }
  16082. // ResetContactType resets all changes to the "contact_type" field.
  16083. func (m *MessageRecordsMutation) ResetContactType() {
  16084. m.contact_type = nil
  16085. m.addcontact_type = nil
  16086. }
  16087. // SetContactWxid sets the "contact_wxid" field.
  16088. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  16089. m.contact_wxid = &s
  16090. }
  16091. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  16092. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  16093. v := m.contact_wxid
  16094. if v == nil {
  16095. return
  16096. }
  16097. return *v, true
  16098. }
  16099. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  16100. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16101. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16102. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  16103. if !m.op.Is(OpUpdateOne) {
  16104. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  16105. }
  16106. if m.id == nil || m.oldValue == nil {
  16107. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  16108. }
  16109. oldValue, err := m.oldValue(ctx)
  16110. if err != nil {
  16111. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  16112. }
  16113. return oldValue.ContactWxid, nil
  16114. }
  16115. // ResetContactWxid resets all changes to the "contact_wxid" field.
  16116. func (m *MessageRecordsMutation) ResetContactWxid() {
  16117. m.contact_wxid = nil
  16118. }
  16119. // SetContentType sets the "content_type" field.
  16120. func (m *MessageRecordsMutation) SetContentType(i int) {
  16121. m.content_type = &i
  16122. m.addcontent_type = nil
  16123. }
  16124. // ContentType returns the value of the "content_type" field in the mutation.
  16125. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  16126. v := m.content_type
  16127. if v == nil {
  16128. return
  16129. }
  16130. return *v, true
  16131. }
  16132. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  16133. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16135. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  16136. if !m.op.Is(OpUpdateOne) {
  16137. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  16138. }
  16139. if m.id == nil || m.oldValue == nil {
  16140. return v, errors.New("OldContentType requires an ID field in the mutation")
  16141. }
  16142. oldValue, err := m.oldValue(ctx)
  16143. if err != nil {
  16144. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  16145. }
  16146. return oldValue.ContentType, nil
  16147. }
  16148. // AddContentType adds i to the "content_type" field.
  16149. func (m *MessageRecordsMutation) AddContentType(i int) {
  16150. if m.addcontent_type != nil {
  16151. *m.addcontent_type += i
  16152. } else {
  16153. m.addcontent_type = &i
  16154. }
  16155. }
  16156. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  16157. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  16158. v := m.addcontent_type
  16159. if v == nil {
  16160. return
  16161. }
  16162. return *v, true
  16163. }
  16164. // ResetContentType resets all changes to the "content_type" field.
  16165. func (m *MessageRecordsMutation) ResetContentType() {
  16166. m.content_type = nil
  16167. m.addcontent_type = nil
  16168. }
  16169. // SetContent sets the "content" field.
  16170. func (m *MessageRecordsMutation) SetContent(s string) {
  16171. m.content = &s
  16172. }
  16173. // Content returns the value of the "content" field in the mutation.
  16174. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  16175. v := m.content
  16176. if v == nil {
  16177. return
  16178. }
  16179. return *v, true
  16180. }
  16181. // OldContent returns the old "content" field's value of the MessageRecords entity.
  16182. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16184. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  16185. if !m.op.Is(OpUpdateOne) {
  16186. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  16187. }
  16188. if m.id == nil || m.oldValue == nil {
  16189. return v, errors.New("OldContent requires an ID field in the mutation")
  16190. }
  16191. oldValue, err := m.oldValue(ctx)
  16192. if err != nil {
  16193. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  16194. }
  16195. return oldValue.Content, nil
  16196. }
  16197. // ResetContent resets all changes to the "content" field.
  16198. func (m *MessageRecordsMutation) ResetContent() {
  16199. m.content = nil
  16200. }
  16201. // SetMeta sets the "meta" field.
  16202. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  16203. m.meta = &ct
  16204. }
  16205. // Meta returns the value of the "meta" field in the mutation.
  16206. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  16207. v := m.meta
  16208. if v == nil {
  16209. return
  16210. }
  16211. return *v, true
  16212. }
  16213. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  16214. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16215. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16216. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  16217. if !m.op.Is(OpUpdateOne) {
  16218. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  16219. }
  16220. if m.id == nil || m.oldValue == nil {
  16221. return v, errors.New("OldMeta requires an ID field in the mutation")
  16222. }
  16223. oldValue, err := m.oldValue(ctx)
  16224. if err != nil {
  16225. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  16226. }
  16227. return oldValue.Meta, nil
  16228. }
  16229. // ClearMeta clears the value of the "meta" field.
  16230. func (m *MessageRecordsMutation) ClearMeta() {
  16231. m.meta = nil
  16232. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  16233. }
  16234. // MetaCleared returns if the "meta" field was cleared in this mutation.
  16235. func (m *MessageRecordsMutation) MetaCleared() bool {
  16236. _, ok := m.clearedFields[messagerecords.FieldMeta]
  16237. return ok
  16238. }
  16239. // ResetMeta resets all changes to the "meta" field.
  16240. func (m *MessageRecordsMutation) ResetMeta() {
  16241. m.meta = nil
  16242. delete(m.clearedFields, messagerecords.FieldMeta)
  16243. }
  16244. // SetErrorDetail sets the "error_detail" field.
  16245. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  16246. m.error_detail = &s
  16247. }
  16248. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  16249. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  16250. v := m.error_detail
  16251. if v == nil {
  16252. return
  16253. }
  16254. return *v, true
  16255. }
  16256. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  16257. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16259. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  16260. if !m.op.Is(OpUpdateOne) {
  16261. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  16262. }
  16263. if m.id == nil || m.oldValue == nil {
  16264. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  16265. }
  16266. oldValue, err := m.oldValue(ctx)
  16267. if err != nil {
  16268. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  16269. }
  16270. return oldValue.ErrorDetail, nil
  16271. }
  16272. // ResetErrorDetail resets all changes to the "error_detail" field.
  16273. func (m *MessageRecordsMutation) ResetErrorDetail() {
  16274. m.error_detail = nil
  16275. }
  16276. // SetSendTime sets the "send_time" field.
  16277. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  16278. m.send_time = &t
  16279. }
  16280. // SendTime returns the value of the "send_time" field in the mutation.
  16281. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  16282. v := m.send_time
  16283. if v == nil {
  16284. return
  16285. }
  16286. return *v, true
  16287. }
  16288. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  16289. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16291. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  16292. if !m.op.Is(OpUpdateOne) {
  16293. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  16294. }
  16295. if m.id == nil || m.oldValue == nil {
  16296. return v, errors.New("OldSendTime requires an ID field in the mutation")
  16297. }
  16298. oldValue, err := m.oldValue(ctx)
  16299. if err != nil {
  16300. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  16301. }
  16302. return oldValue.SendTime, nil
  16303. }
  16304. // ClearSendTime clears the value of the "send_time" field.
  16305. func (m *MessageRecordsMutation) ClearSendTime() {
  16306. m.send_time = nil
  16307. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  16308. }
  16309. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  16310. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  16311. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  16312. return ok
  16313. }
  16314. // ResetSendTime resets all changes to the "send_time" field.
  16315. func (m *MessageRecordsMutation) ResetSendTime() {
  16316. m.send_time = nil
  16317. delete(m.clearedFields, messagerecords.FieldSendTime)
  16318. }
  16319. // SetSourceType sets the "source_type" field.
  16320. func (m *MessageRecordsMutation) SetSourceType(i int) {
  16321. m.source_type = &i
  16322. m.addsource_type = nil
  16323. }
  16324. // SourceType returns the value of the "source_type" field in the mutation.
  16325. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  16326. v := m.source_type
  16327. if v == nil {
  16328. return
  16329. }
  16330. return *v, true
  16331. }
  16332. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  16333. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16335. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  16336. if !m.op.Is(OpUpdateOne) {
  16337. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  16338. }
  16339. if m.id == nil || m.oldValue == nil {
  16340. return v, errors.New("OldSourceType requires an ID field in the mutation")
  16341. }
  16342. oldValue, err := m.oldValue(ctx)
  16343. if err != nil {
  16344. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  16345. }
  16346. return oldValue.SourceType, nil
  16347. }
  16348. // AddSourceType adds i to the "source_type" field.
  16349. func (m *MessageRecordsMutation) AddSourceType(i int) {
  16350. if m.addsource_type != nil {
  16351. *m.addsource_type += i
  16352. } else {
  16353. m.addsource_type = &i
  16354. }
  16355. }
  16356. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  16357. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  16358. v := m.addsource_type
  16359. if v == nil {
  16360. return
  16361. }
  16362. return *v, true
  16363. }
  16364. // ResetSourceType resets all changes to the "source_type" field.
  16365. func (m *MessageRecordsMutation) ResetSourceType() {
  16366. m.source_type = nil
  16367. m.addsource_type = nil
  16368. }
  16369. // SetSourceID sets the "source_id" field.
  16370. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  16371. m.sop_stage = &u
  16372. }
  16373. // SourceID returns the value of the "source_id" field in the mutation.
  16374. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  16375. v := m.sop_stage
  16376. if v == nil {
  16377. return
  16378. }
  16379. return *v, true
  16380. }
  16381. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  16382. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16383. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16384. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  16385. if !m.op.Is(OpUpdateOne) {
  16386. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  16387. }
  16388. if m.id == nil || m.oldValue == nil {
  16389. return v, errors.New("OldSourceID requires an ID field in the mutation")
  16390. }
  16391. oldValue, err := m.oldValue(ctx)
  16392. if err != nil {
  16393. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  16394. }
  16395. return oldValue.SourceID, nil
  16396. }
  16397. // ClearSourceID clears the value of the "source_id" field.
  16398. func (m *MessageRecordsMutation) ClearSourceID() {
  16399. m.sop_stage = nil
  16400. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  16401. }
  16402. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  16403. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  16404. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  16405. return ok
  16406. }
  16407. // ResetSourceID resets all changes to the "source_id" field.
  16408. func (m *MessageRecordsMutation) ResetSourceID() {
  16409. m.sop_stage = nil
  16410. delete(m.clearedFields, messagerecords.FieldSourceID)
  16411. }
  16412. // SetSubSourceID sets the "sub_source_id" field.
  16413. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  16414. m.sop_node = &u
  16415. }
  16416. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  16417. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  16418. v := m.sop_node
  16419. if v == nil {
  16420. return
  16421. }
  16422. return *v, true
  16423. }
  16424. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  16425. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16427. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  16428. if !m.op.Is(OpUpdateOne) {
  16429. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  16430. }
  16431. if m.id == nil || m.oldValue == nil {
  16432. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  16433. }
  16434. oldValue, err := m.oldValue(ctx)
  16435. if err != nil {
  16436. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  16437. }
  16438. return oldValue.SubSourceID, nil
  16439. }
  16440. // ClearSubSourceID clears the value of the "sub_source_id" field.
  16441. func (m *MessageRecordsMutation) ClearSubSourceID() {
  16442. m.sop_node = nil
  16443. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  16444. }
  16445. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  16446. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  16447. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  16448. return ok
  16449. }
  16450. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  16451. func (m *MessageRecordsMutation) ResetSubSourceID() {
  16452. m.sop_node = nil
  16453. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  16454. }
  16455. // SetOrganizationID sets the "organization_id" field.
  16456. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  16457. m.organization_id = &u
  16458. m.addorganization_id = nil
  16459. }
  16460. // OrganizationID returns the value of the "organization_id" field in the mutation.
  16461. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  16462. v := m.organization_id
  16463. if v == nil {
  16464. return
  16465. }
  16466. return *v, true
  16467. }
  16468. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  16469. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16470. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16471. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  16472. if !m.op.Is(OpUpdateOne) {
  16473. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  16474. }
  16475. if m.id == nil || m.oldValue == nil {
  16476. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  16477. }
  16478. oldValue, err := m.oldValue(ctx)
  16479. if err != nil {
  16480. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  16481. }
  16482. return oldValue.OrganizationID, nil
  16483. }
  16484. // AddOrganizationID adds u to the "organization_id" field.
  16485. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  16486. if m.addorganization_id != nil {
  16487. *m.addorganization_id += u
  16488. } else {
  16489. m.addorganization_id = &u
  16490. }
  16491. }
  16492. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  16493. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  16494. v := m.addorganization_id
  16495. if v == nil {
  16496. return
  16497. }
  16498. return *v, true
  16499. }
  16500. // ClearOrganizationID clears the value of the "organization_id" field.
  16501. func (m *MessageRecordsMutation) ClearOrganizationID() {
  16502. m.organization_id = nil
  16503. m.addorganization_id = nil
  16504. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  16505. }
  16506. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  16507. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  16508. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  16509. return ok
  16510. }
  16511. // ResetOrganizationID resets all changes to the "organization_id" field.
  16512. func (m *MessageRecordsMutation) ResetOrganizationID() {
  16513. m.organization_id = nil
  16514. m.addorganization_id = nil
  16515. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  16516. }
  16517. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  16518. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  16519. m.sop_stage = &id
  16520. }
  16521. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  16522. func (m *MessageRecordsMutation) ClearSopStage() {
  16523. m.clearedsop_stage = true
  16524. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  16525. }
  16526. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  16527. func (m *MessageRecordsMutation) SopStageCleared() bool {
  16528. return m.SourceIDCleared() || m.clearedsop_stage
  16529. }
  16530. // SopStageID returns the "sop_stage" edge ID in the mutation.
  16531. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  16532. if m.sop_stage != nil {
  16533. return *m.sop_stage, true
  16534. }
  16535. return
  16536. }
  16537. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  16538. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  16539. // SopStageID instead. It exists only for internal usage by the builders.
  16540. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  16541. if id := m.sop_stage; id != nil {
  16542. ids = append(ids, *id)
  16543. }
  16544. return
  16545. }
  16546. // ResetSopStage resets all changes to the "sop_stage" edge.
  16547. func (m *MessageRecordsMutation) ResetSopStage() {
  16548. m.sop_stage = nil
  16549. m.clearedsop_stage = false
  16550. }
  16551. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  16552. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  16553. m.sop_node = &id
  16554. }
  16555. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  16556. func (m *MessageRecordsMutation) ClearSopNode() {
  16557. m.clearedsop_node = true
  16558. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  16559. }
  16560. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  16561. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  16562. return m.SubSourceIDCleared() || m.clearedsop_node
  16563. }
  16564. // SopNodeID returns the "sop_node" edge ID in the mutation.
  16565. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  16566. if m.sop_node != nil {
  16567. return *m.sop_node, true
  16568. }
  16569. return
  16570. }
  16571. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  16572. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  16573. // SopNodeID instead. It exists only for internal usage by the builders.
  16574. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  16575. if id := m.sop_node; id != nil {
  16576. ids = append(ids, *id)
  16577. }
  16578. return
  16579. }
  16580. // ResetSopNode resets all changes to the "sop_node" edge.
  16581. func (m *MessageRecordsMutation) ResetSopNode() {
  16582. m.sop_node = nil
  16583. m.clearedsop_node = false
  16584. }
  16585. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  16586. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  16587. m.message_contact = &id
  16588. }
  16589. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  16590. func (m *MessageRecordsMutation) ClearMessageContact() {
  16591. m.clearedmessage_contact = true
  16592. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  16593. }
  16594. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  16595. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  16596. return m.ContactIDCleared() || m.clearedmessage_contact
  16597. }
  16598. // MessageContactID returns the "message_contact" edge ID in the mutation.
  16599. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  16600. if m.message_contact != nil {
  16601. return *m.message_contact, true
  16602. }
  16603. return
  16604. }
  16605. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  16606. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  16607. // MessageContactID instead. It exists only for internal usage by the builders.
  16608. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  16609. if id := m.message_contact; id != nil {
  16610. ids = append(ids, *id)
  16611. }
  16612. return
  16613. }
  16614. // ResetMessageContact resets all changes to the "message_contact" edge.
  16615. func (m *MessageRecordsMutation) ResetMessageContact() {
  16616. m.message_contact = nil
  16617. m.clearedmessage_contact = false
  16618. }
  16619. // Where appends a list predicates to the MessageRecordsMutation builder.
  16620. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  16621. m.predicates = append(m.predicates, ps...)
  16622. }
  16623. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  16624. // users can use type-assertion to append predicates that do not depend on any generated package.
  16625. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  16626. p := make([]predicate.MessageRecords, len(ps))
  16627. for i := range ps {
  16628. p[i] = ps[i]
  16629. }
  16630. m.Where(p...)
  16631. }
  16632. // Op returns the operation name.
  16633. func (m *MessageRecordsMutation) Op() Op {
  16634. return m.op
  16635. }
  16636. // SetOp allows setting the mutation operation.
  16637. func (m *MessageRecordsMutation) SetOp(op Op) {
  16638. m.op = op
  16639. }
  16640. // Type returns the node type of this mutation (MessageRecords).
  16641. func (m *MessageRecordsMutation) Type() string {
  16642. return m.typ
  16643. }
  16644. // Fields returns all fields that were changed during this mutation. Note that in
  16645. // order to get all numeric fields that were incremented/decremented, call
  16646. // AddedFields().
  16647. func (m *MessageRecordsMutation) Fields() []string {
  16648. fields := make([]string, 0, 16)
  16649. if m.created_at != nil {
  16650. fields = append(fields, messagerecords.FieldCreatedAt)
  16651. }
  16652. if m.updated_at != nil {
  16653. fields = append(fields, messagerecords.FieldUpdatedAt)
  16654. }
  16655. if m.status != nil {
  16656. fields = append(fields, messagerecords.FieldStatus)
  16657. }
  16658. if m.bot_wxid != nil {
  16659. fields = append(fields, messagerecords.FieldBotWxid)
  16660. }
  16661. if m.message_contact != nil {
  16662. fields = append(fields, messagerecords.FieldContactID)
  16663. }
  16664. if m.contact_type != nil {
  16665. fields = append(fields, messagerecords.FieldContactType)
  16666. }
  16667. if m.contact_wxid != nil {
  16668. fields = append(fields, messagerecords.FieldContactWxid)
  16669. }
  16670. if m.content_type != nil {
  16671. fields = append(fields, messagerecords.FieldContentType)
  16672. }
  16673. if m.content != nil {
  16674. fields = append(fields, messagerecords.FieldContent)
  16675. }
  16676. if m.meta != nil {
  16677. fields = append(fields, messagerecords.FieldMeta)
  16678. }
  16679. if m.error_detail != nil {
  16680. fields = append(fields, messagerecords.FieldErrorDetail)
  16681. }
  16682. if m.send_time != nil {
  16683. fields = append(fields, messagerecords.FieldSendTime)
  16684. }
  16685. if m.source_type != nil {
  16686. fields = append(fields, messagerecords.FieldSourceType)
  16687. }
  16688. if m.sop_stage != nil {
  16689. fields = append(fields, messagerecords.FieldSourceID)
  16690. }
  16691. if m.sop_node != nil {
  16692. fields = append(fields, messagerecords.FieldSubSourceID)
  16693. }
  16694. if m.organization_id != nil {
  16695. fields = append(fields, messagerecords.FieldOrganizationID)
  16696. }
  16697. return fields
  16698. }
  16699. // Field returns the value of a field with the given name. The second boolean
  16700. // return value indicates that this field was not set, or was not defined in the
  16701. // schema.
  16702. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  16703. switch name {
  16704. case messagerecords.FieldCreatedAt:
  16705. return m.CreatedAt()
  16706. case messagerecords.FieldUpdatedAt:
  16707. return m.UpdatedAt()
  16708. case messagerecords.FieldStatus:
  16709. return m.Status()
  16710. case messagerecords.FieldBotWxid:
  16711. return m.BotWxid()
  16712. case messagerecords.FieldContactID:
  16713. return m.ContactID()
  16714. case messagerecords.FieldContactType:
  16715. return m.ContactType()
  16716. case messagerecords.FieldContactWxid:
  16717. return m.ContactWxid()
  16718. case messagerecords.FieldContentType:
  16719. return m.ContentType()
  16720. case messagerecords.FieldContent:
  16721. return m.Content()
  16722. case messagerecords.FieldMeta:
  16723. return m.Meta()
  16724. case messagerecords.FieldErrorDetail:
  16725. return m.ErrorDetail()
  16726. case messagerecords.FieldSendTime:
  16727. return m.SendTime()
  16728. case messagerecords.FieldSourceType:
  16729. return m.SourceType()
  16730. case messagerecords.FieldSourceID:
  16731. return m.SourceID()
  16732. case messagerecords.FieldSubSourceID:
  16733. return m.SubSourceID()
  16734. case messagerecords.FieldOrganizationID:
  16735. return m.OrganizationID()
  16736. }
  16737. return nil, false
  16738. }
  16739. // OldField returns the old value of the field from the database. An error is
  16740. // returned if the mutation operation is not UpdateOne, or the query to the
  16741. // database failed.
  16742. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16743. switch name {
  16744. case messagerecords.FieldCreatedAt:
  16745. return m.OldCreatedAt(ctx)
  16746. case messagerecords.FieldUpdatedAt:
  16747. return m.OldUpdatedAt(ctx)
  16748. case messagerecords.FieldStatus:
  16749. return m.OldStatus(ctx)
  16750. case messagerecords.FieldBotWxid:
  16751. return m.OldBotWxid(ctx)
  16752. case messagerecords.FieldContactID:
  16753. return m.OldContactID(ctx)
  16754. case messagerecords.FieldContactType:
  16755. return m.OldContactType(ctx)
  16756. case messagerecords.FieldContactWxid:
  16757. return m.OldContactWxid(ctx)
  16758. case messagerecords.FieldContentType:
  16759. return m.OldContentType(ctx)
  16760. case messagerecords.FieldContent:
  16761. return m.OldContent(ctx)
  16762. case messagerecords.FieldMeta:
  16763. return m.OldMeta(ctx)
  16764. case messagerecords.FieldErrorDetail:
  16765. return m.OldErrorDetail(ctx)
  16766. case messagerecords.FieldSendTime:
  16767. return m.OldSendTime(ctx)
  16768. case messagerecords.FieldSourceType:
  16769. return m.OldSourceType(ctx)
  16770. case messagerecords.FieldSourceID:
  16771. return m.OldSourceID(ctx)
  16772. case messagerecords.FieldSubSourceID:
  16773. return m.OldSubSourceID(ctx)
  16774. case messagerecords.FieldOrganizationID:
  16775. return m.OldOrganizationID(ctx)
  16776. }
  16777. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  16778. }
  16779. // SetField sets the value of a field with the given name. It returns an error if
  16780. // the field is not defined in the schema, or if the type mismatched the field
  16781. // type.
  16782. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  16783. switch name {
  16784. case messagerecords.FieldCreatedAt:
  16785. v, ok := value.(time.Time)
  16786. if !ok {
  16787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16788. }
  16789. m.SetCreatedAt(v)
  16790. return nil
  16791. case messagerecords.FieldUpdatedAt:
  16792. v, ok := value.(time.Time)
  16793. if !ok {
  16794. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16795. }
  16796. m.SetUpdatedAt(v)
  16797. return nil
  16798. case messagerecords.FieldStatus:
  16799. v, ok := value.(uint8)
  16800. if !ok {
  16801. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16802. }
  16803. m.SetStatus(v)
  16804. return nil
  16805. case messagerecords.FieldBotWxid:
  16806. v, ok := value.(string)
  16807. if !ok {
  16808. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16809. }
  16810. m.SetBotWxid(v)
  16811. return nil
  16812. case messagerecords.FieldContactID:
  16813. v, ok := value.(uint64)
  16814. if !ok {
  16815. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16816. }
  16817. m.SetContactID(v)
  16818. return nil
  16819. case messagerecords.FieldContactType:
  16820. v, ok := value.(int)
  16821. if !ok {
  16822. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16823. }
  16824. m.SetContactType(v)
  16825. return nil
  16826. case messagerecords.FieldContactWxid:
  16827. v, ok := value.(string)
  16828. if !ok {
  16829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16830. }
  16831. m.SetContactWxid(v)
  16832. return nil
  16833. case messagerecords.FieldContentType:
  16834. v, ok := value.(int)
  16835. if !ok {
  16836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16837. }
  16838. m.SetContentType(v)
  16839. return nil
  16840. case messagerecords.FieldContent:
  16841. v, ok := value.(string)
  16842. if !ok {
  16843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16844. }
  16845. m.SetContent(v)
  16846. return nil
  16847. case messagerecords.FieldMeta:
  16848. v, ok := value.(custom_types.Meta)
  16849. if !ok {
  16850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16851. }
  16852. m.SetMeta(v)
  16853. return nil
  16854. case messagerecords.FieldErrorDetail:
  16855. v, ok := value.(string)
  16856. if !ok {
  16857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16858. }
  16859. m.SetErrorDetail(v)
  16860. return nil
  16861. case messagerecords.FieldSendTime:
  16862. v, ok := value.(time.Time)
  16863. if !ok {
  16864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16865. }
  16866. m.SetSendTime(v)
  16867. return nil
  16868. case messagerecords.FieldSourceType:
  16869. v, ok := value.(int)
  16870. if !ok {
  16871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16872. }
  16873. m.SetSourceType(v)
  16874. return nil
  16875. case messagerecords.FieldSourceID:
  16876. v, ok := value.(uint64)
  16877. if !ok {
  16878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16879. }
  16880. m.SetSourceID(v)
  16881. return nil
  16882. case messagerecords.FieldSubSourceID:
  16883. v, ok := value.(uint64)
  16884. if !ok {
  16885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16886. }
  16887. m.SetSubSourceID(v)
  16888. return nil
  16889. case messagerecords.FieldOrganizationID:
  16890. v, ok := value.(uint64)
  16891. if !ok {
  16892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16893. }
  16894. m.SetOrganizationID(v)
  16895. return nil
  16896. }
  16897. return fmt.Errorf("unknown MessageRecords field %s", name)
  16898. }
  16899. // AddedFields returns all numeric fields that were incremented/decremented during
  16900. // this mutation.
  16901. func (m *MessageRecordsMutation) AddedFields() []string {
  16902. var fields []string
  16903. if m.addstatus != nil {
  16904. fields = append(fields, messagerecords.FieldStatus)
  16905. }
  16906. if m.addcontact_type != nil {
  16907. fields = append(fields, messagerecords.FieldContactType)
  16908. }
  16909. if m.addcontent_type != nil {
  16910. fields = append(fields, messagerecords.FieldContentType)
  16911. }
  16912. if m.addsource_type != nil {
  16913. fields = append(fields, messagerecords.FieldSourceType)
  16914. }
  16915. if m.addorganization_id != nil {
  16916. fields = append(fields, messagerecords.FieldOrganizationID)
  16917. }
  16918. return fields
  16919. }
  16920. // AddedField returns the numeric value that was incremented/decremented on a field
  16921. // with the given name. The second boolean return value indicates that this field
  16922. // was not set, or was not defined in the schema.
  16923. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  16924. switch name {
  16925. case messagerecords.FieldStatus:
  16926. return m.AddedStatus()
  16927. case messagerecords.FieldContactType:
  16928. return m.AddedContactType()
  16929. case messagerecords.FieldContentType:
  16930. return m.AddedContentType()
  16931. case messagerecords.FieldSourceType:
  16932. return m.AddedSourceType()
  16933. case messagerecords.FieldOrganizationID:
  16934. return m.AddedOrganizationID()
  16935. }
  16936. return nil, false
  16937. }
  16938. // AddField adds the value to the field with the given name. It returns an error if
  16939. // the field is not defined in the schema, or if the type mismatched the field
  16940. // type.
  16941. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  16942. switch name {
  16943. case messagerecords.FieldStatus:
  16944. v, ok := value.(int8)
  16945. if !ok {
  16946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16947. }
  16948. m.AddStatus(v)
  16949. return nil
  16950. case messagerecords.FieldContactType:
  16951. v, ok := value.(int)
  16952. if !ok {
  16953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16954. }
  16955. m.AddContactType(v)
  16956. return nil
  16957. case messagerecords.FieldContentType:
  16958. v, ok := value.(int)
  16959. if !ok {
  16960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16961. }
  16962. m.AddContentType(v)
  16963. return nil
  16964. case messagerecords.FieldSourceType:
  16965. v, ok := value.(int)
  16966. if !ok {
  16967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16968. }
  16969. m.AddSourceType(v)
  16970. return nil
  16971. case messagerecords.FieldOrganizationID:
  16972. v, ok := value.(int64)
  16973. if !ok {
  16974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16975. }
  16976. m.AddOrganizationID(v)
  16977. return nil
  16978. }
  16979. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  16980. }
  16981. // ClearedFields returns all nullable fields that were cleared during this
  16982. // mutation.
  16983. func (m *MessageRecordsMutation) ClearedFields() []string {
  16984. var fields []string
  16985. if m.FieldCleared(messagerecords.FieldStatus) {
  16986. fields = append(fields, messagerecords.FieldStatus)
  16987. }
  16988. if m.FieldCleared(messagerecords.FieldContactID) {
  16989. fields = append(fields, messagerecords.FieldContactID)
  16990. }
  16991. if m.FieldCleared(messagerecords.FieldMeta) {
  16992. fields = append(fields, messagerecords.FieldMeta)
  16993. }
  16994. if m.FieldCleared(messagerecords.FieldSendTime) {
  16995. fields = append(fields, messagerecords.FieldSendTime)
  16996. }
  16997. if m.FieldCleared(messagerecords.FieldSourceID) {
  16998. fields = append(fields, messagerecords.FieldSourceID)
  16999. }
  17000. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  17001. fields = append(fields, messagerecords.FieldSubSourceID)
  17002. }
  17003. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  17004. fields = append(fields, messagerecords.FieldOrganizationID)
  17005. }
  17006. return fields
  17007. }
  17008. // FieldCleared returns a boolean indicating if a field with the given name was
  17009. // cleared in this mutation.
  17010. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  17011. _, ok := m.clearedFields[name]
  17012. return ok
  17013. }
  17014. // ClearField clears the value of the field with the given name. It returns an
  17015. // error if the field is not defined in the schema.
  17016. func (m *MessageRecordsMutation) ClearField(name string) error {
  17017. switch name {
  17018. case messagerecords.FieldStatus:
  17019. m.ClearStatus()
  17020. return nil
  17021. case messagerecords.FieldContactID:
  17022. m.ClearContactID()
  17023. return nil
  17024. case messagerecords.FieldMeta:
  17025. m.ClearMeta()
  17026. return nil
  17027. case messagerecords.FieldSendTime:
  17028. m.ClearSendTime()
  17029. return nil
  17030. case messagerecords.FieldSourceID:
  17031. m.ClearSourceID()
  17032. return nil
  17033. case messagerecords.FieldSubSourceID:
  17034. m.ClearSubSourceID()
  17035. return nil
  17036. case messagerecords.FieldOrganizationID:
  17037. m.ClearOrganizationID()
  17038. return nil
  17039. }
  17040. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  17041. }
  17042. // ResetField resets all changes in the mutation for the field with the given name.
  17043. // It returns an error if the field is not defined in the schema.
  17044. func (m *MessageRecordsMutation) ResetField(name string) error {
  17045. switch name {
  17046. case messagerecords.FieldCreatedAt:
  17047. m.ResetCreatedAt()
  17048. return nil
  17049. case messagerecords.FieldUpdatedAt:
  17050. m.ResetUpdatedAt()
  17051. return nil
  17052. case messagerecords.FieldStatus:
  17053. m.ResetStatus()
  17054. return nil
  17055. case messagerecords.FieldBotWxid:
  17056. m.ResetBotWxid()
  17057. return nil
  17058. case messagerecords.FieldContactID:
  17059. m.ResetContactID()
  17060. return nil
  17061. case messagerecords.FieldContactType:
  17062. m.ResetContactType()
  17063. return nil
  17064. case messagerecords.FieldContactWxid:
  17065. m.ResetContactWxid()
  17066. return nil
  17067. case messagerecords.FieldContentType:
  17068. m.ResetContentType()
  17069. return nil
  17070. case messagerecords.FieldContent:
  17071. m.ResetContent()
  17072. return nil
  17073. case messagerecords.FieldMeta:
  17074. m.ResetMeta()
  17075. return nil
  17076. case messagerecords.FieldErrorDetail:
  17077. m.ResetErrorDetail()
  17078. return nil
  17079. case messagerecords.FieldSendTime:
  17080. m.ResetSendTime()
  17081. return nil
  17082. case messagerecords.FieldSourceType:
  17083. m.ResetSourceType()
  17084. return nil
  17085. case messagerecords.FieldSourceID:
  17086. m.ResetSourceID()
  17087. return nil
  17088. case messagerecords.FieldSubSourceID:
  17089. m.ResetSubSourceID()
  17090. return nil
  17091. case messagerecords.FieldOrganizationID:
  17092. m.ResetOrganizationID()
  17093. return nil
  17094. }
  17095. return fmt.Errorf("unknown MessageRecords field %s", name)
  17096. }
  17097. // AddedEdges returns all edge names that were set/added in this mutation.
  17098. func (m *MessageRecordsMutation) AddedEdges() []string {
  17099. edges := make([]string, 0, 3)
  17100. if m.sop_stage != nil {
  17101. edges = append(edges, messagerecords.EdgeSopStage)
  17102. }
  17103. if m.sop_node != nil {
  17104. edges = append(edges, messagerecords.EdgeSopNode)
  17105. }
  17106. if m.message_contact != nil {
  17107. edges = append(edges, messagerecords.EdgeMessageContact)
  17108. }
  17109. return edges
  17110. }
  17111. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17112. // name in this mutation.
  17113. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  17114. switch name {
  17115. case messagerecords.EdgeSopStage:
  17116. if id := m.sop_stage; id != nil {
  17117. return []ent.Value{*id}
  17118. }
  17119. case messagerecords.EdgeSopNode:
  17120. if id := m.sop_node; id != nil {
  17121. return []ent.Value{*id}
  17122. }
  17123. case messagerecords.EdgeMessageContact:
  17124. if id := m.message_contact; id != nil {
  17125. return []ent.Value{*id}
  17126. }
  17127. }
  17128. return nil
  17129. }
  17130. // RemovedEdges returns all edge names that were removed in this mutation.
  17131. func (m *MessageRecordsMutation) RemovedEdges() []string {
  17132. edges := make([]string, 0, 3)
  17133. return edges
  17134. }
  17135. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17136. // the given name in this mutation.
  17137. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  17138. return nil
  17139. }
  17140. // ClearedEdges returns all edge names that were cleared in this mutation.
  17141. func (m *MessageRecordsMutation) ClearedEdges() []string {
  17142. edges := make([]string, 0, 3)
  17143. if m.clearedsop_stage {
  17144. edges = append(edges, messagerecords.EdgeSopStage)
  17145. }
  17146. if m.clearedsop_node {
  17147. edges = append(edges, messagerecords.EdgeSopNode)
  17148. }
  17149. if m.clearedmessage_contact {
  17150. edges = append(edges, messagerecords.EdgeMessageContact)
  17151. }
  17152. return edges
  17153. }
  17154. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17155. // was cleared in this mutation.
  17156. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  17157. switch name {
  17158. case messagerecords.EdgeSopStage:
  17159. return m.clearedsop_stage
  17160. case messagerecords.EdgeSopNode:
  17161. return m.clearedsop_node
  17162. case messagerecords.EdgeMessageContact:
  17163. return m.clearedmessage_contact
  17164. }
  17165. return false
  17166. }
  17167. // ClearEdge clears the value of the edge with the given name. It returns an error
  17168. // if that edge is not defined in the schema.
  17169. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  17170. switch name {
  17171. case messagerecords.EdgeSopStage:
  17172. m.ClearSopStage()
  17173. return nil
  17174. case messagerecords.EdgeSopNode:
  17175. m.ClearSopNode()
  17176. return nil
  17177. case messagerecords.EdgeMessageContact:
  17178. m.ClearMessageContact()
  17179. return nil
  17180. }
  17181. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  17182. }
  17183. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17184. // It returns an error if the edge is not defined in the schema.
  17185. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  17186. switch name {
  17187. case messagerecords.EdgeSopStage:
  17188. m.ResetSopStage()
  17189. return nil
  17190. case messagerecords.EdgeSopNode:
  17191. m.ResetSopNode()
  17192. return nil
  17193. case messagerecords.EdgeMessageContact:
  17194. m.ResetMessageContact()
  17195. return nil
  17196. }
  17197. return fmt.Errorf("unknown MessageRecords edge %s", name)
  17198. }
  17199. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  17200. type MsgMutation struct {
  17201. config
  17202. op Op
  17203. typ string
  17204. id *uint64
  17205. created_at *time.Time
  17206. updated_at *time.Time
  17207. deleted_at *time.Time
  17208. status *uint8
  17209. addstatus *int8
  17210. fromwxid *string
  17211. toid *string
  17212. msgtype *int32
  17213. addmsgtype *int32
  17214. msg *string
  17215. batch_no *string
  17216. clearedFields map[string]struct{}
  17217. done bool
  17218. oldValue func(context.Context) (*Msg, error)
  17219. predicates []predicate.Msg
  17220. }
  17221. var _ ent.Mutation = (*MsgMutation)(nil)
  17222. // msgOption allows management of the mutation configuration using functional options.
  17223. type msgOption func(*MsgMutation)
  17224. // newMsgMutation creates new mutation for the Msg entity.
  17225. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  17226. m := &MsgMutation{
  17227. config: c,
  17228. op: op,
  17229. typ: TypeMsg,
  17230. clearedFields: make(map[string]struct{}),
  17231. }
  17232. for _, opt := range opts {
  17233. opt(m)
  17234. }
  17235. return m
  17236. }
  17237. // withMsgID sets the ID field of the mutation.
  17238. func withMsgID(id uint64) msgOption {
  17239. return func(m *MsgMutation) {
  17240. var (
  17241. err error
  17242. once sync.Once
  17243. value *Msg
  17244. )
  17245. m.oldValue = func(ctx context.Context) (*Msg, error) {
  17246. once.Do(func() {
  17247. if m.done {
  17248. err = errors.New("querying old values post mutation is not allowed")
  17249. } else {
  17250. value, err = m.Client().Msg.Get(ctx, id)
  17251. }
  17252. })
  17253. return value, err
  17254. }
  17255. m.id = &id
  17256. }
  17257. }
  17258. // withMsg sets the old Msg of the mutation.
  17259. func withMsg(node *Msg) msgOption {
  17260. return func(m *MsgMutation) {
  17261. m.oldValue = func(context.Context) (*Msg, error) {
  17262. return node, nil
  17263. }
  17264. m.id = &node.ID
  17265. }
  17266. }
  17267. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17268. // executed in a transaction (ent.Tx), a transactional client is returned.
  17269. func (m MsgMutation) Client() *Client {
  17270. client := &Client{config: m.config}
  17271. client.init()
  17272. return client
  17273. }
  17274. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17275. // it returns an error otherwise.
  17276. func (m MsgMutation) Tx() (*Tx, error) {
  17277. if _, ok := m.driver.(*txDriver); !ok {
  17278. return nil, errors.New("ent: mutation is not running in a transaction")
  17279. }
  17280. tx := &Tx{config: m.config}
  17281. tx.init()
  17282. return tx, nil
  17283. }
  17284. // SetID sets the value of the id field. Note that this
  17285. // operation is only accepted on creation of Msg entities.
  17286. func (m *MsgMutation) SetID(id uint64) {
  17287. m.id = &id
  17288. }
  17289. // ID returns the ID value in the mutation. Note that the ID is only available
  17290. // if it was provided to the builder or after it was returned from the database.
  17291. func (m *MsgMutation) ID() (id uint64, exists bool) {
  17292. if m.id == nil {
  17293. return
  17294. }
  17295. return *m.id, true
  17296. }
  17297. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17298. // That means, if the mutation is applied within a transaction with an isolation level such
  17299. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17300. // or updated by the mutation.
  17301. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  17302. switch {
  17303. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17304. id, exists := m.ID()
  17305. if exists {
  17306. return []uint64{id}, nil
  17307. }
  17308. fallthrough
  17309. case m.op.Is(OpUpdate | OpDelete):
  17310. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  17311. default:
  17312. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17313. }
  17314. }
  17315. // SetCreatedAt sets the "created_at" field.
  17316. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  17317. m.created_at = &t
  17318. }
  17319. // CreatedAt returns the value of the "created_at" field in the mutation.
  17320. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  17321. v := m.created_at
  17322. if v == nil {
  17323. return
  17324. }
  17325. return *v, true
  17326. }
  17327. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  17328. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  17329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17330. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17331. if !m.op.Is(OpUpdateOne) {
  17332. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17333. }
  17334. if m.id == nil || m.oldValue == nil {
  17335. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17336. }
  17337. oldValue, err := m.oldValue(ctx)
  17338. if err != nil {
  17339. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17340. }
  17341. return oldValue.CreatedAt, nil
  17342. }
  17343. // ResetCreatedAt resets all changes to the "created_at" field.
  17344. func (m *MsgMutation) ResetCreatedAt() {
  17345. m.created_at = nil
  17346. }
  17347. // SetUpdatedAt sets the "updated_at" field.
  17348. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  17349. m.updated_at = &t
  17350. }
  17351. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17352. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  17353. v := m.updated_at
  17354. if v == nil {
  17355. return
  17356. }
  17357. return *v, true
  17358. }
  17359. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  17360. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  17361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17362. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17363. if !m.op.Is(OpUpdateOne) {
  17364. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17365. }
  17366. if m.id == nil || m.oldValue == nil {
  17367. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17368. }
  17369. oldValue, err := m.oldValue(ctx)
  17370. if err != nil {
  17371. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17372. }
  17373. return oldValue.UpdatedAt, nil
  17374. }
  17375. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17376. func (m *MsgMutation) ResetUpdatedAt() {
  17377. m.updated_at = nil
  17378. }
  17379. // SetDeletedAt sets the "deleted_at" field.
  17380. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  17381. m.deleted_at = &t
  17382. }
  17383. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17384. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  17385. v := m.deleted_at
  17386. if v == nil {
  17387. return
  17388. }
  17389. return *v, true
  17390. }
  17391. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  17392. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  17393. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17394. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17395. if !m.op.Is(OpUpdateOne) {
  17396. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17397. }
  17398. if m.id == nil || m.oldValue == nil {
  17399. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17400. }
  17401. oldValue, err := m.oldValue(ctx)
  17402. if err != nil {
  17403. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17404. }
  17405. return oldValue.DeletedAt, nil
  17406. }
  17407. // ClearDeletedAt clears the value of the "deleted_at" field.
  17408. func (m *MsgMutation) ClearDeletedAt() {
  17409. m.deleted_at = nil
  17410. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  17411. }
  17412. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17413. func (m *MsgMutation) DeletedAtCleared() bool {
  17414. _, ok := m.clearedFields[msg.FieldDeletedAt]
  17415. return ok
  17416. }
  17417. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17418. func (m *MsgMutation) ResetDeletedAt() {
  17419. m.deleted_at = nil
  17420. delete(m.clearedFields, msg.FieldDeletedAt)
  17421. }
  17422. // SetStatus sets the "status" field.
  17423. func (m *MsgMutation) SetStatus(u uint8) {
  17424. m.status = &u
  17425. m.addstatus = nil
  17426. }
  17427. // Status returns the value of the "status" field in the mutation.
  17428. func (m *MsgMutation) Status() (r uint8, exists bool) {
  17429. v := m.status
  17430. if v == nil {
  17431. return
  17432. }
  17433. return *v, true
  17434. }
  17435. // OldStatus returns the old "status" field's value of the Msg entity.
  17436. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  17437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17438. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17439. if !m.op.Is(OpUpdateOne) {
  17440. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17441. }
  17442. if m.id == nil || m.oldValue == nil {
  17443. return v, errors.New("OldStatus requires an ID field in the mutation")
  17444. }
  17445. oldValue, err := m.oldValue(ctx)
  17446. if err != nil {
  17447. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17448. }
  17449. return oldValue.Status, nil
  17450. }
  17451. // AddStatus adds u to the "status" field.
  17452. func (m *MsgMutation) AddStatus(u int8) {
  17453. if m.addstatus != nil {
  17454. *m.addstatus += u
  17455. } else {
  17456. m.addstatus = &u
  17457. }
  17458. }
  17459. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17460. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  17461. v := m.addstatus
  17462. if v == nil {
  17463. return
  17464. }
  17465. return *v, true
  17466. }
  17467. // ClearStatus clears the value of the "status" field.
  17468. func (m *MsgMutation) ClearStatus() {
  17469. m.status = nil
  17470. m.addstatus = nil
  17471. m.clearedFields[msg.FieldStatus] = struct{}{}
  17472. }
  17473. // StatusCleared returns if the "status" field was cleared in this mutation.
  17474. func (m *MsgMutation) StatusCleared() bool {
  17475. _, ok := m.clearedFields[msg.FieldStatus]
  17476. return ok
  17477. }
  17478. // ResetStatus resets all changes to the "status" field.
  17479. func (m *MsgMutation) ResetStatus() {
  17480. m.status = nil
  17481. m.addstatus = nil
  17482. delete(m.clearedFields, msg.FieldStatus)
  17483. }
  17484. // SetFromwxid sets the "fromwxid" field.
  17485. func (m *MsgMutation) SetFromwxid(s string) {
  17486. m.fromwxid = &s
  17487. }
  17488. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  17489. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  17490. v := m.fromwxid
  17491. if v == nil {
  17492. return
  17493. }
  17494. return *v, true
  17495. }
  17496. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  17497. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  17498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17499. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  17500. if !m.op.Is(OpUpdateOne) {
  17501. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  17502. }
  17503. if m.id == nil || m.oldValue == nil {
  17504. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  17505. }
  17506. oldValue, err := m.oldValue(ctx)
  17507. if err != nil {
  17508. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  17509. }
  17510. return oldValue.Fromwxid, nil
  17511. }
  17512. // ClearFromwxid clears the value of the "fromwxid" field.
  17513. func (m *MsgMutation) ClearFromwxid() {
  17514. m.fromwxid = nil
  17515. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  17516. }
  17517. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  17518. func (m *MsgMutation) FromwxidCleared() bool {
  17519. _, ok := m.clearedFields[msg.FieldFromwxid]
  17520. return ok
  17521. }
  17522. // ResetFromwxid resets all changes to the "fromwxid" field.
  17523. func (m *MsgMutation) ResetFromwxid() {
  17524. m.fromwxid = nil
  17525. delete(m.clearedFields, msg.FieldFromwxid)
  17526. }
  17527. // SetToid sets the "toid" field.
  17528. func (m *MsgMutation) SetToid(s string) {
  17529. m.toid = &s
  17530. }
  17531. // Toid returns the value of the "toid" field in the mutation.
  17532. func (m *MsgMutation) Toid() (r string, exists bool) {
  17533. v := m.toid
  17534. if v == nil {
  17535. return
  17536. }
  17537. return *v, true
  17538. }
  17539. // OldToid returns the old "toid" field's value of the Msg entity.
  17540. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  17541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17542. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  17543. if !m.op.Is(OpUpdateOne) {
  17544. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  17545. }
  17546. if m.id == nil || m.oldValue == nil {
  17547. return v, errors.New("OldToid requires an ID field in the mutation")
  17548. }
  17549. oldValue, err := m.oldValue(ctx)
  17550. if err != nil {
  17551. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  17552. }
  17553. return oldValue.Toid, nil
  17554. }
  17555. // ClearToid clears the value of the "toid" field.
  17556. func (m *MsgMutation) ClearToid() {
  17557. m.toid = nil
  17558. m.clearedFields[msg.FieldToid] = struct{}{}
  17559. }
  17560. // ToidCleared returns if the "toid" field was cleared in this mutation.
  17561. func (m *MsgMutation) ToidCleared() bool {
  17562. _, ok := m.clearedFields[msg.FieldToid]
  17563. return ok
  17564. }
  17565. // ResetToid resets all changes to the "toid" field.
  17566. func (m *MsgMutation) ResetToid() {
  17567. m.toid = nil
  17568. delete(m.clearedFields, msg.FieldToid)
  17569. }
  17570. // SetMsgtype sets the "msgtype" field.
  17571. func (m *MsgMutation) SetMsgtype(i int32) {
  17572. m.msgtype = &i
  17573. m.addmsgtype = nil
  17574. }
  17575. // Msgtype returns the value of the "msgtype" field in the mutation.
  17576. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  17577. v := m.msgtype
  17578. if v == nil {
  17579. return
  17580. }
  17581. return *v, true
  17582. }
  17583. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  17584. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  17585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17586. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  17587. if !m.op.Is(OpUpdateOne) {
  17588. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  17589. }
  17590. if m.id == nil || m.oldValue == nil {
  17591. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  17592. }
  17593. oldValue, err := m.oldValue(ctx)
  17594. if err != nil {
  17595. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  17596. }
  17597. return oldValue.Msgtype, nil
  17598. }
  17599. // AddMsgtype adds i to the "msgtype" field.
  17600. func (m *MsgMutation) AddMsgtype(i int32) {
  17601. if m.addmsgtype != nil {
  17602. *m.addmsgtype += i
  17603. } else {
  17604. m.addmsgtype = &i
  17605. }
  17606. }
  17607. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  17608. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  17609. v := m.addmsgtype
  17610. if v == nil {
  17611. return
  17612. }
  17613. return *v, true
  17614. }
  17615. // ClearMsgtype clears the value of the "msgtype" field.
  17616. func (m *MsgMutation) ClearMsgtype() {
  17617. m.msgtype = nil
  17618. m.addmsgtype = nil
  17619. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  17620. }
  17621. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  17622. func (m *MsgMutation) MsgtypeCleared() bool {
  17623. _, ok := m.clearedFields[msg.FieldMsgtype]
  17624. return ok
  17625. }
  17626. // ResetMsgtype resets all changes to the "msgtype" field.
  17627. func (m *MsgMutation) ResetMsgtype() {
  17628. m.msgtype = nil
  17629. m.addmsgtype = nil
  17630. delete(m.clearedFields, msg.FieldMsgtype)
  17631. }
  17632. // SetMsg sets the "msg" field.
  17633. func (m *MsgMutation) SetMsg(s string) {
  17634. m.msg = &s
  17635. }
  17636. // Msg returns the value of the "msg" field in the mutation.
  17637. func (m *MsgMutation) Msg() (r string, exists bool) {
  17638. v := m.msg
  17639. if v == nil {
  17640. return
  17641. }
  17642. return *v, true
  17643. }
  17644. // OldMsg returns the old "msg" field's value of the Msg entity.
  17645. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  17646. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17647. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  17648. if !m.op.Is(OpUpdateOne) {
  17649. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  17650. }
  17651. if m.id == nil || m.oldValue == nil {
  17652. return v, errors.New("OldMsg requires an ID field in the mutation")
  17653. }
  17654. oldValue, err := m.oldValue(ctx)
  17655. if err != nil {
  17656. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  17657. }
  17658. return oldValue.Msg, nil
  17659. }
  17660. // ClearMsg clears the value of the "msg" field.
  17661. func (m *MsgMutation) ClearMsg() {
  17662. m.msg = nil
  17663. m.clearedFields[msg.FieldMsg] = struct{}{}
  17664. }
  17665. // MsgCleared returns if the "msg" field was cleared in this mutation.
  17666. func (m *MsgMutation) MsgCleared() bool {
  17667. _, ok := m.clearedFields[msg.FieldMsg]
  17668. return ok
  17669. }
  17670. // ResetMsg resets all changes to the "msg" field.
  17671. func (m *MsgMutation) ResetMsg() {
  17672. m.msg = nil
  17673. delete(m.clearedFields, msg.FieldMsg)
  17674. }
  17675. // SetBatchNo sets the "batch_no" field.
  17676. func (m *MsgMutation) SetBatchNo(s string) {
  17677. m.batch_no = &s
  17678. }
  17679. // BatchNo returns the value of the "batch_no" field in the mutation.
  17680. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  17681. v := m.batch_no
  17682. if v == nil {
  17683. return
  17684. }
  17685. return *v, true
  17686. }
  17687. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  17688. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  17689. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17690. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  17691. if !m.op.Is(OpUpdateOne) {
  17692. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  17693. }
  17694. if m.id == nil || m.oldValue == nil {
  17695. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  17696. }
  17697. oldValue, err := m.oldValue(ctx)
  17698. if err != nil {
  17699. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  17700. }
  17701. return oldValue.BatchNo, nil
  17702. }
  17703. // ClearBatchNo clears the value of the "batch_no" field.
  17704. func (m *MsgMutation) ClearBatchNo() {
  17705. m.batch_no = nil
  17706. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  17707. }
  17708. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  17709. func (m *MsgMutation) BatchNoCleared() bool {
  17710. _, ok := m.clearedFields[msg.FieldBatchNo]
  17711. return ok
  17712. }
  17713. // ResetBatchNo resets all changes to the "batch_no" field.
  17714. func (m *MsgMutation) ResetBatchNo() {
  17715. m.batch_no = nil
  17716. delete(m.clearedFields, msg.FieldBatchNo)
  17717. }
  17718. // Where appends a list predicates to the MsgMutation builder.
  17719. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  17720. m.predicates = append(m.predicates, ps...)
  17721. }
  17722. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  17723. // users can use type-assertion to append predicates that do not depend on any generated package.
  17724. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  17725. p := make([]predicate.Msg, len(ps))
  17726. for i := range ps {
  17727. p[i] = ps[i]
  17728. }
  17729. m.Where(p...)
  17730. }
  17731. // Op returns the operation name.
  17732. func (m *MsgMutation) Op() Op {
  17733. return m.op
  17734. }
  17735. // SetOp allows setting the mutation operation.
  17736. func (m *MsgMutation) SetOp(op Op) {
  17737. m.op = op
  17738. }
  17739. // Type returns the node type of this mutation (Msg).
  17740. func (m *MsgMutation) Type() string {
  17741. return m.typ
  17742. }
  17743. // Fields returns all fields that were changed during this mutation. Note that in
  17744. // order to get all numeric fields that were incremented/decremented, call
  17745. // AddedFields().
  17746. func (m *MsgMutation) Fields() []string {
  17747. fields := make([]string, 0, 9)
  17748. if m.created_at != nil {
  17749. fields = append(fields, msg.FieldCreatedAt)
  17750. }
  17751. if m.updated_at != nil {
  17752. fields = append(fields, msg.FieldUpdatedAt)
  17753. }
  17754. if m.deleted_at != nil {
  17755. fields = append(fields, msg.FieldDeletedAt)
  17756. }
  17757. if m.status != nil {
  17758. fields = append(fields, msg.FieldStatus)
  17759. }
  17760. if m.fromwxid != nil {
  17761. fields = append(fields, msg.FieldFromwxid)
  17762. }
  17763. if m.toid != nil {
  17764. fields = append(fields, msg.FieldToid)
  17765. }
  17766. if m.msgtype != nil {
  17767. fields = append(fields, msg.FieldMsgtype)
  17768. }
  17769. if m.msg != nil {
  17770. fields = append(fields, msg.FieldMsg)
  17771. }
  17772. if m.batch_no != nil {
  17773. fields = append(fields, msg.FieldBatchNo)
  17774. }
  17775. return fields
  17776. }
  17777. // Field returns the value of a field with the given name. The second boolean
  17778. // return value indicates that this field was not set, or was not defined in the
  17779. // schema.
  17780. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  17781. switch name {
  17782. case msg.FieldCreatedAt:
  17783. return m.CreatedAt()
  17784. case msg.FieldUpdatedAt:
  17785. return m.UpdatedAt()
  17786. case msg.FieldDeletedAt:
  17787. return m.DeletedAt()
  17788. case msg.FieldStatus:
  17789. return m.Status()
  17790. case msg.FieldFromwxid:
  17791. return m.Fromwxid()
  17792. case msg.FieldToid:
  17793. return m.Toid()
  17794. case msg.FieldMsgtype:
  17795. return m.Msgtype()
  17796. case msg.FieldMsg:
  17797. return m.Msg()
  17798. case msg.FieldBatchNo:
  17799. return m.BatchNo()
  17800. }
  17801. return nil, false
  17802. }
  17803. // OldField returns the old value of the field from the database. An error is
  17804. // returned if the mutation operation is not UpdateOne, or the query to the
  17805. // database failed.
  17806. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17807. switch name {
  17808. case msg.FieldCreatedAt:
  17809. return m.OldCreatedAt(ctx)
  17810. case msg.FieldUpdatedAt:
  17811. return m.OldUpdatedAt(ctx)
  17812. case msg.FieldDeletedAt:
  17813. return m.OldDeletedAt(ctx)
  17814. case msg.FieldStatus:
  17815. return m.OldStatus(ctx)
  17816. case msg.FieldFromwxid:
  17817. return m.OldFromwxid(ctx)
  17818. case msg.FieldToid:
  17819. return m.OldToid(ctx)
  17820. case msg.FieldMsgtype:
  17821. return m.OldMsgtype(ctx)
  17822. case msg.FieldMsg:
  17823. return m.OldMsg(ctx)
  17824. case msg.FieldBatchNo:
  17825. return m.OldBatchNo(ctx)
  17826. }
  17827. return nil, fmt.Errorf("unknown Msg field %s", name)
  17828. }
  17829. // SetField sets the value of a field with the given name. It returns an error if
  17830. // the field is not defined in the schema, or if the type mismatched the field
  17831. // type.
  17832. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  17833. switch name {
  17834. case msg.FieldCreatedAt:
  17835. v, ok := value.(time.Time)
  17836. if !ok {
  17837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17838. }
  17839. m.SetCreatedAt(v)
  17840. return nil
  17841. case msg.FieldUpdatedAt:
  17842. v, ok := value.(time.Time)
  17843. if !ok {
  17844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17845. }
  17846. m.SetUpdatedAt(v)
  17847. return nil
  17848. case msg.FieldDeletedAt:
  17849. v, ok := value.(time.Time)
  17850. if !ok {
  17851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17852. }
  17853. m.SetDeletedAt(v)
  17854. return nil
  17855. case msg.FieldStatus:
  17856. v, ok := value.(uint8)
  17857. if !ok {
  17858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17859. }
  17860. m.SetStatus(v)
  17861. return nil
  17862. case msg.FieldFromwxid:
  17863. v, ok := value.(string)
  17864. if !ok {
  17865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17866. }
  17867. m.SetFromwxid(v)
  17868. return nil
  17869. case msg.FieldToid:
  17870. v, ok := value.(string)
  17871. if !ok {
  17872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17873. }
  17874. m.SetToid(v)
  17875. return nil
  17876. case msg.FieldMsgtype:
  17877. v, ok := value.(int32)
  17878. if !ok {
  17879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17880. }
  17881. m.SetMsgtype(v)
  17882. return nil
  17883. case msg.FieldMsg:
  17884. v, ok := value.(string)
  17885. if !ok {
  17886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17887. }
  17888. m.SetMsg(v)
  17889. return nil
  17890. case msg.FieldBatchNo:
  17891. v, ok := value.(string)
  17892. if !ok {
  17893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17894. }
  17895. m.SetBatchNo(v)
  17896. return nil
  17897. }
  17898. return fmt.Errorf("unknown Msg field %s", name)
  17899. }
  17900. // AddedFields returns all numeric fields that were incremented/decremented during
  17901. // this mutation.
  17902. func (m *MsgMutation) AddedFields() []string {
  17903. var fields []string
  17904. if m.addstatus != nil {
  17905. fields = append(fields, msg.FieldStatus)
  17906. }
  17907. if m.addmsgtype != nil {
  17908. fields = append(fields, msg.FieldMsgtype)
  17909. }
  17910. return fields
  17911. }
  17912. // AddedField returns the numeric value that was incremented/decremented on a field
  17913. // with the given name. The second boolean return value indicates that this field
  17914. // was not set, or was not defined in the schema.
  17915. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  17916. switch name {
  17917. case msg.FieldStatus:
  17918. return m.AddedStatus()
  17919. case msg.FieldMsgtype:
  17920. return m.AddedMsgtype()
  17921. }
  17922. return nil, false
  17923. }
  17924. // AddField adds the value to the field with the given name. It returns an error if
  17925. // the field is not defined in the schema, or if the type mismatched the field
  17926. // type.
  17927. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  17928. switch name {
  17929. case msg.FieldStatus:
  17930. v, ok := value.(int8)
  17931. if !ok {
  17932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17933. }
  17934. m.AddStatus(v)
  17935. return nil
  17936. case msg.FieldMsgtype:
  17937. v, ok := value.(int32)
  17938. if !ok {
  17939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17940. }
  17941. m.AddMsgtype(v)
  17942. return nil
  17943. }
  17944. return fmt.Errorf("unknown Msg numeric field %s", name)
  17945. }
  17946. // ClearedFields returns all nullable fields that were cleared during this
  17947. // mutation.
  17948. func (m *MsgMutation) ClearedFields() []string {
  17949. var fields []string
  17950. if m.FieldCleared(msg.FieldDeletedAt) {
  17951. fields = append(fields, msg.FieldDeletedAt)
  17952. }
  17953. if m.FieldCleared(msg.FieldStatus) {
  17954. fields = append(fields, msg.FieldStatus)
  17955. }
  17956. if m.FieldCleared(msg.FieldFromwxid) {
  17957. fields = append(fields, msg.FieldFromwxid)
  17958. }
  17959. if m.FieldCleared(msg.FieldToid) {
  17960. fields = append(fields, msg.FieldToid)
  17961. }
  17962. if m.FieldCleared(msg.FieldMsgtype) {
  17963. fields = append(fields, msg.FieldMsgtype)
  17964. }
  17965. if m.FieldCleared(msg.FieldMsg) {
  17966. fields = append(fields, msg.FieldMsg)
  17967. }
  17968. if m.FieldCleared(msg.FieldBatchNo) {
  17969. fields = append(fields, msg.FieldBatchNo)
  17970. }
  17971. return fields
  17972. }
  17973. // FieldCleared returns a boolean indicating if a field with the given name was
  17974. // cleared in this mutation.
  17975. func (m *MsgMutation) FieldCleared(name string) bool {
  17976. _, ok := m.clearedFields[name]
  17977. return ok
  17978. }
  17979. // ClearField clears the value of the field with the given name. It returns an
  17980. // error if the field is not defined in the schema.
  17981. func (m *MsgMutation) ClearField(name string) error {
  17982. switch name {
  17983. case msg.FieldDeletedAt:
  17984. m.ClearDeletedAt()
  17985. return nil
  17986. case msg.FieldStatus:
  17987. m.ClearStatus()
  17988. return nil
  17989. case msg.FieldFromwxid:
  17990. m.ClearFromwxid()
  17991. return nil
  17992. case msg.FieldToid:
  17993. m.ClearToid()
  17994. return nil
  17995. case msg.FieldMsgtype:
  17996. m.ClearMsgtype()
  17997. return nil
  17998. case msg.FieldMsg:
  17999. m.ClearMsg()
  18000. return nil
  18001. case msg.FieldBatchNo:
  18002. m.ClearBatchNo()
  18003. return nil
  18004. }
  18005. return fmt.Errorf("unknown Msg nullable field %s", name)
  18006. }
  18007. // ResetField resets all changes in the mutation for the field with the given name.
  18008. // It returns an error if the field is not defined in the schema.
  18009. func (m *MsgMutation) ResetField(name string) error {
  18010. switch name {
  18011. case msg.FieldCreatedAt:
  18012. m.ResetCreatedAt()
  18013. return nil
  18014. case msg.FieldUpdatedAt:
  18015. m.ResetUpdatedAt()
  18016. return nil
  18017. case msg.FieldDeletedAt:
  18018. m.ResetDeletedAt()
  18019. return nil
  18020. case msg.FieldStatus:
  18021. m.ResetStatus()
  18022. return nil
  18023. case msg.FieldFromwxid:
  18024. m.ResetFromwxid()
  18025. return nil
  18026. case msg.FieldToid:
  18027. m.ResetToid()
  18028. return nil
  18029. case msg.FieldMsgtype:
  18030. m.ResetMsgtype()
  18031. return nil
  18032. case msg.FieldMsg:
  18033. m.ResetMsg()
  18034. return nil
  18035. case msg.FieldBatchNo:
  18036. m.ResetBatchNo()
  18037. return nil
  18038. }
  18039. return fmt.Errorf("unknown Msg field %s", name)
  18040. }
  18041. // AddedEdges returns all edge names that were set/added in this mutation.
  18042. func (m *MsgMutation) AddedEdges() []string {
  18043. edges := make([]string, 0, 0)
  18044. return edges
  18045. }
  18046. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18047. // name in this mutation.
  18048. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  18049. return nil
  18050. }
  18051. // RemovedEdges returns all edge names that were removed in this mutation.
  18052. func (m *MsgMutation) RemovedEdges() []string {
  18053. edges := make([]string, 0, 0)
  18054. return edges
  18055. }
  18056. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18057. // the given name in this mutation.
  18058. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  18059. return nil
  18060. }
  18061. // ClearedEdges returns all edge names that were cleared in this mutation.
  18062. func (m *MsgMutation) ClearedEdges() []string {
  18063. edges := make([]string, 0, 0)
  18064. return edges
  18065. }
  18066. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18067. // was cleared in this mutation.
  18068. func (m *MsgMutation) EdgeCleared(name string) bool {
  18069. return false
  18070. }
  18071. // ClearEdge clears the value of the edge with the given name. It returns an error
  18072. // if that edge is not defined in the schema.
  18073. func (m *MsgMutation) ClearEdge(name string) error {
  18074. return fmt.Errorf("unknown Msg unique edge %s", name)
  18075. }
  18076. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18077. // It returns an error if the edge is not defined in the schema.
  18078. func (m *MsgMutation) ResetEdge(name string) error {
  18079. return fmt.Errorf("unknown Msg edge %s", name)
  18080. }
  18081. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  18082. type PayRechargeMutation struct {
  18083. config
  18084. op Op
  18085. typ string
  18086. id *uint64
  18087. created_at *time.Time
  18088. updated_at *time.Time
  18089. deleted_at *time.Time
  18090. user_id *string
  18091. number *float32
  18092. addnumber *float32
  18093. status *int
  18094. addstatus *int
  18095. money *float32
  18096. addmoney *float32
  18097. out_trade_no *string
  18098. organization_id *uint64
  18099. addorganization_id *int64
  18100. clearedFields map[string]struct{}
  18101. done bool
  18102. oldValue func(context.Context) (*PayRecharge, error)
  18103. predicates []predicate.PayRecharge
  18104. }
  18105. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  18106. // payrechargeOption allows management of the mutation configuration using functional options.
  18107. type payrechargeOption func(*PayRechargeMutation)
  18108. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  18109. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  18110. m := &PayRechargeMutation{
  18111. config: c,
  18112. op: op,
  18113. typ: TypePayRecharge,
  18114. clearedFields: make(map[string]struct{}),
  18115. }
  18116. for _, opt := range opts {
  18117. opt(m)
  18118. }
  18119. return m
  18120. }
  18121. // withPayRechargeID sets the ID field of the mutation.
  18122. func withPayRechargeID(id uint64) payrechargeOption {
  18123. return func(m *PayRechargeMutation) {
  18124. var (
  18125. err error
  18126. once sync.Once
  18127. value *PayRecharge
  18128. )
  18129. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  18130. once.Do(func() {
  18131. if m.done {
  18132. err = errors.New("querying old values post mutation is not allowed")
  18133. } else {
  18134. value, err = m.Client().PayRecharge.Get(ctx, id)
  18135. }
  18136. })
  18137. return value, err
  18138. }
  18139. m.id = &id
  18140. }
  18141. }
  18142. // withPayRecharge sets the old PayRecharge of the mutation.
  18143. func withPayRecharge(node *PayRecharge) payrechargeOption {
  18144. return func(m *PayRechargeMutation) {
  18145. m.oldValue = func(context.Context) (*PayRecharge, error) {
  18146. return node, nil
  18147. }
  18148. m.id = &node.ID
  18149. }
  18150. }
  18151. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18152. // executed in a transaction (ent.Tx), a transactional client is returned.
  18153. func (m PayRechargeMutation) Client() *Client {
  18154. client := &Client{config: m.config}
  18155. client.init()
  18156. return client
  18157. }
  18158. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18159. // it returns an error otherwise.
  18160. func (m PayRechargeMutation) Tx() (*Tx, error) {
  18161. if _, ok := m.driver.(*txDriver); !ok {
  18162. return nil, errors.New("ent: mutation is not running in a transaction")
  18163. }
  18164. tx := &Tx{config: m.config}
  18165. tx.init()
  18166. return tx, nil
  18167. }
  18168. // SetID sets the value of the id field. Note that this
  18169. // operation is only accepted on creation of PayRecharge entities.
  18170. func (m *PayRechargeMutation) SetID(id uint64) {
  18171. m.id = &id
  18172. }
  18173. // ID returns the ID value in the mutation. Note that the ID is only available
  18174. // if it was provided to the builder or after it was returned from the database.
  18175. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  18176. if m.id == nil {
  18177. return
  18178. }
  18179. return *m.id, true
  18180. }
  18181. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18182. // That means, if the mutation is applied within a transaction with an isolation level such
  18183. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18184. // or updated by the mutation.
  18185. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  18186. switch {
  18187. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18188. id, exists := m.ID()
  18189. if exists {
  18190. return []uint64{id}, nil
  18191. }
  18192. fallthrough
  18193. case m.op.Is(OpUpdate | OpDelete):
  18194. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  18195. default:
  18196. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18197. }
  18198. }
  18199. // SetCreatedAt sets the "created_at" field.
  18200. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  18201. m.created_at = &t
  18202. }
  18203. // CreatedAt returns the value of the "created_at" field in the mutation.
  18204. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  18205. v := m.created_at
  18206. if v == nil {
  18207. return
  18208. }
  18209. return *v, true
  18210. }
  18211. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  18212. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  18213. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18214. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18215. if !m.op.Is(OpUpdateOne) {
  18216. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18217. }
  18218. if m.id == nil || m.oldValue == nil {
  18219. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18220. }
  18221. oldValue, err := m.oldValue(ctx)
  18222. if err != nil {
  18223. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18224. }
  18225. return oldValue.CreatedAt, nil
  18226. }
  18227. // ResetCreatedAt resets all changes to the "created_at" field.
  18228. func (m *PayRechargeMutation) ResetCreatedAt() {
  18229. m.created_at = nil
  18230. }
  18231. // SetUpdatedAt sets the "updated_at" field.
  18232. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  18233. m.updated_at = &t
  18234. }
  18235. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18236. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  18237. v := m.updated_at
  18238. if v == nil {
  18239. return
  18240. }
  18241. return *v, true
  18242. }
  18243. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  18244. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  18245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18246. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18247. if !m.op.Is(OpUpdateOne) {
  18248. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18249. }
  18250. if m.id == nil || m.oldValue == nil {
  18251. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18252. }
  18253. oldValue, err := m.oldValue(ctx)
  18254. if err != nil {
  18255. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18256. }
  18257. return oldValue.UpdatedAt, nil
  18258. }
  18259. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18260. func (m *PayRechargeMutation) ResetUpdatedAt() {
  18261. m.updated_at = nil
  18262. }
  18263. // SetDeletedAt sets the "deleted_at" field.
  18264. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  18265. m.deleted_at = &t
  18266. }
  18267. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18268. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  18269. v := m.deleted_at
  18270. if v == nil {
  18271. return
  18272. }
  18273. return *v, true
  18274. }
  18275. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  18276. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  18277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18278. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18279. if !m.op.Is(OpUpdateOne) {
  18280. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18281. }
  18282. if m.id == nil || m.oldValue == nil {
  18283. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18284. }
  18285. oldValue, err := m.oldValue(ctx)
  18286. if err != nil {
  18287. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18288. }
  18289. return oldValue.DeletedAt, nil
  18290. }
  18291. // ClearDeletedAt clears the value of the "deleted_at" field.
  18292. func (m *PayRechargeMutation) ClearDeletedAt() {
  18293. m.deleted_at = nil
  18294. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  18295. }
  18296. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18297. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  18298. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  18299. return ok
  18300. }
  18301. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18302. func (m *PayRechargeMutation) ResetDeletedAt() {
  18303. m.deleted_at = nil
  18304. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  18305. }
  18306. // SetUserID sets the "user_id" field.
  18307. func (m *PayRechargeMutation) SetUserID(s string) {
  18308. m.user_id = &s
  18309. }
  18310. // UserID returns the value of the "user_id" field in the mutation.
  18311. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  18312. v := m.user_id
  18313. if v == nil {
  18314. return
  18315. }
  18316. return *v, true
  18317. }
  18318. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  18319. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  18320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18321. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  18322. if !m.op.Is(OpUpdateOne) {
  18323. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  18324. }
  18325. if m.id == nil || m.oldValue == nil {
  18326. return v, errors.New("OldUserID requires an ID field in the mutation")
  18327. }
  18328. oldValue, err := m.oldValue(ctx)
  18329. if err != nil {
  18330. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  18331. }
  18332. return oldValue.UserID, nil
  18333. }
  18334. // ResetUserID resets all changes to the "user_id" field.
  18335. func (m *PayRechargeMutation) ResetUserID() {
  18336. m.user_id = nil
  18337. }
  18338. // SetNumber sets the "number" field.
  18339. func (m *PayRechargeMutation) SetNumber(f float32) {
  18340. m.number = &f
  18341. m.addnumber = nil
  18342. }
  18343. // Number returns the value of the "number" field in the mutation.
  18344. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  18345. v := m.number
  18346. if v == nil {
  18347. return
  18348. }
  18349. return *v, true
  18350. }
  18351. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  18352. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  18353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18354. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  18355. if !m.op.Is(OpUpdateOne) {
  18356. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  18357. }
  18358. if m.id == nil || m.oldValue == nil {
  18359. return v, errors.New("OldNumber requires an ID field in the mutation")
  18360. }
  18361. oldValue, err := m.oldValue(ctx)
  18362. if err != nil {
  18363. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  18364. }
  18365. return oldValue.Number, nil
  18366. }
  18367. // AddNumber adds f to the "number" field.
  18368. func (m *PayRechargeMutation) AddNumber(f float32) {
  18369. if m.addnumber != nil {
  18370. *m.addnumber += f
  18371. } else {
  18372. m.addnumber = &f
  18373. }
  18374. }
  18375. // AddedNumber returns the value that was added to the "number" field in this mutation.
  18376. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  18377. v := m.addnumber
  18378. if v == nil {
  18379. return
  18380. }
  18381. return *v, true
  18382. }
  18383. // ResetNumber resets all changes to the "number" field.
  18384. func (m *PayRechargeMutation) ResetNumber() {
  18385. m.number = nil
  18386. m.addnumber = nil
  18387. }
  18388. // SetStatus sets the "status" field.
  18389. func (m *PayRechargeMutation) SetStatus(i int) {
  18390. m.status = &i
  18391. m.addstatus = nil
  18392. }
  18393. // Status returns the value of the "status" field in the mutation.
  18394. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  18395. v := m.status
  18396. if v == nil {
  18397. return
  18398. }
  18399. return *v, true
  18400. }
  18401. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  18402. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  18403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18404. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  18405. if !m.op.Is(OpUpdateOne) {
  18406. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18407. }
  18408. if m.id == nil || m.oldValue == nil {
  18409. return v, errors.New("OldStatus requires an ID field in the mutation")
  18410. }
  18411. oldValue, err := m.oldValue(ctx)
  18412. if err != nil {
  18413. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18414. }
  18415. return oldValue.Status, nil
  18416. }
  18417. // AddStatus adds i to the "status" field.
  18418. func (m *PayRechargeMutation) AddStatus(i int) {
  18419. if m.addstatus != nil {
  18420. *m.addstatus += i
  18421. } else {
  18422. m.addstatus = &i
  18423. }
  18424. }
  18425. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18426. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  18427. v := m.addstatus
  18428. if v == nil {
  18429. return
  18430. }
  18431. return *v, true
  18432. }
  18433. // ClearStatus clears the value of the "status" field.
  18434. func (m *PayRechargeMutation) ClearStatus() {
  18435. m.status = nil
  18436. m.addstatus = nil
  18437. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  18438. }
  18439. // StatusCleared returns if the "status" field was cleared in this mutation.
  18440. func (m *PayRechargeMutation) StatusCleared() bool {
  18441. _, ok := m.clearedFields[payrecharge.FieldStatus]
  18442. return ok
  18443. }
  18444. // ResetStatus resets all changes to the "status" field.
  18445. func (m *PayRechargeMutation) ResetStatus() {
  18446. m.status = nil
  18447. m.addstatus = nil
  18448. delete(m.clearedFields, payrecharge.FieldStatus)
  18449. }
  18450. // SetMoney sets the "money" field.
  18451. func (m *PayRechargeMutation) SetMoney(f float32) {
  18452. m.money = &f
  18453. m.addmoney = nil
  18454. }
  18455. // Money returns the value of the "money" field in the mutation.
  18456. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  18457. v := m.money
  18458. if v == nil {
  18459. return
  18460. }
  18461. return *v, true
  18462. }
  18463. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  18464. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  18465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18466. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  18467. if !m.op.Is(OpUpdateOne) {
  18468. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  18469. }
  18470. if m.id == nil || m.oldValue == nil {
  18471. return v, errors.New("OldMoney requires an ID field in the mutation")
  18472. }
  18473. oldValue, err := m.oldValue(ctx)
  18474. if err != nil {
  18475. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  18476. }
  18477. return oldValue.Money, nil
  18478. }
  18479. // AddMoney adds f to the "money" field.
  18480. func (m *PayRechargeMutation) AddMoney(f float32) {
  18481. if m.addmoney != nil {
  18482. *m.addmoney += f
  18483. } else {
  18484. m.addmoney = &f
  18485. }
  18486. }
  18487. // AddedMoney returns the value that was added to the "money" field in this mutation.
  18488. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  18489. v := m.addmoney
  18490. if v == nil {
  18491. return
  18492. }
  18493. return *v, true
  18494. }
  18495. // ClearMoney clears the value of the "money" field.
  18496. func (m *PayRechargeMutation) ClearMoney() {
  18497. m.money = nil
  18498. m.addmoney = nil
  18499. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  18500. }
  18501. // MoneyCleared returns if the "money" field was cleared in this mutation.
  18502. func (m *PayRechargeMutation) MoneyCleared() bool {
  18503. _, ok := m.clearedFields[payrecharge.FieldMoney]
  18504. return ok
  18505. }
  18506. // ResetMoney resets all changes to the "money" field.
  18507. func (m *PayRechargeMutation) ResetMoney() {
  18508. m.money = nil
  18509. m.addmoney = nil
  18510. delete(m.clearedFields, payrecharge.FieldMoney)
  18511. }
  18512. // SetOutTradeNo sets the "out_trade_no" field.
  18513. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  18514. m.out_trade_no = &s
  18515. }
  18516. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  18517. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  18518. v := m.out_trade_no
  18519. if v == nil {
  18520. return
  18521. }
  18522. return *v, true
  18523. }
  18524. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  18525. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  18526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18527. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  18528. if !m.op.Is(OpUpdateOne) {
  18529. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  18530. }
  18531. if m.id == nil || m.oldValue == nil {
  18532. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  18533. }
  18534. oldValue, err := m.oldValue(ctx)
  18535. if err != nil {
  18536. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  18537. }
  18538. return oldValue.OutTradeNo, nil
  18539. }
  18540. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  18541. func (m *PayRechargeMutation) ClearOutTradeNo() {
  18542. m.out_trade_no = nil
  18543. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  18544. }
  18545. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  18546. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  18547. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  18548. return ok
  18549. }
  18550. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  18551. func (m *PayRechargeMutation) ResetOutTradeNo() {
  18552. m.out_trade_no = nil
  18553. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  18554. }
  18555. // SetOrganizationID sets the "organization_id" field.
  18556. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  18557. m.organization_id = &u
  18558. m.addorganization_id = nil
  18559. }
  18560. // OrganizationID returns the value of the "organization_id" field in the mutation.
  18561. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  18562. v := m.organization_id
  18563. if v == nil {
  18564. return
  18565. }
  18566. return *v, true
  18567. }
  18568. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  18569. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  18570. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18571. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  18572. if !m.op.Is(OpUpdateOne) {
  18573. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  18574. }
  18575. if m.id == nil || m.oldValue == nil {
  18576. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  18577. }
  18578. oldValue, err := m.oldValue(ctx)
  18579. if err != nil {
  18580. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  18581. }
  18582. return oldValue.OrganizationID, nil
  18583. }
  18584. // AddOrganizationID adds u to the "organization_id" field.
  18585. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  18586. if m.addorganization_id != nil {
  18587. *m.addorganization_id += u
  18588. } else {
  18589. m.addorganization_id = &u
  18590. }
  18591. }
  18592. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  18593. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  18594. v := m.addorganization_id
  18595. if v == nil {
  18596. return
  18597. }
  18598. return *v, true
  18599. }
  18600. // ResetOrganizationID resets all changes to the "organization_id" field.
  18601. func (m *PayRechargeMutation) ResetOrganizationID() {
  18602. m.organization_id = nil
  18603. m.addorganization_id = nil
  18604. }
  18605. // Where appends a list predicates to the PayRechargeMutation builder.
  18606. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  18607. m.predicates = append(m.predicates, ps...)
  18608. }
  18609. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  18610. // users can use type-assertion to append predicates that do not depend on any generated package.
  18611. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  18612. p := make([]predicate.PayRecharge, len(ps))
  18613. for i := range ps {
  18614. p[i] = ps[i]
  18615. }
  18616. m.Where(p...)
  18617. }
  18618. // Op returns the operation name.
  18619. func (m *PayRechargeMutation) Op() Op {
  18620. return m.op
  18621. }
  18622. // SetOp allows setting the mutation operation.
  18623. func (m *PayRechargeMutation) SetOp(op Op) {
  18624. m.op = op
  18625. }
  18626. // Type returns the node type of this mutation (PayRecharge).
  18627. func (m *PayRechargeMutation) Type() string {
  18628. return m.typ
  18629. }
  18630. // Fields returns all fields that were changed during this mutation. Note that in
  18631. // order to get all numeric fields that were incremented/decremented, call
  18632. // AddedFields().
  18633. func (m *PayRechargeMutation) Fields() []string {
  18634. fields := make([]string, 0, 9)
  18635. if m.created_at != nil {
  18636. fields = append(fields, payrecharge.FieldCreatedAt)
  18637. }
  18638. if m.updated_at != nil {
  18639. fields = append(fields, payrecharge.FieldUpdatedAt)
  18640. }
  18641. if m.deleted_at != nil {
  18642. fields = append(fields, payrecharge.FieldDeletedAt)
  18643. }
  18644. if m.user_id != nil {
  18645. fields = append(fields, payrecharge.FieldUserID)
  18646. }
  18647. if m.number != nil {
  18648. fields = append(fields, payrecharge.FieldNumber)
  18649. }
  18650. if m.status != nil {
  18651. fields = append(fields, payrecharge.FieldStatus)
  18652. }
  18653. if m.money != nil {
  18654. fields = append(fields, payrecharge.FieldMoney)
  18655. }
  18656. if m.out_trade_no != nil {
  18657. fields = append(fields, payrecharge.FieldOutTradeNo)
  18658. }
  18659. if m.organization_id != nil {
  18660. fields = append(fields, payrecharge.FieldOrganizationID)
  18661. }
  18662. return fields
  18663. }
  18664. // Field returns the value of a field with the given name. The second boolean
  18665. // return value indicates that this field was not set, or was not defined in the
  18666. // schema.
  18667. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  18668. switch name {
  18669. case payrecharge.FieldCreatedAt:
  18670. return m.CreatedAt()
  18671. case payrecharge.FieldUpdatedAt:
  18672. return m.UpdatedAt()
  18673. case payrecharge.FieldDeletedAt:
  18674. return m.DeletedAt()
  18675. case payrecharge.FieldUserID:
  18676. return m.UserID()
  18677. case payrecharge.FieldNumber:
  18678. return m.Number()
  18679. case payrecharge.FieldStatus:
  18680. return m.Status()
  18681. case payrecharge.FieldMoney:
  18682. return m.Money()
  18683. case payrecharge.FieldOutTradeNo:
  18684. return m.OutTradeNo()
  18685. case payrecharge.FieldOrganizationID:
  18686. return m.OrganizationID()
  18687. }
  18688. return nil, false
  18689. }
  18690. // OldField returns the old value of the field from the database. An error is
  18691. // returned if the mutation operation is not UpdateOne, or the query to the
  18692. // database failed.
  18693. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18694. switch name {
  18695. case payrecharge.FieldCreatedAt:
  18696. return m.OldCreatedAt(ctx)
  18697. case payrecharge.FieldUpdatedAt:
  18698. return m.OldUpdatedAt(ctx)
  18699. case payrecharge.FieldDeletedAt:
  18700. return m.OldDeletedAt(ctx)
  18701. case payrecharge.FieldUserID:
  18702. return m.OldUserID(ctx)
  18703. case payrecharge.FieldNumber:
  18704. return m.OldNumber(ctx)
  18705. case payrecharge.FieldStatus:
  18706. return m.OldStatus(ctx)
  18707. case payrecharge.FieldMoney:
  18708. return m.OldMoney(ctx)
  18709. case payrecharge.FieldOutTradeNo:
  18710. return m.OldOutTradeNo(ctx)
  18711. case payrecharge.FieldOrganizationID:
  18712. return m.OldOrganizationID(ctx)
  18713. }
  18714. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  18715. }
  18716. // SetField sets the value of a field with the given name. It returns an error if
  18717. // the field is not defined in the schema, or if the type mismatched the field
  18718. // type.
  18719. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  18720. switch name {
  18721. case payrecharge.FieldCreatedAt:
  18722. v, ok := value.(time.Time)
  18723. if !ok {
  18724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18725. }
  18726. m.SetCreatedAt(v)
  18727. return nil
  18728. case payrecharge.FieldUpdatedAt:
  18729. v, ok := value.(time.Time)
  18730. if !ok {
  18731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18732. }
  18733. m.SetUpdatedAt(v)
  18734. return nil
  18735. case payrecharge.FieldDeletedAt:
  18736. v, ok := value.(time.Time)
  18737. if !ok {
  18738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18739. }
  18740. m.SetDeletedAt(v)
  18741. return nil
  18742. case payrecharge.FieldUserID:
  18743. v, ok := value.(string)
  18744. if !ok {
  18745. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18746. }
  18747. m.SetUserID(v)
  18748. return nil
  18749. case payrecharge.FieldNumber:
  18750. v, ok := value.(float32)
  18751. if !ok {
  18752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18753. }
  18754. m.SetNumber(v)
  18755. return nil
  18756. case payrecharge.FieldStatus:
  18757. v, ok := value.(int)
  18758. if !ok {
  18759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18760. }
  18761. m.SetStatus(v)
  18762. return nil
  18763. case payrecharge.FieldMoney:
  18764. v, ok := value.(float32)
  18765. if !ok {
  18766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18767. }
  18768. m.SetMoney(v)
  18769. return nil
  18770. case payrecharge.FieldOutTradeNo:
  18771. v, ok := value.(string)
  18772. if !ok {
  18773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18774. }
  18775. m.SetOutTradeNo(v)
  18776. return nil
  18777. case payrecharge.FieldOrganizationID:
  18778. v, ok := value.(uint64)
  18779. if !ok {
  18780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18781. }
  18782. m.SetOrganizationID(v)
  18783. return nil
  18784. }
  18785. return fmt.Errorf("unknown PayRecharge field %s", name)
  18786. }
  18787. // AddedFields returns all numeric fields that were incremented/decremented during
  18788. // this mutation.
  18789. func (m *PayRechargeMutation) AddedFields() []string {
  18790. var fields []string
  18791. if m.addnumber != nil {
  18792. fields = append(fields, payrecharge.FieldNumber)
  18793. }
  18794. if m.addstatus != nil {
  18795. fields = append(fields, payrecharge.FieldStatus)
  18796. }
  18797. if m.addmoney != nil {
  18798. fields = append(fields, payrecharge.FieldMoney)
  18799. }
  18800. if m.addorganization_id != nil {
  18801. fields = append(fields, payrecharge.FieldOrganizationID)
  18802. }
  18803. return fields
  18804. }
  18805. // AddedField returns the numeric value that was incremented/decremented on a field
  18806. // with the given name. The second boolean return value indicates that this field
  18807. // was not set, or was not defined in the schema.
  18808. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  18809. switch name {
  18810. case payrecharge.FieldNumber:
  18811. return m.AddedNumber()
  18812. case payrecharge.FieldStatus:
  18813. return m.AddedStatus()
  18814. case payrecharge.FieldMoney:
  18815. return m.AddedMoney()
  18816. case payrecharge.FieldOrganizationID:
  18817. return m.AddedOrganizationID()
  18818. }
  18819. return nil, false
  18820. }
  18821. // AddField adds the value to the field with the given name. It returns an error if
  18822. // the field is not defined in the schema, or if the type mismatched the field
  18823. // type.
  18824. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  18825. switch name {
  18826. case payrecharge.FieldNumber:
  18827. v, ok := value.(float32)
  18828. if !ok {
  18829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18830. }
  18831. m.AddNumber(v)
  18832. return nil
  18833. case payrecharge.FieldStatus:
  18834. v, ok := value.(int)
  18835. if !ok {
  18836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18837. }
  18838. m.AddStatus(v)
  18839. return nil
  18840. case payrecharge.FieldMoney:
  18841. v, ok := value.(float32)
  18842. if !ok {
  18843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18844. }
  18845. m.AddMoney(v)
  18846. return nil
  18847. case payrecharge.FieldOrganizationID:
  18848. v, ok := value.(int64)
  18849. if !ok {
  18850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18851. }
  18852. m.AddOrganizationID(v)
  18853. return nil
  18854. }
  18855. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  18856. }
  18857. // ClearedFields returns all nullable fields that were cleared during this
  18858. // mutation.
  18859. func (m *PayRechargeMutation) ClearedFields() []string {
  18860. var fields []string
  18861. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  18862. fields = append(fields, payrecharge.FieldDeletedAt)
  18863. }
  18864. if m.FieldCleared(payrecharge.FieldStatus) {
  18865. fields = append(fields, payrecharge.FieldStatus)
  18866. }
  18867. if m.FieldCleared(payrecharge.FieldMoney) {
  18868. fields = append(fields, payrecharge.FieldMoney)
  18869. }
  18870. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  18871. fields = append(fields, payrecharge.FieldOutTradeNo)
  18872. }
  18873. return fields
  18874. }
  18875. // FieldCleared returns a boolean indicating if a field with the given name was
  18876. // cleared in this mutation.
  18877. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  18878. _, ok := m.clearedFields[name]
  18879. return ok
  18880. }
  18881. // ClearField clears the value of the field with the given name. It returns an
  18882. // error if the field is not defined in the schema.
  18883. func (m *PayRechargeMutation) ClearField(name string) error {
  18884. switch name {
  18885. case payrecharge.FieldDeletedAt:
  18886. m.ClearDeletedAt()
  18887. return nil
  18888. case payrecharge.FieldStatus:
  18889. m.ClearStatus()
  18890. return nil
  18891. case payrecharge.FieldMoney:
  18892. m.ClearMoney()
  18893. return nil
  18894. case payrecharge.FieldOutTradeNo:
  18895. m.ClearOutTradeNo()
  18896. return nil
  18897. }
  18898. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  18899. }
  18900. // ResetField resets all changes in the mutation for the field with the given name.
  18901. // It returns an error if the field is not defined in the schema.
  18902. func (m *PayRechargeMutation) ResetField(name string) error {
  18903. switch name {
  18904. case payrecharge.FieldCreatedAt:
  18905. m.ResetCreatedAt()
  18906. return nil
  18907. case payrecharge.FieldUpdatedAt:
  18908. m.ResetUpdatedAt()
  18909. return nil
  18910. case payrecharge.FieldDeletedAt:
  18911. m.ResetDeletedAt()
  18912. return nil
  18913. case payrecharge.FieldUserID:
  18914. m.ResetUserID()
  18915. return nil
  18916. case payrecharge.FieldNumber:
  18917. m.ResetNumber()
  18918. return nil
  18919. case payrecharge.FieldStatus:
  18920. m.ResetStatus()
  18921. return nil
  18922. case payrecharge.FieldMoney:
  18923. m.ResetMoney()
  18924. return nil
  18925. case payrecharge.FieldOutTradeNo:
  18926. m.ResetOutTradeNo()
  18927. return nil
  18928. case payrecharge.FieldOrganizationID:
  18929. m.ResetOrganizationID()
  18930. return nil
  18931. }
  18932. return fmt.Errorf("unknown PayRecharge field %s", name)
  18933. }
  18934. // AddedEdges returns all edge names that were set/added in this mutation.
  18935. func (m *PayRechargeMutation) AddedEdges() []string {
  18936. edges := make([]string, 0, 0)
  18937. return edges
  18938. }
  18939. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18940. // name in this mutation.
  18941. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  18942. return nil
  18943. }
  18944. // RemovedEdges returns all edge names that were removed in this mutation.
  18945. func (m *PayRechargeMutation) RemovedEdges() []string {
  18946. edges := make([]string, 0, 0)
  18947. return edges
  18948. }
  18949. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18950. // the given name in this mutation.
  18951. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  18952. return nil
  18953. }
  18954. // ClearedEdges returns all edge names that were cleared in this mutation.
  18955. func (m *PayRechargeMutation) ClearedEdges() []string {
  18956. edges := make([]string, 0, 0)
  18957. return edges
  18958. }
  18959. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18960. // was cleared in this mutation.
  18961. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  18962. return false
  18963. }
  18964. // ClearEdge clears the value of the edge with the given name. It returns an error
  18965. // if that edge is not defined in the schema.
  18966. func (m *PayRechargeMutation) ClearEdge(name string) error {
  18967. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  18968. }
  18969. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18970. // It returns an error if the edge is not defined in the schema.
  18971. func (m *PayRechargeMutation) ResetEdge(name string) error {
  18972. return fmt.Errorf("unknown PayRecharge edge %s", name)
  18973. }
  18974. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  18975. type ServerMutation struct {
  18976. config
  18977. op Op
  18978. typ string
  18979. id *uint64
  18980. created_at *time.Time
  18981. updated_at *time.Time
  18982. status *uint8
  18983. addstatus *int8
  18984. deleted_at *time.Time
  18985. name *string
  18986. public_ip *string
  18987. private_ip *string
  18988. admin_port *string
  18989. clearedFields map[string]struct{}
  18990. wxs map[uint64]struct{}
  18991. removedwxs map[uint64]struct{}
  18992. clearedwxs bool
  18993. done bool
  18994. oldValue func(context.Context) (*Server, error)
  18995. predicates []predicate.Server
  18996. }
  18997. var _ ent.Mutation = (*ServerMutation)(nil)
  18998. // serverOption allows management of the mutation configuration using functional options.
  18999. type serverOption func(*ServerMutation)
  19000. // newServerMutation creates new mutation for the Server entity.
  19001. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  19002. m := &ServerMutation{
  19003. config: c,
  19004. op: op,
  19005. typ: TypeServer,
  19006. clearedFields: make(map[string]struct{}),
  19007. }
  19008. for _, opt := range opts {
  19009. opt(m)
  19010. }
  19011. return m
  19012. }
  19013. // withServerID sets the ID field of the mutation.
  19014. func withServerID(id uint64) serverOption {
  19015. return func(m *ServerMutation) {
  19016. var (
  19017. err error
  19018. once sync.Once
  19019. value *Server
  19020. )
  19021. m.oldValue = func(ctx context.Context) (*Server, error) {
  19022. once.Do(func() {
  19023. if m.done {
  19024. err = errors.New("querying old values post mutation is not allowed")
  19025. } else {
  19026. value, err = m.Client().Server.Get(ctx, id)
  19027. }
  19028. })
  19029. return value, err
  19030. }
  19031. m.id = &id
  19032. }
  19033. }
  19034. // withServer sets the old Server of the mutation.
  19035. func withServer(node *Server) serverOption {
  19036. return func(m *ServerMutation) {
  19037. m.oldValue = func(context.Context) (*Server, error) {
  19038. return node, nil
  19039. }
  19040. m.id = &node.ID
  19041. }
  19042. }
  19043. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19044. // executed in a transaction (ent.Tx), a transactional client is returned.
  19045. func (m ServerMutation) Client() *Client {
  19046. client := &Client{config: m.config}
  19047. client.init()
  19048. return client
  19049. }
  19050. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19051. // it returns an error otherwise.
  19052. func (m ServerMutation) Tx() (*Tx, error) {
  19053. if _, ok := m.driver.(*txDriver); !ok {
  19054. return nil, errors.New("ent: mutation is not running in a transaction")
  19055. }
  19056. tx := &Tx{config: m.config}
  19057. tx.init()
  19058. return tx, nil
  19059. }
  19060. // SetID sets the value of the id field. Note that this
  19061. // operation is only accepted on creation of Server entities.
  19062. func (m *ServerMutation) SetID(id uint64) {
  19063. m.id = &id
  19064. }
  19065. // ID returns the ID value in the mutation. Note that the ID is only available
  19066. // if it was provided to the builder or after it was returned from the database.
  19067. func (m *ServerMutation) ID() (id uint64, exists bool) {
  19068. if m.id == nil {
  19069. return
  19070. }
  19071. return *m.id, true
  19072. }
  19073. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19074. // That means, if the mutation is applied within a transaction with an isolation level such
  19075. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19076. // or updated by the mutation.
  19077. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  19078. switch {
  19079. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19080. id, exists := m.ID()
  19081. if exists {
  19082. return []uint64{id}, nil
  19083. }
  19084. fallthrough
  19085. case m.op.Is(OpUpdate | OpDelete):
  19086. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  19087. default:
  19088. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19089. }
  19090. }
  19091. // SetCreatedAt sets the "created_at" field.
  19092. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  19093. m.created_at = &t
  19094. }
  19095. // CreatedAt returns the value of the "created_at" field in the mutation.
  19096. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  19097. v := m.created_at
  19098. if v == nil {
  19099. return
  19100. }
  19101. return *v, true
  19102. }
  19103. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  19104. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  19105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19106. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19107. if !m.op.Is(OpUpdateOne) {
  19108. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19109. }
  19110. if m.id == nil || m.oldValue == nil {
  19111. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19112. }
  19113. oldValue, err := m.oldValue(ctx)
  19114. if err != nil {
  19115. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19116. }
  19117. return oldValue.CreatedAt, nil
  19118. }
  19119. // ResetCreatedAt resets all changes to the "created_at" field.
  19120. func (m *ServerMutation) ResetCreatedAt() {
  19121. m.created_at = nil
  19122. }
  19123. // SetUpdatedAt sets the "updated_at" field.
  19124. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  19125. m.updated_at = &t
  19126. }
  19127. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19128. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  19129. v := m.updated_at
  19130. if v == nil {
  19131. return
  19132. }
  19133. return *v, true
  19134. }
  19135. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  19136. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  19137. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19138. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19139. if !m.op.Is(OpUpdateOne) {
  19140. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19141. }
  19142. if m.id == nil || m.oldValue == nil {
  19143. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19144. }
  19145. oldValue, err := m.oldValue(ctx)
  19146. if err != nil {
  19147. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19148. }
  19149. return oldValue.UpdatedAt, nil
  19150. }
  19151. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19152. func (m *ServerMutation) ResetUpdatedAt() {
  19153. m.updated_at = nil
  19154. }
  19155. // SetStatus sets the "status" field.
  19156. func (m *ServerMutation) SetStatus(u uint8) {
  19157. m.status = &u
  19158. m.addstatus = nil
  19159. }
  19160. // Status returns the value of the "status" field in the mutation.
  19161. func (m *ServerMutation) Status() (r uint8, exists bool) {
  19162. v := m.status
  19163. if v == nil {
  19164. return
  19165. }
  19166. return *v, true
  19167. }
  19168. // OldStatus returns the old "status" field's value of the Server entity.
  19169. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  19170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19171. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19172. if !m.op.Is(OpUpdateOne) {
  19173. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19174. }
  19175. if m.id == nil || m.oldValue == nil {
  19176. return v, errors.New("OldStatus requires an ID field in the mutation")
  19177. }
  19178. oldValue, err := m.oldValue(ctx)
  19179. if err != nil {
  19180. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19181. }
  19182. return oldValue.Status, nil
  19183. }
  19184. // AddStatus adds u to the "status" field.
  19185. func (m *ServerMutation) AddStatus(u int8) {
  19186. if m.addstatus != nil {
  19187. *m.addstatus += u
  19188. } else {
  19189. m.addstatus = &u
  19190. }
  19191. }
  19192. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19193. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  19194. v := m.addstatus
  19195. if v == nil {
  19196. return
  19197. }
  19198. return *v, true
  19199. }
  19200. // ClearStatus clears the value of the "status" field.
  19201. func (m *ServerMutation) ClearStatus() {
  19202. m.status = nil
  19203. m.addstatus = nil
  19204. m.clearedFields[server.FieldStatus] = struct{}{}
  19205. }
  19206. // StatusCleared returns if the "status" field was cleared in this mutation.
  19207. func (m *ServerMutation) StatusCleared() bool {
  19208. _, ok := m.clearedFields[server.FieldStatus]
  19209. return ok
  19210. }
  19211. // ResetStatus resets all changes to the "status" field.
  19212. func (m *ServerMutation) ResetStatus() {
  19213. m.status = nil
  19214. m.addstatus = nil
  19215. delete(m.clearedFields, server.FieldStatus)
  19216. }
  19217. // SetDeletedAt sets the "deleted_at" field.
  19218. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  19219. m.deleted_at = &t
  19220. }
  19221. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19222. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  19223. v := m.deleted_at
  19224. if v == nil {
  19225. return
  19226. }
  19227. return *v, true
  19228. }
  19229. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  19230. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  19231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19232. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19233. if !m.op.Is(OpUpdateOne) {
  19234. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19235. }
  19236. if m.id == nil || m.oldValue == nil {
  19237. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19238. }
  19239. oldValue, err := m.oldValue(ctx)
  19240. if err != nil {
  19241. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19242. }
  19243. return oldValue.DeletedAt, nil
  19244. }
  19245. // ClearDeletedAt clears the value of the "deleted_at" field.
  19246. func (m *ServerMutation) ClearDeletedAt() {
  19247. m.deleted_at = nil
  19248. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  19249. }
  19250. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19251. func (m *ServerMutation) DeletedAtCleared() bool {
  19252. _, ok := m.clearedFields[server.FieldDeletedAt]
  19253. return ok
  19254. }
  19255. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19256. func (m *ServerMutation) ResetDeletedAt() {
  19257. m.deleted_at = nil
  19258. delete(m.clearedFields, server.FieldDeletedAt)
  19259. }
  19260. // SetName sets the "name" field.
  19261. func (m *ServerMutation) SetName(s string) {
  19262. m.name = &s
  19263. }
  19264. // Name returns the value of the "name" field in the mutation.
  19265. func (m *ServerMutation) Name() (r string, exists bool) {
  19266. v := m.name
  19267. if v == nil {
  19268. return
  19269. }
  19270. return *v, true
  19271. }
  19272. // OldName returns the old "name" field's value of the Server entity.
  19273. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  19274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19275. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  19276. if !m.op.Is(OpUpdateOne) {
  19277. return v, errors.New("OldName is only allowed on UpdateOne operations")
  19278. }
  19279. if m.id == nil || m.oldValue == nil {
  19280. return v, errors.New("OldName requires an ID field in the mutation")
  19281. }
  19282. oldValue, err := m.oldValue(ctx)
  19283. if err != nil {
  19284. return v, fmt.Errorf("querying old value for OldName: %w", err)
  19285. }
  19286. return oldValue.Name, nil
  19287. }
  19288. // ResetName resets all changes to the "name" field.
  19289. func (m *ServerMutation) ResetName() {
  19290. m.name = nil
  19291. }
  19292. // SetPublicIP sets the "public_ip" field.
  19293. func (m *ServerMutation) SetPublicIP(s string) {
  19294. m.public_ip = &s
  19295. }
  19296. // PublicIP returns the value of the "public_ip" field in the mutation.
  19297. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  19298. v := m.public_ip
  19299. if v == nil {
  19300. return
  19301. }
  19302. return *v, true
  19303. }
  19304. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  19305. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  19306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19307. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  19308. if !m.op.Is(OpUpdateOne) {
  19309. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  19310. }
  19311. if m.id == nil || m.oldValue == nil {
  19312. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  19313. }
  19314. oldValue, err := m.oldValue(ctx)
  19315. if err != nil {
  19316. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  19317. }
  19318. return oldValue.PublicIP, nil
  19319. }
  19320. // ResetPublicIP resets all changes to the "public_ip" field.
  19321. func (m *ServerMutation) ResetPublicIP() {
  19322. m.public_ip = nil
  19323. }
  19324. // SetPrivateIP sets the "private_ip" field.
  19325. func (m *ServerMutation) SetPrivateIP(s string) {
  19326. m.private_ip = &s
  19327. }
  19328. // PrivateIP returns the value of the "private_ip" field in the mutation.
  19329. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  19330. v := m.private_ip
  19331. if v == nil {
  19332. return
  19333. }
  19334. return *v, true
  19335. }
  19336. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  19337. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  19338. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19339. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  19340. if !m.op.Is(OpUpdateOne) {
  19341. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  19342. }
  19343. if m.id == nil || m.oldValue == nil {
  19344. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  19345. }
  19346. oldValue, err := m.oldValue(ctx)
  19347. if err != nil {
  19348. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  19349. }
  19350. return oldValue.PrivateIP, nil
  19351. }
  19352. // ResetPrivateIP resets all changes to the "private_ip" field.
  19353. func (m *ServerMutation) ResetPrivateIP() {
  19354. m.private_ip = nil
  19355. }
  19356. // SetAdminPort sets the "admin_port" field.
  19357. func (m *ServerMutation) SetAdminPort(s string) {
  19358. m.admin_port = &s
  19359. }
  19360. // AdminPort returns the value of the "admin_port" field in the mutation.
  19361. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  19362. v := m.admin_port
  19363. if v == nil {
  19364. return
  19365. }
  19366. return *v, true
  19367. }
  19368. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  19369. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  19370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19371. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  19372. if !m.op.Is(OpUpdateOne) {
  19373. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  19374. }
  19375. if m.id == nil || m.oldValue == nil {
  19376. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  19377. }
  19378. oldValue, err := m.oldValue(ctx)
  19379. if err != nil {
  19380. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  19381. }
  19382. return oldValue.AdminPort, nil
  19383. }
  19384. // ResetAdminPort resets all changes to the "admin_port" field.
  19385. func (m *ServerMutation) ResetAdminPort() {
  19386. m.admin_port = nil
  19387. }
  19388. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  19389. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  19390. if m.wxs == nil {
  19391. m.wxs = make(map[uint64]struct{})
  19392. }
  19393. for i := range ids {
  19394. m.wxs[ids[i]] = struct{}{}
  19395. }
  19396. }
  19397. // ClearWxs clears the "wxs" edge to the Wx entity.
  19398. func (m *ServerMutation) ClearWxs() {
  19399. m.clearedwxs = true
  19400. }
  19401. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  19402. func (m *ServerMutation) WxsCleared() bool {
  19403. return m.clearedwxs
  19404. }
  19405. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  19406. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  19407. if m.removedwxs == nil {
  19408. m.removedwxs = make(map[uint64]struct{})
  19409. }
  19410. for i := range ids {
  19411. delete(m.wxs, ids[i])
  19412. m.removedwxs[ids[i]] = struct{}{}
  19413. }
  19414. }
  19415. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  19416. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  19417. for id := range m.removedwxs {
  19418. ids = append(ids, id)
  19419. }
  19420. return
  19421. }
  19422. // WxsIDs returns the "wxs" edge IDs in the mutation.
  19423. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  19424. for id := range m.wxs {
  19425. ids = append(ids, id)
  19426. }
  19427. return
  19428. }
  19429. // ResetWxs resets all changes to the "wxs" edge.
  19430. func (m *ServerMutation) ResetWxs() {
  19431. m.wxs = nil
  19432. m.clearedwxs = false
  19433. m.removedwxs = nil
  19434. }
  19435. // Where appends a list predicates to the ServerMutation builder.
  19436. func (m *ServerMutation) Where(ps ...predicate.Server) {
  19437. m.predicates = append(m.predicates, ps...)
  19438. }
  19439. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  19440. // users can use type-assertion to append predicates that do not depend on any generated package.
  19441. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  19442. p := make([]predicate.Server, len(ps))
  19443. for i := range ps {
  19444. p[i] = ps[i]
  19445. }
  19446. m.Where(p...)
  19447. }
  19448. // Op returns the operation name.
  19449. func (m *ServerMutation) Op() Op {
  19450. return m.op
  19451. }
  19452. // SetOp allows setting the mutation operation.
  19453. func (m *ServerMutation) SetOp(op Op) {
  19454. m.op = op
  19455. }
  19456. // Type returns the node type of this mutation (Server).
  19457. func (m *ServerMutation) Type() string {
  19458. return m.typ
  19459. }
  19460. // Fields returns all fields that were changed during this mutation. Note that in
  19461. // order to get all numeric fields that were incremented/decremented, call
  19462. // AddedFields().
  19463. func (m *ServerMutation) Fields() []string {
  19464. fields := make([]string, 0, 8)
  19465. if m.created_at != nil {
  19466. fields = append(fields, server.FieldCreatedAt)
  19467. }
  19468. if m.updated_at != nil {
  19469. fields = append(fields, server.FieldUpdatedAt)
  19470. }
  19471. if m.status != nil {
  19472. fields = append(fields, server.FieldStatus)
  19473. }
  19474. if m.deleted_at != nil {
  19475. fields = append(fields, server.FieldDeletedAt)
  19476. }
  19477. if m.name != nil {
  19478. fields = append(fields, server.FieldName)
  19479. }
  19480. if m.public_ip != nil {
  19481. fields = append(fields, server.FieldPublicIP)
  19482. }
  19483. if m.private_ip != nil {
  19484. fields = append(fields, server.FieldPrivateIP)
  19485. }
  19486. if m.admin_port != nil {
  19487. fields = append(fields, server.FieldAdminPort)
  19488. }
  19489. return fields
  19490. }
  19491. // Field returns the value of a field with the given name. The second boolean
  19492. // return value indicates that this field was not set, or was not defined in the
  19493. // schema.
  19494. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  19495. switch name {
  19496. case server.FieldCreatedAt:
  19497. return m.CreatedAt()
  19498. case server.FieldUpdatedAt:
  19499. return m.UpdatedAt()
  19500. case server.FieldStatus:
  19501. return m.Status()
  19502. case server.FieldDeletedAt:
  19503. return m.DeletedAt()
  19504. case server.FieldName:
  19505. return m.Name()
  19506. case server.FieldPublicIP:
  19507. return m.PublicIP()
  19508. case server.FieldPrivateIP:
  19509. return m.PrivateIP()
  19510. case server.FieldAdminPort:
  19511. return m.AdminPort()
  19512. }
  19513. return nil, false
  19514. }
  19515. // OldField returns the old value of the field from the database. An error is
  19516. // returned if the mutation operation is not UpdateOne, or the query to the
  19517. // database failed.
  19518. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19519. switch name {
  19520. case server.FieldCreatedAt:
  19521. return m.OldCreatedAt(ctx)
  19522. case server.FieldUpdatedAt:
  19523. return m.OldUpdatedAt(ctx)
  19524. case server.FieldStatus:
  19525. return m.OldStatus(ctx)
  19526. case server.FieldDeletedAt:
  19527. return m.OldDeletedAt(ctx)
  19528. case server.FieldName:
  19529. return m.OldName(ctx)
  19530. case server.FieldPublicIP:
  19531. return m.OldPublicIP(ctx)
  19532. case server.FieldPrivateIP:
  19533. return m.OldPrivateIP(ctx)
  19534. case server.FieldAdminPort:
  19535. return m.OldAdminPort(ctx)
  19536. }
  19537. return nil, fmt.Errorf("unknown Server field %s", name)
  19538. }
  19539. // SetField sets the value of a field with the given name. It returns an error if
  19540. // the field is not defined in the schema, or if the type mismatched the field
  19541. // type.
  19542. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  19543. switch name {
  19544. case server.FieldCreatedAt:
  19545. v, ok := value.(time.Time)
  19546. if !ok {
  19547. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19548. }
  19549. m.SetCreatedAt(v)
  19550. return nil
  19551. case server.FieldUpdatedAt:
  19552. v, ok := value.(time.Time)
  19553. if !ok {
  19554. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19555. }
  19556. m.SetUpdatedAt(v)
  19557. return nil
  19558. case server.FieldStatus:
  19559. v, ok := value.(uint8)
  19560. if !ok {
  19561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19562. }
  19563. m.SetStatus(v)
  19564. return nil
  19565. case server.FieldDeletedAt:
  19566. v, ok := value.(time.Time)
  19567. if !ok {
  19568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19569. }
  19570. m.SetDeletedAt(v)
  19571. return nil
  19572. case server.FieldName:
  19573. v, ok := value.(string)
  19574. if !ok {
  19575. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19576. }
  19577. m.SetName(v)
  19578. return nil
  19579. case server.FieldPublicIP:
  19580. v, ok := value.(string)
  19581. if !ok {
  19582. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19583. }
  19584. m.SetPublicIP(v)
  19585. return nil
  19586. case server.FieldPrivateIP:
  19587. v, ok := value.(string)
  19588. if !ok {
  19589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19590. }
  19591. m.SetPrivateIP(v)
  19592. return nil
  19593. case server.FieldAdminPort:
  19594. v, ok := value.(string)
  19595. if !ok {
  19596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19597. }
  19598. m.SetAdminPort(v)
  19599. return nil
  19600. }
  19601. return fmt.Errorf("unknown Server field %s", name)
  19602. }
  19603. // AddedFields returns all numeric fields that were incremented/decremented during
  19604. // this mutation.
  19605. func (m *ServerMutation) AddedFields() []string {
  19606. var fields []string
  19607. if m.addstatus != nil {
  19608. fields = append(fields, server.FieldStatus)
  19609. }
  19610. return fields
  19611. }
  19612. // AddedField returns the numeric value that was incremented/decremented on a field
  19613. // with the given name. The second boolean return value indicates that this field
  19614. // was not set, or was not defined in the schema.
  19615. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  19616. switch name {
  19617. case server.FieldStatus:
  19618. return m.AddedStatus()
  19619. }
  19620. return nil, false
  19621. }
  19622. // AddField adds the value to the field with the given name. It returns an error if
  19623. // the field is not defined in the schema, or if the type mismatched the field
  19624. // type.
  19625. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  19626. switch name {
  19627. case server.FieldStatus:
  19628. v, ok := value.(int8)
  19629. if !ok {
  19630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19631. }
  19632. m.AddStatus(v)
  19633. return nil
  19634. }
  19635. return fmt.Errorf("unknown Server numeric field %s", name)
  19636. }
  19637. // ClearedFields returns all nullable fields that were cleared during this
  19638. // mutation.
  19639. func (m *ServerMutation) ClearedFields() []string {
  19640. var fields []string
  19641. if m.FieldCleared(server.FieldStatus) {
  19642. fields = append(fields, server.FieldStatus)
  19643. }
  19644. if m.FieldCleared(server.FieldDeletedAt) {
  19645. fields = append(fields, server.FieldDeletedAt)
  19646. }
  19647. return fields
  19648. }
  19649. // FieldCleared returns a boolean indicating if a field with the given name was
  19650. // cleared in this mutation.
  19651. func (m *ServerMutation) FieldCleared(name string) bool {
  19652. _, ok := m.clearedFields[name]
  19653. return ok
  19654. }
  19655. // ClearField clears the value of the field with the given name. It returns an
  19656. // error if the field is not defined in the schema.
  19657. func (m *ServerMutation) ClearField(name string) error {
  19658. switch name {
  19659. case server.FieldStatus:
  19660. m.ClearStatus()
  19661. return nil
  19662. case server.FieldDeletedAt:
  19663. m.ClearDeletedAt()
  19664. return nil
  19665. }
  19666. return fmt.Errorf("unknown Server nullable field %s", name)
  19667. }
  19668. // ResetField resets all changes in the mutation for the field with the given name.
  19669. // It returns an error if the field is not defined in the schema.
  19670. func (m *ServerMutation) ResetField(name string) error {
  19671. switch name {
  19672. case server.FieldCreatedAt:
  19673. m.ResetCreatedAt()
  19674. return nil
  19675. case server.FieldUpdatedAt:
  19676. m.ResetUpdatedAt()
  19677. return nil
  19678. case server.FieldStatus:
  19679. m.ResetStatus()
  19680. return nil
  19681. case server.FieldDeletedAt:
  19682. m.ResetDeletedAt()
  19683. return nil
  19684. case server.FieldName:
  19685. m.ResetName()
  19686. return nil
  19687. case server.FieldPublicIP:
  19688. m.ResetPublicIP()
  19689. return nil
  19690. case server.FieldPrivateIP:
  19691. m.ResetPrivateIP()
  19692. return nil
  19693. case server.FieldAdminPort:
  19694. m.ResetAdminPort()
  19695. return nil
  19696. }
  19697. return fmt.Errorf("unknown Server field %s", name)
  19698. }
  19699. // AddedEdges returns all edge names that were set/added in this mutation.
  19700. func (m *ServerMutation) AddedEdges() []string {
  19701. edges := make([]string, 0, 1)
  19702. if m.wxs != nil {
  19703. edges = append(edges, server.EdgeWxs)
  19704. }
  19705. return edges
  19706. }
  19707. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19708. // name in this mutation.
  19709. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  19710. switch name {
  19711. case server.EdgeWxs:
  19712. ids := make([]ent.Value, 0, len(m.wxs))
  19713. for id := range m.wxs {
  19714. ids = append(ids, id)
  19715. }
  19716. return ids
  19717. }
  19718. return nil
  19719. }
  19720. // RemovedEdges returns all edge names that were removed in this mutation.
  19721. func (m *ServerMutation) RemovedEdges() []string {
  19722. edges := make([]string, 0, 1)
  19723. if m.removedwxs != nil {
  19724. edges = append(edges, server.EdgeWxs)
  19725. }
  19726. return edges
  19727. }
  19728. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19729. // the given name in this mutation.
  19730. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  19731. switch name {
  19732. case server.EdgeWxs:
  19733. ids := make([]ent.Value, 0, len(m.removedwxs))
  19734. for id := range m.removedwxs {
  19735. ids = append(ids, id)
  19736. }
  19737. return ids
  19738. }
  19739. return nil
  19740. }
  19741. // ClearedEdges returns all edge names that were cleared in this mutation.
  19742. func (m *ServerMutation) ClearedEdges() []string {
  19743. edges := make([]string, 0, 1)
  19744. if m.clearedwxs {
  19745. edges = append(edges, server.EdgeWxs)
  19746. }
  19747. return edges
  19748. }
  19749. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19750. // was cleared in this mutation.
  19751. func (m *ServerMutation) EdgeCleared(name string) bool {
  19752. switch name {
  19753. case server.EdgeWxs:
  19754. return m.clearedwxs
  19755. }
  19756. return false
  19757. }
  19758. // ClearEdge clears the value of the edge with the given name. It returns an error
  19759. // if that edge is not defined in the schema.
  19760. func (m *ServerMutation) ClearEdge(name string) error {
  19761. switch name {
  19762. }
  19763. return fmt.Errorf("unknown Server unique edge %s", name)
  19764. }
  19765. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19766. // It returns an error if the edge is not defined in the schema.
  19767. func (m *ServerMutation) ResetEdge(name string) error {
  19768. switch name {
  19769. case server.EdgeWxs:
  19770. m.ResetWxs()
  19771. return nil
  19772. }
  19773. return fmt.Errorf("unknown Server edge %s", name)
  19774. }
  19775. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  19776. type SopNodeMutation struct {
  19777. config
  19778. op Op
  19779. typ string
  19780. id *uint64
  19781. created_at *time.Time
  19782. updated_at *time.Time
  19783. status *uint8
  19784. addstatus *int8
  19785. deleted_at *time.Time
  19786. parent_id *uint64
  19787. addparent_id *int64
  19788. name *string
  19789. condition_type *int
  19790. addcondition_type *int
  19791. condition_list *[]string
  19792. appendcondition_list []string
  19793. no_reply_condition *uint64
  19794. addno_reply_condition *int64
  19795. no_reply_unit *string
  19796. action_message *[]custom_types.Action
  19797. appendaction_message []custom_types.Action
  19798. action_label_add *[]uint64
  19799. appendaction_label_add []uint64
  19800. action_label_del *[]uint64
  19801. appendaction_label_del []uint64
  19802. action_forward **custom_types.ActionForward
  19803. clearedFields map[string]struct{}
  19804. sop_stage *uint64
  19805. clearedsop_stage bool
  19806. node_messages map[uint64]struct{}
  19807. removednode_messages map[uint64]struct{}
  19808. clearednode_messages bool
  19809. done bool
  19810. oldValue func(context.Context) (*SopNode, error)
  19811. predicates []predicate.SopNode
  19812. }
  19813. var _ ent.Mutation = (*SopNodeMutation)(nil)
  19814. // sopnodeOption allows management of the mutation configuration using functional options.
  19815. type sopnodeOption func(*SopNodeMutation)
  19816. // newSopNodeMutation creates new mutation for the SopNode entity.
  19817. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  19818. m := &SopNodeMutation{
  19819. config: c,
  19820. op: op,
  19821. typ: TypeSopNode,
  19822. clearedFields: make(map[string]struct{}),
  19823. }
  19824. for _, opt := range opts {
  19825. opt(m)
  19826. }
  19827. return m
  19828. }
  19829. // withSopNodeID sets the ID field of the mutation.
  19830. func withSopNodeID(id uint64) sopnodeOption {
  19831. return func(m *SopNodeMutation) {
  19832. var (
  19833. err error
  19834. once sync.Once
  19835. value *SopNode
  19836. )
  19837. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  19838. once.Do(func() {
  19839. if m.done {
  19840. err = errors.New("querying old values post mutation is not allowed")
  19841. } else {
  19842. value, err = m.Client().SopNode.Get(ctx, id)
  19843. }
  19844. })
  19845. return value, err
  19846. }
  19847. m.id = &id
  19848. }
  19849. }
  19850. // withSopNode sets the old SopNode of the mutation.
  19851. func withSopNode(node *SopNode) sopnodeOption {
  19852. return func(m *SopNodeMutation) {
  19853. m.oldValue = func(context.Context) (*SopNode, error) {
  19854. return node, nil
  19855. }
  19856. m.id = &node.ID
  19857. }
  19858. }
  19859. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19860. // executed in a transaction (ent.Tx), a transactional client is returned.
  19861. func (m SopNodeMutation) Client() *Client {
  19862. client := &Client{config: m.config}
  19863. client.init()
  19864. return client
  19865. }
  19866. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19867. // it returns an error otherwise.
  19868. func (m SopNodeMutation) Tx() (*Tx, error) {
  19869. if _, ok := m.driver.(*txDriver); !ok {
  19870. return nil, errors.New("ent: mutation is not running in a transaction")
  19871. }
  19872. tx := &Tx{config: m.config}
  19873. tx.init()
  19874. return tx, nil
  19875. }
  19876. // SetID sets the value of the id field. Note that this
  19877. // operation is only accepted on creation of SopNode entities.
  19878. func (m *SopNodeMutation) SetID(id uint64) {
  19879. m.id = &id
  19880. }
  19881. // ID returns the ID value in the mutation. Note that the ID is only available
  19882. // if it was provided to the builder or after it was returned from the database.
  19883. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  19884. if m.id == nil {
  19885. return
  19886. }
  19887. return *m.id, true
  19888. }
  19889. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19890. // That means, if the mutation is applied within a transaction with an isolation level such
  19891. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19892. // or updated by the mutation.
  19893. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  19894. switch {
  19895. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19896. id, exists := m.ID()
  19897. if exists {
  19898. return []uint64{id}, nil
  19899. }
  19900. fallthrough
  19901. case m.op.Is(OpUpdate | OpDelete):
  19902. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  19903. default:
  19904. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19905. }
  19906. }
  19907. // SetCreatedAt sets the "created_at" field.
  19908. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  19909. m.created_at = &t
  19910. }
  19911. // CreatedAt returns the value of the "created_at" field in the mutation.
  19912. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  19913. v := m.created_at
  19914. if v == nil {
  19915. return
  19916. }
  19917. return *v, true
  19918. }
  19919. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  19920. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  19921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19922. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19923. if !m.op.Is(OpUpdateOne) {
  19924. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19925. }
  19926. if m.id == nil || m.oldValue == nil {
  19927. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19928. }
  19929. oldValue, err := m.oldValue(ctx)
  19930. if err != nil {
  19931. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19932. }
  19933. return oldValue.CreatedAt, nil
  19934. }
  19935. // ResetCreatedAt resets all changes to the "created_at" field.
  19936. func (m *SopNodeMutation) ResetCreatedAt() {
  19937. m.created_at = nil
  19938. }
  19939. // SetUpdatedAt sets the "updated_at" field.
  19940. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  19941. m.updated_at = &t
  19942. }
  19943. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19944. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  19945. v := m.updated_at
  19946. if v == nil {
  19947. return
  19948. }
  19949. return *v, true
  19950. }
  19951. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  19952. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  19953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19954. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19955. if !m.op.Is(OpUpdateOne) {
  19956. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19957. }
  19958. if m.id == nil || m.oldValue == nil {
  19959. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19960. }
  19961. oldValue, err := m.oldValue(ctx)
  19962. if err != nil {
  19963. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19964. }
  19965. return oldValue.UpdatedAt, nil
  19966. }
  19967. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19968. func (m *SopNodeMutation) ResetUpdatedAt() {
  19969. m.updated_at = nil
  19970. }
  19971. // SetStatus sets the "status" field.
  19972. func (m *SopNodeMutation) SetStatus(u uint8) {
  19973. m.status = &u
  19974. m.addstatus = nil
  19975. }
  19976. // Status returns the value of the "status" field in the mutation.
  19977. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  19978. v := m.status
  19979. if v == nil {
  19980. return
  19981. }
  19982. return *v, true
  19983. }
  19984. // OldStatus returns the old "status" field's value of the SopNode entity.
  19985. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  19986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19987. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  19988. if !m.op.Is(OpUpdateOne) {
  19989. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19990. }
  19991. if m.id == nil || m.oldValue == nil {
  19992. return v, errors.New("OldStatus requires an ID field in the mutation")
  19993. }
  19994. oldValue, err := m.oldValue(ctx)
  19995. if err != nil {
  19996. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19997. }
  19998. return oldValue.Status, nil
  19999. }
  20000. // AddStatus adds u to the "status" field.
  20001. func (m *SopNodeMutation) AddStatus(u int8) {
  20002. if m.addstatus != nil {
  20003. *m.addstatus += u
  20004. } else {
  20005. m.addstatus = &u
  20006. }
  20007. }
  20008. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20009. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  20010. v := m.addstatus
  20011. if v == nil {
  20012. return
  20013. }
  20014. return *v, true
  20015. }
  20016. // ClearStatus clears the value of the "status" field.
  20017. func (m *SopNodeMutation) ClearStatus() {
  20018. m.status = nil
  20019. m.addstatus = nil
  20020. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  20021. }
  20022. // StatusCleared returns if the "status" field was cleared in this mutation.
  20023. func (m *SopNodeMutation) StatusCleared() bool {
  20024. _, ok := m.clearedFields[sopnode.FieldStatus]
  20025. return ok
  20026. }
  20027. // ResetStatus resets all changes to the "status" field.
  20028. func (m *SopNodeMutation) ResetStatus() {
  20029. m.status = nil
  20030. m.addstatus = nil
  20031. delete(m.clearedFields, sopnode.FieldStatus)
  20032. }
  20033. // SetDeletedAt sets the "deleted_at" field.
  20034. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  20035. m.deleted_at = &t
  20036. }
  20037. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20038. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  20039. v := m.deleted_at
  20040. if v == nil {
  20041. return
  20042. }
  20043. return *v, true
  20044. }
  20045. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  20046. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20048. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20049. if !m.op.Is(OpUpdateOne) {
  20050. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20051. }
  20052. if m.id == nil || m.oldValue == nil {
  20053. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20054. }
  20055. oldValue, err := m.oldValue(ctx)
  20056. if err != nil {
  20057. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20058. }
  20059. return oldValue.DeletedAt, nil
  20060. }
  20061. // ClearDeletedAt clears the value of the "deleted_at" field.
  20062. func (m *SopNodeMutation) ClearDeletedAt() {
  20063. m.deleted_at = nil
  20064. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  20065. }
  20066. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20067. func (m *SopNodeMutation) DeletedAtCleared() bool {
  20068. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  20069. return ok
  20070. }
  20071. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20072. func (m *SopNodeMutation) ResetDeletedAt() {
  20073. m.deleted_at = nil
  20074. delete(m.clearedFields, sopnode.FieldDeletedAt)
  20075. }
  20076. // SetStageID sets the "stage_id" field.
  20077. func (m *SopNodeMutation) SetStageID(u uint64) {
  20078. m.sop_stage = &u
  20079. }
  20080. // StageID returns the value of the "stage_id" field in the mutation.
  20081. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  20082. v := m.sop_stage
  20083. if v == nil {
  20084. return
  20085. }
  20086. return *v, true
  20087. }
  20088. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  20089. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20090. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20091. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  20092. if !m.op.Is(OpUpdateOne) {
  20093. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  20094. }
  20095. if m.id == nil || m.oldValue == nil {
  20096. return v, errors.New("OldStageID requires an ID field in the mutation")
  20097. }
  20098. oldValue, err := m.oldValue(ctx)
  20099. if err != nil {
  20100. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  20101. }
  20102. return oldValue.StageID, nil
  20103. }
  20104. // ResetStageID resets all changes to the "stage_id" field.
  20105. func (m *SopNodeMutation) ResetStageID() {
  20106. m.sop_stage = nil
  20107. }
  20108. // SetParentID sets the "parent_id" field.
  20109. func (m *SopNodeMutation) SetParentID(u uint64) {
  20110. m.parent_id = &u
  20111. m.addparent_id = nil
  20112. }
  20113. // ParentID returns the value of the "parent_id" field in the mutation.
  20114. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  20115. v := m.parent_id
  20116. if v == nil {
  20117. return
  20118. }
  20119. return *v, true
  20120. }
  20121. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  20122. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20124. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  20125. if !m.op.Is(OpUpdateOne) {
  20126. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  20127. }
  20128. if m.id == nil || m.oldValue == nil {
  20129. return v, errors.New("OldParentID requires an ID field in the mutation")
  20130. }
  20131. oldValue, err := m.oldValue(ctx)
  20132. if err != nil {
  20133. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  20134. }
  20135. return oldValue.ParentID, nil
  20136. }
  20137. // AddParentID adds u to the "parent_id" field.
  20138. func (m *SopNodeMutation) AddParentID(u int64) {
  20139. if m.addparent_id != nil {
  20140. *m.addparent_id += u
  20141. } else {
  20142. m.addparent_id = &u
  20143. }
  20144. }
  20145. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  20146. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  20147. v := m.addparent_id
  20148. if v == nil {
  20149. return
  20150. }
  20151. return *v, true
  20152. }
  20153. // ResetParentID resets all changes to the "parent_id" field.
  20154. func (m *SopNodeMutation) ResetParentID() {
  20155. m.parent_id = nil
  20156. m.addparent_id = nil
  20157. }
  20158. // SetName sets the "name" field.
  20159. func (m *SopNodeMutation) SetName(s string) {
  20160. m.name = &s
  20161. }
  20162. // Name returns the value of the "name" field in the mutation.
  20163. func (m *SopNodeMutation) Name() (r string, exists bool) {
  20164. v := m.name
  20165. if v == nil {
  20166. return
  20167. }
  20168. return *v, true
  20169. }
  20170. // OldName returns the old "name" field's value of the SopNode entity.
  20171. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20173. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  20174. if !m.op.Is(OpUpdateOne) {
  20175. return v, errors.New("OldName is only allowed on UpdateOne operations")
  20176. }
  20177. if m.id == nil || m.oldValue == nil {
  20178. return v, errors.New("OldName requires an ID field in the mutation")
  20179. }
  20180. oldValue, err := m.oldValue(ctx)
  20181. if err != nil {
  20182. return v, fmt.Errorf("querying old value for OldName: %w", err)
  20183. }
  20184. return oldValue.Name, nil
  20185. }
  20186. // ResetName resets all changes to the "name" field.
  20187. func (m *SopNodeMutation) ResetName() {
  20188. m.name = nil
  20189. }
  20190. // SetConditionType sets the "condition_type" field.
  20191. func (m *SopNodeMutation) SetConditionType(i int) {
  20192. m.condition_type = &i
  20193. m.addcondition_type = nil
  20194. }
  20195. // ConditionType returns the value of the "condition_type" field in the mutation.
  20196. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  20197. v := m.condition_type
  20198. if v == nil {
  20199. return
  20200. }
  20201. return *v, true
  20202. }
  20203. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  20204. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20206. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  20207. if !m.op.Is(OpUpdateOne) {
  20208. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  20209. }
  20210. if m.id == nil || m.oldValue == nil {
  20211. return v, errors.New("OldConditionType requires an ID field in the mutation")
  20212. }
  20213. oldValue, err := m.oldValue(ctx)
  20214. if err != nil {
  20215. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  20216. }
  20217. return oldValue.ConditionType, nil
  20218. }
  20219. // AddConditionType adds i to the "condition_type" field.
  20220. func (m *SopNodeMutation) AddConditionType(i int) {
  20221. if m.addcondition_type != nil {
  20222. *m.addcondition_type += i
  20223. } else {
  20224. m.addcondition_type = &i
  20225. }
  20226. }
  20227. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  20228. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  20229. v := m.addcondition_type
  20230. if v == nil {
  20231. return
  20232. }
  20233. return *v, true
  20234. }
  20235. // ResetConditionType resets all changes to the "condition_type" field.
  20236. func (m *SopNodeMutation) ResetConditionType() {
  20237. m.condition_type = nil
  20238. m.addcondition_type = nil
  20239. }
  20240. // SetConditionList sets the "condition_list" field.
  20241. func (m *SopNodeMutation) SetConditionList(s []string) {
  20242. m.condition_list = &s
  20243. m.appendcondition_list = nil
  20244. }
  20245. // ConditionList returns the value of the "condition_list" field in the mutation.
  20246. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  20247. v := m.condition_list
  20248. if v == nil {
  20249. return
  20250. }
  20251. return *v, true
  20252. }
  20253. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  20254. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20256. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  20257. if !m.op.Is(OpUpdateOne) {
  20258. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  20259. }
  20260. if m.id == nil || m.oldValue == nil {
  20261. return v, errors.New("OldConditionList requires an ID field in the mutation")
  20262. }
  20263. oldValue, err := m.oldValue(ctx)
  20264. if err != nil {
  20265. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  20266. }
  20267. return oldValue.ConditionList, nil
  20268. }
  20269. // AppendConditionList adds s to the "condition_list" field.
  20270. func (m *SopNodeMutation) AppendConditionList(s []string) {
  20271. m.appendcondition_list = append(m.appendcondition_list, s...)
  20272. }
  20273. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  20274. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  20275. if len(m.appendcondition_list) == 0 {
  20276. return nil, false
  20277. }
  20278. return m.appendcondition_list, true
  20279. }
  20280. // ClearConditionList clears the value of the "condition_list" field.
  20281. func (m *SopNodeMutation) ClearConditionList() {
  20282. m.condition_list = nil
  20283. m.appendcondition_list = nil
  20284. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  20285. }
  20286. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  20287. func (m *SopNodeMutation) ConditionListCleared() bool {
  20288. _, ok := m.clearedFields[sopnode.FieldConditionList]
  20289. return ok
  20290. }
  20291. // ResetConditionList resets all changes to the "condition_list" field.
  20292. func (m *SopNodeMutation) ResetConditionList() {
  20293. m.condition_list = nil
  20294. m.appendcondition_list = nil
  20295. delete(m.clearedFields, sopnode.FieldConditionList)
  20296. }
  20297. // SetNoReplyCondition sets the "no_reply_condition" field.
  20298. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  20299. m.no_reply_condition = &u
  20300. m.addno_reply_condition = nil
  20301. }
  20302. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  20303. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  20304. v := m.no_reply_condition
  20305. if v == nil {
  20306. return
  20307. }
  20308. return *v, true
  20309. }
  20310. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  20311. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20313. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  20314. if !m.op.Is(OpUpdateOne) {
  20315. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  20316. }
  20317. if m.id == nil || m.oldValue == nil {
  20318. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  20319. }
  20320. oldValue, err := m.oldValue(ctx)
  20321. if err != nil {
  20322. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  20323. }
  20324. return oldValue.NoReplyCondition, nil
  20325. }
  20326. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  20327. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  20328. if m.addno_reply_condition != nil {
  20329. *m.addno_reply_condition += u
  20330. } else {
  20331. m.addno_reply_condition = &u
  20332. }
  20333. }
  20334. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  20335. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  20336. v := m.addno_reply_condition
  20337. if v == nil {
  20338. return
  20339. }
  20340. return *v, true
  20341. }
  20342. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  20343. func (m *SopNodeMutation) ResetNoReplyCondition() {
  20344. m.no_reply_condition = nil
  20345. m.addno_reply_condition = nil
  20346. }
  20347. // SetNoReplyUnit sets the "no_reply_unit" field.
  20348. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  20349. m.no_reply_unit = &s
  20350. }
  20351. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  20352. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  20353. v := m.no_reply_unit
  20354. if v == nil {
  20355. return
  20356. }
  20357. return *v, true
  20358. }
  20359. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  20360. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20362. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  20363. if !m.op.Is(OpUpdateOne) {
  20364. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  20365. }
  20366. if m.id == nil || m.oldValue == nil {
  20367. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  20368. }
  20369. oldValue, err := m.oldValue(ctx)
  20370. if err != nil {
  20371. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  20372. }
  20373. return oldValue.NoReplyUnit, nil
  20374. }
  20375. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  20376. func (m *SopNodeMutation) ResetNoReplyUnit() {
  20377. m.no_reply_unit = nil
  20378. }
  20379. // SetActionMessage sets the "action_message" field.
  20380. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  20381. m.action_message = &ct
  20382. m.appendaction_message = nil
  20383. }
  20384. // ActionMessage returns the value of the "action_message" field in the mutation.
  20385. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  20386. v := m.action_message
  20387. if v == nil {
  20388. return
  20389. }
  20390. return *v, true
  20391. }
  20392. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  20393. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20395. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  20396. if !m.op.Is(OpUpdateOne) {
  20397. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  20398. }
  20399. if m.id == nil || m.oldValue == nil {
  20400. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  20401. }
  20402. oldValue, err := m.oldValue(ctx)
  20403. if err != nil {
  20404. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  20405. }
  20406. return oldValue.ActionMessage, nil
  20407. }
  20408. // AppendActionMessage adds ct to the "action_message" field.
  20409. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  20410. m.appendaction_message = append(m.appendaction_message, ct...)
  20411. }
  20412. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  20413. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  20414. if len(m.appendaction_message) == 0 {
  20415. return nil, false
  20416. }
  20417. return m.appendaction_message, true
  20418. }
  20419. // ClearActionMessage clears the value of the "action_message" field.
  20420. func (m *SopNodeMutation) ClearActionMessage() {
  20421. m.action_message = nil
  20422. m.appendaction_message = nil
  20423. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  20424. }
  20425. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  20426. func (m *SopNodeMutation) ActionMessageCleared() bool {
  20427. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  20428. return ok
  20429. }
  20430. // ResetActionMessage resets all changes to the "action_message" field.
  20431. func (m *SopNodeMutation) ResetActionMessage() {
  20432. m.action_message = nil
  20433. m.appendaction_message = nil
  20434. delete(m.clearedFields, sopnode.FieldActionMessage)
  20435. }
  20436. // SetActionLabelAdd sets the "action_label_add" field.
  20437. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  20438. m.action_label_add = &u
  20439. m.appendaction_label_add = nil
  20440. }
  20441. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  20442. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  20443. v := m.action_label_add
  20444. if v == nil {
  20445. return
  20446. }
  20447. return *v, true
  20448. }
  20449. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  20450. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20452. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  20453. if !m.op.Is(OpUpdateOne) {
  20454. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  20455. }
  20456. if m.id == nil || m.oldValue == nil {
  20457. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  20458. }
  20459. oldValue, err := m.oldValue(ctx)
  20460. if err != nil {
  20461. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  20462. }
  20463. return oldValue.ActionLabelAdd, nil
  20464. }
  20465. // AppendActionLabelAdd adds u to the "action_label_add" field.
  20466. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  20467. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  20468. }
  20469. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  20470. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  20471. if len(m.appendaction_label_add) == 0 {
  20472. return nil, false
  20473. }
  20474. return m.appendaction_label_add, true
  20475. }
  20476. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  20477. func (m *SopNodeMutation) ClearActionLabelAdd() {
  20478. m.action_label_add = nil
  20479. m.appendaction_label_add = nil
  20480. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  20481. }
  20482. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  20483. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  20484. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  20485. return ok
  20486. }
  20487. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  20488. func (m *SopNodeMutation) ResetActionLabelAdd() {
  20489. m.action_label_add = nil
  20490. m.appendaction_label_add = nil
  20491. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  20492. }
  20493. // SetActionLabelDel sets the "action_label_del" field.
  20494. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  20495. m.action_label_del = &u
  20496. m.appendaction_label_del = nil
  20497. }
  20498. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  20499. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  20500. v := m.action_label_del
  20501. if v == nil {
  20502. return
  20503. }
  20504. return *v, true
  20505. }
  20506. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  20507. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20509. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  20510. if !m.op.Is(OpUpdateOne) {
  20511. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  20512. }
  20513. if m.id == nil || m.oldValue == nil {
  20514. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  20515. }
  20516. oldValue, err := m.oldValue(ctx)
  20517. if err != nil {
  20518. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  20519. }
  20520. return oldValue.ActionLabelDel, nil
  20521. }
  20522. // AppendActionLabelDel adds u to the "action_label_del" field.
  20523. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  20524. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  20525. }
  20526. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  20527. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  20528. if len(m.appendaction_label_del) == 0 {
  20529. return nil, false
  20530. }
  20531. return m.appendaction_label_del, true
  20532. }
  20533. // ClearActionLabelDel clears the value of the "action_label_del" field.
  20534. func (m *SopNodeMutation) ClearActionLabelDel() {
  20535. m.action_label_del = nil
  20536. m.appendaction_label_del = nil
  20537. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  20538. }
  20539. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  20540. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  20541. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  20542. return ok
  20543. }
  20544. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  20545. func (m *SopNodeMutation) ResetActionLabelDel() {
  20546. m.action_label_del = nil
  20547. m.appendaction_label_del = nil
  20548. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  20549. }
  20550. // SetActionForward sets the "action_forward" field.
  20551. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  20552. m.action_forward = &ctf
  20553. }
  20554. // ActionForward returns the value of the "action_forward" field in the mutation.
  20555. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  20556. v := m.action_forward
  20557. if v == nil {
  20558. return
  20559. }
  20560. return *v, true
  20561. }
  20562. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  20563. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20565. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  20566. if !m.op.Is(OpUpdateOne) {
  20567. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  20568. }
  20569. if m.id == nil || m.oldValue == nil {
  20570. return v, errors.New("OldActionForward requires an ID field in the mutation")
  20571. }
  20572. oldValue, err := m.oldValue(ctx)
  20573. if err != nil {
  20574. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  20575. }
  20576. return oldValue.ActionForward, nil
  20577. }
  20578. // ClearActionForward clears the value of the "action_forward" field.
  20579. func (m *SopNodeMutation) ClearActionForward() {
  20580. m.action_forward = nil
  20581. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  20582. }
  20583. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  20584. func (m *SopNodeMutation) ActionForwardCleared() bool {
  20585. _, ok := m.clearedFields[sopnode.FieldActionForward]
  20586. return ok
  20587. }
  20588. // ResetActionForward resets all changes to the "action_forward" field.
  20589. func (m *SopNodeMutation) ResetActionForward() {
  20590. m.action_forward = nil
  20591. delete(m.clearedFields, sopnode.FieldActionForward)
  20592. }
  20593. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  20594. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  20595. m.sop_stage = &id
  20596. }
  20597. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  20598. func (m *SopNodeMutation) ClearSopStage() {
  20599. m.clearedsop_stage = true
  20600. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  20601. }
  20602. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  20603. func (m *SopNodeMutation) SopStageCleared() bool {
  20604. return m.clearedsop_stage
  20605. }
  20606. // SopStageID returns the "sop_stage" edge ID in the mutation.
  20607. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  20608. if m.sop_stage != nil {
  20609. return *m.sop_stage, true
  20610. }
  20611. return
  20612. }
  20613. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  20614. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  20615. // SopStageID instead. It exists only for internal usage by the builders.
  20616. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  20617. if id := m.sop_stage; id != nil {
  20618. ids = append(ids, *id)
  20619. }
  20620. return
  20621. }
  20622. // ResetSopStage resets all changes to the "sop_stage" edge.
  20623. func (m *SopNodeMutation) ResetSopStage() {
  20624. m.sop_stage = nil
  20625. m.clearedsop_stage = false
  20626. }
  20627. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  20628. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  20629. if m.node_messages == nil {
  20630. m.node_messages = make(map[uint64]struct{})
  20631. }
  20632. for i := range ids {
  20633. m.node_messages[ids[i]] = struct{}{}
  20634. }
  20635. }
  20636. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  20637. func (m *SopNodeMutation) ClearNodeMessages() {
  20638. m.clearednode_messages = true
  20639. }
  20640. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  20641. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  20642. return m.clearednode_messages
  20643. }
  20644. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  20645. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  20646. if m.removednode_messages == nil {
  20647. m.removednode_messages = make(map[uint64]struct{})
  20648. }
  20649. for i := range ids {
  20650. delete(m.node_messages, ids[i])
  20651. m.removednode_messages[ids[i]] = struct{}{}
  20652. }
  20653. }
  20654. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  20655. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  20656. for id := range m.removednode_messages {
  20657. ids = append(ids, id)
  20658. }
  20659. return
  20660. }
  20661. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  20662. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  20663. for id := range m.node_messages {
  20664. ids = append(ids, id)
  20665. }
  20666. return
  20667. }
  20668. // ResetNodeMessages resets all changes to the "node_messages" edge.
  20669. func (m *SopNodeMutation) ResetNodeMessages() {
  20670. m.node_messages = nil
  20671. m.clearednode_messages = false
  20672. m.removednode_messages = nil
  20673. }
  20674. // Where appends a list predicates to the SopNodeMutation builder.
  20675. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  20676. m.predicates = append(m.predicates, ps...)
  20677. }
  20678. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  20679. // users can use type-assertion to append predicates that do not depend on any generated package.
  20680. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  20681. p := make([]predicate.SopNode, len(ps))
  20682. for i := range ps {
  20683. p[i] = ps[i]
  20684. }
  20685. m.Where(p...)
  20686. }
  20687. // Op returns the operation name.
  20688. func (m *SopNodeMutation) Op() Op {
  20689. return m.op
  20690. }
  20691. // SetOp allows setting the mutation operation.
  20692. func (m *SopNodeMutation) SetOp(op Op) {
  20693. m.op = op
  20694. }
  20695. // Type returns the node type of this mutation (SopNode).
  20696. func (m *SopNodeMutation) Type() string {
  20697. return m.typ
  20698. }
  20699. // Fields returns all fields that were changed during this mutation. Note that in
  20700. // order to get all numeric fields that were incremented/decremented, call
  20701. // AddedFields().
  20702. func (m *SopNodeMutation) Fields() []string {
  20703. fields := make([]string, 0, 15)
  20704. if m.created_at != nil {
  20705. fields = append(fields, sopnode.FieldCreatedAt)
  20706. }
  20707. if m.updated_at != nil {
  20708. fields = append(fields, sopnode.FieldUpdatedAt)
  20709. }
  20710. if m.status != nil {
  20711. fields = append(fields, sopnode.FieldStatus)
  20712. }
  20713. if m.deleted_at != nil {
  20714. fields = append(fields, sopnode.FieldDeletedAt)
  20715. }
  20716. if m.sop_stage != nil {
  20717. fields = append(fields, sopnode.FieldStageID)
  20718. }
  20719. if m.parent_id != nil {
  20720. fields = append(fields, sopnode.FieldParentID)
  20721. }
  20722. if m.name != nil {
  20723. fields = append(fields, sopnode.FieldName)
  20724. }
  20725. if m.condition_type != nil {
  20726. fields = append(fields, sopnode.FieldConditionType)
  20727. }
  20728. if m.condition_list != nil {
  20729. fields = append(fields, sopnode.FieldConditionList)
  20730. }
  20731. if m.no_reply_condition != nil {
  20732. fields = append(fields, sopnode.FieldNoReplyCondition)
  20733. }
  20734. if m.no_reply_unit != nil {
  20735. fields = append(fields, sopnode.FieldNoReplyUnit)
  20736. }
  20737. if m.action_message != nil {
  20738. fields = append(fields, sopnode.FieldActionMessage)
  20739. }
  20740. if m.action_label_add != nil {
  20741. fields = append(fields, sopnode.FieldActionLabelAdd)
  20742. }
  20743. if m.action_label_del != nil {
  20744. fields = append(fields, sopnode.FieldActionLabelDel)
  20745. }
  20746. if m.action_forward != nil {
  20747. fields = append(fields, sopnode.FieldActionForward)
  20748. }
  20749. return fields
  20750. }
  20751. // Field returns the value of a field with the given name. The second boolean
  20752. // return value indicates that this field was not set, or was not defined in the
  20753. // schema.
  20754. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  20755. switch name {
  20756. case sopnode.FieldCreatedAt:
  20757. return m.CreatedAt()
  20758. case sopnode.FieldUpdatedAt:
  20759. return m.UpdatedAt()
  20760. case sopnode.FieldStatus:
  20761. return m.Status()
  20762. case sopnode.FieldDeletedAt:
  20763. return m.DeletedAt()
  20764. case sopnode.FieldStageID:
  20765. return m.StageID()
  20766. case sopnode.FieldParentID:
  20767. return m.ParentID()
  20768. case sopnode.FieldName:
  20769. return m.Name()
  20770. case sopnode.FieldConditionType:
  20771. return m.ConditionType()
  20772. case sopnode.FieldConditionList:
  20773. return m.ConditionList()
  20774. case sopnode.FieldNoReplyCondition:
  20775. return m.NoReplyCondition()
  20776. case sopnode.FieldNoReplyUnit:
  20777. return m.NoReplyUnit()
  20778. case sopnode.FieldActionMessage:
  20779. return m.ActionMessage()
  20780. case sopnode.FieldActionLabelAdd:
  20781. return m.ActionLabelAdd()
  20782. case sopnode.FieldActionLabelDel:
  20783. return m.ActionLabelDel()
  20784. case sopnode.FieldActionForward:
  20785. return m.ActionForward()
  20786. }
  20787. return nil, false
  20788. }
  20789. // OldField returns the old value of the field from the database. An error is
  20790. // returned if the mutation operation is not UpdateOne, or the query to the
  20791. // database failed.
  20792. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20793. switch name {
  20794. case sopnode.FieldCreatedAt:
  20795. return m.OldCreatedAt(ctx)
  20796. case sopnode.FieldUpdatedAt:
  20797. return m.OldUpdatedAt(ctx)
  20798. case sopnode.FieldStatus:
  20799. return m.OldStatus(ctx)
  20800. case sopnode.FieldDeletedAt:
  20801. return m.OldDeletedAt(ctx)
  20802. case sopnode.FieldStageID:
  20803. return m.OldStageID(ctx)
  20804. case sopnode.FieldParentID:
  20805. return m.OldParentID(ctx)
  20806. case sopnode.FieldName:
  20807. return m.OldName(ctx)
  20808. case sopnode.FieldConditionType:
  20809. return m.OldConditionType(ctx)
  20810. case sopnode.FieldConditionList:
  20811. return m.OldConditionList(ctx)
  20812. case sopnode.FieldNoReplyCondition:
  20813. return m.OldNoReplyCondition(ctx)
  20814. case sopnode.FieldNoReplyUnit:
  20815. return m.OldNoReplyUnit(ctx)
  20816. case sopnode.FieldActionMessage:
  20817. return m.OldActionMessage(ctx)
  20818. case sopnode.FieldActionLabelAdd:
  20819. return m.OldActionLabelAdd(ctx)
  20820. case sopnode.FieldActionLabelDel:
  20821. return m.OldActionLabelDel(ctx)
  20822. case sopnode.FieldActionForward:
  20823. return m.OldActionForward(ctx)
  20824. }
  20825. return nil, fmt.Errorf("unknown SopNode field %s", name)
  20826. }
  20827. // SetField sets the value of a field with the given name. It returns an error if
  20828. // the field is not defined in the schema, or if the type mismatched the field
  20829. // type.
  20830. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  20831. switch name {
  20832. case sopnode.FieldCreatedAt:
  20833. v, ok := value.(time.Time)
  20834. if !ok {
  20835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20836. }
  20837. m.SetCreatedAt(v)
  20838. return nil
  20839. case sopnode.FieldUpdatedAt:
  20840. v, ok := value.(time.Time)
  20841. if !ok {
  20842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20843. }
  20844. m.SetUpdatedAt(v)
  20845. return nil
  20846. case sopnode.FieldStatus:
  20847. v, ok := value.(uint8)
  20848. if !ok {
  20849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20850. }
  20851. m.SetStatus(v)
  20852. return nil
  20853. case sopnode.FieldDeletedAt:
  20854. v, ok := value.(time.Time)
  20855. if !ok {
  20856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20857. }
  20858. m.SetDeletedAt(v)
  20859. return nil
  20860. case sopnode.FieldStageID:
  20861. v, ok := value.(uint64)
  20862. if !ok {
  20863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20864. }
  20865. m.SetStageID(v)
  20866. return nil
  20867. case sopnode.FieldParentID:
  20868. v, ok := value.(uint64)
  20869. if !ok {
  20870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20871. }
  20872. m.SetParentID(v)
  20873. return nil
  20874. case sopnode.FieldName:
  20875. v, ok := value.(string)
  20876. if !ok {
  20877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20878. }
  20879. m.SetName(v)
  20880. return nil
  20881. case sopnode.FieldConditionType:
  20882. v, ok := value.(int)
  20883. if !ok {
  20884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20885. }
  20886. m.SetConditionType(v)
  20887. return nil
  20888. case sopnode.FieldConditionList:
  20889. v, ok := value.([]string)
  20890. if !ok {
  20891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20892. }
  20893. m.SetConditionList(v)
  20894. return nil
  20895. case sopnode.FieldNoReplyCondition:
  20896. v, ok := value.(uint64)
  20897. if !ok {
  20898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20899. }
  20900. m.SetNoReplyCondition(v)
  20901. return nil
  20902. case sopnode.FieldNoReplyUnit:
  20903. v, ok := value.(string)
  20904. if !ok {
  20905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20906. }
  20907. m.SetNoReplyUnit(v)
  20908. return nil
  20909. case sopnode.FieldActionMessage:
  20910. v, ok := value.([]custom_types.Action)
  20911. if !ok {
  20912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20913. }
  20914. m.SetActionMessage(v)
  20915. return nil
  20916. case sopnode.FieldActionLabelAdd:
  20917. v, ok := value.([]uint64)
  20918. if !ok {
  20919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20920. }
  20921. m.SetActionLabelAdd(v)
  20922. return nil
  20923. case sopnode.FieldActionLabelDel:
  20924. v, ok := value.([]uint64)
  20925. if !ok {
  20926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20927. }
  20928. m.SetActionLabelDel(v)
  20929. return nil
  20930. case sopnode.FieldActionForward:
  20931. v, ok := value.(*custom_types.ActionForward)
  20932. if !ok {
  20933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20934. }
  20935. m.SetActionForward(v)
  20936. return nil
  20937. }
  20938. return fmt.Errorf("unknown SopNode field %s", name)
  20939. }
  20940. // AddedFields returns all numeric fields that were incremented/decremented during
  20941. // this mutation.
  20942. func (m *SopNodeMutation) AddedFields() []string {
  20943. var fields []string
  20944. if m.addstatus != nil {
  20945. fields = append(fields, sopnode.FieldStatus)
  20946. }
  20947. if m.addparent_id != nil {
  20948. fields = append(fields, sopnode.FieldParentID)
  20949. }
  20950. if m.addcondition_type != nil {
  20951. fields = append(fields, sopnode.FieldConditionType)
  20952. }
  20953. if m.addno_reply_condition != nil {
  20954. fields = append(fields, sopnode.FieldNoReplyCondition)
  20955. }
  20956. return fields
  20957. }
  20958. // AddedField returns the numeric value that was incremented/decremented on a field
  20959. // with the given name. The second boolean return value indicates that this field
  20960. // was not set, or was not defined in the schema.
  20961. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  20962. switch name {
  20963. case sopnode.FieldStatus:
  20964. return m.AddedStatus()
  20965. case sopnode.FieldParentID:
  20966. return m.AddedParentID()
  20967. case sopnode.FieldConditionType:
  20968. return m.AddedConditionType()
  20969. case sopnode.FieldNoReplyCondition:
  20970. return m.AddedNoReplyCondition()
  20971. }
  20972. return nil, false
  20973. }
  20974. // AddField adds the value to the field with the given name. It returns an error if
  20975. // the field is not defined in the schema, or if the type mismatched the field
  20976. // type.
  20977. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  20978. switch name {
  20979. case sopnode.FieldStatus:
  20980. v, ok := value.(int8)
  20981. if !ok {
  20982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20983. }
  20984. m.AddStatus(v)
  20985. return nil
  20986. case sopnode.FieldParentID:
  20987. v, ok := value.(int64)
  20988. if !ok {
  20989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20990. }
  20991. m.AddParentID(v)
  20992. return nil
  20993. case sopnode.FieldConditionType:
  20994. v, ok := value.(int)
  20995. if !ok {
  20996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20997. }
  20998. m.AddConditionType(v)
  20999. return nil
  21000. case sopnode.FieldNoReplyCondition:
  21001. v, ok := value.(int64)
  21002. if !ok {
  21003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21004. }
  21005. m.AddNoReplyCondition(v)
  21006. return nil
  21007. }
  21008. return fmt.Errorf("unknown SopNode numeric field %s", name)
  21009. }
  21010. // ClearedFields returns all nullable fields that were cleared during this
  21011. // mutation.
  21012. func (m *SopNodeMutation) ClearedFields() []string {
  21013. var fields []string
  21014. if m.FieldCleared(sopnode.FieldStatus) {
  21015. fields = append(fields, sopnode.FieldStatus)
  21016. }
  21017. if m.FieldCleared(sopnode.FieldDeletedAt) {
  21018. fields = append(fields, sopnode.FieldDeletedAt)
  21019. }
  21020. if m.FieldCleared(sopnode.FieldConditionList) {
  21021. fields = append(fields, sopnode.FieldConditionList)
  21022. }
  21023. if m.FieldCleared(sopnode.FieldActionMessage) {
  21024. fields = append(fields, sopnode.FieldActionMessage)
  21025. }
  21026. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  21027. fields = append(fields, sopnode.FieldActionLabelAdd)
  21028. }
  21029. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  21030. fields = append(fields, sopnode.FieldActionLabelDel)
  21031. }
  21032. if m.FieldCleared(sopnode.FieldActionForward) {
  21033. fields = append(fields, sopnode.FieldActionForward)
  21034. }
  21035. return fields
  21036. }
  21037. // FieldCleared returns a boolean indicating if a field with the given name was
  21038. // cleared in this mutation.
  21039. func (m *SopNodeMutation) FieldCleared(name string) bool {
  21040. _, ok := m.clearedFields[name]
  21041. return ok
  21042. }
  21043. // ClearField clears the value of the field with the given name. It returns an
  21044. // error if the field is not defined in the schema.
  21045. func (m *SopNodeMutation) ClearField(name string) error {
  21046. switch name {
  21047. case sopnode.FieldStatus:
  21048. m.ClearStatus()
  21049. return nil
  21050. case sopnode.FieldDeletedAt:
  21051. m.ClearDeletedAt()
  21052. return nil
  21053. case sopnode.FieldConditionList:
  21054. m.ClearConditionList()
  21055. return nil
  21056. case sopnode.FieldActionMessage:
  21057. m.ClearActionMessage()
  21058. return nil
  21059. case sopnode.FieldActionLabelAdd:
  21060. m.ClearActionLabelAdd()
  21061. return nil
  21062. case sopnode.FieldActionLabelDel:
  21063. m.ClearActionLabelDel()
  21064. return nil
  21065. case sopnode.FieldActionForward:
  21066. m.ClearActionForward()
  21067. return nil
  21068. }
  21069. return fmt.Errorf("unknown SopNode nullable field %s", name)
  21070. }
  21071. // ResetField resets all changes in the mutation for the field with the given name.
  21072. // It returns an error if the field is not defined in the schema.
  21073. func (m *SopNodeMutation) ResetField(name string) error {
  21074. switch name {
  21075. case sopnode.FieldCreatedAt:
  21076. m.ResetCreatedAt()
  21077. return nil
  21078. case sopnode.FieldUpdatedAt:
  21079. m.ResetUpdatedAt()
  21080. return nil
  21081. case sopnode.FieldStatus:
  21082. m.ResetStatus()
  21083. return nil
  21084. case sopnode.FieldDeletedAt:
  21085. m.ResetDeletedAt()
  21086. return nil
  21087. case sopnode.FieldStageID:
  21088. m.ResetStageID()
  21089. return nil
  21090. case sopnode.FieldParentID:
  21091. m.ResetParentID()
  21092. return nil
  21093. case sopnode.FieldName:
  21094. m.ResetName()
  21095. return nil
  21096. case sopnode.FieldConditionType:
  21097. m.ResetConditionType()
  21098. return nil
  21099. case sopnode.FieldConditionList:
  21100. m.ResetConditionList()
  21101. return nil
  21102. case sopnode.FieldNoReplyCondition:
  21103. m.ResetNoReplyCondition()
  21104. return nil
  21105. case sopnode.FieldNoReplyUnit:
  21106. m.ResetNoReplyUnit()
  21107. return nil
  21108. case sopnode.FieldActionMessage:
  21109. m.ResetActionMessage()
  21110. return nil
  21111. case sopnode.FieldActionLabelAdd:
  21112. m.ResetActionLabelAdd()
  21113. return nil
  21114. case sopnode.FieldActionLabelDel:
  21115. m.ResetActionLabelDel()
  21116. return nil
  21117. case sopnode.FieldActionForward:
  21118. m.ResetActionForward()
  21119. return nil
  21120. }
  21121. return fmt.Errorf("unknown SopNode field %s", name)
  21122. }
  21123. // AddedEdges returns all edge names that were set/added in this mutation.
  21124. func (m *SopNodeMutation) AddedEdges() []string {
  21125. edges := make([]string, 0, 2)
  21126. if m.sop_stage != nil {
  21127. edges = append(edges, sopnode.EdgeSopStage)
  21128. }
  21129. if m.node_messages != nil {
  21130. edges = append(edges, sopnode.EdgeNodeMessages)
  21131. }
  21132. return edges
  21133. }
  21134. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21135. // name in this mutation.
  21136. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  21137. switch name {
  21138. case sopnode.EdgeSopStage:
  21139. if id := m.sop_stage; id != nil {
  21140. return []ent.Value{*id}
  21141. }
  21142. case sopnode.EdgeNodeMessages:
  21143. ids := make([]ent.Value, 0, len(m.node_messages))
  21144. for id := range m.node_messages {
  21145. ids = append(ids, id)
  21146. }
  21147. return ids
  21148. }
  21149. return nil
  21150. }
  21151. // RemovedEdges returns all edge names that were removed in this mutation.
  21152. func (m *SopNodeMutation) RemovedEdges() []string {
  21153. edges := make([]string, 0, 2)
  21154. if m.removednode_messages != nil {
  21155. edges = append(edges, sopnode.EdgeNodeMessages)
  21156. }
  21157. return edges
  21158. }
  21159. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21160. // the given name in this mutation.
  21161. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  21162. switch name {
  21163. case sopnode.EdgeNodeMessages:
  21164. ids := make([]ent.Value, 0, len(m.removednode_messages))
  21165. for id := range m.removednode_messages {
  21166. ids = append(ids, id)
  21167. }
  21168. return ids
  21169. }
  21170. return nil
  21171. }
  21172. // ClearedEdges returns all edge names that were cleared in this mutation.
  21173. func (m *SopNodeMutation) ClearedEdges() []string {
  21174. edges := make([]string, 0, 2)
  21175. if m.clearedsop_stage {
  21176. edges = append(edges, sopnode.EdgeSopStage)
  21177. }
  21178. if m.clearednode_messages {
  21179. edges = append(edges, sopnode.EdgeNodeMessages)
  21180. }
  21181. return edges
  21182. }
  21183. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21184. // was cleared in this mutation.
  21185. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  21186. switch name {
  21187. case sopnode.EdgeSopStage:
  21188. return m.clearedsop_stage
  21189. case sopnode.EdgeNodeMessages:
  21190. return m.clearednode_messages
  21191. }
  21192. return false
  21193. }
  21194. // ClearEdge clears the value of the edge with the given name. It returns an error
  21195. // if that edge is not defined in the schema.
  21196. func (m *SopNodeMutation) ClearEdge(name string) error {
  21197. switch name {
  21198. case sopnode.EdgeSopStage:
  21199. m.ClearSopStage()
  21200. return nil
  21201. }
  21202. return fmt.Errorf("unknown SopNode unique edge %s", name)
  21203. }
  21204. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21205. // It returns an error if the edge is not defined in the schema.
  21206. func (m *SopNodeMutation) ResetEdge(name string) error {
  21207. switch name {
  21208. case sopnode.EdgeSopStage:
  21209. m.ResetSopStage()
  21210. return nil
  21211. case sopnode.EdgeNodeMessages:
  21212. m.ResetNodeMessages()
  21213. return nil
  21214. }
  21215. return fmt.Errorf("unknown SopNode edge %s", name)
  21216. }
  21217. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  21218. type SopStageMutation struct {
  21219. config
  21220. op Op
  21221. typ string
  21222. id *uint64
  21223. created_at *time.Time
  21224. updated_at *time.Time
  21225. status *uint8
  21226. addstatus *int8
  21227. deleted_at *time.Time
  21228. name *string
  21229. condition_type *int
  21230. addcondition_type *int
  21231. condition_operator *int
  21232. addcondition_operator *int
  21233. condition_list *[]custom_types.Condition
  21234. appendcondition_list []custom_types.Condition
  21235. action_message *[]custom_types.Action
  21236. appendaction_message []custom_types.Action
  21237. action_label_add *[]uint64
  21238. appendaction_label_add []uint64
  21239. action_label_del *[]uint64
  21240. appendaction_label_del []uint64
  21241. action_forward **custom_types.ActionForward
  21242. index_sort *int
  21243. addindex_sort *int
  21244. clearedFields map[string]struct{}
  21245. sop_task *uint64
  21246. clearedsop_task bool
  21247. stage_nodes map[uint64]struct{}
  21248. removedstage_nodes map[uint64]struct{}
  21249. clearedstage_nodes bool
  21250. stage_messages map[uint64]struct{}
  21251. removedstage_messages map[uint64]struct{}
  21252. clearedstage_messages bool
  21253. done bool
  21254. oldValue func(context.Context) (*SopStage, error)
  21255. predicates []predicate.SopStage
  21256. }
  21257. var _ ent.Mutation = (*SopStageMutation)(nil)
  21258. // sopstageOption allows management of the mutation configuration using functional options.
  21259. type sopstageOption func(*SopStageMutation)
  21260. // newSopStageMutation creates new mutation for the SopStage entity.
  21261. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  21262. m := &SopStageMutation{
  21263. config: c,
  21264. op: op,
  21265. typ: TypeSopStage,
  21266. clearedFields: make(map[string]struct{}),
  21267. }
  21268. for _, opt := range opts {
  21269. opt(m)
  21270. }
  21271. return m
  21272. }
  21273. // withSopStageID sets the ID field of the mutation.
  21274. func withSopStageID(id uint64) sopstageOption {
  21275. return func(m *SopStageMutation) {
  21276. var (
  21277. err error
  21278. once sync.Once
  21279. value *SopStage
  21280. )
  21281. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  21282. once.Do(func() {
  21283. if m.done {
  21284. err = errors.New("querying old values post mutation is not allowed")
  21285. } else {
  21286. value, err = m.Client().SopStage.Get(ctx, id)
  21287. }
  21288. })
  21289. return value, err
  21290. }
  21291. m.id = &id
  21292. }
  21293. }
  21294. // withSopStage sets the old SopStage of the mutation.
  21295. func withSopStage(node *SopStage) sopstageOption {
  21296. return func(m *SopStageMutation) {
  21297. m.oldValue = func(context.Context) (*SopStage, error) {
  21298. return node, nil
  21299. }
  21300. m.id = &node.ID
  21301. }
  21302. }
  21303. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21304. // executed in a transaction (ent.Tx), a transactional client is returned.
  21305. func (m SopStageMutation) Client() *Client {
  21306. client := &Client{config: m.config}
  21307. client.init()
  21308. return client
  21309. }
  21310. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21311. // it returns an error otherwise.
  21312. func (m SopStageMutation) Tx() (*Tx, error) {
  21313. if _, ok := m.driver.(*txDriver); !ok {
  21314. return nil, errors.New("ent: mutation is not running in a transaction")
  21315. }
  21316. tx := &Tx{config: m.config}
  21317. tx.init()
  21318. return tx, nil
  21319. }
  21320. // SetID sets the value of the id field. Note that this
  21321. // operation is only accepted on creation of SopStage entities.
  21322. func (m *SopStageMutation) SetID(id uint64) {
  21323. m.id = &id
  21324. }
  21325. // ID returns the ID value in the mutation. Note that the ID is only available
  21326. // if it was provided to the builder or after it was returned from the database.
  21327. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  21328. if m.id == nil {
  21329. return
  21330. }
  21331. return *m.id, true
  21332. }
  21333. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21334. // That means, if the mutation is applied within a transaction with an isolation level such
  21335. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21336. // or updated by the mutation.
  21337. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  21338. switch {
  21339. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21340. id, exists := m.ID()
  21341. if exists {
  21342. return []uint64{id}, nil
  21343. }
  21344. fallthrough
  21345. case m.op.Is(OpUpdate | OpDelete):
  21346. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  21347. default:
  21348. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21349. }
  21350. }
  21351. // SetCreatedAt sets the "created_at" field.
  21352. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  21353. m.created_at = &t
  21354. }
  21355. // CreatedAt returns the value of the "created_at" field in the mutation.
  21356. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  21357. v := m.created_at
  21358. if v == nil {
  21359. return
  21360. }
  21361. return *v, true
  21362. }
  21363. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  21364. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  21365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21366. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21367. if !m.op.Is(OpUpdateOne) {
  21368. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21369. }
  21370. if m.id == nil || m.oldValue == nil {
  21371. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21372. }
  21373. oldValue, err := m.oldValue(ctx)
  21374. if err != nil {
  21375. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21376. }
  21377. return oldValue.CreatedAt, nil
  21378. }
  21379. // ResetCreatedAt resets all changes to the "created_at" field.
  21380. func (m *SopStageMutation) ResetCreatedAt() {
  21381. m.created_at = nil
  21382. }
  21383. // SetUpdatedAt sets the "updated_at" field.
  21384. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  21385. m.updated_at = &t
  21386. }
  21387. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21388. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  21389. v := m.updated_at
  21390. if v == nil {
  21391. return
  21392. }
  21393. return *v, true
  21394. }
  21395. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  21396. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  21397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21398. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21399. if !m.op.Is(OpUpdateOne) {
  21400. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21401. }
  21402. if m.id == nil || m.oldValue == nil {
  21403. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21404. }
  21405. oldValue, err := m.oldValue(ctx)
  21406. if err != nil {
  21407. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21408. }
  21409. return oldValue.UpdatedAt, nil
  21410. }
  21411. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21412. func (m *SopStageMutation) ResetUpdatedAt() {
  21413. m.updated_at = nil
  21414. }
  21415. // SetStatus sets the "status" field.
  21416. func (m *SopStageMutation) SetStatus(u uint8) {
  21417. m.status = &u
  21418. m.addstatus = nil
  21419. }
  21420. // Status returns the value of the "status" field in the mutation.
  21421. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  21422. v := m.status
  21423. if v == nil {
  21424. return
  21425. }
  21426. return *v, true
  21427. }
  21428. // OldStatus returns the old "status" field's value of the SopStage entity.
  21429. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  21430. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21431. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  21432. if !m.op.Is(OpUpdateOne) {
  21433. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  21434. }
  21435. if m.id == nil || m.oldValue == nil {
  21436. return v, errors.New("OldStatus requires an ID field in the mutation")
  21437. }
  21438. oldValue, err := m.oldValue(ctx)
  21439. if err != nil {
  21440. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  21441. }
  21442. return oldValue.Status, nil
  21443. }
  21444. // AddStatus adds u to the "status" field.
  21445. func (m *SopStageMutation) AddStatus(u int8) {
  21446. if m.addstatus != nil {
  21447. *m.addstatus += u
  21448. } else {
  21449. m.addstatus = &u
  21450. }
  21451. }
  21452. // AddedStatus returns the value that was added to the "status" field in this mutation.
  21453. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  21454. v := m.addstatus
  21455. if v == nil {
  21456. return
  21457. }
  21458. return *v, true
  21459. }
  21460. // ClearStatus clears the value of the "status" field.
  21461. func (m *SopStageMutation) ClearStatus() {
  21462. m.status = nil
  21463. m.addstatus = nil
  21464. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  21465. }
  21466. // StatusCleared returns if the "status" field was cleared in this mutation.
  21467. func (m *SopStageMutation) StatusCleared() bool {
  21468. _, ok := m.clearedFields[sopstage.FieldStatus]
  21469. return ok
  21470. }
  21471. // ResetStatus resets all changes to the "status" field.
  21472. func (m *SopStageMutation) ResetStatus() {
  21473. m.status = nil
  21474. m.addstatus = nil
  21475. delete(m.clearedFields, sopstage.FieldStatus)
  21476. }
  21477. // SetDeletedAt sets the "deleted_at" field.
  21478. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  21479. m.deleted_at = &t
  21480. }
  21481. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21482. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  21483. v := m.deleted_at
  21484. if v == nil {
  21485. return
  21486. }
  21487. return *v, true
  21488. }
  21489. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  21490. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  21491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21492. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21493. if !m.op.Is(OpUpdateOne) {
  21494. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21495. }
  21496. if m.id == nil || m.oldValue == nil {
  21497. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21498. }
  21499. oldValue, err := m.oldValue(ctx)
  21500. if err != nil {
  21501. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21502. }
  21503. return oldValue.DeletedAt, nil
  21504. }
  21505. // ClearDeletedAt clears the value of the "deleted_at" field.
  21506. func (m *SopStageMutation) ClearDeletedAt() {
  21507. m.deleted_at = nil
  21508. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  21509. }
  21510. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21511. func (m *SopStageMutation) DeletedAtCleared() bool {
  21512. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  21513. return ok
  21514. }
  21515. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21516. func (m *SopStageMutation) ResetDeletedAt() {
  21517. m.deleted_at = nil
  21518. delete(m.clearedFields, sopstage.FieldDeletedAt)
  21519. }
  21520. // SetTaskID sets the "task_id" field.
  21521. func (m *SopStageMutation) SetTaskID(u uint64) {
  21522. m.sop_task = &u
  21523. }
  21524. // TaskID returns the value of the "task_id" field in the mutation.
  21525. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  21526. v := m.sop_task
  21527. if v == nil {
  21528. return
  21529. }
  21530. return *v, true
  21531. }
  21532. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  21533. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  21534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21535. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  21536. if !m.op.Is(OpUpdateOne) {
  21537. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  21538. }
  21539. if m.id == nil || m.oldValue == nil {
  21540. return v, errors.New("OldTaskID requires an ID field in the mutation")
  21541. }
  21542. oldValue, err := m.oldValue(ctx)
  21543. if err != nil {
  21544. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  21545. }
  21546. return oldValue.TaskID, nil
  21547. }
  21548. // ResetTaskID resets all changes to the "task_id" field.
  21549. func (m *SopStageMutation) ResetTaskID() {
  21550. m.sop_task = nil
  21551. }
  21552. // SetName sets the "name" field.
  21553. func (m *SopStageMutation) SetName(s string) {
  21554. m.name = &s
  21555. }
  21556. // Name returns the value of the "name" field in the mutation.
  21557. func (m *SopStageMutation) Name() (r string, exists bool) {
  21558. v := m.name
  21559. if v == nil {
  21560. return
  21561. }
  21562. return *v, true
  21563. }
  21564. // OldName returns the old "name" field's value of the SopStage entity.
  21565. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  21566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21567. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  21568. if !m.op.Is(OpUpdateOne) {
  21569. return v, errors.New("OldName is only allowed on UpdateOne operations")
  21570. }
  21571. if m.id == nil || m.oldValue == nil {
  21572. return v, errors.New("OldName requires an ID field in the mutation")
  21573. }
  21574. oldValue, err := m.oldValue(ctx)
  21575. if err != nil {
  21576. return v, fmt.Errorf("querying old value for OldName: %w", err)
  21577. }
  21578. return oldValue.Name, nil
  21579. }
  21580. // ResetName resets all changes to the "name" field.
  21581. func (m *SopStageMutation) ResetName() {
  21582. m.name = nil
  21583. }
  21584. // SetConditionType sets the "condition_type" field.
  21585. func (m *SopStageMutation) SetConditionType(i int) {
  21586. m.condition_type = &i
  21587. m.addcondition_type = nil
  21588. }
  21589. // ConditionType returns the value of the "condition_type" field in the mutation.
  21590. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  21591. v := m.condition_type
  21592. if v == nil {
  21593. return
  21594. }
  21595. return *v, true
  21596. }
  21597. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  21598. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  21599. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21600. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  21601. if !m.op.Is(OpUpdateOne) {
  21602. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  21603. }
  21604. if m.id == nil || m.oldValue == nil {
  21605. return v, errors.New("OldConditionType requires an ID field in the mutation")
  21606. }
  21607. oldValue, err := m.oldValue(ctx)
  21608. if err != nil {
  21609. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  21610. }
  21611. return oldValue.ConditionType, nil
  21612. }
  21613. // AddConditionType adds i to the "condition_type" field.
  21614. func (m *SopStageMutation) AddConditionType(i int) {
  21615. if m.addcondition_type != nil {
  21616. *m.addcondition_type += i
  21617. } else {
  21618. m.addcondition_type = &i
  21619. }
  21620. }
  21621. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  21622. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  21623. v := m.addcondition_type
  21624. if v == nil {
  21625. return
  21626. }
  21627. return *v, true
  21628. }
  21629. // ResetConditionType resets all changes to the "condition_type" field.
  21630. func (m *SopStageMutation) ResetConditionType() {
  21631. m.condition_type = nil
  21632. m.addcondition_type = nil
  21633. }
  21634. // SetConditionOperator sets the "condition_operator" field.
  21635. func (m *SopStageMutation) SetConditionOperator(i int) {
  21636. m.condition_operator = &i
  21637. m.addcondition_operator = nil
  21638. }
  21639. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  21640. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  21641. v := m.condition_operator
  21642. if v == nil {
  21643. return
  21644. }
  21645. return *v, true
  21646. }
  21647. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  21648. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  21649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21650. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  21651. if !m.op.Is(OpUpdateOne) {
  21652. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  21653. }
  21654. if m.id == nil || m.oldValue == nil {
  21655. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  21656. }
  21657. oldValue, err := m.oldValue(ctx)
  21658. if err != nil {
  21659. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  21660. }
  21661. return oldValue.ConditionOperator, nil
  21662. }
  21663. // AddConditionOperator adds i to the "condition_operator" field.
  21664. func (m *SopStageMutation) AddConditionOperator(i int) {
  21665. if m.addcondition_operator != nil {
  21666. *m.addcondition_operator += i
  21667. } else {
  21668. m.addcondition_operator = &i
  21669. }
  21670. }
  21671. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  21672. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  21673. v := m.addcondition_operator
  21674. if v == nil {
  21675. return
  21676. }
  21677. return *v, true
  21678. }
  21679. // ResetConditionOperator resets all changes to the "condition_operator" field.
  21680. func (m *SopStageMutation) ResetConditionOperator() {
  21681. m.condition_operator = nil
  21682. m.addcondition_operator = nil
  21683. }
  21684. // SetConditionList sets the "condition_list" field.
  21685. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  21686. m.condition_list = &ct
  21687. m.appendcondition_list = nil
  21688. }
  21689. // ConditionList returns the value of the "condition_list" field in the mutation.
  21690. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  21691. v := m.condition_list
  21692. if v == nil {
  21693. return
  21694. }
  21695. return *v, true
  21696. }
  21697. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  21698. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  21699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21700. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  21701. if !m.op.Is(OpUpdateOne) {
  21702. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  21703. }
  21704. if m.id == nil || m.oldValue == nil {
  21705. return v, errors.New("OldConditionList requires an ID field in the mutation")
  21706. }
  21707. oldValue, err := m.oldValue(ctx)
  21708. if err != nil {
  21709. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  21710. }
  21711. return oldValue.ConditionList, nil
  21712. }
  21713. // AppendConditionList adds ct to the "condition_list" field.
  21714. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  21715. m.appendcondition_list = append(m.appendcondition_list, ct...)
  21716. }
  21717. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  21718. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  21719. if len(m.appendcondition_list) == 0 {
  21720. return nil, false
  21721. }
  21722. return m.appendcondition_list, true
  21723. }
  21724. // ResetConditionList resets all changes to the "condition_list" field.
  21725. func (m *SopStageMutation) ResetConditionList() {
  21726. m.condition_list = nil
  21727. m.appendcondition_list = nil
  21728. }
  21729. // SetActionMessage sets the "action_message" field.
  21730. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  21731. m.action_message = &ct
  21732. m.appendaction_message = nil
  21733. }
  21734. // ActionMessage returns the value of the "action_message" field in the mutation.
  21735. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  21736. v := m.action_message
  21737. if v == nil {
  21738. return
  21739. }
  21740. return *v, true
  21741. }
  21742. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  21743. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  21744. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21745. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  21746. if !m.op.Is(OpUpdateOne) {
  21747. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  21748. }
  21749. if m.id == nil || m.oldValue == nil {
  21750. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  21751. }
  21752. oldValue, err := m.oldValue(ctx)
  21753. if err != nil {
  21754. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  21755. }
  21756. return oldValue.ActionMessage, nil
  21757. }
  21758. // AppendActionMessage adds ct to the "action_message" field.
  21759. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  21760. m.appendaction_message = append(m.appendaction_message, ct...)
  21761. }
  21762. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  21763. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  21764. if len(m.appendaction_message) == 0 {
  21765. return nil, false
  21766. }
  21767. return m.appendaction_message, true
  21768. }
  21769. // ClearActionMessage clears the value of the "action_message" field.
  21770. func (m *SopStageMutation) ClearActionMessage() {
  21771. m.action_message = nil
  21772. m.appendaction_message = nil
  21773. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  21774. }
  21775. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  21776. func (m *SopStageMutation) ActionMessageCleared() bool {
  21777. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  21778. return ok
  21779. }
  21780. // ResetActionMessage resets all changes to the "action_message" field.
  21781. func (m *SopStageMutation) ResetActionMessage() {
  21782. m.action_message = nil
  21783. m.appendaction_message = nil
  21784. delete(m.clearedFields, sopstage.FieldActionMessage)
  21785. }
  21786. // SetActionLabelAdd sets the "action_label_add" field.
  21787. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  21788. m.action_label_add = &u
  21789. m.appendaction_label_add = nil
  21790. }
  21791. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  21792. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  21793. v := m.action_label_add
  21794. if v == nil {
  21795. return
  21796. }
  21797. return *v, true
  21798. }
  21799. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  21800. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  21801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21802. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  21803. if !m.op.Is(OpUpdateOne) {
  21804. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  21805. }
  21806. if m.id == nil || m.oldValue == nil {
  21807. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  21808. }
  21809. oldValue, err := m.oldValue(ctx)
  21810. if err != nil {
  21811. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  21812. }
  21813. return oldValue.ActionLabelAdd, nil
  21814. }
  21815. // AppendActionLabelAdd adds u to the "action_label_add" field.
  21816. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  21817. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  21818. }
  21819. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  21820. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  21821. if len(m.appendaction_label_add) == 0 {
  21822. return nil, false
  21823. }
  21824. return m.appendaction_label_add, true
  21825. }
  21826. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  21827. func (m *SopStageMutation) ClearActionLabelAdd() {
  21828. m.action_label_add = nil
  21829. m.appendaction_label_add = nil
  21830. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  21831. }
  21832. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  21833. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  21834. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  21835. return ok
  21836. }
  21837. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  21838. func (m *SopStageMutation) ResetActionLabelAdd() {
  21839. m.action_label_add = nil
  21840. m.appendaction_label_add = nil
  21841. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  21842. }
  21843. // SetActionLabelDel sets the "action_label_del" field.
  21844. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  21845. m.action_label_del = &u
  21846. m.appendaction_label_del = nil
  21847. }
  21848. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  21849. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  21850. v := m.action_label_del
  21851. if v == nil {
  21852. return
  21853. }
  21854. return *v, true
  21855. }
  21856. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  21857. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  21858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21859. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  21860. if !m.op.Is(OpUpdateOne) {
  21861. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  21862. }
  21863. if m.id == nil || m.oldValue == nil {
  21864. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  21865. }
  21866. oldValue, err := m.oldValue(ctx)
  21867. if err != nil {
  21868. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  21869. }
  21870. return oldValue.ActionLabelDel, nil
  21871. }
  21872. // AppendActionLabelDel adds u to the "action_label_del" field.
  21873. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  21874. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  21875. }
  21876. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  21877. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  21878. if len(m.appendaction_label_del) == 0 {
  21879. return nil, false
  21880. }
  21881. return m.appendaction_label_del, true
  21882. }
  21883. // ClearActionLabelDel clears the value of the "action_label_del" field.
  21884. func (m *SopStageMutation) ClearActionLabelDel() {
  21885. m.action_label_del = nil
  21886. m.appendaction_label_del = nil
  21887. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  21888. }
  21889. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  21890. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  21891. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  21892. return ok
  21893. }
  21894. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  21895. func (m *SopStageMutation) ResetActionLabelDel() {
  21896. m.action_label_del = nil
  21897. m.appendaction_label_del = nil
  21898. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  21899. }
  21900. // SetActionForward sets the "action_forward" field.
  21901. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  21902. m.action_forward = &ctf
  21903. }
  21904. // ActionForward returns the value of the "action_forward" field in the mutation.
  21905. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  21906. v := m.action_forward
  21907. if v == nil {
  21908. return
  21909. }
  21910. return *v, true
  21911. }
  21912. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  21913. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  21914. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21915. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  21916. if !m.op.Is(OpUpdateOne) {
  21917. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  21918. }
  21919. if m.id == nil || m.oldValue == nil {
  21920. return v, errors.New("OldActionForward requires an ID field in the mutation")
  21921. }
  21922. oldValue, err := m.oldValue(ctx)
  21923. if err != nil {
  21924. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  21925. }
  21926. return oldValue.ActionForward, nil
  21927. }
  21928. // ClearActionForward clears the value of the "action_forward" field.
  21929. func (m *SopStageMutation) ClearActionForward() {
  21930. m.action_forward = nil
  21931. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  21932. }
  21933. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  21934. func (m *SopStageMutation) ActionForwardCleared() bool {
  21935. _, ok := m.clearedFields[sopstage.FieldActionForward]
  21936. return ok
  21937. }
  21938. // ResetActionForward resets all changes to the "action_forward" field.
  21939. func (m *SopStageMutation) ResetActionForward() {
  21940. m.action_forward = nil
  21941. delete(m.clearedFields, sopstage.FieldActionForward)
  21942. }
  21943. // SetIndexSort sets the "index_sort" field.
  21944. func (m *SopStageMutation) SetIndexSort(i int) {
  21945. m.index_sort = &i
  21946. m.addindex_sort = nil
  21947. }
  21948. // IndexSort returns the value of the "index_sort" field in the mutation.
  21949. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  21950. v := m.index_sort
  21951. if v == nil {
  21952. return
  21953. }
  21954. return *v, true
  21955. }
  21956. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  21957. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  21958. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21959. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  21960. if !m.op.Is(OpUpdateOne) {
  21961. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  21962. }
  21963. if m.id == nil || m.oldValue == nil {
  21964. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  21965. }
  21966. oldValue, err := m.oldValue(ctx)
  21967. if err != nil {
  21968. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  21969. }
  21970. return oldValue.IndexSort, nil
  21971. }
  21972. // AddIndexSort adds i to the "index_sort" field.
  21973. func (m *SopStageMutation) AddIndexSort(i int) {
  21974. if m.addindex_sort != nil {
  21975. *m.addindex_sort += i
  21976. } else {
  21977. m.addindex_sort = &i
  21978. }
  21979. }
  21980. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  21981. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  21982. v := m.addindex_sort
  21983. if v == nil {
  21984. return
  21985. }
  21986. return *v, true
  21987. }
  21988. // ClearIndexSort clears the value of the "index_sort" field.
  21989. func (m *SopStageMutation) ClearIndexSort() {
  21990. m.index_sort = nil
  21991. m.addindex_sort = nil
  21992. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  21993. }
  21994. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  21995. func (m *SopStageMutation) IndexSortCleared() bool {
  21996. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  21997. return ok
  21998. }
  21999. // ResetIndexSort resets all changes to the "index_sort" field.
  22000. func (m *SopStageMutation) ResetIndexSort() {
  22001. m.index_sort = nil
  22002. m.addindex_sort = nil
  22003. delete(m.clearedFields, sopstage.FieldIndexSort)
  22004. }
  22005. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  22006. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  22007. m.sop_task = &id
  22008. }
  22009. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  22010. func (m *SopStageMutation) ClearSopTask() {
  22011. m.clearedsop_task = true
  22012. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  22013. }
  22014. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  22015. func (m *SopStageMutation) SopTaskCleared() bool {
  22016. return m.clearedsop_task
  22017. }
  22018. // SopTaskID returns the "sop_task" edge ID in the mutation.
  22019. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  22020. if m.sop_task != nil {
  22021. return *m.sop_task, true
  22022. }
  22023. return
  22024. }
  22025. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  22026. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22027. // SopTaskID instead. It exists only for internal usage by the builders.
  22028. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  22029. if id := m.sop_task; id != nil {
  22030. ids = append(ids, *id)
  22031. }
  22032. return
  22033. }
  22034. // ResetSopTask resets all changes to the "sop_task" edge.
  22035. func (m *SopStageMutation) ResetSopTask() {
  22036. m.sop_task = nil
  22037. m.clearedsop_task = false
  22038. }
  22039. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  22040. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  22041. if m.stage_nodes == nil {
  22042. m.stage_nodes = make(map[uint64]struct{})
  22043. }
  22044. for i := range ids {
  22045. m.stage_nodes[ids[i]] = struct{}{}
  22046. }
  22047. }
  22048. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  22049. func (m *SopStageMutation) ClearStageNodes() {
  22050. m.clearedstage_nodes = true
  22051. }
  22052. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  22053. func (m *SopStageMutation) StageNodesCleared() bool {
  22054. return m.clearedstage_nodes
  22055. }
  22056. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  22057. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  22058. if m.removedstage_nodes == nil {
  22059. m.removedstage_nodes = make(map[uint64]struct{})
  22060. }
  22061. for i := range ids {
  22062. delete(m.stage_nodes, ids[i])
  22063. m.removedstage_nodes[ids[i]] = struct{}{}
  22064. }
  22065. }
  22066. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  22067. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  22068. for id := range m.removedstage_nodes {
  22069. ids = append(ids, id)
  22070. }
  22071. return
  22072. }
  22073. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  22074. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  22075. for id := range m.stage_nodes {
  22076. ids = append(ids, id)
  22077. }
  22078. return
  22079. }
  22080. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  22081. func (m *SopStageMutation) ResetStageNodes() {
  22082. m.stage_nodes = nil
  22083. m.clearedstage_nodes = false
  22084. m.removedstage_nodes = nil
  22085. }
  22086. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  22087. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  22088. if m.stage_messages == nil {
  22089. m.stage_messages = make(map[uint64]struct{})
  22090. }
  22091. for i := range ids {
  22092. m.stage_messages[ids[i]] = struct{}{}
  22093. }
  22094. }
  22095. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  22096. func (m *SopStageMutation) ClearStageMessages() {
  22097. m.clearedstage_messages = true
  22098. }
  22099. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  22100. func (m *SopStageMutation) StageMessagesCleared() bool {
  22101. return m.clearedstage_messages
  22102. }
  22103. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  22104. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  22105. if m.removedstage_messages == nil {
  22106. m.removedstage_messages = make(map[uint64]struct{})
  22107. }
  22108. for i := range ids {
  22109. delete(m.stage_messages, ids[i])
  22110. m.removedstage_messages[ids[i]] = struct{}{}
  22111. }
  22112. }
  22113. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  22114. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  22115. for id := range m.removedstage_messages {
  22116. ids = append(ids, id)
  22117. }
  22118. return
  22119. }
  22120. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  22121. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  22122. for id := range m.stage_messages {
  22123. ids = append(ids, id)
  22124. }
  22125. return
  22126. }
  22127. // ResetStageMessages resets all changes to the "stage_messages" edge.
  22128. func (m *SopStageMutation) ResetStageMessages() {
  22129. m.stage_messages = nil
  22130. m.clearedstage_messages = false
  22131. m.removedstage_messages = nil
  22132. }
  22133. // Where appends a list predicates to the SopStageMutation builder.
  22134. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  22135. m.predicates = append(m.predicates, ps...)
  22136. }
  22137. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  22138. // users can use type-assertion to append predicates that do not depend on any generated package.
  22139. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  22140. p := make([]predicate.SopStage, len(ps))
  22141. for i := range ps {
  22142. p[i] = ps[i]
  22143. }
  22144. m.Where(p...)
  22145. }
  22146. // Op returns the operation name.
  22147. func (m *SopStageMutation) Op() Op {
  22148. return m.op
  22149. }
  22150. // SetOp allows setting the mutation operation.
  22151. func (m *SopStageMutation) SetOp(op Op) {
  22152. m.op = op
  22153. }
  22154. // Type returns the node type of this mutation (SopStage).
  22155. func (m *SopStageMutation) Type() string {
  22156. return m.typ
  22157. }
  22158. // Fields returns all fields that were changed during this mutation. Note that in
  22159. // order to get all numeric fields that were incremented/decremented, call
  22160. // AddedFields().
  22161. func (m *SopStageMutation) Fields() []string {
  22162. fields := make([]string, 0, 14)
  22163. if m.created_at != nil {
  22164. fields = append(fields, sopstage.FieldCreatedAt)
  22165. }
  22166. if m.updated_at != nil {
  22167. fields = append(fields, sopstage.FieldUpdatedAt)
  22168. }
  22169. if m.status != nil {
  22170. fields = append(fields, sopstage.FieldStatus)
  22171. }
  22172. if m.deleted_at != nil {
  22173. fields = append(fields, sopstage.FieldDeletedAt)
  22174. }
  22175. if m.sop_task != nil {
  22176. fields = append(fields, sopstage.FieldTaskID)
  22177. }
  22178. if m.name != nil {
  22179. fields = append(fields, sopstage.FieldName)
  22180. }
  22181. if m.condition_type != nil {
  22182. fields = append(fields, sopstage.FieldConditionType)
  22183. }
  22184. if m.condition_operator != nil {
  22185. fields = append(fields, sopstage.FieldConditionOperator)
  22186. }
  22187. if m.condition_list != nil {
  22188. fields = append(fields, sopstage.FieldConditionList)
  22189. }
  22190. if m.action_message != nil {
  22191. fields = append(fields, sopstage.FieldActionMessage)
  22192. }
  22193. if m.action_label_add != nil {
  22194. fields = append(fields, sopstage.FieldActionLabelAdd)
  22195. }
  22196. if m.action_label_del != nil {
  22197. fields = append(fields, sopstage.FieldActionLabelDel)
  22198. }
  22199. if m.action_forward != nil {
  22200. fields = append(fields, sopstage.FieldActionForward)
  22201. }
  22202. if m.index_sort != nil {
  22203. fields = append(fields, sopstage.FieldIndexSort)
  22204. }
  22205. return fields
  22206. }
  22207. // Field returns the value of a field with the given name. The second boolean
  22208. // return value indicates that this field was not set, or was not defined in the
  22209. // schema.
  22210. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  22211. switch name {
  22212. case sopstage.FieldCreatedAt:
  22213. return m.CreatedAt()
  22214. case sopstage.FieldUpdatedAt:
  22215. return m.UpdatedAt()
  22216. case sopstage.FieldStatus:
  22217. return m.Status()
  22218. case sopstage.FieldDeletedAt:
  22219. return m.DeletedAt()
  22220. case sopstage.FieldTaskID:
  22221. return m.TaskID()
  22222. case sopstage.FieldName:
  22223. return m.Name()
  22224. case sopstage.FieldConditionType:
  22225. return m.ConditionType()
  22226. case sopstage.FieldConditionOperator:
  22227. return m.ConditionOperator()
  22228. case sopstage.FieldConditionList:
  22229. return m.ConditionList()
  22230. case sopstage.FieldActionMessage:
  22231. return m.ActionMessage()
  22232. case sopstage.FieldActionLabelAdd:
  22233. return m.ActionLabelAdd()
  22234. case sopstage.FieldActionLabelDel:
  22235. return m.ActionLabelDel()
  22236. case sopstage.FieldActionForward:
  22237. return m.ActionForward()
  22238. case sopstage.FieldIndexSort:
  22239. return m.IndexSort()
  22240. }
  22241. return nil, false
  22242. }
  22243. // OldField returns the old value of the field from the database. An error is
  22244. // returned if the mutation operation is not UpdateOne, or the query to the
  22245. // database failed.
  22246. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22247. switch name {
  22248. case sopstage.FieldCreatedAt:
  22249. return m.OldCreatedAt(ctx)
  22250. case sopstage.FieldUpdatedAt:
  22251. return m.OldUpdatedAt(ctx)
  22252. case sopstage.FieldStatus:
  22253. return m.OldStatus(ctx)
  22254. case sopstage.FieldDeletedAt:
  22255. return m.OldDeletedAt(ctx)
  22256. case sopstage.FieldTaskID:
  22257. return m.OldTaskID(ctx)
  22258. case sopstage.FieldName:
  22259. return m.OldName(ctx)
  22260. case sopstage.FieldConditionType:
  22261. return m.OldConditionType(ctx)
  22262. case sopstage.FieldConditionOperator:
  22263. return m.OldConditionOperator(ctx)
  22264. case sopstage.FieldConditionList:
  22265. return m.OldConditionList(ctx)
  22266. case sopstage.FieldActionMessage:
  22267. return m.OldActionMessage(ctx)
  22268. case sopstage.FieldActionLabelAdd:
  22269. return m.OldActionLabelAdd(ctx)
  22270. case sopstage.FieldActionLabelDel:
  22271. return m.OldActionLabelDel(ctx)
  22272. case sopstage.FieldActionForward:
  22273. return m.OldActionForward(ctx)
  22274. case sopstage.FieldIndexSort:
  22275. return m.OldIndexSort(ctx)
  22276. }
  22277. return nil, fmt.Errorf("unknown SopStage field %s", name)
  22278. }
  22279. // SetField sets the value of a field with the given name. It returns an error if
  22280. // the field is not defined in the schema, or if the type mismatched the field
  22281. // type.
  22282. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  22283. switch name {
  22284. case sopstage.FieldCreatedAt:
  22285. v, ok := value.(time.Time)
  22286. if !ok {
  22287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22288. }
  22289. m.SetCreatedAt(v)
  22290. return nil
  22291. case sopstage.FieldUpdatedAt:
  22292. v, ok := value.(time.Time)
  22293. if !ok {
  22294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22295. }
  22296. m.SetUpdatedAt(v)
  22297. return nil
  22298. case sopstage.FieldStatus:
  22299. v, ok := value.(uint8)
  22300. if !ok {
  22301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22302. }
  22303. m.SetStatus(v)
  22304. return nil
  22305. case sopstage.FieldDeletedAt:
  22306. v, ok := value.(time.Time)
  22307. if !ok {
  22308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22309. }
  22310. m.SetDeletedAt(v)
  22311. return nil
  22312. case sopstage.FieldTaskID:
  22313. v, ok := value.(uint64)
  22314. if !ok {
  22315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22316. }
  22317. m.SetTaskID(v)
  22318. return nil
  22319. case sopstage.FieldName:
  22320. v, ok := value.(string)
  22321. if !ok {
  22322. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22323. }
  22324. m.SetName(v)
  22325. return nil
  22326. case sopstage.FieldConditionType:
  22327. v, ok := value.(int)
  22328. if !ok {
  22329. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22330. }
  22331. m.SetConditionType(v)
  22332. return nil
  22333. case sopstage.FieldConditionOperator:
  22334. v, ok := value.(int)
  22335. if !ok {
  22336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22337. }
  22338. m.SetConditionOperator(v)
  22339. return nil
  22340. case sopstage.FieldConditionList:
  22341. v, ok := value.([]custom_types.Condition)
  22342. if !ok {
  22343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22344. }
  22345. m.SetConditionList(v)
  22346. return nil
  22347. case sopstage.FieldActionMessage:
  22348. v, ok := value.([]custom_types.Action)
  22349. if !ok {
  22350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22351. }
  22352. m.SetActionMessage(v)
  22353. return nil
  22354. case sopstage.FieldActionLabelAdd:
  22355. v, ok := value.([]uint64)
  22356. if !ok {
  22357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22358. }
  22359. m.SetActionLabelAdd(v)
  22360. return nil
  22361. case sopstage.FieldActionLabelDel:
  22362. v, ok := value.([]uint64)
  22363. if !ok {
  22364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22365. }
  22366. m.SetActionLabelDel(v)
  22367. return nil
  22368. case sopstage.FieldActionForward:
  22369. v, ok := value.(*custom_types.ActionForward)
  22370. if !ok {
  22371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22372. }
  22373. m.SetActionForward(v)
  22374. return nil
  22375. case sopstage.FieldIndexSort:
  22376. v, ok := value.(int)
  22377. if !ok {
  22378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22379. }
  22380. m.SetIndexSort(v)
  22381. return nil
  22382. }
  22383. return fmt.Errorf("unknown SopStage field %s", name)
  22384. }
  22385. // AddedFields returns all numeric fields that were incremented/decremented during
  22386. // this mutation.
  22387. func (m *SopStageMutation) AddedFields() []string {
  22388. var fields []string
  22389. if m.addstatus != nil {
  22390. fields = append(fields, sopstage.FieldStatus)
  22391. }
  22392. if m.addcondition_type != nil {
  22393. fields = append(fields, sopstage.FieldConditionType)
  22394. }
  22395. if m.addcondition_operator != nil {
  22396. fields = append(fields, sopstage.FieldConditionOperator)
  22397. }
  22398. if m.addindex_sort != nil {
  22399. fields = append(fields, sopstage.FieldIndexSort)
  22400. }
  22401. return fields
  22402. }
  22403. // AddedField returns the numeric value that was incremented/decremented on a field
  22404. // with the given name. The second boolean return value indicates that this field
  22405. // was not set, or was not defined in the schema.
  22406. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  22407. switch name {
  22408. case sopstage.FieldStatus:
  22409. return m.AddedStatus()
  22410. case sopstage.FieldConditionType:
  22411. return m.AddedConditionType()
  22412. case sopstage.FieldConditionOperator:
  22413. return m.AddedConditionOperator()
  22414. case sopstage.FieldIndexSort:
  22415. return m.AddedIndexSort()
  22416. }
  22417. return nil, false
  22418. }
  22419. // AddField adds the value to the field with the given name. It returns an error if
  22420. // the field is not defined in the schema, or if the type mismatched the field
  22421. // type.
  22422. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  22423. switch name {
  22424. case sopstage.FieldStatus:
  22425. v, ok := value.(int8)
  22426. if !ok {
  22427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22428. }
  22429. m.AddStatus(v)
  22430. return nil
  22431. case sopstage.FieldConditionType:
  22432. v, ok := value.(int)
  22433. if !ok {
  22434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22435. }
  22436. m.AddConditionType(v)
  22437. return nil
  22438. case sopstage.FieldConditionOperator:
  22439. v, ok := value.(int)
  22440. if !ok {
  22441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22442. }
  22443. m.AddConditionOperator(v)
  22444. return nil
  22445. case sopstage.FieldIndexSort:
  22446. v, ok := value.(int)
  22447. if !ok {
  22448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22449. }
  22450. m.AddIndexSort(v)
  22451. return nil
  22452. }
  22453. return fmt.Errorf("unknown SopStage numeric field %s", name)
  22454. }
  22455. // ClearedFields returns all nullable fields that were cleared during this
  22456. // mutation.
  22457. func (m *SopStageMutation) ClearedFields() []string {
  22458. var fields []string
  22459. if m.FieldCleared(sopstage.FieldStatus) {
  22460. fields = append(fields, sopstage.FieldStatus)
  22461. }
  22462. if m.FieldCleared(sopstage.FieldDeletedAt) {
  22463. fields = append(fields, sopstage.FieldDeletedAt)
  22464. }
  22465. if m.FieldCleared(sopstage.FieldActionMessage) {
  22466. fields = append(fields, sopstage.FieldActionMessage)
  22467. }
  22468. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  22469. fields = append(fields, sopstage.FieldActionLabelAdd)
  22470. }
  22471. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  22472. fields = append(fields, sopstage.FieldActionLabelDel)
  22473. }
  22474. if m.FieldCleared(sopstage.FieldActionForward) {
  22475. fields = append(fields, sopstage.FieldActionForward)
  22476. }
  22477. if m.FieldCleared(sopstage.FieldIndexSort) {
  22478. fields = append(fields, sopstage.FieldIndexSort)
  22479. }
  22480. return fields
  22481. }
  22482. // FieldCleared returns a boolean indicating if a field with the given name was
  22483. // cleared in this mutation.
  22484. func (m *SopStageMutation) FieldCleared(name string) bool {
  22485. _, ok := m.clearedFields[name]
  22486. return ok
  22487. }
  22488. // ClearField clears the value of the field with the given name. It returns an
  22489. // error if the field is not defined in the schema.
  22490. func (m *SopStageMutation) ClearField(name string) error {
  22491. switch name {
  22492. case sopstage.FieldStatus:
  22493. m.ClearStatus()
  22494. return nil
  22495. case sopstage.FieldDeletedAt:
  22496. m.ClearDeletedAt()
  22497. return nil
  22498. case sopstage.FieldActionMessage:
  22499. m.ClearActionMessage()
  22500. return nil
  22501. case sopstage.FieldActionLabelAdd:
  22502. m.ClearActionLabelAdd()
  22503. return nil
  22504. case sopstage.FieldActionLabelDel:
  22505. m.ClearActionLabelDel()
  22506. return nil
  22507. case sopstage.FieldActionForward:
  22508. m.ClearActionForward()
  22509. return nil
  22510. case sopstage.FieldIndexSort:
  22511. m.ClearIndexSort()
  22512. return nil
  22513. }
  22514. return fmt.Errorf("unknown SopStage nullable field %s", name)
  22515. }
  22516. // ResetField resets all changes in the mutation for the field with the given name.
  22517. // It returns an error if the field is not defined in the schema.
  22518. func (m *SopStageMutation) ResetField(name string) error {
  22519. switch name {
  22520. case sopstage.FieldCreatedAt:
  22521. m.ResetCreatedAt()
  22522. return nil
  22523. case sopstage.FieldUpdatedAt:
  22524. m.ResetUpdatedAt()
  22525. return nil
  22526. case sopstage.FieldStatus:
  22527. m.ResetStatus()
  22528. return nil
  22529. case sopstage.FieldDeletedAt:
  22530. m.ResetDeletedAt()
  22531. return nil
  22532. case sopstage.FieldTaskID:
  22533. m.ResetTaskID()
  22534. return nil
  22535. case sopstage.FieldName:
  22536. m.ResetName()
  22537. return nil
  22538. case sopstage.FieldConditionType:
  22539. m.ResetConditionType()
  22540. return nil
  22541. case sopstage.FieldConditionOperator:
  22542. m.ResetConditionOperator()
  22543. return nil
  22544. case sopstage.FieldConditionList:
  22545. m.ResetConditionList()
  22546. return nil
  22547. case sopstage.FieldActionMessage:
  22548. m.ResetActionMessage()
  22549. return nil
  22550. case sopstage.FieldActionLabelAdd:
  22551. m.ResetActionLabelAdd()
  22552. return nil
  22553. case sopstage.FieldActionLabelDel:
  22554. m.ResetActionLabelDel()
  22555. return nil
  22556. case sopstage.FieldActionForward:
  22557. m.ResetActionForward()
  22558. return nil
  22559. case sopstage.FieldIndexSort:
  22560. m.ResetIndexSort()
  22561. return nil
  22562. }
  22563. return fmt.Errorf("unknown SopStage field %s", name)
  22564. }
  22565. // AddedEdges returns all edge names that were set/added in this mutation.
  22566. func (m *SopStageMutation) AddedEdges() []string {
  22567. edges := make([]string, 0, 3)
  22568. if m.sop_task != nil {
  22569. edges = append(edges, sopstage.EdgeSopTask)
  22570. }
  22571. if m.stage_nodes != nil {
  22572. edges = append(edges, sopstage.EdgeStageNodes)
  22573. }
  22574. if m.stage_messages != nil {
  22575. edges = append(edges, sopstage.EdgeStageMessages)
  22576. }
  22577. return edges
  22578. }
  22579. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22580. // name in this mutation.
  22581. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  22582. switch name {
  22583. case sopstage.EdgeSopTask:
  22584. if id := m.sop_task; id != nil {
  22585. return []ent.Value{*id}
  22586. }
  22587. case sopstage.EdgeStageNodes:
  22588. ids := make([]ent.Value, 0, len(m.stage_nodes))
  22589. for id := range m.stage_nodes {
  22590. ids = append(ids, id)
  22591. }
  22592. return ids
  22593. case sopstage.EdgeStageMessages:
  22594. ids := make([]ent.Value, 0, len(m.stage_messages))
  22595. for id := range m.stage_messages {
  22596. ids = append(ids, id)
  22597. }
  22598. return ids
  22599. }
  22600. return nil
  22601. }
  22602. // RemovedEdges returns all edge names that were removed in this mutation.
  22603. func (m *SopStageMutation) RemovedEdges() []string {
  22604. edges := make([]string, 0, 3)
  22605. if m.removedstage_nodes != nil {
  22606. edges = append(edges, sopstage.EdgeStageNodes)
  22607. }
  22608. if m.removedstage_messages != nil {
  22609. edges = append(edges, sopstage.EdgeStageMessages)
  22610. }
  22611. return edges
  22612. }
  22613. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22614. // the given name in this mutation.
  22615. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  22616. switch name {
  22617. case sopstage.EdgeStageNodes:
  22618. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  22619. for id := range m.removedstage_nodes {
  22620. ids = append(ids, id)
  22621. }
  22622. return ids
  22623. case sopstage.EdgeStageMessages:
  22624. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  22625. for id := range m.removedstage_messages {
  22626. ids = append(ids, id)
  22627. }
  22628. return ids
  22629. }
  22630. return nil
  22631. }
  22632. // ClearedEdges returns all edge names that were cleared in this mutation.
  22633. func (m *SopStageMutation) ClearedEdges() []string {
  22634. edges := make([]string, 0, 3)
  22635. if m.clearedsop_task {
  22636. edges = append(edges, sopstage.EdgeSopTask)
  22637. }
  22638. if m.clearedstage_nodes {
  22639. edges = append(edges, sopstage.EdgeStageNodes)
  22640. }
  22641. if m.clearedstage_messages {
  22642. edges = append(edges, sopstage.EdgeStageMessages)
  22643. }
  22644. return edges
  22645. }
  22646. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22647. // was cleared in this mutation.
  22648. func (m *SopStageMutation) EdgeCleared(name string) bool {
  22649. switch name {
  22650. case sopstage.EdgeSopTask:
  22651. return m.clearedsop_task
  22652. case sopstage.EdgeStageNodes:
  22653. return m.clearedstage_nodes
  22654. case sopstage.EdgeStageMessages:
  22655. return m.clearedstage_messages
  22656. }
  22657. return false
  22658. }
  22659. // ClearEdge clears the value of the edge with the given name. It returns an error
  22660. // if that edge is not defined in the schema.
  22661. func (m *SopStageMutation) ClearEdge(name string) error {
  22662. switch name {
  22663. case sopstage.EdgeSopTask:
  22664. m.ClearSopTask()
  22665. return nil
  22666. }
  22667. return fmt.Errorf("unknown SopStage unique edge %s", name)
  22668. }
  22669. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22670. // It returns an error if the edge is not defined in the schema.
  22671. func (m *SopStageMutation) ResetEdge(name string) error {
  22672. switch name {
  22673. case sopstage.EdgeSopTask:
  22674. m.ResetSopTask()
  22675. return nil
  22676. case sopstage.EdgeStageNodes:
  22677. m.ResetStageNodes()
  22678. return nil
  22679. case sopstage.EdgeStageMessages:
  22680. m.ResetStageMessages()
  22681. return nil
  22682. }
  22683. return fmt.Errorf("unknown SopStage edge %s", name)
  22684. }
  22685. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  22686. type SopTaskMutation struct {
  22687. config
  22688. op Op
  22689. typ string
  22690. id *uint64
  22691. created_at *time.Time
  22692. updated_at *time.Time
  22693. status *uint8
  22694. addstatus *int8
  22695. deleted_at *time.Time
  22696. name *string
  22697. bot_wxid_list *[]string
  22698. appendbot_wxid_list []string
  22699. _type *int
  22700. add_type *int
  22701. plan_start_time *time.Time
  22702. plan_end_time *time.Time
  22703. creator_id *string
  22704. organization_id *uint64
  22705. addorganization_id *int64
  22706. token *[]string
  22707. appendtoken []string
  22708. clearedFields map[string]struct{}
  22709. task_stages map[uint64]struct{}
  22710. removedtask_stages map[uint64]struct{}
  22711. clearedtask_stages bool
  22712. done bool
  22713. oldValue func(context.Context) (*SopTask, error)
  22714. predicates []predicate.SopTask
  22715. }
  22716. var _ ent.Mutation = (*SopTaskMutation)(nil)
  22717. // soptaskOption allows management of the mutation configuration using functional options.
  22718. type soptaskOption func(*SopTaskMutation)
  22719. // newSopTaskMutation creates new mutation for the SopTask entity.
  22720. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  22721. m := &SopTaskMutation{
  22722. config: c,
  22723. op: op,
  22724. typ: TypeSopTask,
  22725. clearedFields: make(map[string]struct{}),
  22726. }
  22727. for _, opt := range opts {
  22728. opt(m)
  22729. }
  22730. return m
  22731. }
  22732. // withSopTaskID sets the ID field of the mutation.
  22733. func withSopTaskID(id uint64) soptaskOption {
  22734. return func(m *SopTaskMutation) {
  22735. var (
  22736. err error
  22737. once sync.Once
  22738. value *SopTask
  22739. )
  22740. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  22741. once.Do(func() {
  22742. if m.done {
  22743. err = errors.New("querying old values post mutation is not allowed")
  22744. } else {
  22745. value, err = m.Client().SopTask.Get(ctx, id)
  22746. }
  22747. })
  22748. return value, err
  22749. }
  22750. m.id = &id
  22751. }
  22752. }
  22753. // withSopTask sets the old SopTask of the mutation.
  22754. func withSopTask(node *SopTask) soptaskOption {
  22755. return func(m *SopTaskMutation) {
  22756. m.oldValue = func(context.Context) (*SopTask, error) {
  22757. return node, nil
  22758. }
  22759. m.id = &node.ID
  22760. }
  22761. }
  22762. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22763. // executed in a transaction (ent.Tx), a transactional client is returned.
  22764. func (m SopTaskMutation) Client() *Client {
  22765. client := &Client{config: m.config}
  22766. client.init()
  22767. return client
  22768. }
  22769. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22770. // it returns an error otherwise.
  22771. func (m SopTaskMutation) Tx() (*Tx, error) {
  22772. if _, ok := m.driver.(*txDriver); !ok {
  22773. return nil, errors.New("ent: mutation is not running in a transaction")
  22774. }
  22775. tx := &Tx{config: m.config}
  22776. tx.init()
  22777. return tx, nil
  22778. }
  22779. // SetID sets the value of the id field. Note that this
  22780. // operation is only accepted on creation of SopTask entities.
  22781. func (m *SopTaskMutation) SetID(id uint64) {
  22782. m.id = &id
  22783. }
  22784. // ID returns the ID value in the mutation. Note that the ID is only available
  22785. // if it was provided to the builder or after it was returned from the database.
  22786. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  22787. if m.id == nil {
  22788. return
  22789. }
  22790. return *m.id, true
  22791. }
  22792. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22793. // That means, if the mutation is applied within a transaction with an isolation level such
  22794. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22795. // or updated by the mutation.
  22796. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  22797. switch {
  22798. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22799. id, exists := m.ID()
  22800. if exists {
  22801. return []uint64{id}, nil
  22802. }
  22803. fallthrough
  22804. case m.op.Is(OpUpdate | OpDelete):
  22805. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  22806. default:
  22807. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22808. }
  22809. }
  22810. // SetCreatedAt sets the "created_at" field.
  22811. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  22812. m.created_at = &t
  22813. }
  22814. // CreatedAt returns the value of the "created_at" field in the mutation.
  22815. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  22816. v := m.created_at
  22817. if v == nil {
  22818. return
  22819. }
  22820. return *v, true
  22821. }
  22822. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  22823. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  22824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22825. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22826. if !m.op.Is(OpUpdateOne) {
  22827. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22828. }
  22829. if m.id == nil || m.oldValue == nil {
  22830. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22831. }
  22832. oldValue, err := m.oldValue(ctx)
  22833. if err != nil {
  22834. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22835. }
  22836. return oldValue.CreatedAt, nil
  22837. }
  22838. // ResetCreatedAt resets all changes to the "created_at" field.
  22839. func (m *SopTaskMutation) ResetCreatedAt() {
  22840. m.created_at = nil
  22841. }
  22842. // SetUpdatedAt sets the "updated_at" field.
  22843. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  22844. m.updated_at = &t
  22845. }
  22846. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22847. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  22848. v := m.updated_at
  22849. if v == nil {
  22850. return
  22851. }
  22852. return *v, true
  22853. }
  22854. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  22855. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  22856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22857. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22858. if !m.op.Is(OpUpdateOne) {
  22859. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22860. }
  22861. if m.id == nil || m.oldValue == nil {
  22862. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22863. }
  22864. oldValue, err := m.oldValue(ctx)
  22865. if err != nil {
  22866. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22867. }
  22868. return oldValue.UpdatedAt, nil
  22869. }
  22870. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22871. func (m *SopTaskMutation) ResetUpdatedAt() {
  22872. m.updated_at = nil
  22873. }
  22874. // SetStatus sets the "status" field.
  22875. func (m *SopTaskMutation) SetStatus(u uint8) {
  22876. m.status = &u
  22877. m.addstatus = nil
  22878. }
  22879. // Status returns the value of the "status" field in the mutation.
  22880. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  22881. v := m.status
  22882. if v == nil {
  22883. return
  22884. }
  22885. return *v, true
  22886. }
  22887. // OldStatus returns the old "status" field's value of the SopTask entity.
  22888. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  22889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22890. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22891. if !m.op.Is(OpUpdateOne) {
  22892. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22893. }
  22894. if m.id == nil || m.oldValue == nil {
  22895. return v, errors.New("OldStatus requires an ID field in the mutation")
  22896. }
  22897. oldValue, err := m.oldValue(ctx)
  22898. if err != nil {
  22899. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22900. }
  22901. return oldValue.Status, nil
  22902. }
  22903. // AddStatus adds u to the "status" field.
  22904. func (m *SopTaskMutation) AddStatus(u int8) {
  22905. if m.addstatus != nil {
  22906. *m.addstatus += u
  22907. } else {
  22908. m.addstatus = &u
  22909. }
  22910. }
  22911. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22912. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  22913. v := m.addstatus
  22914. if v == nil {
  22915. return
  22916. }
  22917. return *v, true
  22918. }
  22919. // ClearStatus clears the value of the "status" field.
  22920. func (m *SopTaskMutation) ClearStatus() {
  22921. m.status = nil
  22922. m.addstatus = nil
  22923. m.clearedFields[soptask.FieldStatus] = struct{}{}
  22924. }
  22925. // StatusCleared returns if the "status" field was cleared in this mutation.
  22926. func (m *SopTaskMutation) StatusCleared() bool {
  22927. _, ok := m.clearedFields[soptask.FieldStatus]
  22928. return ok
  22929. }
  22930. // ResetStatus resets all changes to the "status" field.
  22931. func (m *SopTaskMutation) ResetStatus() {
  22932. m.status = nil
  22933. m.addstatus = nil
  22934. delete(m.clearedFields, soptask.FieldStatus)
  22935. }
  22936. // SetDeletedAt sets the "deleted_at" field.
  22937. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  22938. m.deleted_at = &t
  22939. }
  22940. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22941. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  22942. v := m.deleted_at
  22943. if v == nil {
  22944. return
  22945. }
  22946. return *v, true
  22947. }
  22948. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  22949. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  22950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22951. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22952. if !m.op.Is(OpUpdateOne) {
  22953. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22954. }
  22955. if m.id == nil || m.oldValue == nil {
  22956. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22957. }
  22958. oldValue, err := m.oldValue(ctx)
  22959. if err != nil {
  22960. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22961. }
  22962. return oldValue.DeletedAt, nil
  22963. }
  22964. // ClearDeletedAt clears the value of the "deleted_at" field.
  22965. func (m *SopTaskMutation) ClearDeletedAt() {
  22966. m.deleted_at = nil
  22967. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  22968. }
  22969. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22970. func (m *SopTaskMutation) DeletedAtCleared() bool {
  22971. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  22972. return ok
  22973. }
  22974. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22975. func (m *SopTaskMutation) ResetDeletedAt() {
  22976. m.deleted_at = nil
  22977. delete(m.clearedFields, soptask.FieldDeletedAt)
  22978. }
  22979. // SetName sets the "name" field.
  22980. func (m *SopTaskMutation) SetName(s string) {
  22981. m.name = &s
  22982. }
  22983. // Name returns the value of the "name" field in the mutation.
  22984. func (m *SopTaskMutation) Name() (r string, exists bool) {
  22985. v := m.name
  22986. if v == nil {
  22987. return
  22988. }
  22989. return *v, true
  22990. }
  22991. // OldName returns the old "name" field's value of the SopTask entity.
  22992. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  22993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22994. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  22995. if !m.op.Is(OpUpdateOne) {
  22996. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22997. }
  22998. if m.id == nil || m.oldValue == nil {
  22999. return v, errors.New("OldName requires an ID field in the mutation")
  23000. }
  23001. oldValue, err := m.oldValue(ctx)
  23002. if err != nil {
  23003. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23004. }
  23005. return oldValue.Name, nil
  23006. }
  23007. // ResetName resets all changes to the "name" field.
  23008. func (m *SopTaskMutation) ResetName() {
  23009. m.name = nil
  23010. }
  23011. // SetBotWxidList sets the "bot_wxid_list" field.
  23012. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  23013. m.bot_wxid_list = &s
  23014. m.appendbot_wxid_list = nil
  23015. }
  23016. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  23017. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  23018. v := m.bot_wxid_list
  23019. if v == nil {
  23020. return
  23021. }
  23022. return *v, true
  23023. }
  23024. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  23025. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23027. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  23028. if !m.op.Is(OpUpdateOne) {
  23029. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  23030. }
  23031. if m.id == nil || m.oldValue == nil {
  23032. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  23033. }
  23034. oldValue, err := m.oldValue(ctx)
  23035. if err != nil {
  23036. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  23037. }
  23038. return oldValue.BotWxidList, nil
  23039. }
  23040. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  23041. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  23042. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  23043. }
  23044. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  23045. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  23046. if len(m.appendbot_wxid_list) == 0 {
  23047. return nil, false
  23048. }
  23049. return m.appendbot_wxid_list, true
  23050. }
  23051. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  23052. func (m *SopTaskMutation) ClearBotWxidList() {
  23053. m.bot_wxid_list = nil
  23054. m.appendbot_wxid_list = nil
  23055. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  23056. }
  23057. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  23058. func (m *SopTaskMutation) BotWxidListCleared() bool {
  23059. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  23060. return ok
  23061. }
  23062. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  23063. func (m *SopTaskMutation) ResetBotWxidList() {
  23064. m.bot_wxid_list = nil
  23065. m.appendbot_wxid_list = nil
  23066. delete(m.clearedFields, soptask.FieldBotWxidList)
  23067. }
  23068. // SetType sets the "type" field.
  23069. func (m *SopTaskMutation) SetType(i int) {
  23070. m._type = &i
  23071. m.add_type = nil
  23072. }
  23073. // GetType returns the value of the "type" field in the mutation.
  23074. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  23075. v := m._type
  23076. if v == nil {
  23077. return
  23078. }
  23079. return *v, true
  23080. }
  23081. // OldType returns the old "type" field's value of the SopTask entity.
  23082. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23084. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  23085. if !m.op.Is(OpUpdateOne) {
  23086. return v, errors.New("OldType is only allowed on UpdateOne operations")
  23087. }
  23088. if m.id == nil || m.oldValue == nil {
  23089. return v, errors.New("OldType requires an ID field in the mutation")
  23090. }
  23091. oldValue, err := m.oldValue(ctx)
  23092. if err != nil {
  23093. return v, fmt.Errorf("querying old value for OldType: %w", err)
  23094. }
  23095. return oldValue.Type, nil
  23096. }
  23097. // AddType adds i to the "type" field.
  23098. func (m *SopTaskMutation) AddType(i int) {
  23099. if m.add_type != nil {
  23100. *m.add_type += i
  23101. } else {
  23102. m.add_type = &i
  23103. }
  23104. }
  23105. // AddedType returns the value that was added to the "type" field in this mutation.
  23106. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  23107. v := m.add_type
  23108. if v == nil {
  23109. return
  23110. }
  23111. return *v, true
  23112. }
  23113. // ResetType resets all changes to the "type" field.
  23114. func (m *SopTaskMutation) ResetType() {
  23115. m._type = nil
  23116. m.add_type = nil
  23117. }
  23118. // SetPlanStartTime sets the "plan_start_time" field.
  23119. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  23120. m.plan_start_time = &t
  23121. }
  23122. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  23123. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  23124. v := m.plan_start_time
  23125. if v == nil {
  23126. return
  23127. }
  23128. return *v, true
  23129. }
  23130. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  23131. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23132. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23133. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  23134. if !m.op.Is(OpUpdateOne) {
  23135. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  23136. }
  23137. if m.id == nil || m.oldValue == nil {
  23138. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  23139. }
  23140. oldValue, err := m.oldValue(ctx)
  23141. if err != nil {
  23142. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  23143. }
  23144. return oldValue.PlanStartTime, nil
  23145. }
  23146. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  23147. func (m *SopTaskMutation) ClearPlanStartTime() {
  23148. m.plan_start_time = nil
  23149. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  23150. }
  23151. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  23152. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  23153. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  23154. return ok
  23155. }
  23156. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  23157. func (m *SopTaskMutation) ResetPlanStartTime() {
  23158. m.plan_start_time = nil
  23159. delete(m.clearedFields, soptask.FieldPlanStartTime)
  23160. }
  23161. // SetPlanEndTime sets the "plan_end_time" field.
  23162. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  23163. m.plan_end_time = &t
  23164. }
  23165. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  23166. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  23167. v := m.plan_end_time
  23168. if v == nil {
  23169. return
  23170. }
  23171. return *v, true
  23172. }
  23173. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  23174. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23175. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23176. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  23177. if !m.op.Is(OpUpdateOne) {
  23178. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  23179. }
  23180. if m.id == nil || m.oldValue == nil {
  23181. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  23182. }
  23183. oldValue, err := m.oldValue(ctx)
  23184. if err != nil {
  23185. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  23186. }
  23187. return oldValue.PlanEndTime, nil
  23188. }
  23189. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  23190. func (m *SopTaskMutation) ClearPlanEndTime() {
  23191. m.plan_end_time = nil
  23192. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  23193. }
  23194. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  23195. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  23196. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  23197. return ok
  23198. }
  23199. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  23200. func (m *SopTaskMutation) ResetPlanEndTime() {
  23201. m.plan_end_time = nil
  23202. delete(m.clearedFields, soptask.FieldPlanEndTime)
  23203. }
  23204. // SetCreatorID sets the "creator_id" field.
  23205. func (m *SopTaskMutation) SetCreatorID(s string) {
  23206. m.creator_id = &s
  23207. }
  23208. // CreatorID returns the value of the "creator_id" field in the mutation.
  23209. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  23210. v := m.creator_id
  23211. if v == nil {
  23212. return
  23213. }
  23214. return *v, true
  23215. }
  23216. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  23217. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23219. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  23220. if !m.op.Is(OpUpdateOne) {
  23221. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  23222. }
  23223. if m.id == nil || m.oldValue == nil {
  23224. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  23225. }
  23226. oldValue, err := m.oldValue(ctx)
  23227. if err != nil {
  23228. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  23229. }
  23230. return oldValue.CreatorID, nil
  23231. }
  23232. // ClearCreatorID clears the value of the "creator_id" field.
  23233. func (m *SopTaskMutation) ClearCreatorID() {
  23234. m.creator_id = nil
  23235. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  23236. }
  23237. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  23238. func (m *SopTaskMutation) CreatorIDCleared() bool {
  23239. _, ok := m.clearedFields[soptask.FieldCreatorID]
  23240. return ok
  23241. }
  23242. // ResetCreatorID resets all changes to the "creator_id" field.
  23243. func (m *SopTaskMutation) ResetCreatorID() {
  23244. m.creator_id = nil
  23245. delete(m.clearedFields, soptask.FieldCreatorID)
  23246. }
  23247. // SetOrganizationID sets the "organization_id" field.
  23248. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  23249. m.organization_id = &u
  23250. m.addorganization_id = nil
  23251. }
  23252. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23253. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  23254. v := m.organization_id
  23255. if v == nil {
  23256. return
  23257. }
  23258. return *v, true
  23259. }
  23260. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  23261. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23263. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23264. if !m.op.Is(OpUpdateOne) {
  23265. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23266. }
  23267. if m.id == nil || m.oldValue == nil {
  23268. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23269. }
  23270. oldValue, err := m.oldValue(ctx)
  23271. if err != nil {
  23272. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23273. }
  23274. return oldValue.OrganizationID, nil
  23275. }
  23276. // AddOrganizationID adds u to the "organization_id" field.
  23277. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  23278. if m.addorganization_id != nil {
  23279. *m.addorganization_id += u
  23280. } else {
  23281. m.addorganization_id = &u
  23282. }
  23283. }
  23284. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23285. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  23286. v := m.addorganization_id
  23287. if v == nil {
  23288. return
  23289. }
  23290. return *v, true
  23291. }
  23292. // ClearOrganizationID clears the value of the "organization_id" field.
  23293. func (m *SopTaskMutation) ClearOrganizationID() {
  23294. m.organization_id = nil
  23295. m.addorganization_id = nil
  23296. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  23297. }
  23298. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  23299. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  23300. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  23301. return ok
  23302. }
  23303. // ResetOrganizationID resets all changes to the "organization_id" field.
  23304. func (m *SopTaskMutation) ResetOrganizationID() {
  23305. m.organization_id = nil
  23306. m.addorganization_id = nil
  23307. delete(m.clearedFields, soptask.FieldOrganizationID)
  23308. }
  23309. // SetToken sets the "token" field.
  23310. func (m *SopTaskMutation) SetToken(s []string) {
  23311. m.token = &s
  23312. m.appendtoken = nil
  23313. }
  23314. // Token returns the value of the "token" field in the mutation.
  23315. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  23316. v := m.token
  23317. if v == nil {
  23318. return
  23319. }
  23320. return *v, true
  23321. }
  23322. // OldToken returns the old "token" field's value of the SopTask entity.
  23323. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23325. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  23326. if !m.op.Is(OpUpdateOne) {
  23327. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  23328. }
  23329. if m.id == nil || m.oldValue == nil {
  23330. return v, errors.New("OldToken requires an ID field in the mutation")
  23331. }
  23332. oldValue, err := m.oldValue(ctx)
  23333. if err != nil {
  23334. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  23335. }
  23336. return oldValue.Token, nil
  23337. }
  23338. // AppendToken adds s to the "token" field.
  23339. func (m *SopTaskMutation) AppendToken(s []string) {
  23340. m.appendtoken = append(m.appendtoken, s...)
  23341. }
  23342. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  23343. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  23344. if len(m.appendtoken) == 0 {
  23345. return nil, false
  23346. }
  23347. return m.appendtoken, true
  23348. }
  23349. // ClearToken clears the value of the "token" field.
  23350. func (m *SopTaskMutation) ClearToken() {
  23351. m.token = nil
  23352. m.appendtoken = nil
  23353. m.clearedFields[soptask.FieldToken] = struct{}{}
  23354. }
  23355. // TokenCleared returns if the "token" field was cleared in this mutation.
  23356. func (m *SopTaskMutation) TokenCleared() bool {
  23357. _, ok := m.clearedFields[soptask.FieldToken]
  23358. return ok
  23359. }
  23360. // ResetToken resets all changes to the "token" field.
  23361. func (m *SopTaskMutation) ResetToken() {
  23362. m.token = nil
  23363. m.appendtoken = nil
  23364. delete(m.clearedFields, soptask.FieldToken)
  23365. }
  23366. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  23367. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  23368. if m.task_stages == nil {
  23369. m.task_stages = make(map[uint64]struct{})
  23370. }
  23371. for i := range ids {
  23372. m.task_stages[ids[i]] = struct{}{}
  23373. }
  23374. }
  23375. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  23376. func (m *SopTaskMutation) ClearTaskStages() {
  23377. m.clearedtask_stages = true
  23378. }
  23379. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  23380. func (m *SopTaskMutation) TaskStagesCleared() bool {
  23381. return m.clearedtask_stages
  23382. }
  23383. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  23384. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  23385. if m.removedtask_stages == nil {
  23386. m.removedtask_stages = make(map[uint64]struct{})
  23387. }
  23388. for i := range ids {
  23389. delete(m.task_stages, ids[i])
  23390. m.removedtask_stages[ids[i]] = struct{}{}
  23391. }
  23392. }
  23393. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  23394. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  23395. for id := range m.removedtask_stages {
  23396. ids = append(ids, id)
  23397. }
  23398. return
  23399. }
  23400. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  23401. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  23402. for id := range m.task_stages {
  23403. ids = append(ids, id)
  23404. }
  23405. return
  23406. }
  23407. // ResetTaskStages resets all changes to the "task_stages" edge.
  23408. func (m *SopTaskMutation) ResetTaskStages() {
  23409. m.task_stages = nil
  23410. m.clearedtask_stages = false
  23411. m.removedtask_stages = nil
  23412. }
  23413. // Where appends a list predicates to the SopTaskMutation builder.
  23414. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  23415. m.predicates = append(m.predicates, ps...)
  23416. }
  23417. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  23418. // users can use type-assertion to append predicates that do not depend on any generated package.
  23419. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  23420. p := make([]predicate.SopTask, len(ps))
  23421. for i := range ps {
  23422. p[i] = ps[i]
  23423. }
  23424. m.Where(p...)
  23425. }
  23426. // Op returns the operation name.
  23427. func (m *SopTaskMutation) Op() Op {
  23428. return m.op
  23429. }
  23430. // SetOp allows setting the mutation operation.
  23431. func (m *SopTaskMutation) SetOp(op Op) {
  23432. m.op = op
  23433. }
  23434. // Type returns the node type of this mutation (SopTask).
  23435. func (m *SopTaskMutation) Type() string {
  23436. return m.typ
  23437. }
  23438. // Fields returns all fields that were changed during this mutation. Note that in
  23439. // order to get all numeric fields that were incremented/decremented, call
  23440. // AddedFields().
  23441. func (m *SopTaskMutation) Fields() []string {
  23442. fields := make([]string, 0, 12)
  23443. if m.created_at != nil {
  23444. fields = append(fields, soptask.FieldCreatedAt)
  23445. }
  23446. if m.updated_at != nil {
  23447. fields = append(fields, soptask.FieldUpdatedAt)
  23448. }
  23449. if m.status != nil {
  23450. fields = append(fields, soptask.FieldStatus)
  23451. }
  23452. if m.deleted_at != nil {
  23453. fields = append(fields, soptask.FieldDeletedAt)
  23454. }
  23455. if m.name != nil {
  23456. fields = append(fields, soptask.FieldName)
  23457. }
  23458. if m.bot_wxid_list != nil {
  23459. fields = append(fields, soptask.FieldBotWxidList)
  23460. }
  23461. if m._type != nil {
  23462. fields = append(fields, soptask.FieldType)
  23463. }
  23464. if m.plan_start_time != nil {
  23465. fields = append(fields, soptask.FieldPlanStartTime)
  23466. }
  23467. if m.plan_end_time != nil {
  23468. fields = append(fields, soptask.FieldPlanEndTime)
  23469. }
  23470. if m.creator_id != nil {
  23471. fields = append(fields, soptask.FieldCreatorID)
  23472. }
  23473. if m.organization_id != nil {
  23474. fields = append(fields, soptask.FieldOrganizationID)
  23475. }
  23476. if m.token != nil {
  23477. fields = append(fields, soptask.FieldToken)
  23478. }
  23479. return fields
  23480. }
  23481. // Field returns the value of a field with the given name. The second boolean
  23482. // return value indicates that this field was not set, or was not defined in the
  23483. // schema.
  23484. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  23485. switch name {
  23486. case soptask.FieldCreatedAt:
  23487. return m.CreatedAt()
  23488. case soptask.FieldUpdatedAt:
  23489. return m.UpdatedAt()
  23490. case soptask.FieldStatus:
  23491. return m.Status()
  23492. case soptask.FieldDeletedAt:
  23493. return m.DeletedAt()
  23494. case soptask.FieldName:
  23495. return m.Name()
  23496. case soptask.FieldBotWxidList:
  23497. return m.BotWxidList()
  23498. case soptask.FieldType:
  23499. return m.GetType()
  23500. case soptask.FieldPlanStartTime:
  23501. return m.PlanStartTime()
  23502. case soptask.FieldPlanEndTime:
  23503. return m.PlanEndTime()
  23504. case soptask.FieldCreatorID:
  23505. return m.CreatorID()
  23506. case soptask.FieldOrganizationID:
  23507. return m.OrganizationID()
  23508. case soptask.FieldToken:
  23509. return m.Token()
  23510. }
  23511. return nil, false
  23512. }
  23513. // OldField returns the old value of the field from the database. An error is
  23514. // returned if the mutation operation is not UpdateOne, or the query to the
  23515. // database failed.
  23516. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23517. switch name {
  23518. case soptask.FieldCreatedAt:
  23519. return m.OldCreatedAt(ctx)
  23520. case soptask.FieldUpdatedAt:
  23521. return m.OldUpdatedAt(ctx)
  23522. case soptask.FieldStatus:
  23523. return m.OldStatus(ctx)
  23524. case soptask.FieldDeletedAt:
  23525. return m.OldDeletedAt(ctx)
  23526. case soptask.FieldName:
  23527. return m.OldName(ctx)
  23528. case soptask.FieldBotWxidList:
  23529. return m.OldBotWxidList(ctx)
  23530. case soptask.FieldType:
  23531. return m.OldType(ctx)
  23532. case soptask.FieldPlanStartTime:
  23533. return m.OldPlanStartTime(ctx)
  23534. case soptask.FieldPlanEndTime:
  23535. return m.OldPlanEndTime(ctx)
  23536. case soptask.FieldCreatorID:
  23537. return m.OldCreatorID(ctx)
  23538. case soptask.FieldOrganizationID:
  23539. return m.OldOrganizationID(ctx)
  23540. case soptask.FieldToken:
  23541. return m.OldToken(ctx)
  23542. }
  23543. return nil, fmt.Errorf("unknown SopTask field %s", name)
  23544. }
  23545. // SetField sets the value of a field with the given name. It returns an error if
  23546. // the field is not defined in the schema, or if the type mismatched the field
  23547. // type.
  23548. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  23549. switch name {
  23550. case soptask.FieldCreatedAt:
  23551. v, ok := value.(time.Time)
  23552. if !ok {
  23553. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23554. }
  23555. m.SetCreatedAt(v)
  23556. return nil
  23557. case soptask.FieldUpdatedAt:
  23558. v, ok := value.(time.Time)
  23559. if !ok {
  23560. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23561. }
  23562. m.SetUpdatedAt(v)
  23563. return nil
  23564. case soptask.FieldStatus:
  23565. v, ok := value.(uint8)
  23566. if !ok {
  23567. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23568. }
  23569. m.SetStatus(v)
  23570. return nil
  23571. case soptask.FieldDeletedAt:
  23572. v, ok := value.(time.Time)
  23573. if !ok {
  23574. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23575. }
  23576. m.SetDeletedAt(v)
  23577. return nil
  23578. case soptask.FieldName:
  23579. v, ok := value.(string)
  23580. if !ok {
  23581. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23582. }
  23583. m.SetName(v)
  23584. return nil
  23585. case soptask.FieldBotWxidList:
  23586. v, ok := value.([]string)
  23587. if !ok {
  23588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23589. }
  23590. m.SetBotWxidList(v)
  23591. return nil
  23592. case soptask.FieldType:
  23593. v, ok := value.(int)
  23594. if !ok {
  23595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23596. }
  23597. m.SetType(v)
  23598. return nil
  23599. case soptask.FieldPlanStartTime:
  23600. v, ok := value.(time.Time)
  23601. if !ok {
  23602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23603. }
  23604. m.SetPlanStartTime(v)
  23605. return nil
  23606. case soptask.FieldPlanEndTime:
  23607. v, ok := value.(time.Time)
  23608. if !ok {
  23609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23610. }
  23611. m.SetPlanEndTime(v)
  23612. return nil
  23613. case soptask.FieldCreatorID:
  23614. v, ok := value.(string)
  23615. if !ok {
  23616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23617. }
  23618. m.SetCreatorID(v)
  23619. return nil
  23620. case soptask.FieldOrganizationID:
  23621. v, ok := value.(uint64)
  23622. if !ok {
  23623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23624. }
  23625. m.SetOrganizationID(v)
  23626. return nil
  23627. case soptask.FieldToken:
  23628. v, ok := value.([]string)
  23629. if !ok {
  23630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23631. }
  23632. m.SetToken(v)
  23633. return nil
  23634. }
  23635. return fmt.Errorf("unknown SopTask field %s", name)
  23636. }
  23637. // AddedFields returns all numeric fields that were incremented/decremented during
  23638. // this mutation.
  23639. func (m *SopTaskMutation) AddedFields() []string {
  23640. var fields []string
  23641. if m.addstatus != nil {
  23642. fields = append(fields, soptask.FieldStatus)
  23643. }
  23644. if m.add_type != nil {
  23645. fields = append(fields, soptask.FieldType)
  23646. }
  23647. if m.addorganization_id != nil {
  23648. fields = append(fields, soptask.FieldOrganizationID)
  23649. }
  23650. return fields
  23651. }
  23652. // AddedField returns the numeric value that was incremented/decremented on a field
  23653. // with the given name. The second boolean return value indicates that this field
  23654. // was not set, or was not defined in the schema.
  23655. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  23656. switch name {
  23657. case soptask.FieldStatus:
  23658. return m.AddedStatus()
  23659. case soptask.FieldType:
  23660. return m.AddedType()
  23661. case soptask.FieldOrganizationID:
  23662. return m.AddedOrganizationID()
  23663. }
  23664. return nil, false
  23665. }
  23666. // AddField adds the value to the field with the given name. It returns an error if
  23667. // the field is not defined in the schema, or if the type mismatched the field
  23668. // type.
  23669. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  23670. switch name {
  23671. case soptask.FieldStatus:
  23672. v, ok := value.(int8)
  23673. if !ok {
  23674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23675. }
  23676. m.AddStatus(v)
  23677. return nil
  23678. case soptask.FieldType:
  23679. v, ok := value.(int)
  23680. if !ok {
  23681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23682. }
  23683. m.AddType(v)
  23684. return nil
  23685. case soptask.FieldOrganizationID:
  23686. v, ok := value.(int64)
  23687. if !ok {
  23688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23689. }
  23690. m.AddOrganizationID(v)
  23691. return nil
  23692. }
  23693. return fmt.Errorf("unknown SopTask numeric field %s", name)
  23694. }
  23695. // ClearedFields returns all nullable fields that were cleared during this
  23696. // mutation.
  23697. func (m *SopTaskMutation) ClearedFields() []string {
  23698. var fields []string
  23699. if m.FieldCleared(soptask.FieldStatus) {
  23700. fields = append(fields, soptask.FieldStatus)
  23701. }
  23702. if m.FieldCleared(soptask.FieldDeletedAt) {
  23703. fields = append(fields, soptask.FieldDeletedAt)
  23704. }
  23705. if m.FieldCleared(soptask.FieldBotWxidList) {
  23706. fields = append(fields, soptask.FieldBotWxidList)
  23707. }
  23708. if m.FieldCleared(soptask.FieldPlanStartTime) {
  23709. fields = append(fields, soptask.FieldPlanStartTime)
  23710. }
  23711. if m.FieldCleared(soptask.FieldPlanEndTime) {
  23712. fields = append(fields, soptask.FieldPlanEndTime)
  23713. }
  23714. if m.FieldCleared(soptask.FieldCreatorID) {
  23715. fields = append(fields, soptask.FieldCreatorID)
  23716. }
  23717. if m.FieldCleared(soptask.FieldOrganizationID) {
  23718. fields = append(fields, soptask.FieldOrganizationID)
  23719. }
  23720. if m.FieldCleared(soptask.FieldToken) {
  23721. fields = append(fields, soptask.FieldToken)
  23722. }
  23723. return fields
  23724. }
  23725. // FieldCleared returns a boolean indicating if a field with the given name was
  23726. // cleared in this mutation.
  23727. func (m *SopTaskMutation) FieldCleared(name string) bool {
  23728. _, ok := m.clearedFields[name]
  23729. return ok
  23730. }
  23731. // ClearField clears the value of the field with the given name. It returns an
  23732. // error if the field is not defined in the schema.
  23733. func (m *SopTaskMutation) ClearField(name string) error {
  23734. switch name {
  23735. case soptask.FieldStatus:
  23736. m.ClearStatus()
  23737. return nil
  23738. case soptask.FieldDeletedAt:
  23739. m.ClearDeletedAt()
  23740. return nil
  23741. case soptask.FieldBotWxidList:
  23742. m.ClearBotWxidList()
  23743. return nil
  23744. case soptask.FieldPlanStartTime:
  23745. m.ClearPlanStartTime()
  23746. return nil
  23747. case soptask.FieldPlanEndTime:
  23748. m.ClearPlanEndTime()
  23749. return nil
  23750. case soptask.FieldCreatorID:
  23751. m.ClearCreatorID()
  23752. return nil
  23753. case soptask.FieldOrganizationID:
  23754. m.ClearOrganizationID()
  23755. return nil
  23756. case soptask.FieldToken:
  23757. m.ClearToken()
  23758. return nil
  23759. }
  23760. return fmt.Errorf("unknown SopTask nullable field %s", name)
  23761. }
  23762. // ResetField resets all changes in the mutation for the field with the given name.
  23763. // It returns an error if the field is not defined in the schema.
  23764. func (m *SopTaskMutation) ResetField(name string) error {
  23765. switch name {
  23766. case soptask.FieldCreatedAt:
  23767. m.ResetCreatedAt()
  23768. return nil
  23769. case soptask.FieldUpdatedAt:
  23770. m.ResetUpdatedAt()
  23771. return nil
  23772. case soptask.FieldStatus:
  23773. m.ResetStatus()
  23774. return nil
  23775. case soptask.FieldDeletedAt:
  23776. m.ResetDeletedAt()
  23777. return nil
  23778. case soptask.FieldName:
  23779. m.ResetName()
  23780. return nil
  23781. case soptask.FieldBotWxidList:
  23782. m.ResetBotWxidList()
  23783. return nil
  23784. case soptask.FieldType:
  23785. m.ResetType()
  23786. return nil
  23787. case soptask.FieldPlanStartTime:
  23788. m.ResetPlanStartTime()
  23789. return nil
  23790. case soptask.FieldPlanEndTime:
  23791. m.ResetPlanEndTime()
  23792. return nil
  23793. case soptask.FieldCreatorID:
  23794. m.ResetCreatorID()
  23795. return nil
  23796. case soptask.FieldOrganizationID:
  23797. m.ResetOrganizationID()
  23798. return nil
  23799. case soptask.FieldToken:
  23800. m.ResetToken()
  23801. return nil
  23802. }
  23803. return fmt.Errorf("unknown SopTask field %s", name)
  23804. }
  23805. // AddedEdges returns all edge names that were set/added in this mutation.
  23806. func (m *SopTaskMutation) AddedEdges() []string {
  23807. edges := make([]string, 0, 1)
  23808. if m.task_stages != nil {
  23809. edges = append(edges, soptask.EdgeTaskStages)
  23810. }
  23811. return edges
  23812. }
  23813. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23814. // name in this mutation.
  23815. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  23816. switch name {
  23817. case soptask.EdgeTaskStages:
  23818. ids := make([]ent.Value, 0, len(m.task_stages))
  23819. for id := range m.task_stages {
  23820. ids = append(ids, id)
  23821. }
  23822. return ids
  23823. }
  23824. return nil
  23825. }
  23826. // RemovedEdges returns all edge names that were removed in this mutation.
  23827. func (m *SopTaskMutation) RemovedEdges() []string {
  23828. edges := make([]string, 0, 1)
  23829. if m.removedtask_stages != nil {
  23830. edges = append(edges, soptask.EdgeTaskStages)
  23831. }
  23832. return edges
  23833. }
  23834. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23835. // the given name in this mutation.
  23836. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  23837. switch name {
  23838. case soptask.EdgeTaskStages:
  23839. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  23840. for id := range m.removedtask_stages {
  23841. ids = append(ids, id)
  23842. }
  23843. return ids
  23844. }
  23845. return nil
  23846. }
  23847. // ClearedEdges returns all edge names that were cleared in this mutation.
  23848. func (m *SopTaskMutation) ClearedEdges() []string {
  23849. edges := make([]string, 0, 1)
  23850. if m.clearedtask_stages {
  23851. edges = append(edges, soptask.EdgeTaskStages)
  23852. }
  23853. return edges
  23854. }
  23855. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23856. // was cleared in this mutation.
  23857. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  23858. switch name {
  23859. case soptask.EdgeTaskStages:
  23860. return m.clearedtask_stages
  23861. }
  23862. return false
  23863. }
  23864. // ClearEdge clears the value of the edge with the given name. It returns an error
  23865. // if that edge is not defined in the schema.
  23866. func (m *SopTaskMutation) ClearEdge(name string) error {
  23867. switch name {
  23868. }
  23869. return fmt.Errorf("unknown SopTask unique edge %s", name)
  23870. }
  23871. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23872. // It returns an error if the edge is not defined in the schema.
  23873. func (m *SopTaskMutation) ResetEdge(name string) error {
  23874. switch name {
  23875. case soptask.EdgeTaskStages:
  23876. m.ResetTaskStages()
  23877. return nil
  23878. }
  23879. return fmt.Errorf("unknown SopTask edge %s", name)
  23880. }
  23881. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  23882. type TokenMutation struct {
  23883. config
  23884. op Op
  23885. typ string
  23886. id *uint64
  23887. created_at *time.Time
  23888. updated_at *time.Time
  23889. deleted_at *time.Time
  23890. expire_at *time.Time
  23891. token *string
  23892. mac *string
  23893. organization_id *uint64
  23894. addorganization_id *int64
  23895. custom_agent_base *string
  23896. custom_agent_key *string
  23897. openai_base *string
  23898. openai_key *string
  23899. clearedFields map[string]struct{}
  23900. agent *uint64
  23901. clearedagent bool
  23902. done bool
  23903. oldValue func(context.Context) (*Token, error)
  23904. predicates []predicate.Token
  23905. }
  23906. var _ ent.Mutation = (*TokenMutation)(nil)
  23907. // tokenOption allows management of the mutation configuration using functional options.
  23908. type tokenOption func(*TokenMutation)
  23909. // newTokenMutation creates new mutation for the Token entity.
  23910. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  23911. m := &TokenMutation{
  23912. config: c,
  23913. op: op,
  23914. typ: TypeToken,
  23915. clearedFields: make(map[string]struct{}),
  23916. }
  23917. for _, opt := range opts {
  23918. opt(m)
  23919. }
  23920. return m
  23921. }
  23922. // withTokenID sets the ID field of the mutation.
  23923. func withTokenID(id uint64) tokenOption {
  23924. return func(m *TokenMutation) {
  23925. var (
  23926. err error
  23927. once sync.Once
  23928. value *Token
  23929. )
  23930. m.oldValue = func(ctx context.Context) (*Token, error) {
  23931. once.Do(func() {
  23932. if m.done {
  23933. err = errors.New("querying old values post mutation is not allowed")
  23934. } else {
  23935. value, err = m.Client().Token.Get(ctx, id)
  23936. }
  23937. })
  23938. return value, err
  23939. }
  23940. m.id = &id
  23941. }
  23942. }
  23943. // withToken sets the old Token of the mutation.
  23944. func withToken(node *Token) tokenOption {
  23945. return func(m *TokenMutation) {
  23946. m.oldValue = func(context.Context) (*Token, error) {
  23947. return node, nil
  23948. }
  23949. m.id = &node.ID
  23950. }
  23951. }
  23952. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23953. // executed in a transaction (ent.Tx), a transactional client is returned.
  23954. func (m TokenMutation) Client() *Client {
  23955. client := &Client{config: m.config}
  23956. client.init()
  23957. return client
  23958. }
  23959. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23960. // it returns an error otherwise.
  23961. func (m TokenMutation) Tx() (*Tx, error) {
  23962. if _, ok := m.driver.(*txDriver); !ok {
  23963. return nil, errors.New("ent: mutation is not running in a transaction")
  23964. }
  23965. tx := &Tx{config: m.config}
  23966. tx.init()
  23967. return tx, nil
  23968. }
  23969. // SetID sets the value of the id field. Note that this
  23970. // operation is only accepted on creation of Token entities.
  23971. func (m *TokenMutation) SetID(id uint64) {
  23972. m.id = &id
  23973. }
  23974. // ID returns the ID value in the mutation. Note that the ID is only available
  23975. // if it was provided to the builder or after it was returned from the database.
  23976. func (m *TokenMutation) ID() (id uint64, exists bool) {
  23977. if m.id == nil {
  23978. return
  23979. }
  23980. return *m.id, true
  23981. }
  23982. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23983. // That means, if the mutation is applied within a transaction with an isolation level such
  23984. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23985. // or updated by the mutation.
  23986. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  23987. switch {
  23988. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23989. id, exists := m.ID()
  23990. if exists {
  23991. return []uint64{id}, nil
  23992. }
  23993. fallthrough
  23994. case m.op.Is(OpUpdate | OpDelete):
  23995. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  23996. default:
  23997. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23998. }
  23999. }
  24000. // SetCreatedAt sets the "created_at" field.
  24001. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  24002. m.created_at = &t
  24003. }
  24004. // CreatedAt returns the value of the "created_at" field in the mutation.
  24005. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  24006. v := m.created_at
  24007. if v == nil {
  24008. return
  24009. }
  24010. return *v, true
  24011. }
  24012. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  24013. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24015. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24016. if !m.op.Is(OpUpdateOne) {
  24017. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24018. }
  24019. if m.id == nil || m.oldValue == nil {
  24020. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24021. }
  24022. oldValue, err := m.oldValue(ctx)
  24023. if err != nil {
  24024. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24025. }
  24026. return oldValue.CreatedAt, nil
  24027. }
  24028. // ResetCreatedAt resets all changes to the "created_at" field.
  24029. func (m *TokenMutation) ResetCreatedAt() {
  24030. m.created_at = nil
  24031. }
  24032. // SetUpdatedAt sets the "updated_at" field.
  24033. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  24034. m.updated_at = &t
  24035. }
  24036. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24037. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  24038. v := m.updated_at
  24039. if v == nil {
  24040. return
  24041. }
  24042. return *v, true
  24043. }
  24044. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  24045. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24047. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24048. if !m.op.Is(OpUpdateOne) {
  24049. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24050. }
  24051. if m.id == nil || m.oldValue == nil {
  24052. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24053. }
  24054. oldValue, err := m.oldValue(ctx)
  24055. if err != nil {
  24056. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24057. }
  24058. return oldValue.UpdatedAt, nil
  24059. }
  24060. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24061. func (m *TokenMutation) ResetUpdatedAt() {
  24062. m.updated_at = nil
  24063. }
  24064. // SetDeletedAt sets the "deleted_at" field.
  24065. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  24066. m.deleted_at = &t
  24067. }
  24068. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24069. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  24070. v := m.deleted_at
  24071. if v == nil {
  24072. return
  24073. }
  24074. return *v, true
  24075. }
  24076. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  24077. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24078. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24079. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24080. if !m.op.Is(OpUpdateOne) {
  24081. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24082. }
  24083. if m.id == nil || m.oldValue == nil {
  24084. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24085. }
  24086. oldValue, err := m.oldValue(ctx)
  24087. if err != nil {
  24088. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24089. }
  24090. return oldValue.DeletedAt, nil
  24091. }
  24092. // ClearDeletedAt clears the value of the "deleted_at" field.
  24093. func (m *TokenMutation) ClearDeletedAt() {
  24094. m.deleted_at = nil
  24095. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  24096. }
  24097. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24098. func (m *TokenMutation) DeletedAtCleared() bool {
  24099. _, ok := m.clearedFields[token.FieldDeletedAt]
  24100. return ok
  24101. }
  24102. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24103. func (m *TokenMutation) ResetDeletedAt() {
  24104. m.deleted_at = nil
  24105. delete(m.clearedFields, token.FieldDeletedAt)
  24106. }
  24107. // SetExpireAt sets the "expire_at" field.
  24108. func (m *TokenMutation) SetExpireAt(t time.Time) {
  24109. m.expire_at = &t
  24110. }
  24111. // ExpireAt returns the value of the "expire_at" field in the mutation.
  24112. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  24113. v := m.expire_at
  24114. if v == nil {
  24115. return
  24116. }
  24117. return *v, true
  24118. }
  24119. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  24120. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24122. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  24123. if !m.op.Is(OpUpdateOne) {
  24124. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  24125. }
  24126. if m.id == nil || m.oldValue == nil {
  24127. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  24128. }
  24129. oldValue, err := m.oldValue(ctx)
  24130. if err != nil {
  24131. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  24132. }
  24133. return oldValue.ExpireAt, nil
  24134. }
  24135. // ClearExpireAt clears the value of the "expire_at" field.
  24136. func (m *TokenMutation) ClearExpireAt() {
  24137. m.expire_at = nil
  24138. m.clearedFields[token.FieldExpireAt] = struct{}{}
  24139. }
  24140. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  24141. func (m *TokenMutation) ExpireAtCleared() bool {
  24142. _, ok := m.clearedFields[token.FieldExpireAt]
  24143. return ok
  24144. }
  24145. // ResetExpireAt resets all changes to the "expire_at" field.
  24146. func (m *TokenMutation) ResetExpireAt() {
  24147. m.expire_at = nil
  24148. delete(m.clearedFields, token.FieldExpireAt)
  24149. }
  24150. // SetToken sets the "token" field.
  24151. func (m *TokenMutation) SetToken(s string) {
  24152. m.token = &s
  24153. }
  24154. // Token returns the value of the "token" field in the mutation.
  24155. func (m *TokenMutation) Token() (r string, exists bool) {
  24156. v := m.token
  24157. if v == nil {
  24158. return
  24159. }
  24160. return *v, true
  24161. }
  24162. // OldToken returns the old "token" field's value of the Token entity.
  24163. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24165. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  24166. if !m.op.Is(OpUpdateOne) {
  24167. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  24168. }
  24169. if m.id == nil || m.oldValue == nil {
  24170. return v, errors.New("OldToken requires an ID field in the mutation")
  24171. }
  24172. oldValue, err := m.oldValue(ctx)
  24173. if err != nil {
  24174. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  24175. }
  24176. return oldValue.Token, nil
  24177. }
  24178. // ClearToken clears the value of the "token" field.
  24179. func (m *TokenMutation) ClearToken() {
  24180. m.token = nil
  24181. m.clearedFields[token.FieldToken] = struct{}{}
  24182. }
  24183. // TokenCleared returns if the "token" field was cleared in this mutation.
  24184. func (m *TokenMutation) TokenCleared() bool {
  24185. _, ok := m.clearedFields[token.FieldToken]
  24186. return ok
  24187. }
  24188. // ResetToken resets all changes to the "token" field.
  24189. func (m *TokenMutation) ResetToken() {
  24190. m.token = nil
  24191. delete(m.clearedFields, token.FieldToken)
  24192. }
  24193. // SetMAC sets the "mac" field.
  24194. func (m *TokenMutation) SetMAC(s string) {
  24195. m.mac = &s
  24196. }
  24197. // MAC returns the value of the "mac" field in the mutation.
  24198. func (m *TokenMutation) MAC() (r string, exists bool) {
  24199. v := m.mac
  24200. if v == nil {
  24201. return
  24202. }
  24203. return *v, true
  24204. }
  24205. // OldMAC returns the old "mac" field's value of the Token entity.
  24206. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24208. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  24209. if !m.op.Is(OpUpdateOne) {
  24210. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  24211. }
  24212. if m.id == nil || m.oldValue == nil {
  24213. return v, errors.New("OldMAC requires an ID field in the mutation")
  24214. }
  24215. oldValue, err := m.oldValue(ctx)
  24216. if err != nil {
  24217. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  24218. }
  24219. return oldValue.MAC, nil
  24220. }
  24221. // ClearMAC clears the value of the "mac" field.
  24222. func (m *TokenMutation) ClearMAC() {
  24223. m.mac = nil
  24224. m.clearedFields[token.FieldMAC] = struct{}{}
  24225. }
  24226. // MACCleared returns if the "mac" field was cleared in this mutation.
  24227. func (m *TokenMutation) MACCleared() bool {
  24228. _, ok := m.clearedFields[token.FieldMAC]
  24229. return ok
  24230. }
  24231. // ResetMAC resets all changes to the "mac" field.
  24232. func (m *TokenMutation) ResetMAC() {
  24233. m.mac = nil
  24234. delete(m.clearedFields, token.FieldMAC)
  24235. }
  24236. // SetOrganizationID sets the "organization_id" field.
  24237. func (m *TokenMutation) SetOrganizationID(u uint64) {
  24238. m.organization_id = &u
  24239. m.addorganization_id = nil
  24240. }
  24241. // OrganizationID returns the value of the "organization_id" field in the mutation.
  24242. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  24243. v := m.organization_id
  24244. if v == nil {
  24245. return
  24246. }
  24247. return *v, true
  24248. }
  24249. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  24250. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24252. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  24253. if !m.op.Is(OpUpdateOne) {
  24254. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  24255. }
  24256. if m.id == nil || m.oldValue == nil {
  24257. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  24258. }
  24259. oldValue, err := m.oldValue(ctx)
  24260. if err != nil {
  24261. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  24262. }
  24263. return oldValue.OrganizationID, nil
  24264. }
  24265. // AddOrganizationID adds u to the "organization_id" field.
  24266. func (m *TokenMutation) AddOrganizationID(u int64) {
  24267. if m.addorganization_id != nil {
  24268. *m.addorganization_id += u
  24269. } else {
  24270. m.addorganization_id = &u
  24271. }
  24272. }
  24273. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  24274. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  24275. v := m.addorganization_id
  24276. if v == nil {
  24277. return
  24278. }
  24279. return *v, true
  24280. }
  24281. // ResetOrganizationID resets all changes to the "organization_id" field.
  24282. func (m *TokenMutation) ResetOrganizationID() {
  24283. m.organization_id = nil
  24284. m.addorganization_id = nil
  24285. }
  24286. // SetAgentID sets the "agent_id" field.
  24287. func (m *TokenMutation) SetAgentID(u uint64) {
  24288. m.agent = &u
  24289. }
  24290. // AgentID returns the value of the "agent_id" field in the mutation.
  24291. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  24292. v := m.agent
  24293. if v == nil {
  24294. return
  24295. }
  24296. return *v, true
  24297. }
  24298. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  24299. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24301. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  24302. if !m.op.Is(OpUpdateOne) {
  24303. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  24304. }
  24305. if m.id == nil || m.oldValue == nil {
  24306. return v, errors.New("OldAgentID requires an ID field in the mutation")
  24307. }
  24308. oldValue, err := m.oldValue(ctx)
  24309. if err != nil {
  24310. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  24311. }
  24312. return oldValue.AgentID, nil
  24313. }
  24314. // ResetAgentID resets all changes to the "agent_id" field.
  24315. func (m *TokenMutation) ResetAgentID() {
  24316. m.agent = nil
  24317. }
  24318. // SetCustomAgentBase sets the "custom_agent_base" field.
  24319. func (m *TokenMutation) SetCustomAgentBase(s string) {
  24320. m.custom_agent_base = &s
  24321. }
  24322. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  24323. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  24324. v := m.custom_agent_base
  24325. if v == nil {
  24326. return
  24327. }
  24328. return *v, true
  24329. }
  24330. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  24331. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24333. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  24334. if !m.op.Is(OpUpdateOne) {
  24335. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  24336. }
  24337. if m.id == nil || m.oldValue == nil {
  24338. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  24339. }
  24340. oldValue, err := m.oldValue(ctx)
  24341. if err != nil {
  24342. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  24343. }
  24344. return oldValue.CustomAgentBase, nil
  24345. }
  24346. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  24347. func (m *TokenMutation) ClearCustomAgentBase() {
  24348. m.custom_agent_base = nil
  24349. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  24350. }
  24351. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  24352. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  24353. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  24354. return ok
  24355. }
  24356. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  24357. func (m *TokenMutation) ResetCustomAgentBase() {
  24358. m.custom_agent_base = nil
  24359. delete(m.clearedFields, token.FieldCustomAgentBase)
  24360. }
  24361. // SetCustomAgentKey sets the "custom_agent_key" field.
  24362. func (m *TokenMutation) SetCustomAgentKey(s string) {
  24363. m.custom_agent_key = &s
  24364. }
  24365. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  24366. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  24367. v := m.custom_agent_key
  24368. if v == nil {
  24369. return
  24370. }
  24371. return *v, true
  24372. }
  24373. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  24374. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24376. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  24377. if !m.op.Is(OpUpdateOne) {
  24378. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  24379. }
  24380. if m.id == nil || m.oldValue == nil {
  24381. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  24382. }
  24383. oldValue, err := m.oldValue(ctx)
  24384. if err != nil {
  24385. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  24386. }
  24387. return oldValue.CustomAgentKey, nil
  24388. }
  24389. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  24390. func (m *TokenMutation) ClearCustomAgentKey() {
  24391. m.custom_agent_key = nil
  24392. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  24393. }
  24394. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  24395. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  24396. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  24397. return ok
  24398. }
  24399. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  24400. func (m *TokenMutation) ResetCustomAgentKey() {
  24401. m.custom_agent_key = nil
  24402. delete(m.clearedFields, token.FieldCustomAgentKey)
  24403. }
  24404. // SetOpenaiBase sets the "openai_base" field.
  24405. func (m *TokenMutation) SetOpenaiBase(s string) {
  24406. m.openai_base = &s
  24407. }
  24408. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  24409. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  24410. v := m.openai_base
  24411. if v == nil {
  24412. return
  24413. }
  24414. return *v, true
  24415. }
  24416. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  24417. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24419. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  24420. if !m.op.Is(OpUpdateOne) {
  24421. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  24422. }
  24423. if m.id == nil || m.oldValue == nil {
  24424. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  24425. }
  24426. oldValue, err := m.oldValue(ctx)
  24427. if err != nil {
  24428. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  24429. }
  24430. return oldValue.OpenaiBase, nil
  24431. }
  24432. // ClearOpenaiBase clears the value of the "openai_base" field.
  24433. func (m *TokenMutation) ClearOpenaiBase() {
  24434. m.openai_base = nil
  24435. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  24436. }
  24437. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  24438. func (m *TokenMutation) OpenaiBaseCleared() bool {
  24439. _, ok := m.clearedFields[token.FieldOpenaiBase]
  24440. return ok
  24441. }
  24442. // ResetOpenaiBase resets all changes to the "openai_base" field.
  24443. func (m *TokenMutation) ResetOpenaiBase() {
  24444. m.openai_base = nil
  24445. delete(m.clearedFields, token.FieldOpenaiBase)
  24446. }
  24447. // SetOpenaiKey sets the "openai_key" field.
  24448. func (m *TokenMutation) SetOpenaiKey(s string) {
  24449. m.openai_key = &s
  24450. }
  24451. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  24452. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  24453. v := m.openai_key
  24454. if v == nil {
  24455. return
  24456. }
  24457. return *v, true
  24458. }
  24459. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  24460. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24462. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  24463. if !m.op.Is(OpUpdateOne) {
  24464. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  24465. }
  24466. if m.id == nil || m.oldValue == nil {
  24467. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  24468. }
  24469. oldValue, err := m.oldValue(ctx)
  24470. if err != nil {
  24471. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  24472. }
  24473. return oldValue.OpenaiKey, nil
  24474. }
  24475. // ClearOpenaiKey clears the value of the "openai_key" field.
  24476. func (m *TokenMutation) ClearOpenaiKey() {
  24477. m.openai_key = nil
  24478. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  24479. }
  24480. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  24481. func (m *TokenMutation) OpenaiKeyCleared() bool {
  24482. _, ok := m.clearedFields[token.FieldOpenaiKey]
  24483. return ok
  24484. }
  24485. // ResetOpenaiKey resets all changes to the "openai_key" field.
  24486. func (m *TokenMutation) ResetOpenaiKey() {
  24487. m.openai_key = nil
  24488. delete(m.clearedFields, token.FieldOpenaiKey)
  24489. }
  24490. // ClearAgent clears the "agent" edge to the Agent entity.
  24491. func (m *TokenMutation) ClearAgent() {
  24492. m.clearedagent = true
  24493. m.clearedFields[token.FieldAgentID] = struct{}{}
  24494. }
  24495. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  24496. func (m *TokenMutation) AgentCleared() bool {
  24497. return m.clearedagent
  24498. }
  24499. // AgentIDs returns the "agent" edge IDs in the mutation.
  24500. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  24501. // AgentID instead. It exists only for internal usage by the builders.
  24502. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  24503. if id := m.agent; id != nil {
  24504. ids = append(ids, *id)
  24505. }
  24506. return
  24507. }
  24508. // ResetAgent resets all changes to the "agent" edge.
  24509. func (m *TokenMutation) ResetAgent() {
  24510. m.agent = nil
  24511. m.clearedagent = false
  24512. }
  24513. // Where appends a list predicates to the TokenMutation builder.
  24514. func (m *TokenMutation) Where(ps ...predicate.Token) {
  24515. m.predicates = append(m.predicates, ps...)
  24516. }
  24517. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  24518. // users can use type-assertion to append predicates that do not depend on any generated package.
  24519. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  24520. p := make([]predicate.Token, len(ps))
  24521. for i := range ps {
  24522. p[i] = ps[i]
  24523. }
  24524. m.Where(p...)
  24525. }
  24526. // Op returns the operation name.
  24527. func (m *TokenMutation) Op() Op {
  24528. return m.op
  24529. }
  24530. // SetOp allows setting the mutation operation.
  24531. func (m *TokenMutation) SetOp(op Op) {
  24532. m.op = op
  24533. }
  24534. // Type returns the node type of this mutation (Token).
  24535. func (m *TokenMutation) Type() string {
  24536. return m.typ
  24537. }
  24538. // Fields returns all fields that were changed during this mutation. Note that in
  24539. // order to get all numeric fields that were incremented/decremented, call
  24540. // AddedFields().
  24541. func (m *TokenMutation) Fields() []string {
  24542. fields := make([]string, 0, 12)
  24543. if m.created_at != nil {
  24544. fields = append(fields, token.FieldCreatedAt)
  24545. }
  24546. if m.updated_at != nil {
  24547. fields = append(fields, token.FieldUpdatedAt)
  24548. }
  24549. if m.deleted_at != nil {
  24550. fields = append(fields, token.FieldDeletedAt)
  24551. }
  24552. if m.expire_at != nil {
  24553. fields = append(fields, token.FieldExpireAt)
  24554. }
  24555. if m.token != nil {
  24556. fields = append(fields, token.FieldToken)
  24557. }
  24558. if m.mac != nil {
  24559. fields = append(fields, token.FieldMAC)
  24560. }
  24561. if m.organization_id != nil {
  24562. fields = append(fields, token.FieldOrganizationID)
  24563. }
  24564. if m.agent != nil {
  24565. fields = append(fields, token.FieldAgentID)
  24566. }
  24567. if m.custom_agent_base != nil {
  24568. fields = append(fields, token.FieldCustomAgentBase)
  24569. }
  24570. if m.custom_agent_key != nil {
  24571. fields = append(fields, token.FieldCustomAgentKey)
  24572. }
  24573. if m.openai_base != nil {
  24574. fields = append(fields, token.FieldOpenaiBase)
  24575. }
  24576. if m.openai_key != nil {
  24577. fields = append(fields, token.FieldOpenaiKey)
  24578. }
  24579. return fields
  24580. }
  24581. // Field returns the value of a field with the given name. The second boolean
  24582. // return value indicates that this field was not set, or was not defined in the
  24583. // schema.
  24584. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  24585. switch name {
  24586. case token.FieldCreatedAt:
  24587. return m.CreatedAt()
  24588. case token.FieldUpdatedAt:
  24589. return m.UpdatedAt()
  24590. case token.FieldDeletedAt:
  24591. return m.DeletedAt()
  24592. case token.FieldExpireAt:
  24593. return m.ExpireAt()
  24594. case token.FieldToken:
  24595. return m.Token()
  24596. case token.FieldMAC:
  24597. return m.MAC()
  24598. case token.FieldOrganizationID:
  24599. return m.OrganizationID()
  24600. case token.FieldAgentID:
  24601. return m.AgentID()
  24602. case token.FieldCustomAgentBase:
  24603. return m.CustomAgentBase()
  24604. case token.FieldCustomAgentKey:
  24605. return m.CustomAgentKey()
  24606. case token.FieldOpenaiBase:
  24607. return m.OpenaiBase()
  24608. case token.FieldOpenaiKey:
  24609. return m.OpenaiKey()
  24610. }
  24611. return nil, false
  24612. }
  24613. // OldField returns the old value of the field from the database. An error is
  24614. // returned if the mutation operation is not UpdateOne, or the query to the
  24615. // database failed.
  24616. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24617. switch name {
  24618. case token.FieldCreatedAt:
  24619. return m.OldCreatedAt(ctx)
  24620. case token.FieldUpdatedAt:
  24621. return m.OldUpdatedAt(ctx)
  24622. case token.FieldDeletedAt:
  24623. return m.OldDeletedAt(ctx)
  24624. case token.FieldExpireAt:
  24625. return m.OldExpireAt(ctx)
  24626. case token.FieldToken:
  24627. return m.OldToken(ctx)
  24628. case token.FieldMAC:
  24629. return m.OldMAC(ctx)
  24630. case token.FieldOrganizationID:
  24631. return m.OldOrganizationID(ctx)
  24632. case token.FieldAgentID:
  24633. return m.OldAgentID(ctx)
  24634. case token.FieldCustomAgentBase:
  24635. return m.OldCustomAgentBase(ctx)
  24636. case token.FieldCustomAgentKey:
  24637. return m.OldCustomAgentKey(ctx)
  24638. case token.FieldOpenaiBase:
  24639. return m.OldOpenaiBase(ctx)
  24640. case token.FieldOpenaiKey:
  24641. return m.OldOpenaiKey(ctx)
  24642. }
  24643. return nil, fmt.Errorf("unknown Token field %s", name)
  24644. }
  24645. // SetField sets the value of a field with the given name. It returns an error if
  24646. // the field is not defined in the schema, or if the type mismatched the field
  24647. // type.
  24648. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  24649. switch name {
  24650. case token.FieldCreatedAt:
  24651. v, ok := value.(time.Time)
  24652. if !ok {
  24653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24654. }
  24655. m.SetCreatedAt(v)
  24656. return nil
  24657. case token.FieldUpdatedAt:
  24658. v, ok := value.(time.Time)
  24659. if !ok {
  24660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24661. }
  24662. m.SetUpdatedAt(v)
  24663. return nil
  24664. case token.FieldDeletedAt:
  24665. v, ok := value.(time.Time)
  24666. if !ok {
  24667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24668. }
  24669. m.SetDeletedAt(v)
  24670. return nil
  24671. case token.FieldExpireAt:
  24672. v, ok := value.(time.Time)
  24673. if !ok {
  24674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24675. }
  24676. m.SetExpireAt(v)
  24677. return nil
  24678. case token.FieldToken:
  24679. v, ok := value.(string)
  24680. if !ok {
  24681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24682. }
  24683. m.SetToken(v)
  24684. return nil
  24685. case token.FieldMAC:
  24686. v, ok := value.(string)
  24687. if !ok {
  24688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24689. }
  24690. m.SetMAC(v)
  24691. return nil
  24692. case token.FieldOrganizationID:
  24693. v, ok := value.(uint64)
  24694. if !ok {
  24695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24696. }
  24697. m.SetOrganizationID(v)
  24698. return nil
  24699. case token.FieldAgentID:
  24700. v, ok := value.(uint64)
  24701. if !ok {
  24702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24703. }
  24704. m.SetAgentID(v)
  24705. return nil
  24706. case token.FieldCustomAgentBase:
  24707. v, ok := value.(string)
  24708. if !ok {
  24709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24710. }
  24711. m.SetCustomAgentBase(v)
  24712. return nil
  24713. case token.FieldCustomAgentKey:
  24714. v, ok := value.(string)
  24715. if !ok {
  24716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24717. }
  24718. m.SetCustomAgentKey(v)
  24719. return nil
  24720. case token.FieldOpenaiBase:
  24721. v, ok := value.(string)
  24722. if !ok {
  24723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24724. }
  24725. m.SetOpenaiBase(v)
  24726. return nil
  24727. case token.FieldOpenaiKey:
  24728. v, ok := value.(string)
  24729. if !ok {
  24730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24731. }
  24732. m.SetOpenaiKey(v)
  24733. return nil
  24734. }
  24735. return fmt.Errorf("unknown Token field %s", name)
  24736. }
  24737. // AddedFields returns all numeric fields that were incremented/decremented during
  24738. // this mutation.
  24739. func (m *TokenMutation) AddedFields() []string {
  24740. var fields []string
  24741. if m.addorganization_id != nil {
  24742. fields = append(fields, token.FieldOrganizationID)
  24743. }
  24744. return fields
  24745. }
  24746. // AddedField returns the numeric value that was incremented/decremented on a field
  24747. // with the given name. The second boolean return value indicates that this field
  24748. // was not set, or was not defined in the schema.
  24749. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  24750. switch name {
  24751. case token.FieldOrganizationID:
  24752. return m.AddedOrganizationID()
  24753. }
  24754. return nil, false
  24755. }
  24756. // AddField adds the value to the field with the given name. It returns an error if
  24757. // the field is not defined in the schema, or if the type mismatched the field
  24758. // type.
  24759. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  24760. switch name {
  24761. case token.FieldOrganizationID:
  24762. v, ok := value.(int64)
  24763. if !ok {
  24764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24765. }
  24766. m.AddOrganizationID(v)
  24767. return nil
  24768. }
  24769. return fmt.Errorf("unknown Token numeric field %s", name)
  24770. }
  24771. // ClearedFields returns all nullable fields that were cleared during this
  24772. // mutation.
  24773. func (m *TokenMutation) ClearedFields() []string {
  24774. var fields []string
  24775. if m.FieldCleared(token.FieldDeletedAt) {
  24776. fields = append(fields, token.FieldDeletedAt)
  24777. }
  24778. if m.FieldCleared(token.FieldExpireAt) {
  24779. fields = append(fields, token.FieldExpireAt)
  24780. }
  24781. if m.FieldCleared(token.FieldToken) {
  24782. fields = append(fields, token.FieldToken)
  24783. }
  24784. if m.FieldCleared(token.FieldMAC) {
  24785. fields = append(fields, token.FieldMAC)
  24786. }
  24787. if m.FieldCleared(token.FieldCustomAgentBase) {
  24788. fields = append(fields, token.FieldCustomAgentBase)
  24789. }
  24790. if m.FieldCleared(token.FieldCustomAgentKey) {
  24791. fields = append(fields, token.FieldCustomAgentKey)
  24792. }
  24793. if m.FieldCleared(token.FieldOpenaiBase) {
  24794. fields = append(fields, token.FieldOpenaiBase)
  24795. }
  24796. if m.FieldCleared(token.FieldOpenaiKey) {
  24797. fields = append(fields, token.FieldOpenaiKey)
  24798. }
  24799. return fields
  24800. }
  24801. // FieldCleared returns a boolean indicating if a field with the given name was
  24802. // cleared in this mutation.
  24803. func (m *TokenMutation) FieldCleared(name string) bool {
  24804. _, ok := m.clearedFields[name]
  24805. return ok
  24806. }
  24807. // ClearField clears the value of the field with the given name. It returns an
  24808. // error if the field is not defined in the schema.
  24809. func (m *TokenMutation) ClearField(name string) error {
  24810. switch name {
  24811. case token.FieldDeletedAt:
  24812. m.ClearDeletedAt()
  24813. return nil
  24814. case token.FieldExpireAt:
  24815. m.ClearExpireAt()
  24816. return nil
  24817. case token.FieldToken:
  24818. m.ClearToken()
  24819. return nil
  24820. case token.FieldMAC:
  24821. m.ClearMAC()
  24822. return nil
  24823. case token.FieldCustomAgentBase:
  24824. m.ClearCustomAgentBase()
  24825. return nil
  24826. case token.FieldCustomAgentKey:
  24827. m.ClearCustomAgentKey()
  24828. return nil
  24829. case token.FieldOpenaiBase:
  24830. m.ClearOpenaiBase()
  24831. return nil
  24832. case token.FieldOpenaiKey:
  24833. m.ClearOpenaiKey()
  24834. return nil
  24835. }
  24836. return fmt.Errorf("unknown Token nullable field %s", name)
  24837. }
  24838. // ResetField resets all changes in the mutation for the field with the given name.
  24839. // It returns an error if the field is not defined in the schema.
  24840. func (m *TokenMutation) ResetField(name string) error {
  24841. switch name {
  24842. case token.FieldCreatedAt:
  24843. m.ResetCreatedAt()
  24844. return nil
  24845. case token.FieldUpdatedAt:
  24846. m.ResetUpdatedAt()
  24847. return nil
  24848. case token.FieldDeletedAt:
  24849. m.ResetDeletedAt()
  24850. return nil
  24851. case token.FieldExpireAt:
  24852. m.ResetExpireAt()
  24853. return nil
  24854. case token.FieldToken:
  24855. m.ResetToken()
  24856. return nil
  24857. case token.FieldMAC:
  24858. m.ResetMAC()
  24859. return nil
  24860. case token.FieldOrganizationID:
  24861. m.ResetOrganizationID()
  24862. return nil
  24863. case token.FieldAgentID:
  24864. m.ResetAgentID()
  24865. return nil
  24866. case token.FieldCustomAgentBase:
  24867. m.ResetCustomAgentBase()
  24868. return nil
  24869. case token.FieldCustomAgentKey:
  24870. m.ResetCustomAgentKey()
  24871. return nil
  24872. case token.FieldOpenaiBase:
  24873. m.ResetOpenaiBase()
  24874. return nil
  24875. case token.FieldOpenaiKey:
  24876. m.ResetOpenaiKey()
  24877. return nil
  24878. }
  24879. return fmt.Errorf("unknown Token field %s", name)
  24880. }
  24881. // AddedEdges returns all edge names that were set/added in this mutation.
  24882. func (m *TokenMutation) AddedEdges() []string {
  24883. edges := make([]string, 0, 1)
  24884. if m.agent != nil {
  24885. edges = append(edges, token.EdgeAgent)
  24886. }
  24887. return edges
  24888. }
  24889. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24890. // name in this mutation.
  24891. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  24892. switch name {
  24893. case token.EdgeAgent:
  24894. if id := m.agent; id != nil {
  24895. return []ent.Value{*id}
  24896. }
  24897. }
  24898. return nil
  24899. }
  24900. // RemovedEdges returns all edge names that were removed in this mutation.
  24901. func (m *TokenMutation) RemovedEdges() []string {
  24902. edges := make([]string, 0, 1)
  24903. return edges
  24904. }
  24905. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24906. // the given name in this mutation.
  24907. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  24908. return nil
  24909. }
  24910. // ClearedEdges returns all edge names that were cleared in this mutation.
  24911. func (m *TokenMutation) ClearedEdges() []string {
  24912. edges := make([]string, 0, 1)
  24913. if m.clearedagent {
  24914. edges = append(edges, token.EdgeAgent)
  24915. }
  24916. return edges
  24917. }
  24918. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24919. // was cleared in this mutation.
  24920. func (m *TokenMutation) EdgeCleared(name string) bool {
  24921. switch name {
  24922. case token.EdgeAgent:
  24923. return m.clearedagent
  24924. }
  24925. return false
  24926. }
  24927. // ClearEdge clears the value of the edge with the given name. It returns an error
  24928. // if that edge is not defined in the schema.
  24929. func (m *TokenMutation) ClearEdge(name string) error {
  24930. switch name {
  24931. case token.EdgeAgent:
  24932. m.ClearAgent()
  24933. return nil
  24934. }
  24935. return fmt.Errorf("unknown Token unique edge %s", name)
  24936. }
  24937. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24938. // It returns an error if the edge is not defined in the schema.
  24939. func (m *TokenMutation) ResetEdge(name string) error {
  24940. switch name {
  24941. case token.EdgeAgent:
  24942. m.ResetAgent()
  24943. return nil
  24944. }
  24945. return fmt.Errorf("unknown Token edge %s", name)
  24946. }
  24947. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  24948. type TutorialMutation struct {
  24949. config
  24950. op Op
  24951. typ string
  24952. id *uint64
  24953. created_at *time.Time
  24954. updated_at *time.Time
  24955. deleted_at *time.Time
  24956. index *int
  24957. addindex *int
  24958. title *string
  24959. content *string
  24960. organization_id *uint64
  24961. addorganization_id *int64
  24962. clearedFields map[string]struct{}
  24963. employee *uint64
  24964. clearedemployee bool
  24965. done bool
  24966. oldValue func(context.Context) (*Tutorial, error)
  24967. predicates []predicate.Tutorial
  24968. }
  24969. var _ ent.Mutation = (*TutorialMutation)(nil)
  24970. // tutorialOption allows management of the mutation configuration using functional options.
  24971. type tutorialOption func(*TutorialMutation)
  24972. // newTutorialMutation creates new mutation for the Tutorial entity.
  24973. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  24974. m := &TutorialMutation{
  24975. config: c,
  24976. op: op,
  24977. typ: TypeTutorial,
  24978. clearedFields: make(map[string]struct{}),
  24979. }
  24980. for _, opt := range opts {
  24981. opt(m)
  24982. }
  24983. return m
  24984. }
  24985. // withTutorialID sets the ID field of the mutation.
  24986. func withTutorialID(id uint64) tutorialOption {
  24987. return func(m *TutorialMutation) {
  24988. var (
  24989. err error
  24990. once sync.Once
  24991. value *Tutorial
  24992. )
  24993. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  24994. once.Do(func() {
  24995. if m.done {
  24996. err = errors.New("querying old values post mutation is not allowed")
  24997. } else {
  24998. value, err = m.Client().Tutorial.Get(ctx, id)
  24999. }
  25000. })
  25001. return value, err
  25002. }
  25003. m.id = &id
  25004. }
  25005. }
  25006. // withTutorial sets the old Tutorial of the mutation.
  25007. func withTutorial(node *Tutorial) tutorialOption {
  25008. return func(m *TutorialMutation) {
  25009. m.oldValue = func(context.Context) (*Tutorial, error) {
  25010. return node, nil
  25011. }
  25012. m.id = &node.ID
  25013. }
  25014. }
  25015. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25016. // executed in a transaction (ent.Tx), a transactional client is returned.
  25017. func (m TutorialMutation) Client() *Client {
  25018. client := &Client{config: m.config}
  25019. client.init()
  25020. return client
  25021. }
  25022. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25023. // it returns an error otherwise.
  25024. func (m TutorialMutation) Tx() (*Tx, error) {
  25025. if _, ok := m.driver.(*txDriver); !ok {
  25026. return nil, errors.New("ent: mutation is not running in a transaction")
  25027. }
  25028. tx := &Tx{config: m.config}
  25029. tx.init()
  25030. return tx, nil
  25031. }
  25032. // SetID sets the value of the id field. Note that this
  25033. // operation is only accepted on creation of Tutorial entities.
  25034. func (m *TutorialMutation) SetID(id uint64) {
  25035. m.id = &id
  25036. }
  25037. // ID returns the ID value in the mutation. Note that the ID is only available
  25038. // if it was provided to the builder or after it was returned from the database.
  25039. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  25040. if m.id == nil {
  25041. return
  25042. }
  25043. return *m.id, true
  25044. }
  25045. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25046. // That means, if the mutation is applied within a transaction with an isolation level such
  25047. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25048. // or updated by the mutation.
  25049. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  25050. switch {
  25051. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25052. id, exists := m.ID()
  25053. if exists {
  25054. return []uint64{id}, nil
  25055. }
  25056. fallthrough
  25057. case m.op.Is(OpUpdate | OpDelete):
  25058. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  25059. default:
  25060. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25061. }
  25062. }
  25063. // SetCreatedAt sets the "created_at" field.
  25064. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  25065. m.created_at = &t
  25066. }
  25067. // CreatedAt returns the value of the "created_at" field in the mutation.
  25068. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  25069. v := m.created_at
  25070. if v == nil {
  25071. return
  25072. }
  25073. return *v, true
  25074. }
  25075. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  25076. // If the Tutorial 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 *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25079. if !m.op.Is(OpUpdateOne) {
  25080. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25081. }
  25082. if m.id == nil || m.oldValue == nil {
  25083. return v, errors.New("OldCreatedAt 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 OldCreatedAt: %w", err)
  25088. }
  25089. return oldValue.CreatedAt, nil
  25090. }
  25091. // ResetCreatedAt resets all changes to the "created_at" field.
  25092. func (m *TutorialMutation) ResetCreatedAt() {
  25093. m.created_at = nil
  25094. }
  25095. // SetUpdatedAt sets the "updated_at" field.
  25096. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  25097. m.updated_at = &t
  25098. }
  25099. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25100. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  25101. v := m.updated_at
  25102. if v == nil {
  25103. return
  25104. }
  25105. return *v, true
  25106. }
  25107. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  25108. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  25109. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25110. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25111. if !m.op.Is(OpUpdateOne) {
  25112. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25113. }
  25114. if m.id == nil || m.oldValue == nil {
  25115. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25116. }
  25117. oldValue, err := m.oldValue(ctx)
  25118. if err != nil {
  25119. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25120. }
  25121. return oldValue.UpdatedAt, nil
  25122. }
  25123. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25124. func (m *TutorialMutation) ResetUpdatedAt() {
  25125. m.updated_at = nil
  25126. }
  25127. // SetDeletedAt sets the "deleted_at" field.
  25128. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  25129. m.deleted_at = &t
  25130. }
  25131. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25132. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  25133. v := m.deleted_at
  25134. if v == nil {
  25135. return
  25136. }
  25137. return *v, true
  25138. }
  25139. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  25140. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  25141. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25142. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25143. if !m.op.Is(OpUpdateOne) {
  25144. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25145. }
  25146. if m.id == nil || m.oldValue == nil {
  25147. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25148. }
  25149. oldValue, err := m.oldValue(ctx)
  25150. if err != nil {
  25151. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25152. }
  25153. return oldValue.DeletedAt, nil
  25154. }
  25155. // ClearDeletedAt clears the value of the "deleted_at" field.
  25156. func (m *TutorialMutation) ClearDeletedAt() {
  25157. m.deleted_at = nil
  25158. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  25159. }
  25160. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25161. func (m *TutorialMutation) DeletedAtCleared() bool {
  25162. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  25163. return ok
  25164. }
  25165. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25166. func (m *TutorialMutation) ResetDeletedAt() {
  25167. m.deleted_at = nil
  25168. delete(m.clearedFields, tutorial.FieldDeletedAt)
  25169. }
  25170. // SetEmployeeID sets the "employee_id" field.
  25171. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  25172. m.employee = &u
  25173. }
  25174. // EmployeeID returns the value of the "employee_id" field in the mutation.
  25175. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  25176. v := m.employee
  25177. if v == nil {
  25178. return
  25179. }
  25180. return *v, true
  25181. }
  25182. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  25183. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  25184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25185. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  25186. if !m.op.Is(OpUpdateOne) {
  25187. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  25188. }
  25189. if m.id == nil || m.oldValue == nil {
  25190. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  25191. }
  25192. oldValue, err := m.oldValue(ctx)
  25193. if err != nil {
  25194. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  25195. }
  25196. return oldValue.EmployeeID, nil
  25197. }
  25198. // ResetEmployeeID resets all changes to the "employee_id" field.
  25199. func (m *TutorialMutation) ResetEmployeeID() {
  25200. m.employee = nil
  25201. }
  25202. // SetIndex sets the "index" field.
  25203. func (m *TutorialMutation) SetIndex(i int) {
  25204. m.index = &i
  25205. m.addindex = nil
  25206. }
  25207. // Index returns the value of the "index" field in the mutation.
  25208. func (m *TutorialMutation) Index() (r int, exists bool) {
  25209. v := m.index
  25210. if v == nil {
  25211. return
  25212. }
  25213. return *v, true
  25214. }
  25215. // OldIndex returns the old "index" field's value of the Tutorial entity.
  25216. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  25217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25218. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  25219. if !m.op.Is(OpUpdateOne) {
  25220. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  25221. }
  25222. if m.id == nil || m.oldValue == nil {
  25223. return v, errors.New("OldIndex requires an ID field in the mutation")
  25224. }
  25225. oldValue, err := m.oldValue(ctx)
  25226. if err != nil {
  25227. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  25228. }
  25229. return oldValue.Index, nil
  25230. }
  25231. // AddIndex adds i to the "index" field.
  25232. func (m *TutorialMutation) AddIndex(i int) {
  25233. if m.addindex != nil {
  25234. *m.addindex += i
  25235. } else {
  25236. m.addindex = &i
  25237. }
  25238. }
  25239. // AddedIndex returns the value that was added to the "index" field in this mutation.
  25240. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  25241. v := m.addindex
  25242. if v == nil {
  25243. return
  25244. }
  25245. return *v, true
  25246. }
  25247. // ResetIndex resets all changes to the "index" field.
  25248. func (m *TutorialMutation) ResetIndex() {
  25249. m.index = nil
  25250. m.addindex = nil
  25251. }
  25252. // SetTitle sets the "title" field.
  25253. func (m *TutorialMutation) SetTitle(s string) {
  25254. m.title = &s
  25255. }
  25256. // Title returns the value of the "title" field in the mutation.
  25257. func (m *TutorialMutation) Title() (r string, exists bool) {
  25258. v := m.title
  25259. if v == nil {
  25260. return
  25261. }
  25262. return *v, true
  25263. }
  25264. // OldTitle returns the old "title" field's value of the Tutorial entity.
  25265. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  25266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25267. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  25268. if !m.op.Is(OpUpdateOne) {
  25269. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  25270. }
  25271. if m.id == nil || m.oldValue == nil {
  25272. return v, errors.New("OldTitle requires an ID field in the mutation")
  25273. }
  25274. oldValue, err := m.oldValue(ctx)
  25275. if err != nil {
  25276. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  25277. }
  25278. return oldValue.Title, nil
  25279. }
  25280. // ResetTitle resets all changes to the "title" field.
  25281. func (m *TutorialMutation) ResetTitle() {
  25282. m.title = nil
  25283. }
  25284. // SetContent sets the "content" field.
  25285. func (m *TutorialMutation) SetContent(s string) {
  25286. m.content = &s
  25287. }
  25288. // Content returns the value of the "content" field in the mutation.
  25289. func (m *TutorialMutation) Content() (r string, exists bool) {
  25290. v := m.content
  25291. if v == nil {
  25292. return
  25293. }
  25294. return *v, true
  25295. }
  25296. // OldContent returns the old "content" field's value of the Tutorial entity.
  25297. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  25298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25299. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  25300. if !m.op.Is(OpUpdateOne) {
  25301. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  25302. }
  25303. if m.id == nil || m.oldValue == nil {
  25304. return v, errors.New("OldContent requires an ID field in the mutation")
  25305. }
  25306. oldValue, err := m.oldValue(ctx)
  25307. if err != nil {
  25308. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  25309. }
  25310. return oldValue.Content, nil
  25311. }
  25312. // ResetContent resets all changes to the "content" field.
  25313. func (m *TutorialMutation) ResetContent() {
  25314. m.content = nil
  25315. }
  25316. // SetOrganizationID sets the "organization_id" field.
  25317. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  25318. m.organization_id = &u
  25319. m.addorganization_id = nil
  25320. }
  25321. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25322. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  25323. v := m.organization_id
  25324. if v == nil {
  25325. return
  25326. }
  25327. return *v, true
  25328. }
  25329. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  25330. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  25331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25332. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25333. if !m.op.Is(OpUpdateOne) {
  25334. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25335. }
  25336. if m.id == nil || m.oldValue == nil {
  25337. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25338. }
  25339. oldValue, err := m.oldValue(ctx)
  25340. if err != nil {
  25341. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25342. }
  25343. return oldValue.OrganizationID, nil
  25344. }
  25345. // AddOrganizationID adds u to the "organization_id" field.
  25346. func (m *TutorialMutation) AddOrganizationID(u int64) {
  25347. if m.addorganization_id != nil {
  25348. *m.addorganization_id += u
  25349. } else {
  25350. m.addorganization_id = &u
  25351. }
  25352. }
  25353. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25354. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  25355. v := m.addorganization_id
  25356. if v == nil {
  25357. return
  25358. }
  25359. return *v, true
  25360. }
  25361. // ResetOrganizationID resets all changes to the "organization_id" field.
  25362. func (m *TutorialMutation) ResetOrganizationID() {
  25363. m.organization_id = nil
  25364. m.addorganization_id = nil
  25365. }
  25366. // ClearEmployee clears the "employee" edge to the Employee entity.
  25367. func (m *TutorialMutation) ClearEmployee() {
  25368. m.clearedemployee = true
  25369. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  25370. }
  25371. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  25372. func (m *TutorialMutation) EmployeeCleared() bool {
  25373. return m.clearedemployee
  25374. }
  25375. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  25376. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25377. // EmployeeID instead. It exists only for internal usage by the builders.
  25378. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  25379. if id := m.employee; id != nil {
  25380. ids = append(ids, *id)
  25381. }
  25382. return
  25383. }
  25384. // ResetEmployee resets all changes to the "employee" edge.
  25385. func (m *TutorialMutation) ResetEmployee() {
  25386. m.employee = nil
  25387. m.clearedemployee = false
  25388. }
  25389. // Where appends a list predicates to the TutorialMutation builder.
  25390. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  25391. m.predicates = append(m.predicates, ps...)
  25392. }
  25393. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  25394. // users can use type-assertion to append predicates that do not depend on any generated package.
  25395. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  25396. p := make([]predicate.Tutorial, len(ps))
  25397. for i := range ps {
  25398. p[i] = ps[i]
  25399. }
  25400. m.Where(p...)
  25401. }
  25402. // Op returns the operation name.
  25403. func (m *TutorialMutation) Op() Op {
  25404. return m.op
  25405. }
  25406. // SetOp allows setting the mutation operation.
  25407. func (m *TutorialMutation) SetOp(op Op) {
  25408. m.op = op
  25409. }
  25410. // Type returns the node type of this mutation (Tutorial).
  25411. func (m *TutorialMutation) Type() string {
  25412. return m.typ
  25413. }
  25414. // Fields returns all fields that were changed during this mutation. Note that in
  25415. // order to get all numeric fields that were incremented/decremented, call
  25416. // AddedFields().
  25417. func (m *TutorialMutation) Fields() []string {
  25418. fields := make([]string, 0, 8)
  25419. if m.created_at != nil {
  25420. fields = append(fields, tutorial.FieldCreatedAt)
  25421. }
  25422. if m.updated_at != nil {
  25423. fields = append(fields, tutorial.FieldUpdatedAt)
  25424. }
  25425. if m.deleted_at != nil {
  25426. fields = append(fields, tutorial.FieldDeletedAt)
  25427. }
  25428. if m.employee != nil {
  25429. fields = append(fields, tutorial.FieldEmployeeID)
  25430. }
  25431. if m.index != nil {
  25432. fields = append(fields, tutorial.FieldIndex)
  25433. }
  25434. if m.title != nil {
  25435. fields = append(fields, tutorial.FieldTitle)
  25436. }
  25437. if m.content != nil {
  25438. fields = append(fields, tutorial.FieldContent)
  25439. }
  25440. if m.organization_id != nil {
  25441. fields = append(fields, tutorial.FieldOrganizationID)
  25442. }
  25443. return fields
  25444. }
  25445. // Field returns the value of a field with the given name. The second boolean
  25446. // return value indicates that this field was not set, or was not defined in the
  25447. // schema.
  25448. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  25449. switch name {
  25450. case tutorial.FieldCreatedAt:
  25451. return m.CreatedAt()
  25452. case tutorial.FieldUpdatedAt:
  25453. return m.UpdatedAt()
  25454. case tutorial.FieldDeletedAt:
  25455. return m.DeletedAt()
  25456. case tutorial.FieldEmployeeID:
  25457. return m.EmployeeID()
  25458. case tutorial.FieldIndex:
  25459. return m.Index()
  25460. case tutorial.FieldTitle:
  25461. return m.Title()
  25462. case tutorial.FieldContent:
  25463. return m.Content()
  25464. case tutorial.FieldOrganizationID:
  25465. return m.OrganizationID()
  25466. }
  25467. return nil, false
  25468. }
  25469. // OldField returns the old value of the field from the database. An error is
  25470. // returned if the mutation operation is not UpdateOne, or the query to the
  25471. // database failed.
  25472. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25473. switch name {
  25474. case tutorial.FieldCreatedAt:
  25475. return m.OldCreatedAt(ctx)
  25476. case tutorial.FieldUpdatedAt:
  25477. return m.OldUpdatedAt(ctx)
  25478. case tutorial.FieldDeletedAt:
  25479. return m.OldDeletedAt(ctx)
  25480. case tutorial.FieldEmployeeID:
  25481. return m.OldEmployeeID(ctx)
  25482. case tutorial.FieldIndex:
  25483. return m.OldIndex(ctx)
  25484. case tutorial.FieldTitle:
  25485. return m.OldTitle(ctx)
  25486. case tutorial.FieldContent:
  25487. return m.OldContent(ctx)
  25488. case tutorial.FieldOrganizationID:
  25489. return m.OldOrganizationID(ctx)
  25490. }
  25491. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  25492. }
  25493. // SetField sets the value of a field with the given name. It returns an error if
  25494. // the field is not defined in the schema, or if the type mismatched the field
  25495. // type.
  25496. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  25497. switch name {
  25498. case tutorial.FieldCreatedAt:
  25499. v, ok := value.(time.Time)
  25500. if !ok {
  25501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25502. }
  25503. m.SetCreatedAt(v)
  25504. return nil
  25505. case tutorial.FieldUpdatedAt:
  25506. v, ok := value.(time.Time)
  25507. if !ok {
  25508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25509. }
  25510. m.SetUpdatedAt(v)
  25511. return nil
  25512. case tutorial.FieldDeletedAt:
  25513. v, ok := value.(time.Time)
  25514. if !ok {
  25515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25516. }
  25517. m.SetDeletedAt(v)
  25518. return nil
  25519. case tutorial.FieldEmployeeID:
  25520. v, ok := value.(uint64)
  25521. if !ok {
  25522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25523. }
  25524. m.SetEmployeeID(v)
  25525. return nil
  25526. case tutorial.FieldIndex:
  25527. v, ok := value.(int)
  25528. if !ok {
  25529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25530. }
  25531. m.SetIndex(v)
  25532. return nil
  25533. case tutorial.FieldTitle:
  25534. v, ok := value.(string)
  25535. if !ok {
  25536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25537. }
  25538. m.SetTitle(v)
  25539. return nil
  25540. case tutorial.FieldContent:
  25541. v, ok := value.(string)
  25542. if !ok {
  25543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25544. }
  25545. m.SetContent(v)
  25546. return nil
  25547. case tutorial.FieldOrganizationID:
  25548. v, ok := value.(uint64)
  25549. if !ok {
  25550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25551. }
  25552. m.SetOrganizationID(v)
  25553. return nil
  25554. }
  25555. return fmt.Errorf("unknown Tutorial field %s", name)
  25556. }
  25557. // AddedFields returns all numeric fields that were incremented/decremented during
  25558. // this mutation.
  25559. func (m *TutorialMutation) AddedFields() []string {
  25560. var fields []string
  25561. if m.addindex != nil {
  25562. fields = append(fields, tutorial.FieldIndex)
  25563. }
  25564. if m.addorganization_id != nil {
  25565. fields = append(fields, tutorial.FieldOrganizationID)
  25566. }
  25567. return fields
  25568. }
  25569. // AddedField returns the numeric value that was incremented/decremented on a field
  25570. // with the given name. The second boolean return value indicates that this field
  25571. // was not set, or was not defined in the schema.
  25572. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  25573. switch name {
  25574. case tutorial.FieldIndex:
  25575. return m.AddedIndex()
  25576. case tutorial.FieldOrganizationID:
  25577. return m.AddedOrganizationID()
  25578. }
  25579. return nil, false
  25580. }
  25581. // AddField adds the value to the field with the given name. It returns an error if
  25582. // the field is not defined in the schema, or if the type mismatched the field
  25583. // type.
  25584. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  25585. switch name {
  25586. case tutorial.FieldIndex:
  25587. v, ok := value.(int)
  25588. if !ok {
  25589. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25590. }
  25591. m.AddIndex(v)
  25592. return nil
  25593. case tutorial.FieldOrganizationID:
  25594. v, ok := value.(int64)
  25595. if !ok {
  25596. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25597. }
  25598. m.AddOrganizationID(v)
  25599. return nil
  25600. }
  25601. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  25602. }
  25603. // ClearedFields returns all nullable fields that were cleared during this
  25604. // mutation.
  25605. func (m *TutorialMutation) ClearedFields() []string {
  25606. var fields []string
  25607. if m.FieldCleared(tutorial.FieldDeletedAt) {
  25608. fields = append(fields, tutorial.FieldDeletedAt)
  25609. }
  25610. return fields
  25611. }
  25612. // FieldCleared returns a boolean indicating if a field with the given name was
  25613. // cleared in this mutation.
  25614. func (m *TutorialMutation) FieldCleared(name string) bool {
  25615. _, ok := m.clearedFields[name]
  25616. return ok
  25617. }
  25618. // ClearField clears the value of the field with the given name. It returns an
  25619. // error if the field is not defined in the schema.
  25620. func (m *TutorialMutation) ClearField(name string) error {
  25621. switch name {
  25622. case tutorial.FieldDeletedAt:
  25623. m.ClearDeletedAt()
  25624. return nil
  25625. }
  25626. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  25627. }
  25628. // ResetField resets all changes in the mutation for the field with the given name.
  25629. // It returns an error if the field is not defined in the schema.
  25630. func (m *TutorialMutation) ResetField(name string) error {
  25631. switch name {
  25632. case tutorial.FieldCreatedAt:
  25633. m.ResetCreatedAt()
  25634. return nil
  25635. case tutorial.FieldUpdatedAt:
  25636. m.ResetUpdatedAt()
  25637. return nil
  25638. case tutorial.FieldDeletedAt:
  25639. m.ResetDeletedAt()
  25640. return nil
  25641. case tutorial.FieldEmployeeID:
  25642. m.ResetEmployeeID()
  25643. return nil
  25644. case tutorial.FieldIndex:
  25645. m.ResetIndex()
  25646. return nil
  25647. case tutorial.FieldTitle:
  25648. m.ResetTitle()
  25649. return nil
  25650. case tutorial.FieldContent:
  25651. m.ResetContent()
  25652. return nil
  25653. case tutorial.FieldOrganizationID:
  25654. m.ResetOrganizationID()
  25655. return nil
  25656. }
  25657. return fmt.Errorf("unknown Tutorial field %s", name)
  25658. }
  25659. // AddedEdges returns all edge names that were set/added in this mutation.
  25660. func (m *TutorialMutation) AddedEdges() []string {
  25661. edges := make([]string, 0, 1)
  25662. if m.employee != nil {
  25663. edges = append(edges, tutorial.EdgeEmployee)
  25664. }
  25665. return edges
  25666. }
  25667. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25668. // name in this mutation.
  25669. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  25670. switch name {
  25671. case tutorial.EdgeEmployee:
  25672. if id := m.employee; id != nil {
  25673. return []ent.Value{*id}
  25674. }
  25675. }
  25676. return nil
  25677. }
  25678. // RemovedEdges returns all edge names that were removed in this mutation.
  25679. func (m *TutorialMutation) RemovedEdges() []string {
  25680. edges := make([]string, 0, 1)
  25681. return edges
  25682. }
  25683. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25684. // the given name in this mutation.
  25685. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  25686. return nil
  25687. }
  25688. // ClearedEdges returns all edge names that were cleared in this mutation.
  25689. func (m *TutorialMutation) ClearedEdges() []string {
  25690. edges := make([]string, 0, 1)
  25691. if m.clearedemployee {
  25692. edges = append(edges, tutorial.EdgeEmployee)
  25693. }
  25694. return edges
  25695. }
  25696. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25697. // was cleared in this mutation.
  25698. func (m *TutorialMutation) EdgeCleared(name string) bool {
  25699. switch name {
  25700. case tutorial.EdgeEmployee:
  25701. return m.clearedemployee
  25702. }
  25703. return false
  25704. }
  25705. // ClearEdge clears the value of the edge with the given name. It returns an error
  25706. // if that edge is not defined in the schema.
  25707. func (m *TutorialMutation) ClearEdge(name string) error {
  25708. switch name {
  25709. case tutorial.EdgeEmployee:
  25710. m.ClearEmployee()
  25711. return nil
  25712. }
  25713. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  25714. }
  25715. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25716. // It returns an error if the edge is not defined in the schema.
  25717. func (m *TutorialMutation) ResetEdge(name string) error {
  25718. switch name {
  25719. case tutorial.EdgeEmployee:
  25720. m.ResetEmployee()
  25721. return nil
  25722. }
  25723. return fmt.Errorf("unknown Tutorial edge %s", name)
  25724. }
  25725. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  25726. type UsageDetailMutation struct {
  25727. config
  25728. op Op
  25729. typ string
  25730. id *uint64
  25731. created_at *time.Time
  25732. updated_at *time.Time
  25733. status *uint8
  25734. addstatus *int8
  25735. _type *int
  25736. add_type *int
  25737. bot_id *string
  25738. receiver_id *string
  25739. app *int
  25740. addapp *int
  25741. session_id *uint64
  25742. addsession_id *int64
  25743. request *string
  25744. response *string
  25745. original_data *custom_types.OriginalData
  25746. total_tokens *uint64
  25747. addtotal_tokens *int64
  25748. prompt_tokens *uint64
  25749. addprompt_tokens *int64
  25750. completion_tokens *uint64
  25751. addcompletion_tokens *int64
  25752. organization_id *uint64
  25753. addorganization_id *int64
  25754. clearedFields map[string]struct{}
  25755. done bool
  25756. oldValue func(context.Context) (*UsageDetail, error)
  25757. predicates []predicate.UsageDetail
  25758. }
  25759. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  25760. // usagedetailOption allows management of the mutation configuration using functional options.
  25761. type usagedetailOption func(*UsageDetailMutation)
  25762. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  25763. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  25764. m := &UsageDetailMutation{
  25765. config: c,
  25766. op: op,
  25767. typ: TypeUsageDetail,
  25768. clearedFields: make(map[string]struct{}),
  25769. }
  25770. for _, opt := range opts {
  25771. opt(m)
  25772. }
  25773. return m
  25774. }
  25775. // withUsageDetailID sets the ID field of the mutation.
  25776. func withUsageDetailID(id uint64) usagedetailOption {
  25777. return func(m *UsageDetailMutation) {
  25778. var (
  25779. err error
  25780. once sync.Once
  25781. value *UsageDetail
  25782. )
  25783. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  25784. once.Do(func() {
  25785. if m.done {
  25786. err = errors.New("querying old values post mutation is not allowed")
  25787. } else {
  25788. value, err = m.Client().UsageDetail.Get(ctx, id)
  25789. }
  25790. })
  25791. return value, err
  25792. }
  25793. m.id = &id
  25794. }
  25795. }
  25796. // withUsageDetail sets the old UsageDetail of the mutation.
  25797. func withUsageDetail(node *UsageDetail) usagedetailOption {
  25798. return func(m *UsageDetailMutation) {
  25799. m.oldValue = func(context.Context) (*UsageDetail, error) {
  25800. return node, nil
  25801. }
  25802. m.id = &node.ID
  25803. }
  25804. }
  25805. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25806. // executed in a transaction (ent.Tx), a transactional client is returned.
  25807. func (m UsageDetailMutation) Client() *Client {
  25808. client := &Client{config: m.config}
  25809. client.init()
  25810. return client
  25811. }
  25812. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25813. // it returns an error otherwise.
  25814. func (m UsageDetailMutation) Tx() (*Tx, error) {
  25815. if _, ok := m.driver.(*txDriver); !ok {
  25816. return nil, errors.New("ent: mutation is not running in a transaction")
  25817. }
  25818. tx := &Tx{config: m.config}
  25819. tx.init()
  25820. return tx, nil
  25821. }
  25822. // SetID sets the value of the id field. Note that this
  25823. // operation is only accepted on creation of UsageDetail entities.
  25824. func (m *UsageDetailMutation) SetID(id uint64) {
  25825. m.id = &id
  25826. }
  25827. // ID returns the ID value in the mutation. Note that the ID is only available
  25828. // if it was provided to the builder or after it was returned from the database.
  25829. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  25830. if m.id == nil {
  25831. return
  25832. }
  25833. return *m.id, true
  25834. }
  25835. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25836. // That means, if the mutation is applied within a transaction with an isolation level such
  25837. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25838. // or updated by the mutation.
  25839. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  25840. switch {
  25841. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25842. id, exists := m.ID()
  25843. if exists {
  25844. return []uint64{id}, nil
  25845. }
  25846. fallthrough
  25847. case m.op.Is(OpUpdate | OpDelete):
  25848. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  25849. default:
  25850. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25851. }
  25852. }
  25853. // SetCreatedAt sets the "created_at" field.
  25854. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  25855. m.created_at = &t
  25856. }
  25857. // CreatedAt returns the value of the "created_at" field in the mutation.
  25858. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  25859. v := m.created_at
  25860. if v == nil {
  25861. return
  25862. }
  25863. return *v, true
  25864. }
  25865. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  25866. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  25867. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25868. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25869. if !m.op.Is(OpUpdateOne) {
  25870. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25871. }
  25872. if m.id == nil || m.oldValue == nil {
  25873. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25874. }
  25875. oldValue, err := m.oldValue(ctx)
  25876. if err != nil {
  25877. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25878. }
  25879. return oldValue.CreatedAt, nil
  25880. }
  25881. // ResetCreatedAt resets all changes to the "created_at" field.
  25882. func (m *UsageDetailMutation) ResetCreatedAt() {
  25883. m.created_at = nil
  25884. }
  25885. // SetUpdatedAt sets the "updated_at" field.
  25886. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  25887. m.updated_at = &t
  25888. }
  25889. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25890. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  25891. v := m.updated_at
  25892. if v == nil {
  25893. return
  25894. }
  25895. return *v, true
  25896. }
  25897. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  25898. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  25899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25900. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25901. if !m.op.Is(OpUpdateOne) {
  25902. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25903. }
  25904. if m.id == nil || m.oldValue == nil {
  25905. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25906. }
  25907. oldValue, err := m.oldValue(ctx)
  25908. if err != nil {
  25909. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25910. }
  25911. return oldValue.UpdatedAt, nil
  25912. }
  25913. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25914. func (m *UsageDetailMutation) ResetUpdatedAt() {
  25915. m.updated_at = nil
  25916. }
  25917. // SetStatus sets the "status" field.
  25918. func (m *UsageDetailMutation) SetStatus(u uint8) {
  25919. m.status = &u
  25920. m.addstatus = nil
  25921. }
  25922. // Status returns the value of the "status" field in the mutation.
  25923. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  25924. v := m.status
  25925. if v == nil {
  25926. return
  25927. }
  25928. return *v, true
  25929. }
  25930. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  25931. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  25932. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25933. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  25934. if !m.op.Is(OpUpdateOne) {
  25935. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  25936. }
  25937. if m.id == nil || m.oldValue == nil {
  25938. return v, errors.New("OldStatus requires an ID field in the mutation")
  25939. }
  25940. oldValue, err := m.oldValue(ctx)
  25941. if err != nil {
  25942. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  25943. }
  25944. return oldValue.Status, nil
  25945. }
  25946. // AddStatus adds u to the "status" field.
  25947. func (m *UsageDetailMutation) AddStatus(u int8) {
  25948. if m.addstatus != nil {
  25949. *m.addstatus += u
  25950. } else {
  25951. m.addstatus = &u
  25952. }
  25953. }
  25954. // AddedStatus returns the value that was added to the "status" field in this mutation.
  25955. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  25956. v := m.addstatus
  25957. if v == nil {
  25958. return
  25959. }
  25960. return *v, true
  25961. }
  25962. // ClearStatus clears the value of the "status" field.
  25963. func (m *UsageDetailMutation) ClearStatus() {
  25964. m.status = nil
  25965. m.addstatus = nil
  25966. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  25967. }
  25968. // StatusCleared returns if the "status" field was cleared in this mutation.
  25969. func (m *UsageDetailMutation) StatusCleared() bool {
  25970. _, ok := m.clearedFields[usagedetail.FieldStatus]
  25971. return ok
  25972. }
  25973. // ResetStatus resets all changes to the "status" field.
  25974. func (m *UsageDetailMutation) ResetStatus() {
  25975. m.status = nil
  25976. m.addstatus = nil
  25977. delete(m.clearedFields, usagedetail.FieldStatus)
  25978. }
  25979. // SetType sets the "type" field.
  25980. func (m *UsageDetailMutation) SetType(i int) {
  25981. m._type = &i
  25982. m.add_type = nil
  25983. }
  25984. // GetType returns the value of the "type" field in the mutation.
  25985. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  25986. v := m._type
  25987. if v == nil {
  25988. return
  25989. }
  25990. return *v, true
  25991. }
  25992. // OldType returns the old "type" field's value of the UsageDetail entity.
  25993. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  25994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25995. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  25996. if !m.op.Is(OpUpdateOne) {
  25997. return v, errors.New("OldType is only allowed on UpdateOne operations")
  25998. }
  25999. if m.id == nil || m.oldValue == nil {
  26000. return v, errors.New("OldType requires an ID field in the mutation")
  26001. }
  26002. oldValue, err := m.oldValue(ctx)
  26003. if err != nil {
  26004. return v, fmt.Errorf("querying old value for OldType: %w", err)
  26005. }
  26006. return oldValue.Type, nil
  26007. }
  26008. // AddType adds i to the "type" field.
  26009. func (m *UsageDetailMutation) AddType(i int) {
  26010. if m.add_type != nil {
  26011. *m.add_type += i
  26012. } else {
  26013. m.add_type = &i
  26014. }
  26015. }
  26016. // AddedType returns the value that was added to the "type" field in this mutation.
  26017. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  26018. v := m.add_type
  26019. if v == nil {
  26020. return
  26021. }
  26022. return *v, true
  26023. }
  26024. // ClearType clears the value of the "type" field.
  26025. func (m *UsageDetailMutation) ClearType() {
  26026. m._type = nil
  26027. m.add_type = nil
  26028. m.clearedFields[usagedetail.FieldType] = struct{}{}
  26029. }
  26030. // TypeCleared returns if the "type" field was cleared in this mutation.
  26031. func (m *UsageDetailMutation) TypeCleared() bool {
  26032. _, ok := m.clearedFields[usagedetail.FieldType]
  26033. return ok
  26034. }
  26035. // ResetType resets all changes to the "type" field.
  26036. func (m *UsageDetailMutation) ResetType() {
  26037. m._type = nil
  26038. m.add_type = nil
  26039. delete(m.clearedFields, usagedetail.FieldType)
  26040. }
  26041. // SetBotID sets the "bot_id" field.
  26042. func (m *UsageDetailMutation) SetBotID(s string) {
  26043. m.bot_id = &s
  26044. }
  26045. // BotID returns the value of the "bot_id" field in the mutation.
  26046. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  26047. v := m.bot_id
  26048. if v == nil {
  26049. return
  26050. }
  26051. return *v, true
  26052. }
  26053. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  26054. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26056. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  26057. if !m.op.Is(OpUpdateOne) {
  26058. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  26059. }
  26060. if m.id == nil || m.oldValue == nil {
  26061. return v, errors.New("OldBotID requires an ID field in the mutation")
  26062. }
  26063. oldValue, err := m.oldValue(ctx)
  26064. if err != nil {
  26065. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  26066. }
  26067. return oldValue.BotID, nil
  26068. }
  26069. // ResetBotID resets all changes to the "bot_id" field.
  26070. func (m *UsageDetailMutation) ResetBotID() {
  26071. m.bot_id = nil
  26072. }
  26073. // SetReceiverID sets the "receiver_id" field.
  26074. func (m *UsageDetailMutation) SetReceiverID(s string) {
  26075. m.receiver_id = &s
  26076. }
  26077. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  26078. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  26079. v := m.receiver_id
  26080. if v == nil {
  26081. return
  26082. }
  26083. return *v, true
  26084. }
  26085. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  26086. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26088. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  26089. if !m.op.Is(OpUpdateOne) {
  26090. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  26091. }
  26092. if m.id == nil || m.oldValue == nil {
  26093. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  26094. }
  26095. oldValue, err := m.oldValue(ctx)
  26096. if err != nil {
  26097. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  26098. }
  26099. return oldValue.ReceiverID, nil
  26100. }
  26101. // ResetReceiverID resets all changes to the "receiver_id" field.
  26102. func (m *UsageDetailMutation) ResetReceiverID() {
  26103. m.receiver_id = nil
  26104. }
  26105. // SetApp sets the "app" field.
  26106. func (m *UsageDetailMutation) SetApp(i int) {
  26107. m.app = &i
  26108. m.addapp = nil
  26109. }
  26110. // App returns the value of the "app" field in the mutation.
  26111. func (m *UsageDetailMutation) App() (r int, exists bool) {
  26112. v := m.app
  26113. if v == nil {
  26114. return
  26115. }
  26116. return *v, true
  26117. }
  26118. // OldApp returns the old "app" field's value of the UsageDetail entity.
  26119. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26121. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  26122. if !m.op.Is(OpUpdateOne) {
  26123. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  26124. }
  26125. if m.id == nil || m.oldValue == nil {
  26126. return v, errors.New("OldApp requires an ID field in the mutation")
  26127. }
  26128. oldValue, err := m.oldValue(ctx)
  26129. if err != nil {
  26130. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  26131. }
  26132. return oldValue.App, nil
  26133. }
  26134. // AddApp adds i to the "app" field.
  26135. func (m *UsageDetailMutation) AddApp(i int) {
  26136. if m.addapp != nil {
  26137. *m.addapp += i
  26138. } else {
  26139. m.addapp = &i
  26140. }
  26141. }
  26142. // AddedApp returns the value that was added to the "app" field in this mutation.
  26143. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  26144. v := m.addapp
  26145. if v == nil {
  26146. return
  26147. }
  26148. return *v, true
  26149. }
  26150. // ClearApp clears the value of the "app" field.
  26151. func (m *UsageDetailMutation) ClearApp() {
  26152. m.app = nil
  26153. m.addapp = nil
  26154. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  26155. }
  26156. // AppCleared returns if the "app" field was cleared in this mutation.
  26157. func (m *UsageDetailMutation) AppCleared() bool {
  26158. _, ok := m.clearedFields[usagedetail.FieldApp]
  26159. return ok
  26160. }
  26161. // ResetApp resets all changes to the "app" field.
  26162. func (m *UsageDetailMutation) ResetApp() {
  26163. m.app = nil
  26164. m.addapp = nil
  26165. delete(m.clearedFields, usagedetail.FieldApp)
  26166. }
  26167. // SetSessionID sets the "session_id" field.
  26168. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  26169. m.session_id = &u
  26170. m.addsession_id = nil
  26171. }
  26172. // SessionID returns the value of the "session_id" field in the mutation.
  26173. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  26174. v := m.session_id
  26175. if v == nil {
  26176. return
  26177. }
  26178. return *v, true
  26179. }
  26180. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  26181. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26183. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  26184. if !m.op.Is(OpUpdateOne) {
  26185. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  26186. }
  26187. if m.id == nil || m.oldValue == nil {
  26188. return v, errors.New("OldSessionID requires an ID field in the mutation")
  26189. }
  26190. oldValue, err := m.oldValue(ctx)
  26191. if err != nil {
  26192. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  26193. }
  26194. return oldValue.SessionID, nil
  26195. }
  26196. // AddSessionID adds u to the "session_id" field.
  26197. func (m *UsageDetailMutation) AddSessionID(u int64) {
  26198. if m.addsession_id != nil {
  26199. *m.addsession_id += u
  26200. } else {
  26201. m.addsession_id = &u
  26202. }
  26203. }
  26204. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  26205. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  26206. v := m.addsession_id
  26207. if v == nil {
  26208. return
  26209. }
  26210. return *v, true
  26211. }
  26212. // ClearSessionID clears the value of the "session_id" field.
  26213. func (m *UsageDetailMutation) ClearSessionID() {
  26214. m.session_id = nil
  26215. m.addsession_id = nil
  26216. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  26217. }
  26218. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  26219. func (m *UsageDetailMutation) SessionIDCleared() bool {
  26220. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  26221. return ok
  26222. }
  26223. // ResetSessionID resets all changes to the "session_id" field.
  26224. func (m *UsageDetailMutation) ResetSessionID() {
  26225. m.session_id = nil
  26226. m.addsession_id = nil
  26227. delete(m.clearedFields, usagedetail.FieldSessionID)
  26228. }
  26229. // SetRequest sets the "request" field.
  26230. func (m *UsageDetailMutation) SetRequest(s string) {
  26231. m.request = &s
  26232. }
  26233. // Request returns the value of the "request" field in the mutation.
  26234. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  26235. v := m.request
  26236. if v == nil {
  26237. return
  26238. }
  26239. return *v, true
  26240. }
  26241. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  26242. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26243. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26244. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  26245. if !m.op.Is(OpUpdateOne) {
  26246. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  26247. }
  26248. if m.id == nil || m.oldValue == nil {
  26249. return v, errors.New("OldRequest requires an ID field in the mutation")
  26250. }
  26251. oldValue, err := m.oldValue(ctx)
  26252. if err != nil {
  26253. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  26254. }
  26255. return oldValue.Request, nil
  26256. }
  26257. // ResetRequest resets all changes to the "request" field.
  26258. func (m *UsageDetailMutation) ResetRequest() {
  26259. m.request = nil
  26260. }
  26261. // SetResponse sets the "response" field.
  26262. func (m *UsageDetailMutation) SetResponse(s string) {
  26263. m.response = &s
  26264. }
  26265. // Response returns the value of the "response" field in the mutation.
  26266. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  26267. v := m.response
  26268. if v == nil {
  26269. return
  26270. }
  26271. return *v, true
  26272. }
  26273. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  26274. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26275. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26276. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  26277. if !m.op.Is(OpUpdateOne) {
  26278. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  26279. }
  26280. if m.id == nil || m.oldValue == nil {
  26281. return v, errors.New("OldResponse requires an ID field in the mutation")
  26282. }
  26283. oldValue, err := m.oldValue(ctx)
  26284. if err != nil {
  26285. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  26286. }
  26287. return oldValue.Response, nil
  26288. }
  26289. // ResetResponse resets all changes to the "response" field.
  26290. func (m *UsageDetailMutation) ResetResponse() {
  26291. m.response = nil
  26292. }
  26293. // SetOriginalData sets the "original_data" field.
  26294. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  26295. m.original_data = &ctd
  26296. }
  26297. // OriginalData returns the value of the "original_data" field in the mutation.
  26298. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  26299. v := m.original_data
  26300. if v == nil {
  26301. return
  26302. }
  26303. return *v, true
  26304. }
  26305. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  26306. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26307. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26308. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  26309. if !m.op.Is(OpUpdateOne) {
  26310. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  26311. }
  26312. if m.id == nil || m.oldValue == nil {
  26313. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  26314. }
  26315. oldValue, err := m.oldValue(ctx)
  26316. if err != nil {
  26317. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  26318. }
  26319. return oldValue.OriginalData, nil
  26320. }
  26321. // ResetOriginalData resets all changes to the "original_data" field.
  26322. func (m *UsageDetailMutation) ResetOriginalData() {
  26323. m.original_data = nil
  26324. }
  26325. // SetTotalTokens sets the "total_tokens" field.
  26326. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  26327. m.total_tokens = &u
  26328. m.addtotal_tokens = nil
  26329. }
  26330. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  26331. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  26332. v := m.total_tokens
  26333. if v == nil {
  26334. return
  26335. }
  26336. return *v, true
  26337. }
  26338. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  26339. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26340. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26341. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  26342. if !m.op.Is(OpUpdateOne) {
  26343. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  26344. }
  26345. if m.id == nil || m.oldValue == nil {
  26346. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  26347. }
  26348. oldValue, err := m.oldValue(ctx)
  26349. if err != nil {
  26350. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  26351. }
  26352. return oldValue.TotalTokens, nil
  26353. }
  26354. // AddTotalTokens adds u to the "total_tokens" field.
  26355. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  26356. if m.addtotal_tokens != nil {
  26357. *m.addtotal_tokens += u
  26358. } else {
  26359. m.addtotal_tokens = &u
  26360. }
  26361. }
  26362. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  26363. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  26364. v := m.addtotal_tokens
  26365. if v == nil {
  26366. return
  26367. }
  26368. return *v, true
  26369. }
  26370. // ClearTotalTokens clears the value of the "total_tokens" field.
  26371. func (m *UsageDetailMutation) ClearTotalTokens() {
  26372. m.total_tokens = nil
  26373. m.addtotal_tokens = nil
  26374. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  26375. }
  26376. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  26377. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  26378. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  26379. return ok
  26380. }
  26381. // ResetTotalTokens resets all changes to the "total_tokens" field.
  26382. func (m *UsageDetailMutation) ResetTotalTokens() {
  26383. m.total_tokens = nil
  26384. m.addtotal_tokens = nil
  26385. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  26386. }
  26387. // SetPromptTokens sets the "prompt_tokens" field.
  26388. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  26389. m.prompt_tokens = &u
  26390. m.addprompt_tokens = nil
  26391. }
  26392. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  26393. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  26394. v := m.prompt_tokens
  26395. if v == nil {
  26396. return
  26397. }
  26398. return *v, true
  26399. }
  26400. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  26401. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26403. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  26404. if !m.op.Is(OpUpdateOne) {
  26405. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  26406. }
  26407. if m.id == nil || m.oldValue == nil {
  26408. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  26409. }
  26410. oldValue, err := m.oldValue(ctx)
  26411. if err != nil {
  26412. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  26413. }
  26414. return oldValue.PromptTokens, nil
  26415. }
  26416. // AddPromptTokens adds u to the "prompt_tokens" field.
  26417. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  26418. if m.addprompt_tokens != nil {
  26419. *m.addprompt_tokens += u
  26420. } else {
  26421. m.addprompt_tokens = &u
  26422. }
  26423. }
  26424. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  26425. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  26426. v := m.addprompt_tokens
  26427. if v == nil {
  26428. return
  26429. }
  26430. return *v, true
  26431. }
  26432. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  26433. func (m *UsageDetailMutation) ClearPromptTokens() {
  26434. m.prompt_tokens = nil
  26435. m.addprompt_tokens = nil
  26436. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  26437. }
  26438. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  26439. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  26440. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  26441. return ok
  26442. }
  26443. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  26444. func (m *UsageDetailMutation) ResetPromptTokens() {
  26445. m.prompt_tokens = nil
  26446. m.addprompt_tokens = nil
  26447. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  26448. }
  26449. // SetCompletionTokens sets the "completion_tokens" field.
  26450. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  26451. m.completion_tokens = &u
  26452. m.addcompletion_tokens = nil
  26453. }
  26454. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  26455. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  26456. v := m.completion_tokens
  26457. if v == nil {
  26458. return
  26459. }
  26460. return *v, true
  26461. }
  26462. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  26463. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26465. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  26466. if !m.op.Is(OpUpdateOne) {
  26467. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  26468. }
  26469. if m.id == nil || m.oldValue == nil {
  26470. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  26471. }
  26472. oldValue, err := m.oldValue(ctx)
  26473. if err != nil {
  26474. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  26475. }
  26476. return oldValue.CompletionTokens, nil
  26477. }
  26478. // AddCompletionTokens adds u to the "completion_tokens" field.
  26479. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  26480. if m.addcompletion_tokens != nil {
  26481. *m.addcompletion_tokens += u
  26482. } else {
  26483. m.addcompletion_tokens = &u
  26484. }
  26485. }
  26486. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  26487. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  26488. v := m.addcompletion_tokens
  26489. if v == nil {
  26490. return
  26491. }
  26492. return *v, true
  26493. }
  26494. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  26495. func (m *UsageDetailMutation) ClearCompletionTokens() {
  26496. m.completion_tokens = nil
  26497. m.addcompletion_tokens = nil
  26498. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  26499. }
  26500. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  26501. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  26502. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  26503. return ok
  26504. }
  26505. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  26506. func (m *UsageDetailMutation) ResetCompletionTokens() {
  26507. m.completion_tokens = nil
  26508. m.addcompletion_tokens = nil
  26509. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  26510. }
  26511. // SetOrganizationID sets the "organization_id" field.
  26512. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  26513. m.organization_id = &u
  26514. m.addorganization_id = nil
  26515. }
  26516. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26517. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  26518. v := m.organization_id
  26519. if v == nil {
  26520. return
  26521. }
  26522. return *v, true
  26523. }
  26524. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  26525. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26527. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26528. if !m.op.Is(OpUpdateOne) {
  26529. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26530. }
  26531. if m.id == nil || m.oldValue == nil {
  26532. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26533. }
  26534. oldValue, err := m.oldValue(ctx)
  26535. if err != nil {
  26536. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26537. }
  26538. return oldValue.OrganizationID, nil
  26539. }
  26540. // AddOrganizationID adds u to the "organization_id" field.
  26541. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  26542. if m.addorganization_id != nil {
  26543. *m.addorganization_id += u
  26544. } else {
  26545. m.addorganization_id = &u
  26546. }
  26547. }
  26548. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26549. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  26550. v := m.addorganization_id
  26551. if v == nil {
  26552. return
  26553. }
  26554. return *v, true
  26555. }
  26556. // ClearOrganizationID clears the value of the "organization_id" field.
  26557. func (m *UsageDetailMutation) ClearOrganizationID() {
  26558. m.organization_id = nil
  26559. m.addorganization_id = nil
  26560. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  26561. }
  26562. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  26563. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  26564. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  26565. return ok
  26566. }
  26567. // ResetOrganizationID resets all changes to the "organization_id" field.
  26568. func (m *UsageDetailMutation) ResetOrganizationID() {
  26569. m.organization_id = nil
  26570. m.addorganization_id = nil
  26571. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  26572. }
  26573. // Where appends a list predicates to the UsageDetailMutation builder.
  26574. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  26575. m.predicates = append(m.predicates, ps...)
  26576. }
  26577. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  26578. // users can use type-assertion to append predicates that do not depend on any generated package.
  26579. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  26580. p := make([]predicate.UsageDetail, len(ps))
  26581. for i := range ps {
  26582. p[i] = ps[i]
  26583. }
  26584. m.Where(p...)
  26585. }
  26586. // Op returns the operation name.
  26587. func (m *UsageDetailMutation) Op() Op {
  26588. return m.op
  26589. }
  26590. // SetOp allows setting the mutation operation.
  26591. func (m *UsageDetailMutation) SetOp(op Op) {
  26592. m.op = op
  26593. }
  26594. // Type returns the node type of this mutation (UsageDetail).
  26595. func (m *UsageDetailMutation) Type() string {
  26596. return m.typ
  26597. }
  26598. // Fields returns all fields that were changed during this mutation. Note that in
  26599. // order to get all numeric fields that were incremented/decremented, call
  26600. // AddedFields().
  26601. func (m *UsageDetailMutation) Fields() []string {
  26602. fields := make([]string, 0, 15)
  26603. if m.created_at != nil {
  26604. fields = append(fields, usagedetail.FieldCreatedAt)
  26605. }
  26606. if m.updated_at != nil {
  26607. fields = append(fields, usagedetail.FieldUpdatedAt)
  26608. }
  26609. if m.status != nil {
  26610. fields = append(fields, usagedetail.FieldStatus)
  26611. }
  26612. if m._type != nil {
  26613. fields = append(fields, usagedetail.FieldType)
  26614. }
  26615. if m.bot_id != nil {
  26616. fields = append(fields, usagedetail.FieldBotID)
  26617. }
  26618. if m.receiver_id != nil {
  26619. fields = append(fields, usagedetail.FieldReceiverID)
  26620. }
  26621. if m.app != nil {
  26622. fields = append(fields, usagedetail.FieldApp)
  26623. }
  26624. if m.session_id != nil {
  26625. fields = append(fields, usagedetail.FieldSessionID)
  26626. }
  26627. if m.request != nil {
  26628. fields = append(fields, usagedetail.FieldRequest)
  26629. }
  26630. if m.response != nil {
  26631. fields = append(fields, usagedetail.FieldResponse)
  26632. }
  26633. if m.original_data != nil {
  26634. fields = append(fields, usagedetail.FieldOriginalData)
  26635. }
  26636. if m.total_tokens != nil {
  26637. fields = append(fields, usagedetail.FieldTotalTokens)
  26638. }
  26639. if m.prompt_tokens != nil {
  26640. fields = append(fields, usagedetail.FieldPromptTokens)
  26641. }
  26642. if m.completion_tokens != nil {
  26643. fields = append(fields, usagedetail.FieldCompletionTokens)
  26644. }
  26645. if m.organization_id != nil {
  26646. fields = append(fields, usagedetail.FieldOrganizationID)
  26647. }
  26648. return fields
  26649. }
  26650. // Field returns the value of a field with the given name. The second boolean
  26651. // return value indicates that this field was not set, or was not defined in the
  26652. // schema.
  26653. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  26654. switch name {
  26655. case usagedetail.FieldCreatedAt:
  26656. return m.CreatedAt()
  26657. case usagedetail.FieldUpdatedAt:
  26658. return m.UpdatedAt()
  26659. case usagedetail.FieldStatus:
  26660. return m.Status()
  26661. case usagedetail.FieldType:
  26662. return m.GetType()
  26663. case usagedetail.FieldBotID:
  26664. return m.BotID()
  26665. case usagedetail.FieldReceiverID:
  26666. return m.ReceiverID()
  26667. case usagedetail.FieldApp:
  26668. return m.App()
  26669. case usagedetail.FieldSessionID:
  26670. return m.SessionID()
  26671. case usagedetail.FieldRequest:
  26672. return m.Request()
  26673. case usagedetail.FieldResponse:
  26674. return m.Response()
  26675. case usagedetail.FieldOriginalData:
  26676. return m.OriginalData()
  26677. case usagedetail.FieldTotalTokens:
  26678. return m.TotalTokens()
  26679. case usagedetail.FieldPromptTokens:
  26680. return m.PromptTokens()
  26681. case usagedetail.FieldCompletionTokens:
  26682. return m.CompletionTokens()
  26683. case usagedetail.FieldOrganizationID:
  26684. return m.OrganizationID()
  26685. }
  26686. return nil, false
  26687. }
  26688. // OldField returns the old value of the field from the database. An error is
  26689. // returned if the mutation operation is not UpdateOne, or the query to the
  26690. // database failed.
  26691. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26692. switch name {
  26693. case usagedetail.FieldCreatedAt:
  26694. return m.OldCreatedAt(ctx)
  26695. case usagedetail.FieldUpdatedAt:
  26696. return m.OldUpdatedAt(ctx)
  26697. case usagedetail.FieldStatus:
  26698. return m.OldStatus(ctx)
  26699. case usagedetail.FieldType:
  26700. return m.OldType(ctx)
  26701. case usagedetail.FieldBotID:
  26702. return m.OldBotID(ctx)
  26703. case usagedetail.FieldReceiverID:
  26704. return m.OldReceiverID(ctx)
  26705. case usagedetail.FieldApp:
  26706. return m.OldApp(ctx)
  26707. case usagedetail.FieldSessionID:
  26708. return m.OldSessionID(ctx)
  26709. case usagedetail.FieldRequest:
  26710. return m.OldRequest(ctx)
  26711. case usagedetail.FieldResponse:
  26712. return m.OldResponse(ctx)
  26713. case usagedetail.FieldOriginalData:
  26714. return m.OldOriginalData(ctx)
  26715. case usagedetail.FieldTotalTokens:
  26716. return m.OldTotalTokens(ctx)
  26717. case usagedetail.FieldPromptTokens:
  26718. return m.OldPromptTokens(ctx)
  26719. case usagedetail.FieldCompletionTokens:
  26720. return m.OldCompletionTokens(ctx)
  26721. case usagedetail.FieldOrganizationID:
  26722. return m.OldOrganizationID(ctx)
  26723. }
  26724. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  26725. }
  26726. // SetField sets the value of a field with the given name. It returns an error if
  26727. // the field is not defined in the schema, or if the type mismatched the field
  26728. // type.
  26729. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  26730. switch name {
  26731. case usagedetail.FieldCreatedAt:
  26732. v, ok := value.(time.Time)
  26733. if !ok {
  26734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26735. }
  26736. m.SetCreatedAt(v)
  26737. return nil
  26738. case usagedetail.FieldUpdatedAt:
  26739. v, ok := value.(time.Time)
  26740. if !ok {
  26741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26742. }
  26743. m.SetUpdatedAt(v)
  26744. return nil
  26745. case usagedetail.FieldStatus:
  26746. v, ok := value.(uint8)
  26747. if !ok {
  26748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26749. }
  26750. m.SetStatus(v)
  26751. return nil
  26752. case usagedetail.FieldType:
  26753. v, ok := value.(int)
  26754. if !ok {
  26755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26756. }
  26757. m.SetType(v)
  26758. return nil
  26759. case usagedetail.FieldBotID:
  26760. v, ok := value.(string)
  26761. if !ok {
  26762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26763. }
  26764. m.SetBotID(v)
  26765. return nil
  26766. case usagedetail.FieldReceiverID:
  26767. v, ok := value.(string)
  26768. if !ok {
  26769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26770. }
  26771. m.SetReceiverID(v)
  26772. return nil
  26773. case usagedetail.FieldApp:
  26774. v, ok := value.(int)
  26775. if !ok {
  26776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26777. }
  26778. m.SetApp(v)
  26779. return nil
  26780. case usagedetail.FieldSessionID:
  26781. v, ok := value.(uint64)
  26782. if !ok {
  26783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26784. }
  26785. m.SetSessionID(v)
  26786. return nil
  26787. case usagedetail.FieldRequest:
  26788. v, ok := value.(string)
  26789. if !ok {
  26790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26791. }
  26792. m.SetRequest(v)
  26793. return nil
  26794. case usagedetail.FieldResponse:
  26795. v, ok := value.(string)
  26796. if !ok {
  26797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26798. }
  26799. m.SetResponse(v)
  26800. return nil
  26801. case usagedetail.FieldOriginalData:
  26802. v, ok := value.(custom_types.OriginalData)
  26803. if !ok {
  26804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26805. }
  26806. m.SetOriginalData(v)
  26807. return nil
  26808. case usagedetail.FieldTotalTokens:
  26809. v, ok := value.(uint64)
  26810. if !ok {
  26811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26812. }
  26813. m.SetTotalTokens(v)
  26814. return nil
  26815. case usagedetail.FieldPromptTokens:
  26816. v, ok := value.(uint64)
  26817. if !ok {
  26818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26819. }
  26820. m.SetPromptTokens(v)
  26821. return nil
  26822. case usagedetail.FieldCompletionTokens:
  26823. v, ok := value.(uint64)
  26824. if !ok {
  26825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26826. }
  26827. m.SetCompletionTokens(v)
  26828. return nil
  26829. case usagedetail.FieldOrganizationID:
  26830. v, ok := value.(uint64)
  26831. if !ok {
  26832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26833. }
  26834. m.SetOrganizationID(v)
  26835. return nil
  26836. }
  26837. return fmt.Errorf("unknown UsageDetail field %s", name)
  26838. }
  26839. // AddedFields returns all numeric fields that were incremented/decremented during
  26840. // this mutation.
  26841. func (m *UsageDetailMutation) AddedFields() []string {
  26842. var fields []string
  26843. if m.addstatus != nil {
  26844. fields = append(fields, usagedetail.FieldStatus)
  26845. }
  26846. if m.add_type != nil {
  26847. fields = append(fields, usagedetail.FieldType)
  26848. }
  26849. if m.addapp != nil {
  26850. fields = append(fields, usagedetail.FieldApp)
  26851. }
  26852. if m.addsession_id != nil {
  26853. fields = append(fields, usagedetail.FieldSessionID)
  26854. }
  26855. if m.addtotal_tokens != nil {
  26856. fields = append(fields, usagedetail.FieldTotalTokens)
  26857. }
  26858. if m.addprompt_tokens != nil {
  26859. fields = append(fields, usagedetail.FieldPromptTokens)
  26860. }
  26861. if m.addcompletion_tokens != nil {
  26862. fields = append(fields, usagedetail.FieldCompletionTokens)
  26863. }
  26864. if m.addorganization_id != nil {
  26865. fields = append(fields, usagedetail.FieldOrganizationID)
  26866. }
  26867. return fields
  26868. }
  26869. // AddedField returns the numeric value that was incremented/decremented on a field
  26870. // with the given name. The second boolean return value indicates that this field
  26871. // was not set, or was not defined in the schema.
  26872. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  26873. switch name {
  26874. case usagedetail.FieldStatus:
  26875. return m.AddedStatus()
  26876. case usagedetail.FieldType:
  26877. return m.AddedType()
  26878. case usagedetail.FieldApp:
  26879. return m.AddedApp()
  26880. case usagedetail.FieldSessionID:
  26881. return m.AddedSessionID()
  26882. case usagedetail.FieldTotalTokens:
  26883. return m.AddedTotalTokens()
  26884. case usagedetail.FieldPromptTokens:
  26885. return m.AddedPromptTokens()
  26886. case usagedetail.FieldCompletionTokens:
  26887. return m.AddedCompletionTokens()
  26888. case usagedetail.FieldOrganizationID:
  26889. return m.AddedOrganizationID()
  26890. }
  26891. return nil, false
  26892. }
  26893. // AddField adds the value to the field with the given name. It returns an error if
  26894. // the field is not defined in the schema, or if the type mismatched the field
  26895. // type.
  26896. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  26897. switch name {
  26898. case usagedetail.FieldStatus:
  26899. v, ok := value.(int8)
  26900. if !ok {
  26901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26902. }
  26903. m.AddStatus(v)
  26904. return nil
  26905. case usagedetail.FieldType:
  26906. v, ok := value.(int)
  26907. if !ok {
  26908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26909. }
  26910. m.AddType(v)
  26911. return nil
  26912. case usagedetail.FieldApp:
  26913. v, ok := value.(int)
  26914. if !ok {
  26915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26916. }
  26917. m.AddApp(v)
  26918. return nil
  26919. case usagedetail.FieldSessionID:
  26920. v, ok := value.(int64)
  26921. if !ok {
  26922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26923. }
  26924. m.AddSessionID(v)
  26925. return nil
  26926. case usagedetail.FieldTotalTokens:
  26927. v, ok := value.(int64)
  26928. if !ok {
  26929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26930. }
  26931. m.AddTotalTokens(v)
  26932. return nil
  26933. case usagedetail.FieldPromptTokens:
  26934. v, ok := value.(int64)
  26935. if !ok {
  26936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26937. }
  26938. m.AddPromptTokens(v)
  26939. return nil
  26940. case usagedetail.FieldCompletionTokens:
  26941. v, ok := value.(int64)
  26942. if !ok {
  26943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26944. }
  26945. m.AddCompletionTokens(v)
  26946. return nil
  26947. case usagedetail.FieldOrganizationID:
  26948. v, ok := value.(int64)
  26949. if !ok {
  26950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26951. }
  26952. m.AddOrganizationID(v)
  26953. return nil
  26954. }
  26955. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  26956. }
  26957. // ClearedFields returns all nullable fields that were cleared during this
  26958. // mutation.
  26959. func (m *UsageDetailMutation) ClearedFields() []string {
  26960. var fields []string
  26961. if m.FieldCleared(usagedetail.FieldStatus) {
  26962. fields = append(fields, usagedetail.FieldStatus)
  26963. }
  26964. if m.FieldCleared(usagedetail.FieldType) {
  26965. fields = append(fields, usagedetail.FieldType)
  26966. }
  26967. if m.FieldCleared(usagedetail.FieldApp) {
  26968. fields = append(fields, usagedetail.FieldApp)
  26969. }
  26970. if m.FieldCleared(usagedetail.FieldSessionID) {
  26971. fields = append(fields, usagedetail.FieldSessionID)
  26972. }
  26973. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  26974. fields = append(fields, usagedetail.FieldTotalTokens)
  26975. }
  26976. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  26977. fields = append(fields, usagedetail.FieldPromptTokens)
  26978. }
  26979. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  26980. fields = append(fields, usagedetail.FieldCompletionTokens)
  26981. }
  26982. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  26983. fields = append(fields, usagedetail.FieldOrganizationID)
  26984. }
  26985. return fields
  26986. }
  26987. // FieldCleared returns a boolean indicating if a field with the given name was
  26988. // cleared in this mutation.
  26989. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  26990. _, ok := m.clearedFields[name]
  26991. return ok
  26992. }
  26993. // ClearField clears the value of the field with the given name. It returns an
  26994. // error if the field is not defined in the schema.
  26995. func (m *UsageDetailMutation) ClearField(name string) error {
  26996. switch name {
  26997. case usagedetail.FieldStatus:
  26998. m.ClearStatus()
  26999. return nil
  27000. case usagedetail.FieldType:
  27001. m.ClearType()
  27002. return nil
  27003. case usagedetail.FieldApp:
  27004. m.ClearApp()
  27005. return nil
  27006. case usagedetail.FieldSessionID:
  27007. m.ClearSessionID()
  27008. return nil
  27009. case usagedetail.FieldTotalTokens:
  27010. m.ClearTotalTokens()
  27011. return nil
  27012. case usagedetail.FieldPromptTokens:
  27013. m.ClearPromptTokens()
  27014. return nil
  27015. case usagedetail.FieldCompletionTokens:
  27016. m.ClearCompletionTokens()
  27017. return nil
  27018. case usagedetail.FieldOrganizationID:
  27019. m.ClearOrganizationID()
  27020. return nil
  27021. }
  27022. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  27023. }
  27024. // ResetField resets all changes in the mutation for the field with the given name.
  27025. // It returns an error if the field is not defined in the schema.
  27026. func (m *UsageDetailMutation) ResetField(name string) error {
  27027. switch name {
  27028. case usagedetail.FieldCreatedAt:
  27029. m.ResetCreatedAt()
  27030. return nil
  27031. case usagedetail.FieldUpdatedAt:
  27032. m.ResetUpdatedAt()
  27033. return nil
  27034. case usagedetail.FieldStatus:
  27035. m.ResetStatus()
  27036. return nil
  27037. case usagedetail.FieldType:
  27038. m.ResetType()
  27039. return nil
  27040. case usagedetail.FieldBotID:
  27041. m.ResetBotID()
  27042. return nil
  27043. case usagedetail.FieldReceiverID:
  27044. m.ResetReceiverID()
  27045. return nil
  27046. case usagedetail.FieldApp:
  27047. m.ResetApp()
  27048. return nil
  27049. case usagedetail.FieldSessionID:
  27050. m.ResetSessionID()
  27051. return nil
  27052. case usagedetail.FieldRequest:
  27053. m.ResetRequest()
  27054. return nil
  27055. case usagedetail.FieldResponse:
  27056. m.ResetResponse()
  27057. return nil
  27058. case usagedetail.FieldOriginalData:
  27059. m.ResetOriginalData()
  27060. return nil
  27061. case usagedetail.FieldTotalTokens:
  27062. m.ResetTotalTokens()
  27063. return nil
  27064. case usagedetail.FieldPromptTokens:
  27065. m.ResetPromptTokens()
  27066. return nil
  27067. case usagedetail.FieldCompletionTokens:
  27068. m.ResetCompletionTokens()
  27069. return nil
  27070. case usagedetail.FieldOrganizationID:
  27071. m.ResetOrganizationID()
  27072. return nil
  27073. }
  27074. return fmt.Errorf("unknown UsageDetail field %s", name)
  27075. }
  27076. // AddedEdges returns all edge names that were set/added in this mutation.
  27077. func (m *UsageDetailMutation) AddedEdges() []string {
  27078. edges := make([]string, 0, 0)
  27079. return edges
  27080. }
  27081. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27082. // name in this mutation.
  27083. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  27084. return nil
  27085. }
  27086. // RemovedEdges returns all edge names that were removed in this mutation.
  27087. func (m *UsageDetailMutation) RemovedEdges() []string {
  27088. edges := make([]string, 0, 0)
  27089. return edges
  27090. }
  27091. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27092. // the given name in this mutation.
  27093. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  27094. return nil
  27095. }
  27096. // ClearedEdges returns all edge names that were cleared in this mutation.
  27097. func (m *UsageDetailMutation) ClearedEdges() []string {
  27098. edges := make([]string, 0, 0)
  27099. return edges
  27100. }
  27101. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27102. // was cleared in this mutation.
  27103. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  27104. return false
  27105. }
  27106. // ClearEdge clears the value of the edge with the given name. It returns an error
  27107. // if that edge is not defined in the schema.
  27108. func (m *UsageDetailMutation) ClearEdge(name string) error {
  27109. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  27110. }
  27111. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27112. // It returns an error if the edge is not defined in the schema.
  27113. func (m *UsageDetailMutation) ResetEdge(name string) error {
  27114. return fmt.Errorf("unknown UsageDetail edge %s", name)
  27115. }
  27116. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  27117. type UsageStatisticDayMutation struct {
  27118. config
  27119. op Op
  27120. typ string
  27121. id *uint64
  27122. created_at *time.Time
  27123. updated_at *time.Time
  27124. status *uint8
  27125. addstatus *int8
  27126. deleted_at *time.Time
  27127. addtime *uint64
  27128. addaddtime *int64
  27129. _type *int
  27130. add_type *int
  27131. bot_id *string
  27132. organization_id *uint64
  27133. addorganization_id *int64
  27134. ai_response *uint64
  27135. addai_response *int64
  27136. sop_run *uint64
  27137. addsop_run *int64
  27138. total_friend *uint64
  27139. addtotal_friend *int64
  27140. total_group *uint64
  27141. addtotal_group *int64
  27142. account_balance *uint64
  27143. addaccount_balance *int64
  27144. consume_token *uint64
  27145. addconsume_token *int64
  27146. active_user *uint64
  27147. addactive_user *int64
  27148. new_user *int64
  27149. addnew_user *int64
  27150. label_dist *[]custom_types.LabelDist
  27151. appendlabel_dist []custom_types.LabelDist
  27152. clearedFields map[string]struct{}
  27153. done bool
  27154. oldValue func(context.Context) (*UsageStatisticDay, error)
  27155. predicates []predicate.UsageStatisticDay
  27156. }
  27157. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  27158. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  27159. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  27160. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  27161. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  27162. m := &UsageStatisticDayMutation{
  27163. config: c,
  27164. op: op,
  27165. typ: TypeUsageStatisticDay,
  27166. clearedFields: make(map[string]struct{}),
  27167. }
  27168. for _, opt := range opts {
  27169. opt(m)
  27170. }
  27171. return m
  27172. }
  27173. // withUsageStatisticDayID sets the ID field of the mutation.
  27174. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  27175. return func(m *UsageStatisticDayMutation) {
  27176. var (
  27177. err error
  27178. once sync.Once
  27179. value *UsageStatisticDay
  27180. )
  27181. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  27182. once.Do(func() {
  27183. if m.done {
  27184. err = errors.New("querying old values post mutation is not allowed")
  27185. } else {
  27186. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  27187. }
  27188. })
  27189. return value, err
  27190. }
  27191. m.id = &id
  27192. }
  27193. }
  27194. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  27195. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  27196. return func(m *UsageStatisticDayMutation) {
  27197. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  27198. return node, nil
  27199. }
  27200. m.id = &node.ID
  27201. }
  27202. }
  27203. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27204. // executed in a transaction (ent.Tx), a transactional client is returned.
  27205. func (m UsageStatisticDayMutation) Client() *Client {
  27206. client := &Client{config: m.config}
  27207. client.init()
  27208. return client
  27209. }
  27210. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27211. // it returns an error otherwise.
  27212. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  27213. if _, ok := m.driver.(*txDriver); !ok {
  27214. return nil, errors.New("ent: mutation is not running in a transaction")
  27215. }
  27216. tx := &Tx{config: m.config}
  27217. tx.init()
  27218. return tx, nil
  27219. }
  27220. // SetID sets the value of the id field. Note that this
  27221. // operation is only accepted on creation of UsageStatisticDay entities.
  27222. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  27223. m.id = &id
  27224. }
  27225. // ID returns the ID value in the mutation. Note that the ID is only available
  27226. // if it was provided to the builder or after it was returned from the database.
  27227. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  27228. if m.id == nil {
  27229. return
  27230. }
  27231. return *m.id, true
  27232. }
  27233. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27234. // That means, if the mutation is applied within a transaction with an isolation level such
  27235. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27236. // or updated by the mutation.
  27237. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  27238. switch {
  27239. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27240. id, exists := m.ID()
  27241. if exists {
  27242. return []uint64{id}, nil
  27243. }
  27244. fallthrough
  27245. case m.op.Is(OpUpdate | OpDelete):
  27246. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  27247. default:
  27248. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27249. }
  27250. }
  27251. // SetCreatedAt sets the "created_at" field.
  27252. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  27253. m.created_at = &t
  27254. }
  27255. // CreatedAt returns the value of the "created_at" field in the mutation.
  27256. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  27257. v := m.created_at
  27258. if v == nil {
  27259. return
  27260. }
  27261. return *v, true
  27262. }
  27263. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  27264. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  27265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27266. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27267. if !m.op.Is(OpUpdateOne) {
  27268. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27269. }
  27270. if m.id == nil || m.oldValue == nil {
  27271. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27272. }
  27273. oldValue, err := m.oldValue(ctx)
  27274. if err != nil {
  27275. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27276. }
  27277. return oldValue.CreatedAt, nil
  27278. }
  27279. // ResetCreatedAt resets all changes to the "created_at" field.
  27280. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  27281. m.created_at = nil
  27282. }
  27283. // SetUpdatedAt sets the "updated_at" field.
  27284. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  27285. m.updated_at = &t
  27286. }
  27287. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27288. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  27289. v := m.updated_at
  27290. if v == nil {
  27291. return
  27292. }
  27293. return *v, true
  27294. }
  27295. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  27296. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  27297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27298. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27299. if !m.op.Is(OpUpdateOne) {
  27300. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27301. }
  27302. if m.id == nil || m.oldValue == nil {
  27303. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27304. }
  27305. oldValue, err := m.oldValue(ctx)
  27306. if err != nil {
  27307. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27308. }
  27309. return oldValue.UpdatedAt, nil
  27310. }
  27311. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27312. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  27313. m.updated_at = nil
  27314. }
  27315. // SetStatus sets the "status" field.
  27316. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  27317. m.status = &u
  27318. m.addstatus = nil
  27319. }
  27320. // Status returns the value of the "status" field in the mutation.
  27321. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  27322. v := m.status
  27323. if v == nil {
  27324. return
  27325. }
  27326. return *v, true
  27327. }
  27328. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  27329. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  27330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27331. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27332. if !m.op.Is(OpUpdateOne) {
  27333. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27334. }
  27335. if m.id == nil || m.oldValue == nil {
  27336. return v, errors.New("OldStatus requires an ID field in the mutation")
  27337. }
  27338. oldValue, err := m.oldValue(ctx)
  27339. if err != nil {
  27340. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27341. }
  27342. return oldValue.Status, nil
  27343. }
  27344. // AddStatus adds u to the "status" field.
  27345. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  27346. if m.addstatus != nil {
  27347. *m.addstatus += u
  27348. } else {
  27349. m.addstatus = &u
  27350. }
  27351. }
  27352. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27353. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  27354. v := m.addstatus
  27355. if v == nil {
  27356. return
  27357. }
  27358. return *v, true
  27359. }
  27360. // ClearStatus clears the value of the "status" field.
  27361. func (m *UsageStatisticDayMutation) ClearStatus() {
  27362. m.status = nil
  27363. m.addstatus = nil
  27364. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  27365. }
  27366. // StatusCleared returns if the "status" field was cleared in this mutation.
  27367. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  27368. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  27369. return ok
  27370. }
  27371. // ResetStatus resets all changes to the "status" field.
  27372. func (m *UsageStatisticDayMutation) ResetStatus() {
  27373. m.status = nil
  27374. m.addstatus = nil
  27375. delete(m.clearedFields, usagestatisticday.FieldStatus)
  27376. }
  27377. // SetDeletedAt sets the "deleted_at" field.
  27378. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  27379. m.deleted_at = &t
  27380. }
  27381. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27382. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  27383. v := m.deleted_at
  27384. if v == nil {
  27385. return
  27386. }
  27387. return *v, true
  27388. }
  27389. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  27390. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  27391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27392. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27393. if !m.op.Is(OpUpdateOne) {
  27394. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27395. }
  27396. if m.id == nil || m.oldValue == nil {
  27397. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27398. }
  27399. oldValue, err := m.oldValue(ctx)
  27400. if err != nil {
  27401. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27402. }
  27403. return oldValue.DeletedAt, nil
  27404. }
  27405. // ClearDeletedAt clears the value of the "deleted_at" field.
  27406. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  27407. m.deleted_at = nil
  27408. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  27409. }
  27410. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27411. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  27412. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  27413. return ok
  27414. }
  27415. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27416. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  27417. m.deleted_at = nil
  27418. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  27419. }
  27420. // SetAddtime sets the "addtime" field.
  27421. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  27422. m.addtime = &u
  27423. m.addaddtime = nil
  27424. }
  27425. // Addtime returns the value of the "addtime" field in the mutation.
  27426. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  27427. v := m.addtime
  27428. if v == nil {
  27429. return
  27430. }
  27431. return *v, true
  27432. }
  27433. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  27434. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  27435. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27436. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  27437. if !m.op.Is(OpUpdateOne) {
  27438. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  27439. }
  27440. if m.id == nil || m.oldValue == nil {
  27441. return v, errors.New("OldAddtime requires an ID field in the mutation")
  27442. }
  27443. oldValue, err := m.oldValue(ctx)
  27444. if err != nil {
  27445. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  27446. }
  27447. return oldValue.Addtime, nil
  27448. }
  27449. // AddAddtime adds u to the "addtime" field.
  27450. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  27451. if m.addaddtime != nil {
  27452. *m.addaddtime += u
  27453. } else {
  27454. m.addaddtime = &u
  27455. }
  27456. }
  27457. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  27458. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  27459. v := m.addaddtime
  27460. if v == nil {
  27461. return
  27462. }
  27463. return *v, true
  27464. }
  27465. // ResetAddtime resets all changes to the "addtime" field.
  27466. func (m *UsageStatisticDayMutation) ResetAddtime() {
  27467. m.addtime = nil
  27468. m.addaddtime = nil
  27469. }
  27470. // SetType sets the "type" field.
  27471. func (m *UsageStatisticDayMutation) SetType(i int) {
  27472. m._type = &i
  27473. m.add_type = nil
  27474. }
  27475. // GetType returns the value of the "type" field in the mutation.
  27476. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  27477. v := m._type
  27478. if v == nil {
  27479. return
  27480. }
  27481. return *v, true
  27482. }
  27483. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  27484. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  27485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27486. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  27487. if !m.op.Is(OpUpdateOne) {
  27488. return v, errors.New("OldType is only allowed on UpdateOne operations")
  27489. }
  27490. if m.id == nil || m.oldValue == nil {
  27491. return v, errors.New("OldType requires an ID field in the mutation")
  27492. }
  27493. oldValue, err := m.oldValue(ctx)
  27494. if err != nil {
  27495. return v, fmt.Errorf("querying old value for OldType: %w", err)
  27496. }
  27497. return oldValue.Type, nil
  27498. }
  27499. // AddType adds i to the "type" field.
  27500. func (m *UsageStatisticDayMutation) AddType(i int) {
  27501. if m.add_type != nil {
  27502. *m.add_type += i
  27503. } else {
  27504. m.add_type = &i
  27505. }
  27506. }
  27507. // AddedType returns the value that was added to the "type" field in this mutation.
  27508. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  27509. v := m.add_type
  27510. if v == nil {
  27511. return
  27512. }
  27513. return *v, true
  27514. }
  27515. // ResetType resets all changes to the "type" field.
  27516. func (m *UsageStatisticDayMutation) ResetType() {
  27517. m._type = nil
  27518. m.add_type = nil
  27519. }
  27520. // SetBotID sets the "bot_id" field.
  27521. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  27522. m.bot_id = &s
  27523. }
  27524. // BotID returns the value of the "bot_id" field in the mutation.
  27525. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  27526. v := m.bot_id
  27527. if v == nil {
  27528. return
  27529. }
  27530. return *v, true
  27531. }
  27532. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  27533. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  27534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27535. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  27536. if !m.op.Is(OpUpdateOne) {
  27537. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  27538. }
  27539. if m.id == nil || m.oldValue == nil {
  27540. return v, errors.New("OldBotID requires an ID field in the mutation")
  27541. }
  27542. oldValue, err := m.oldValue(ctx)
  27543. if err != nil {
  27544. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  27545. }
  27546. return oldValue.BotID, nil
  27547. }
  27548. // ClearBotID clears the value of the "bot_id" field.
  27549. func (m *UsageStatisticDayMutation) ClearBotID() {
  27550. m.bot_id = nil
  27551. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  27552. }
  27553. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  27554. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  27555. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  27556. return ok
  27557. }
  27558. // ResetBotID resets all changes to the "bot_id" field.
  27559. func (m *UsageStatisticDayMutation) ResetBotID() {
  27560. m.bot_id = nil
  27561. delete(m.clearedFields, usagestatisticday.FieldBotID)
  27562. }
  27563. // SetOrganizationID sets the "organization_id" field.
  27564. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  27565. m.organization_id = &u
  27566. m.addorganization_id = nil
  27567. }
  27568. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27569. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  27570. v := m.organization_id
  27571. if v == nil {
  27572. return
  27573. }
  27574. return *v, true
  27575. }
  27576. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  27577. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  27578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27579. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27580. if !m.op.Is(OpUpdateOne) {
  27581. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27582. }
  27583. if m.id == nil || m.oldValue == nil {
  27584. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27585. }
  27586. oldValue, err := m.oldValue(ctx)
  27587. if err != nil {
  27588. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27589. }
  27590. return oldValue.OrganizationID, nil
  27591. }
  27592. // AddOrganizationID adds u to the "organization_id" field.
  27593. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  27594. if m.addorganization_id != nil {
  27595. *m.addorganization_id += u
  27596. } else {
  27597. m.addorganization_id = &u
  27598. }
  27599. }
  27600. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27601. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  27602. v := m.addorganization_id
  27603. if v == nil {
  27604. return
  27605. }
  27606. return *v, true
  27607. }
  27608. // ClearOrganizationID clears the value of the "organization_id" field.
  27609. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  27610. m.organization_id = nil
  27611. m.addorganization_id = nil
  27612. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  27613. }
  27614. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  27615. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  27616. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  27617. return ok
  27618. }
  27619. // ResetOrganizationID resets all changes to the "organization_id" field.
  27620. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  27621. m.organization_id = nil
  27622. m.addorganization_id = nil
  27623. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  27624. }
  27625. // SetAiResponse sets the "ai_response" field.
  27626. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  27627. m.ai_response = &u
  27628. m.addai_response = nil
  27629. }
  27630. // AiResponse returns the value of the "ai_response" field in the mutation.
  27631. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  27632. v := m.ai_response
  27633. if v == nil {
  27634. return
  27635. }
  27636. return *v, true
  27637. }
  27638. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  27639. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  27640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27641. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  27642. if !m.op.Is(OpUpdateOne) {
  27643. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  27644. }
  27645. if m.id == nil || m.oldValue == nil {
  27646. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  27647. }
  27648. oldValue, err := m.oldValue(ctx)
  27649. if err != nil {
  27650. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  27651. }
  27652. return oldValue.AiResponse, nil
  27653. }
  27654. // AddAiResponse adds u to the "ai_response" field.
  27655. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  27656. if m.addai_response != nil {
  27657. *m.addai_response += u
  27658. } else {
  27659. m.addai_response = &u
  27660. }
  27661. }
  27662. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  27663. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  27664. v := m.addai_response
  27665. if v == nil {
  27666. return
  27667. }
  27668. return *v, true
  27669. }
  27670. // ResetAiResponse resets all changes to the "ai_response" field.
  27671. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  27672. m.ai_response = nil
  27673. m.addai_response = nil
  27674. }
  27675. // SetSopRun sets the "sop_run" field.
  27676. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  27677. m.sop_run = &u
  27678. m.addsop_run = nil
  27679. }
  27680. // SopRun returns the value of the "sop_run" field in the mutation.
  27681. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  27682. v := m.sop_run
  27683. if v == nil {
  27684. return
  27685. }
  27686. return *v, true
  27687. }
  27688. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  27689. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  27690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27691. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  27692. if !m.op.Is(OpUpdateOne) {
  27693. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  27694. }
  27695. if m.id == nil || m.oldValue == nil {
  27696. return v, errors.New("OldSopRun requires an ID field in the mutation")
  27697. }
  27698. oldValue, err := m.oldValue(ctx)
  27699. if err != nil {
  27700. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  27701. }
  27702. return oldValue.SopRun, nil
  27703. }
  27704. // AddSopRun adds u to the "sop_run" field.
  27705. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  27706. if m.addsop_run != nil {
  27707. *m.addsop_run += u
  27708. } else {
  27709. m.addsop_run = &u
  27710. }
  27711. }
  27712. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  27713. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  27714. v := m.addsop_run
  27715. if v == nil {
  27716. return
  27717. }
  27718. return *v, true
  27719. }
  27720. // ResetSopRun resets all changes to the "sop_run" field.
  27721. func (m *UsageStatisticDayMutation) ResetSopRun() {
  27722. m.sop_run = nil
  27723. m.addsop_run = nil
  27724. }
  27725. // SetTotalFriend sets the "total_friend" field.
  27726. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  27727. m.total_friend = &u
  27728. m.addtotal_friend = nil
  27729. }
  27730. // TotalFriend returns the value of the "total_friend" field in the mutation.
  27731. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  27732. v := m.total_friend
  27733. if v == nil {
  27734. return
  27735. }
  27736. return *v, true
  27737. }
  27738. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  27739. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  27740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27741. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  27742. if !m.op.Is(OpUpdateOne) {
  27743. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  27744. }
  27745. if m.id == nil || m.oldValue == nil {
  27746. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  27747. }
  27748. oldValue, err := m.oldValue(ctx)
  27749. if err != nil {
  27750. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  27751. }
  27752. return oldValue.TotalFriend, nil
  27753. }
  27754. // AddTotalFriend adds u to the "total_friend" field.
  27755. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  27756. if m.addtotal_friend != nil {
  27757. *m.addtotal_friend += u
  27758. } else {
  27759. m.addtotal_friend = &u
  27760. }
  27761. }
  27762. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  27763. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  27764. v := m.addtotal_friend
  27765. if v == nil {
  27766. return
  27767. }
  27768. return *v, true
  27769. }
  27770. // ResetTotalFriend resets all changes to the "total_friend" field.
  27771. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  27772. m.total_friend = nil
  27773. m.addtotal_friend = nil
  27774. }
  27775. // SetTotalGroup sets the "total_group" field.
  27776. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  27777. m.total_group = &u
  27778. m.addtotal_group = nil
  27779. }
  27780. // TotalGroup returns the value of the "total_group" field in the mutation.
  27781. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  27782. v := m.total_group
  27783. if v == nil {
  27784. return
  27785. }
  27786. return *v, true
  27787. }
  27788. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  27789. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  27790. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27791. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  27792. if !m.op.Is(OpUpdateOne) {
  27793. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  27794. }
  27795. if m.id == nil || m.oldValue == nil {
  27796. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  27797. }
  27798. oldValue, err := m.oldValue(ctx)
  27799. if err != nil {
  27800. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  27801. }
  27802. return oldValue.TotalGroup, nil
  27803. }
  27804. // AddTotalGroup adds u to the "total_group" field.
  27805. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  27806. if m.addtotal_group != nil {
  27807. *m.addtotal_group += u
  27808. } else {
  27809. m.addtotal_group = &u
  27810. }
  27811. }
  27812. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  27813. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  27814. v := m.addtotal_group
  27815. if v == nil {
  27816. return
  27817. }
  27818. return *v, true
  27819. }
  27820. // ResetTotalGroup resets all changes to the "total_group" field.
  27821. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  27822. m.total_group = nil
  27823. m.addtotal_group = nil
  27824. }
  27825. // SetAccountBalance sets the "account_balance" field.
  27826. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  27827. m.account_balance = &u
  27828. m.addaccount_balance = nil
  27829. }
  27830. // AccountBalance returns the value of the "account_balance" field in the mutation.
  27831. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  27832. v := m.account_balance
  27833. if v == nil {
  27834. return
  27835. }
  27836. return *v, true
  27837. }
  27838. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  27839. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  27840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27841. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  27842. if !m.op.Is(OpUpdateOne) {
  27843. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  27844. }
  27845. if m.id == nil || m.oldValue == nil {
  27846. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  27847. }
  27848. oldValue, err := m.oldValue(ctx)
  27849. if err != nil {
  27850. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  27851. }
  27852. return oldValue.AccountBalance, nil
  27853. }
  27854. // AddAccountBalance adds u to the "account_balance" field.
  27855. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  27856. if m.addaccount_balance != nil {
  27857. *m.addaccount_balance += u
  27858. } else {
  27859. m.addaccount_balance = &u
  27860. }
  27861. }
  27862. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  27863. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  27864. v := m.addaccount_balance
  27865. if v == nil {
  27866. return
  27867. }
  27868. return *v, true
  27869. }
  27870. // ResetAccountBalance resets all changes to the "account_balance" field.
  27871. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  27872. m.account_balance = nil
  27873. m.addaccount_balance = nil
  27874. }
  27875. // SetConsumeToken sets the "consume_token" field.
  27876. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  27877. m.consume_token = &u
  27878. m.addconsume_token = nil
  27879. }
  27880. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  27881. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  27882. v := m.consume_token
  27883. if v == nil {
  27884. return
  27885. }
  27886. return *v, true
  27887. }
  27888. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  27889. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  27890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27891. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  27892. if !m.op.Is(OpUpdateOne) {
  27893. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  27894. }
  27895. if m.id == nil || m.oldValue == nil {
  27896. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  27897. }
  27898. oldValue, err := m.oldValue(ctx)
  27899. if err != nil {
  27900. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  27901. }
  27902. return oldValue.ConsumeToken, nil
  27903. }
  27904. // AddConsumeToken adds u to the "consume_token" field.
  27905. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  27906. if m.addconsume_token != nil {
  27907. *m.addconsume_token += u
  27908. } else {
  27909. m.addconsume_token = &u
  27910. }
  27911. }
  27912. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  27913. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  27914. v := m.addconsume_token
  27915. if v == nil {
  27916. return
  27917. }
  27918. return *v, true
  27919. }
  27920. // ResetConsumeToken resets all changes to the "consume_token" field.
  27921. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  27922. m.consume_token = nil
  27923. m.addconsume_token = nil
  27924. }
  27925. // SetActiveUser sets the "active_user" field.
  27926. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  27927. m.active_user = &u
  27928. m.addactive_user = nil
  27929. }
  27930. // ActiveUser returns the value of the "active_user" field in the mutation.
  27931. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  27932. v := m.active_user
  27933. if v == nil {
  27934. return
  27935. }
  27936. return *v, true
  27937. }
  27938. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  27939. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  27940. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27941. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  27942. if !m.op.Is(OpUpdateOne) {
  27943. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  27944. }
  27945. if m.id == nil || m.oldValue == nil {
  27946. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  27947. }
  27948. oldValue, err := m.oldValue(ctx)
  27949. if err != nil {
  27950. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  27951. }
  27952. return oldValue.ActiveUser, nil
  27953. }
  27954. // AddActiveUser adds u to the "active_user" field.
  27955. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  27956. if m.addactive_user != nil {
  27957. *m.addactive_user += u
  27958. } else {
  27959. m.addactive_user = &u
  27960. }
  27961. }
  27962. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  27963. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  27964. v := m.addactive_user
  27965. if v == nil {
  27966. return
  27967. }
  27968. return *v, true
  27969. }
  27970. // ResetActiveUser resets all changes to the "active_user" field.
  27971. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  27972. m.active_user = nil
  27973. m.addactive_user = nil
  27974. }
  27975. // SetNewUser sets the "new_user" field.
  27976. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  27977. m.new_user = &i
  27978. m.addnew_user = nil
  27979. }
  27980. // NewUser returns the value of the "new_user" field in the mutation.
  27981. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  27982. v := m.new_user
  27983. if v == nil {
  27984. return
  27985. }
  27986. return *v, true
  27987. }
  27988. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  27989. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  27990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27991. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  27992. if !m.op.Is(OpUpdateOne) {
  27993. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  27994. }
  27995. if m.id == nil || m.oldValue == nil {
  27996. return v, errors.New("OldNewUser requires an ID field in the mutation")
  27997. }
  27998. oldValue, err := m.oldValue(ctx)
  27999. if err != nil {
  28000. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  28001. }
  28002. return oldValue.NewUser, nil
  28003. }
  28004. // AddNewUser adds i to the "new_user" field.
  28005. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  28006. if m.addnew_user != nil {
  28007. *m.addnew_user += i
  28008. } else {
  28009. m.addnew_user = &i
  28010. }
  28011. }
  28012. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  28013. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  28014. v := m.addnew_user
  28015. if v == nil {
  28016. return
  28017. }
  28018. return *v, true
  28019. }
  28020. // ResetNewUser resets all changes to the "new_user" field.
  28021. func (m *UsageStatisticDayMutation) ResetNewUser() {
  28022. m.new_user = nil
  28023. m.addnew_user = nil
  28024. }
  28025. // SetLabelDist sets the "label_dist" field.
  28026. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  28027. m.label_dist = &ctd
  28028. m.appendlabel_dist = nil
  28029. }
  28030. // LabelDist returns the value of the "label_dist" field in the mutation.
  28031. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  28032. v := m.label_dist
  28033. if v == nil {
  28034. return
  28035. }
  28036. return *v, true
  28037. }
  28038. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  28039. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28041. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  28042. if !m.op.Is(OpUpdateOne) {
  28043. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  28044. }
  28045. if m.id == nil || m.oldValue == nil {
  28046. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  28047. }
  28048. oldValue, err := m.oldValue(ctx)
  28049. if err != nil {
  28050. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  28051. }
  28052. return oldValue.LabelDist, nil
  28053. }
  28054. // AppendLabelDist adds ctd to the "label_dist" field.
  28055. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  28056. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  28057. }
  28058. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  28059. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  28060. if len(m.appendlabel_dist) == 0 {
  28061. return nil, false
  28062. }
  28063. return m.appendlabel_dist, true
  28064. }
  28065. // ResetLabelDist resets all changes to the "label_dist" field.
  28066. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  28067. m.label_dist = nil
  28068. m.appendlabel_dist = nil
  28069. }
  28070. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  28071. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  28072. m.predicates = append(m.predicates, ps...)
  28073. }
  28074. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  28075. // users can use type-assertion to append predicates that do not depend on any generated package.
  28076. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  28077. p := make([]predicate.UsageStatisticDay, len(ps))
  28078. for i := range ps {
  28079. p[i] = ps[i]
  28080. }
  28081. m.Where(p...)
  28082. }
  28083. // Op returns the operation name.
  28084. func (m *UsageStatisticDayMutation) Op() Op {
  28085. return m.op
  28086. }
  28087. // SetOp allows setting the mutation operation.
  28088. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  28089. m.op = op
  28090. }
  28091. // Type returns the node type of this mutation (UsageStatisticDay).
  28092. func (m *UsageStatisticDayMutation) Type() string {
  28093. return m.typ
  28094. }
  28095. // Fields returns all fields that were changed during this mutation. Note that in
  28096. // order to get all numeric fields that were incremented/decremented, call
  28097. // AddedFields().
  28098. func (m *UsageStatisticDayMutation) Fields() []string {
  28099. fields := make([]string, 0, 17)
  28100. if m.created_at != nil {
  28101. fields = append(fields, usagestatisticday.FieldCreatedAt)
  28102. }
  28103. if m.updated_at != nil {
  28104. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  28105. }
  28106. if m.status != nil {
  28107. fields = append(fields, usagestatisticday.FieldStatus)
  28108. }
  28109. if m.deleted_at != nil {
  28110. fields = append(fields, usagestatisticday.FieldDeletedAt)
  28111. }
  28112. if m.addtime != nil {
  28113. fields = append(fields, usagestatisticday.FieldAddtime)
  28114. }
  28115. if m._type != nil {
  28116. fields = append(fields, usagestatisticday.FieldType)
  28117. }
  28118. if m.bot_id != nil {
  28119. fields = append(fields, usagestatisticday.FieldBotID)
  28120. }
  28121. if m.organization_id != nil {
  28122. fields = append(fields, usagestatisticday.FieldOrganizationID)
  28123. }
  28124. if m.ai_response != nil {
  28125. fields = append(fields, usagestatisticday.FieldAiResponse)
  28126. }
  28127. if m.sop_run != nil {
  28128. fields = append(fields, usagestatisticday.FieldSopRun)
  28129. }
  28130. if m.total_friend != nil {
  28131. fields = append(fields, usagestatisticday.FieldTotalFriend)
  28132. }
  28133. if m.total_group != nil {
  28134. fields = append(fields, usagestatisticday.FieldTotalGroup)
  28135. }
  28136. if m.account_balance != nil {
  28137. fields = append(fields, usagestatisticday.FieldAccountBalance)
  28138. }
  28139. if m.consume_token != nil {
  28140. fields = append(fields, usagestatisticday.FieldConsumeToken)
  28141. }
  28142. if m.active_user != nil {
  28143. fields = append(fields, usagestatisticday.FieldActiveUser)
  28144. }
  28145. if m.new_user != nil {
  28146. fields = append(fields, usagestatisticday.FieldNewUser)
  28147. }
  28148. if m.label_dist != nil {
  28149. fields = append(fields, usagestatisticday.FieldLabelDist)
  28150. }
  28151. return fields
  28152. }
  28153. // Field returns the value of a field with the given name. The second boolean
  28154. // return value indicates that this field was not set, or was not defined in the
  28155. // schema.
  28156. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  28157. switch name {
  28158. case usagestatisticday.FieldCreatedAt:
  28159. return m.CreatedAt()
  28160. case usagestatisticday.FieldUpdatedAt:
  28161. return m.UpdatedAt()
  28162. case usagestatisticday.FieldStatus:
  28163. return m.Status()
  28164. case usagestatisticday.FieldDeletedAt:
  28165. return m.DeletedAt()
  28166. case usagestatisticday.FieldAddtime:
  28167. return m.Addtime()
  28168. case usagestatisticday.FieldType:
  28169. return m.GetType()
  28170. case usagestatisticday.FieldBotID:
  28171. return m.BotID()
  28172. case usagestatisticday.FieldOrganizationID:
  28173. return m.OrganizationID()
  28174. case usagestatisticday.FieldAiResponse:
  28175. return m.AiResponse()
  28176. case usagestatisticday.FieldSopRun:
  28177. return m.SopRun()
  28178. case usagestatisticday.FieldTotalFriend:
  28179. return m.TotalFriend()
  28180. case usagestatisticday.FieldTotalGroup:
  28181. return m.TotalGroup()
  28182. case usagestatisticday.FieldAccountBalance:
  28183. return m.AccountBalance()
  28184. case usagestatisticday.FieldConsumeToken:
  28185. return m.ConsumeToken()
  28186. case usagestatisticday.FieldActiveUser:
  28187. return m.ActiveUser()
  28188. case usagestatisticday.FieldNewUser:
  28189. return m.NewUser()
  28190. case usagestatisticday.FieldLabelDist:
  28191. return m.LabelDist()
  28192. }
  28193. return nil, false
  28194. }
  28195. // OldField returns the old value of the field from the database. An error is
  28196. // returned if the mutation operation is not UpdateOne, or the query to the
  28197. // database failed.
  28198. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28199. switch name {
  28200. case usagestatisticday.FieldCreatedAt:
  28201. return m.OldCreatedAt(ctx)
  28202. case usagestatisticday.FieldUpdatedAt:
  28203. return m.OldUpdatedAt(ctx)
  28204. case usagestatisticday.FieldStatus:
  28205. return m.OldStatus(ctx)
  28206. case usagestatisticday.FieldDeletedAt:
  28207. return m.OldDeletedAt(ctx)
  28208. case usagestatisticday.FieldAddtime:
  28209. return m.OldAddtime(ctx)
  28210. case usagestatisticday.FieldType:
  28211. return m.OldType(ctx)
  28212. case usagestatisticday.FieldBotID:
  28213. return m.OldBotID(ctx)
  28214. case usagestatisticday.FieldOrganizationID:
  28215. return m.OldOrganizationID(ctx)
  28216. case usagestatisticday.FieldAiResponse:
  28217. return m.OldAiResponse(ctx)
  28218. case usagestatisticday.FieldSopRun:
  28219. return m.OldSopRun(ctx)
  28220. case usagestatisticday.FieldTotalFriend:
  28221. return m.OldTotalFriend(ctx)
  28222. case usagestatisticday.FieldTotalGroup:
  28223. return m.OldTotalGroup(ctx)
  28224. case usagestatisticday.FieldAccountBalance:
  28225. return m.OldAccountBalance(ctx)
  28226. case usagestatisticday.FieldConsumeToken:
  28227. return m.OldConsumeToken(ctx)
  28228. case usagestatisticday.FieldActiveUser:
  28229. return m.OldActiveUser(ctx)
  28230. case usagestatisticday.FieldNewUser:
  28231. return m.OldNewUser(ctx)
  28232. case usagestatisticday.FieldLabelDist:
  28233. return m.OldLabelDist(ctx)
  28234. }
  28235. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  28236. }
  28237. // SetField sets the value of a field with the given name. It returns an error if
  28238. // the field is not defined in the schema, or if the type mismatched the field
  28239. // type.
  28240. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  28241. switch name {
  28242. case usagestatisticday.FieldCreatedAt:
  28243. v, ok := value.(time.Time)
  28244. if !ok {
  28245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28246. }
  28247. m.SetCreatedAt(v)
  28248. return nil
  28249. case usagestatisticday.FieldUpdatedAt:
  28250. v, ok := value.(time.Time)
  28251. if !ok {
  28252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28253. }
  28254. m.SetUpdatedAt(v)
  28255. return nil
  28256. case usagestatisticday.FieldStatus:
  28257. v, ok := value.(uint8)
  28258. if !ok {
  28259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28260. }
  28261. m.SetStatus(v)
  28262. return nil
  28263. case usagestatisticday.FieldDeletedAt:
  28264. v, ok := value.(time.Time)
  28265. if !ok {
  28266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28267. }
  28268. m.SetDeletedAt(v)
  28269. return nil
  28270. case usagestatisticday.FieldAddtime:
  28271. v, ok := value.(uint64)
  28272. if !ok {
  28273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28274. }
  28275. m.SetAddtime(v)
  28276. return nil
  28277. case usagestatisticday.FieldType:
  28278. v, ok := value.(int)
  28279. if !ok {
  28280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28281. }
  28282. m.SetType(v)
  28283. return nil
  28284. case usagestatisticday.FieldBotID:
  28285. v, ok := value.(string)
  28286. if !ok {
  28287. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28288. }
  28289. m.SetBotID(v)
  28290. return nil
  28291. case usagestatisticday.FieldOrganizationID:
  28292. v, ok := value.(uint64)
  28293. if !ok {
  28294. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28295. }
  28296. m.SetOrganizationID(v)
  28297. return nil
  28298. case usagestatisticday.FieldAiResponse:
  28299. v, ok := value.(uint64)
  28300. if !ok {
  28301. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28302. }
  28303. m.SetAiResponse(v)
  28304. return nil
  28305. case usagestatisticday.FieldSopRun:
  28306. v, ok := value.(uint64)
  28307. if !ok {
  28308. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28309. }
  28310. m.SetSopRun(v)
  28311. return nil
  28312. case usagestatisticday.FieldTotalFriend:
  28313. v, ok := value.(uint64)
  28314. if !ok {
  28315. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28316. }
  28317. m.SetTotalFriend(v)
  28318. return nil
  28319. case usagestatisticday.FieldTotalGroup:
  28320. v, ok := value.(uint64)
  28321. if !ok {
  28322. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28323. }
  28324. m.SetTotalGroup(v)
  28325. return nil
  28326. case usagestatisticday.FieldAccountBalance:
  28327. v, ok := value.(uint64)
  28328. if !ok {
  28329. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28330. }
  28331. m.SetAccountBalance(v)
  28332. return nil
  28333. case usagestatisticday.FieldConsumeToken:
  28334. v, ok := value.(uint64)
  28335. if !ok {
  28336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28337. }
  28338. m.SetConsumeToken(v)
  28339. return nil
  28340. case usagestatisticday.FieldActiveUser:
  28341. v, ok := value.(uint64)
  28342. if !ok {
  28343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28344. }
  28345. m.SetActiveUser(v)
  28346. return nil
  28347. case usagestatisticday.FieldNewUser:
  28348. v, ok := value.(int64)
  28349. if !ok {
  28350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28351. }
  28352. m.SetNewUser(v)
  28353. return nil
  28354. case usagestatisticday.FieldLabelDist:
  28355. v, ok := value.([]custom_types.LabelDist)
  28356. if !ok {
  28357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28358. }
  28359. m.SetLabelDist(v)
  28360. return nil
  28361. }
  28362. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  28363. }
  28364. // AddedFields returns all numeric fields that were incremented/decremented during
  28365. // this mutation.
  28366. func (m *UsageStatisticDayMutation) AddedFields() []string {
  28367. var fields []string
  28368. if m.addstatus != nil {
  28369. fields = append(fields, usagestatisticday.FieldStatus)
  28370. }
  28371. if m.addaddtime != nil {
  28372. fields = append(fields, usagestatisticday.FieldAddtime)
  28373. }
  28374. if m.add_type != nil {
  28375. fields = append(fields, usagestatisticday.FieldType)
  28376. }
  28377. if m.addorganization_id != nil {
  28378. fields = append(fields, usagestatisticday.FieldOrganizationID)
  28379. }
  28380. if m.addai_response != nil {
  28381. fields = append(fields, usagestatisticday.FieldAiResponse)
  28382. }
  28383. if m.addsop_run != nil {
  28384. fields = append(fields, usagestatisticday.FieldSopRun)
  28385. }
  28386. if m.addtotal_friend != nil {
  28387. fields = append(fields, usagestatisticday.FieldTotalFriend)
  28388. }
  28389. if m.addtotal_group != nil {
  28390. fields = append(fields, usagestatisticday.FieldTotalGroup)
  28391. }
  28392. if m.addaccount_balance != nil {
  28393. fields = append(fields, usagestatisticday.FieldAccountBalance)
  28394. }
  28395. if m.addconsume_token != nil {
  28396. fields = append(fields, usagestatisticday.FieldConsumeToken)
  28397. }
  28398. if m.addactive_user != nil {
  28399. fields = append(fields, usagestatisticday.FieldActiveUser)
  28400. }
  28401. if m.addnew_user != nil {
  28402. fields = append(fields, usagestatisticday.FieldNewUser)
  28403. }
  28404. return fields
  28405. }
  28406. // AddedField returns the numeric value that was incremented/decremented on a field
  28407. // with the given name. The second boolean return value indicates that this field
  28408. // was not set, or was not defined in the schema.
  28409. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  28410. switch name {
  28411. case usagestatisticday.FieldStatus:
  28412. return m.AddedStatus()
  28413. case usagestatisticday.FieldAddtime:
  28414. return m.AddedAddtime()
  28415. case usagestatisticday.FieldType:
  28416. return m.AddedType()
  28417. case usagestatisticday.FieldOrganizationID:
  28418. return m.AddedOrganizationID()
  28419. case usagestatisticday.FieldAiResponse:
  28420. return m.AddedAiResponse()
  28421. case usagestatisticday.FieldSopRun:
  28422. return m.AddedSopRun()
  28423. case usagestatisticday.FieldTotalFriend:
  28424. return m.AddedTotalFriend()
  28425. case usagestatisticday.FieldTotalGroup:
  28426. return m.AddedTotalGroup()
  28427. case usagestatisticday.FieldAccountBalance:
  28428. return m.AddedAccountBalance()
  28429. case usagestatisticday.FieldConsumeToken:
  28430. return m.AddedConsumeToken()
  28431. case usagestatisticday.FieldActiveUser:
  28432. return m.AddedActiveUser()
  28433. case usagestatisticday.FieldNewUser:
  28434. return m.AddedNewUser()
  28435. }
  28436. return nil, false
  28437. }
  28438. // AddField adds the value to the field with the given name. It returns an error if
  28439. // the field is not defined in the schema, or if the type mismatched the field
  28440. // type.
  28441. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  28442. switch name {
  28443. case usagestatisticday.FieldStatus:
  28444. v, ok := value.(int8)
  28445. if !ok {
  28446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28447. }
  28448. m.AddStatus(v)
  28449. return nil
  28450. case usagestatisticday.FieldAddtime:
  28451. v, ok := value.(int64)
  28452. if !ok {
  28453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28454. }
  28455. m.AddAddtime(v)
  28456. return nil
  28457. case usagestatisticday.FieldType:
  28458. v, ok := value.(int)
  28459. if !ok {
  28460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28461. }
  28462. m.AddType(v)
  28463. return nil
  28464. case usagestatisticday.FieldOrganizationID:
  28465. v, ok := value.(int64)
  28466. if !ok {
  28467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28468. }
  28469. m.AddOrganizationID(v)
  28470. return nil
  28471. case usagestatisticday.FieldAiResponse:
  28472. v, ok := value.(int64)
  28473. if !ok {
  28474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28475. }
  28476. m.AddAiResponse(v)
  28477. return nil
  28478. case usagestatisticday.FieldSopRun:
  28479. v, ok := value.(int64)
  28480. if !ok {
  28481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28482. }
  28483. m.AddSopRun(v)
  28484. return nil
  28485. case usagestatisticday.FieldTotalFriend:
  28486. v, ok := value.(int64)
  28487. if !ok {
  28488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28489. }
  28490. m.AddTotalFriend(v)
  28491. return nil
  28492. case usagestatisticday.FieldTotalGroup:
  28493. v, ok := value.(int64)
  28494. if !ok {
  28495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28496. }
  28497. m.AddTotalGroup(v)
  28498. return nil
  28499. case usagestatisticday.FieldAccountBalance:
  28500. v, ok := value.(int64)
  28501. if !ok {
  28502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28503. }
  28504. m.AddAccountBalance(v)
  28505. return nil
  28506. case usagestatisticday.FieldConsumeToken:
  28507. v, ok := value.(int64)
  28508. if !ok {
  28509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28510. }
  28511. m.AddConsumeToken(v)
  28512. return nil
  28513. case usagestatisticday.FieldActiveUser:
  28514. v, ok := value.(int64)
  28515. if !ok {
  28516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28517. }
  28518. m.AddActiveUser(v)
  28519. return nil
  28520. case usagestatisticday.FieldNewUser:
  28521. v, ok := value.(int64)
  28522. if !ok {
  28523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28524. }
  28525. m.AddNewUser(v)
  28526. return nil
  28527. }
  28528. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  28529. }
  28530. // ClearedFields returns all nullable fields that were cleared during this
  28531. // mutation.
  28532. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  28533. var fields []string
  28534. if m.FieldCleared(usagestatisticday.FieldStatus) {
  28535. fields = append(fields, usagestatisticday.FieldStatus)
  28536. }
  28537. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  28538. fields = append(fields, usagestatisticday.FieldDeletedAt)
  28539. }
  28540. if m.FieldCleared(usagestatisticday.FieldBotID) {
  28541. fields = append(fields, usagestatisticday.FieldBotID)
  28542. }
  28543. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  28544. fields = append(fields, usagestatisticday.FieldOrganizationID)
  28545. }
  28546. return fields
  28547. }
  28548. // FieldCleared returns a boolean indicating if a field with the given name was
  28549. // cleared in this mutation.
  28550. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  28551. _, ok := m.clearedFields[name]
  28552. return ok
  28553. }
  28554. // ClearField clears the value of the field with the given name. It returns an
  28555. // error if the field is not defined in the schema.
  28556. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  28557. switch name {
  28558. case usagestatisticday.FieldStatus:
  28559. m.ClearStatus()
  28560. return nil
  28561. case usagestatisticday.FieldDeletedAt:
  28562. m.ClearDeletedAt()
  28563. return nil
  28564. case usagestatisticday.FieldBotID:
  28565. m.ClearBotID()
  28566. return nil
  28567. case usagestatisticday.FieldOrganizationID:
  28568. m.ClearOrganizationID()
  28569. return nil
  28570. }
  28571. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  28572. }
  28573. // ResetField resets all changes in the mutation for the field with the given name.
  28574. // It returns an error if the field is not defined in the schema.
  28575. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  28576. switch name {
  28577. case usagestatisticday.FieldCreatedAt:
  28578. m.ResetCreatedAt()
  28579. return nil
  28580. case usagestatisticday.FieldUpdatedAt:
  28581. m.ResetUpdatedAt()
  28582. return nil
  28583. case usagestatisticday.FieldStatus:
  28584. m.ResetStatus()
  28585. return nil
  28586. case usagestatisticday.FieldDeletedAt:
  28587. m.ResetDeletedAt()
  28588. return nil
  28589. case usagestatisticday.FieldAddtime:
  28590. m.ResetAddtime()
  28591. return nil
  28592. case usagestatisticday.FieldType:
  28593. m.ResetType()
  28594. return nil
  28595. case usagestatisticday.FieldBotID:
  28596. m.ResetBotID()
  28597. return nil
  28598. case usagestatisticday.FieldOrganizationID:
  28599. m.ResetOrganizationID()
  28600. return nil
  28601. case usagestatisticday.FieldAiResponse:
  28602. m.ResetAiResponse()
  28603. return nil
  28604. case usagestatisticday.FieldSopRun:
  28605. m.ResetSopRun()
  28606. return nil
  28607. case usagestatisticday.FieldTotalFriend:
  28608. m.ResetTotalFriend()
  28609. return nil
  28610. case usagestatisticday.FieldTotalGroup:
  28611. m.ResetTotalGroup()
  28612. return nil
  28613. case usagestatisticday.FieldAccountBalance:
  28614. m.ResetAccountBalance()
  28615. return nil
  28616. case usagestatisticday.FieldConsumeToken:
  28617. m.ResetConsumeToken()
  28618. return nil
  28619. case usagestatisticday.FieldActiveUser:
  28620. m.ResetActiveUser()
  28621. return nil
  28622. case usagestatisticday.FieldNewUser:
  28623. m.ResetNewUser()
  28624. return nil
  28625. case usagestatisticday.FieldLabelDist:
  28626. m.ResetLabelDist()
  28627. return nil
  28628. }
  28629. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  28630. }
  28631. // AddedEdges returns all edge names that were set/added in this mutation.
  28632. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  28633. edges := make([]string, 0, 0)
  28634. return edges
  28635. }
  28636. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28637. // name in this mutation.
  28638. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  28639. return nil
  28640. }
  28641. // RemovedEdges returns all edge names that were removed in this mutation.
  28642. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  28643. edges := make([]string, 0, 0)
  28644. return edges
  28645. }
  28646. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28647. // the given name in this mutation.
  28648. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  28649. return nil
  28650. }
  28651. // ClearedEdges returns all edge names that were cleared in this mutation.
  28652. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  28653. edges := make([]string, 0, 0)
  28654. return edges
  28655. }
  28656. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28657. // was cleared in this mutation.
  28658. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  28659. return false
  28660. }
  28661. // ClearEdge clears the value of the edge with the given name. It returns an error
  28662. // if that edge is not defined in the schema.
  28663. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  28664. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  28665. }
  28666. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28667. // It returns an error if the edge is not defined in the schema.
  28668. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  28669. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  28670. }
  28671. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  28672. type UsageStatisticHourMutation struct {
  28673. config
  28674. op Op
  28675. typ string
  28676. id *uint64
  28677. created_at *time.Time
  28678. updated_at *time.Time
  28679. status *uint8
  28680. addstatus *int8
  28681. deleted_at *time.Time
  28682. addtime *uint64
  28683. addaddtime *int64
  28684. _type *int
  28685. add_type *int
  28686. bot_id *string
  28687. organization_id *uint64
  28688. addorganization_id *int64
  28689. ai_response *uint64
  28690. addai_response *int64
  28691. sop_run *uint64
  28692. addsop_run *int64
  28693. total_friend *uint64
  28694. addtotal_friend *int64
  28695. total_group *uint64
  28696. addtotal_group *int64
  28697. account_balance *uint64
  28698. addaccount_balance *int64
  28699. consume_token *uint64
  28700. addconsume_token *int64
  28701. active_user *uint64
  28702. addactive_user *int64
  28703. new_user *int64
  28704. addnew_user *int64
  28705. label_dist *[]custom_types.LabelDist
  28706. appendlabel_dist []custom_types.LabelDist
  28707. clearedFields map[string]struct{}
  28708. done bool
  28709. oldValue func(context.Context) (*UsageStatisticHour, error)
  28710. predicates []predicate.UsageStatisticHour
  28711. }
  28712. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  28713. // usagestatistichourOption allows management of the mutation configuration using functional options.
  28714. type usagestatistichourOption func(*UsageStatisticHourMutation)
  28715. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  28716. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  28717. m := &UsageStatisticHourMutation{
  28718. config: c,
  28719. op: op,
  28720. typ: TypeUsageStatisticHour,
  28721. clearedFields: make(map[string]struct{}),
  28722. }
  28723. for _, opt := range opts {
  28724. opt(m)
  28725. }
  28726. return m
  28727. }
  28728. // withUsageStatisticHourID sets the ID field of the mutation.
  28729. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  28730. return func(m *UsageStatisticHourMutation) {
  28731. var (
  28732. err error
  28733. once sync.Once
  28734. value *UsageStatisticHour
  28735. )
  28736. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  28737. once.Do(func() {
  28738. if m.done {
  28739. err = errors.New("querying old values post mutation is not allowed")
  28740. } else {
  28741. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  28742. }
  28743. })
  28744. return value, err
  28745. }
  28746. m.id = &id
  28747. }
  28748. }
  28749. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  28750. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  28751. return func(m *UsageStatisticHourMutation) {
  28752. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  28753. return node, nil
  28754. }
  28755. m.id = &node.ID
  28756. }
  28757. }
  28758. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28759. // executed in a transaction (ent.Tx), a transactional client is returned.
  28760. func (m UsageStatisticHourMutation) Client() *Client {
  28761. client := &Client{config: m.config}
  28762. client.init()
  28763. return client
  28764. }
  28765. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28766. // it returns an error otherwise.
  28767. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  28768. if _, ok := m.driver.(*txDriver); !ok {
  28769. return nil, errors.New("ent: mutation is not running in a transaction")
  28770. }
  28771. tx := &Tx{config: m.config}
  28772. tx.init()
  28773. return tx, nil
  28774. }
  28775. // SetID sets the value of the id field. Note that this
  28776. // operation is only accepted on creation of UsageStatisticHour entities.
  28777. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  28778. m.id = &id
  28779. }
  28780. // ID returns the ID value in the mutation. Note that the ID is only available
  28781. // if it was provided to the builder or after it was returned from the database.
  28782. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  28783. if m.id == nil {
  28784. return
  28785. }
  28786. return *m.id, true
  28787. }
  28788. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28789. // That means, if the mutation is applied within a transaction with an isolation level such
  28790. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28791. // or updated by the mutation.
  28792. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  28793. switch {
  28794. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28795. id, exists := m.ID()
  28796. if exists {
  28797. return []uint64{id}, nil
  28798. }
  28799. fallthrough
  28800. case m.op.Is(OpUpdate | OpDelete):
  28801. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  28802. default:
  28803. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28804. }
  28805. }
  28806. // SetCreatedAt sets the "created_at" field.
  28807. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  28808. m.created_at = &t
  28809. }
  28810. // CreatedAt returns the value of the "created_at" field in the mutation.
  28811. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  28812. v := m.created_at
  28813. if v == nil {
  28814. return
  28815. }
  28816. return *v, true
  28817. }
  28818. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  28819. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  28820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28821. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28822. if !m.op.Is(OpUpdateOne) {
  28823. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28824. }
  28825. if m.id == nil || m.oldValue == nil {
  28826. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28827. }
  28828. oldValue, err := m.oldValue(ctx)
  28829. if err != nil {
  28830. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28831. }
  28832. return oldValue.CreatedAt, nil
  28833. }
  28834. // ResetCreatedAt resets all changes to the "created_at" field.
  28835. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  28836. m.created_at = nil
  28837. }
  28838. // SetUpdatedAt sets the "updated_at" field.
  28839. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  28840. m.updated_at = &t
  28841. }
  28842. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28843. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  28844. v := m.updated_at
  28845. if v == nil {
  28846. return
  28847. }
  28848. return *v, true
  28849. }
  28850. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  28851. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  28852. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28853. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28854. if !m.op.Is(OpUpdateOne) {
  28855. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28856. }
  28857. if m.id == nil || m.oldValue == nil {
  28858. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28859. }
  28860. oldValue, err := m.oldValue(ctx)
  28861. if err != nil {
  28862. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28863. }
  28864. return oldValue.UpdatedAt, nil
  28865. }
  28866. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28867. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  28868. m.updated_at = nil
  28869. }
  28870. // SetStatus sets the "status" field.
  28871. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  28872. m.status = &u
  28873. m.addstatus = nil
  28874. }
  28875. // Status returns the value of the "status" field in the mutation.
  28876. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  28877. v := m.status
  28878. if v == nil {
  28879. return
  28880. }
  28881. return *v, true
  28882. }
  28883. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  28884. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  28885. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28886. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28887. if !m.op.Is(OpUpdateOne) {
  28888. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28889. }
  28890. if m.id == nil || m.oldValue == nil {
  28891. return v, errors.New("OldStatus requires an ID field in the mutation")
  28892. }
  28893. oldValue, err := m.oldValue(ctx)
  28894. if err != nil {
  28895. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28896. }
  28897. return oldValue.Status, nil
  28898. }
  28899. // AddStatus adds u to the "status" field.
  28900. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  28901. if m.addstatus != nil {
  28902. *m.addstatus += u
  28903. } else {
  28904. m.addstatus = &u
  28905. }
  28906. }
  28907. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28908. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  28909. v := m.addstatus
  28910. if v == nil {
  28911. return
  28912. }
  28913. return *v, true
  28914. }
  28915. // ClearStatus clears the value of the "status" field.
  28916. func (m *UsageStatisticHourMutation) ClearStatus() {
  28917. m.status = nil
  28918. m.addstatus = nil
  28919. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  28920. }
  28921. // StatusCleared returns if the "status" field was cleared in this mutation.
  28922. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  28923. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  28924. return ok
  28925. }
  28926. // ResetStatus resets all changes to the "status" field.
  28927. func (m *UsageStatisticHourMutation) ResetStatus() {
  28928. m.status = nil
  28929. m.addstatus = nil
  28930. delete(m.clearedFields, usagestatistichour.FieldStatus)
  28931. }
  28932. // SetDeletedAt sets the "deleted_at" field.
  28933. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  28934. m.deleted_at = &t
  28935. }
  28936. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28937. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  28938. v := m.deleted_at
  28939. if v == nil {
  28940. return
  28941. }
  28942. return *v, true
  28943. }
  28944. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  28945. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  28946. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28947. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28948. if !m.op.Is(OpUpdateOne) {
  28949. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28950. }
  28951. if m.id == nil || m.oldValue == nil {
  28952. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28953. }
  28954. oldValue, err := m.oldValue(ctx)
  28955. if err != nil {
  28956. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28957. }
  28958. return oldValue.DeletedAt, nil
  28959. }
  28960. // ClearDeletedAt clears the value of the "deleted_at" field.
  28961. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  28962. m.deleted_at = nil
  28963. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  28964. }
  28965. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28966. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  28967. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  28968. return ok
  28969. }
  28970. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28971. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  28972. m.deleted_at = nil
  28973. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  28974. }
  28975. // SetAddtime sets the "addtime" field.
  28976. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  28977. m.addtime = &u
  28978. m.addaddtime = nil
  28979. }
  28980. // Addtime returns the value of the "addtime" field in the mutation.
  28981. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  28982. v := m.addtime
  28983. if v == nil {
  28984. return
  28985. }
  28986. return *v, true
  28987. }
  28988. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  28989. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  28990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28991. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  28992. if !m.op.Is(OpUpdateOne) {
  28993. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  28994. }
  28995. if m.id == nil || m.oldValue == nil {
  28996. return v, errors.New("OldAddtime requires an ID field in the mutation")
  28997. }
  28998. oldValue, err := m.oldValue(ctx)
  28999. if err != nil {
  29000. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  29001. }
  29002. return oldValue.Addtime, nil
  29003. }
  29004. // AddAddtime adds u to the "addtime" field.
  29005. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  29006. if m.addaddtime != nil {
  29007. *m.addaddtime += u
  29008. } else {
  29009. m.addaddtime = &u
  29010. }
  29011. }
  29012. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  29013. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  29014. v := m.addaddtime
  29015. if v == nil {
  29016. return
  29017. }
  29018. return *v, true
  29019. }
  29020. // ResetAddtime resets all changes to the "addtime" field.
  29021. func (m *UsageStatisticHourMutation) ResetAddtime() {
  29022. m.addtime = nil
  29023. m.addaddtime = nil
  29024. }
  29025. // SetType sets the "type" field.
  29026. func (m *UsageStatisticHourMutation) SetType(i int) {
  29027. m._type = &i
  29028. m.add_type = nil
  29029. }
  29030. // GetType returns the value of the "type" field in the mutation.
  29031. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  29032. v := m._type
  29033. if v == nil {
  29034. return
  29035. }
  29036. return *v, true
  29037. }
  29038. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  29039. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29041. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  29042. if !m.op.Is(OpUpdateOne) {
  29043. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29044. }
  29045. if m.id == nil || m.oldValue == nil {
  29046. return v, errors.New("OldType requires an ID field in the mutation")
  29047. }
  29048. oldValue, err := m.oldValue(ctx)
  29049. if err != nil {
  29050. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29051. }
  29052. return oldValue.Type, nil
  29053. }
  29054. // AddType adds i to the "type" field.
  29055. func (m *UsageStatisticHourMutation) AddType(i int) {
  29056. if m.add_type != nil {
  29057. *m.add_type += i
  29058. } else {
  29059. m.add_type = &i
  29060. }
  29061. }
  29062. // AddedType returns the value that was added to the "type" field in this mutation.
  29063. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  29064. v := m.add_type
  29065. if v == nil {
  29066. return
  29067. }
  29068. return *v, true
  29069. }
  29070. // ResetType resets all changes to the "type" field.
  29071. func (m *UsageStatisticHourMutation) ResetType() {
  29072. m._type = nil
  29073. m.add_type = nil
  29074. }
  29075. // SetBotID sets the "bot_id" field.
  29076. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  29077. m.bot_id = &s
  29078. }
  29079. // BotID returns the value of the "bot_id" field in the mutation.
  29080. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  29081. v := m.bot_id
  29082. if v == nil {
  29083. return
  29084. }
  29085. return *v, true
  29086. }
  29087. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  29088. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29090. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  29091. if !m.op.Is(OpUpdateOne) {
  29092. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  29093. }
  29094. if m.id == nil || m.oldValue == nil {
  29095. return v, errors.New("OldBotID requires an ID field in the mutation")
  29096. }
  29097. oldValue, err := m.oldValue(ctx)
  29098. if err != nil {
  29099. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  29100. }
  29101. return oldValue.BotID, nil
  29102. }
  29103. // ClearBotID clears the value of the "bot_id" field.
  29104. func (m *UsageStatisticHourMutation) ClearBotID() {
  29105. m.bot_id = nil
  29106. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  29107. }
  29108. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  29109. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  29110. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  29111. return ok
  29112. }
  29113. // ResetBotID resets all changes to the "bot_id" field.
  29114. func (m *UsageStatisticHourMutation) ResetBotID() {
  29115. m.bot_id = nil
  29116. delete(m.clearedFields, usagestatistichour.FieldBotID)
  29117. }
  29118. // SetOrganizationID sets the "organization_id" field.
  29119. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  29120. m.organization_id = &u
  29121. m.addorganization_id = nil
  29122. }
  29123. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29124. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  29125. v := m.organization_id
  29126. if v == nil {
  29127. return
  29128. }
  29129. return *v, true
  29130. }
  29131. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  29132. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29134. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29135. if !m.op.Is(OpUpdateOne) {
  29136. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29137. }
  29138. if m.id == nil || m.oldValue == nil {
  29139. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29140. }
  29141. oldValue, err := m.oldValue(ctx)
  29142. if err != nil {
  29143. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29144. }
  29145. return oldValue.OrganizationID, nil
  29146. }
  29147. // AddOrganizationID adds u to the "organization_id" field.
  29148. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  29149. if m.addorganization_id != nil {
  29150. *m.addorganization_id += u
  29151. } else {
  29152. m.addorganization_id = &u
  29153. }
  29154. }
  29155. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29156. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  29157. v := m.addorganization_id
  29158. if v == nil {
  29159. return
  29160. }
  29161. return *v, true
  29162. }
  29163. // ClearOrganizationID clears the value of the "organization_id" field.
  29164. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  29165. m.organization_id = nil
  29166. m.addorganization_id = nil
  29167. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  29168. }
  29169. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  29170. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  29171. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  29172. return ok
  29173. }
  29174. // ResetOrganizationID resets all changes to the "organization_id" field.
  29175. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  29176. m.organization_id = nil
  29177. m.addorganization_id = nil
  29178. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  29179. }
  29180. // SetAiResponse sets the "ai_response" field.
  29181. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  29182. m.ai_response = &u
  29183. m.addai_response = nil
  29184. }
  29185. // AiResponse returns the value of the "ai_response" field in the mutation.
  29186. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  29187. v := m.ai_response
  29188. if v == nil {
  29189. return
  29190. }
  29191. return *v, true
  29192. }
  29193. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  29194. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29195. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29196. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  29197. if !m.op.Is(OpUpdateOne) {
  29198. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  29199. }
  29200. if m.id == nil || m.oldValue == nil {
  29201. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  29202. }
  29203. oldValue, err := m.oldValue(ctx)
  29204. if err != nil {
  29205. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  29206. }
  29207. return oldValue.AiResponse, nil
  29208. }
  29209. // AddAiResponse adds u to the "ai_response" field.
  29210. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  29211. if m.addai_response != nil {
  29212. *m.addai_response += u
  29213. } else {
  29214. m.addai_response = &u
  29215. }
  29216. }
  29217. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  29218. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  29219. v := m.addai_response
  29220. if v == nil {
  29221. return
  29222. }
  29223. return *v, true
  29224. }
  29225. // ResetAiResponse resets all changes to the "ai_response" field.
  29226. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  29227. m.ai_response = nil
  29228. m.addai_response = nil
  29229. }
  29230. // SetSopRun sets the "sop_run" field.
  29231. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  29232. m.sop_run = &u
  29233. m.addsop_run = nil
  29234. }
  29235. // SopRun returns the value of the "sop_run" field in the mutation.
  29236. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  29237. v := m.sop_run
  29238. if v == nil {
  29239. return
  29240. }
  29241. return *v, true
  29242. }
  29243. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  29244. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29246. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  29247. if !m.op.Is(OpUpdateOne) {
  29248. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  29249. }
  29250. if m.id == nil || m.oldValue == nil {
  29251. return v, errors.New("OldSopRun requires an ID field in the mutation")
  29252. }
  29253. oldValue, err := m.oldValue(ctx)
  29254. if err != nil {
  29255. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  29256. }
  29257. return oldValue.SopRun, nil
  29258. }
  29259. // AddSopRun adds u to the "sop_run" field.
  29260. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  29261. if m.addsop_run != nil {
  29262. *m.addsop_run += u
  29263. } else {
  29264. m.addsop_run = &u
  29265. }
  29266. }
  29267. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  29268. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  29269. v := m.addsop_run
  29270. if v == nil {
  29271. return
  29272. }
  29273. return *v, true
  29274. }
  29275. // ResetSopRun resets all changes to the "sop_run" field.
  29276. func (m *UsageStatisticHourMutation) ResetSopRun() {
  29277. m.sop_run = nil
  29278. m.addsop_run = nil
  29279. }
  29280. // SetTotalFriend sets the "total_friend" field.
  29281. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  29282. m.total_friend = &u
  29283. m.addtotal_friend = nil
  29284. }
  29285. // TotalFriend returns the value of the "total_friend" field in the mutation.
  29286. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  29287. v := m.total_friend
  29288. if v == nil {
  29289. return
  29290. }
  29291. return *v, true
  29292. }
  29293. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  29294. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29296. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  29297. if !m.op.Is(OpUpdateOne) {
  29298. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  29299. }
  29300. if m.id == nil || m.oldValue == nil {
  29301. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  29302. }
  29303. oldValue, err := m.oldValue(ctx)
  29304. if err != nil {
  29305. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  29306. }
  29307. return oldValue.TotalFriend, nil
  29308. }
  29309. // AddTotalFriend adds u to the "total_friend" field.
  29310. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  29311. if m.addtotal_friend != nil {
  29312. *m.addtotal_friend += u
  29313. } else {
  29314. m.addtotal_friend = &u
  29315. }
  29316. }
  29317. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  29318. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  29319. v := m.addtotal_friend
  29320. if v == nil {
  29321. return
  29322. }
  29323. return *v, true
  29324. }
  29325. // ResetTotalFriend resets all changes to the "total_friend" field.
  29326. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  29327. m.total_friend = nil
  29328. m.addtotal_friend = nil
  29329. }
  29330. // SetTotalGroup sets the "total_group" field.
  29331. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  29332. m.total_group = &u
  29333. m.addtotal_group = nil
  29334. }
  29335. // TotalGroup returns the value of the "total_group" field in the mutation.
  29336. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  29337. v := m.total_group
  29338. if v == nil {
  29339. return
  29340. }
  29341. return *v, true
  29342. }
  29343. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  29344. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29346. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  29347. if !m.op.Is(OpUpdateOne) {
  29348. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  29349. }
  29350. if m.id == nil || m.oldValue == nil {
  29351. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  29352. }
  29353. oldValue, err := m.oldValue(ctx)
  29354. if err != nil {
  29355. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  29356. }
  29357. return oldValue.TotalGroup, nil
  29358. }
  29359. // AddTotalGroup adds u to the "total_group" field.
  29360. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  29361. if m.addtotal_group != nil {
  29362. *m.addtotal_group += u
  29363. } else {
  29364. m.addtotal_group = &u
  29365. }
  29366. }
  29367. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  29368. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  29369. v := m.addtotal_group
  29370. if v == nil {
  29371. return
  29372. }
  29373. return *v, true
  29374. }
  29375. // ResetTotalGroup resets all changes to the "total_group" field.
  29376. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  29377. m.total_group = nil
  29378. m.addtotal_group = nil
  29379. }
  29380. // SetAccountBalance sets the "account_balance" field.
  29381. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  29382. m.account_balance = &u
  29383. m.addaccount_balance = nil
  29384. }
  29385. // AccountBalance returns the value of the "account_balance" field in the mutation.
  29386. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  29387. v := m.account_balance
  29388. if v == nil {
  29389. return
  29390. }
  29391. return *v, true
  29392. }
  29393. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  29394. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29396. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  29397. if !m.op.Is(OpUpdateOne) {
  29398. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  29399. }
  29400. if m.id == nil || m.oldValue == nil {
  29401. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  29402. }
  29403. oldValue, err := m.oldValue(ctx)
  29404. if err != nil {
  29405. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  29406. }
  29407. return oldValue.AccountBalance, nil
  29408. }
  29409. // AddAccountBalance adds u to the "account_balance" field.
  29410. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  29411. if m.addaccount_balance != nil {
  29412. *m.addaccount_balance += u
  29413. } else {
  29414. m.addaccount_balance = &u
  29415. }
  29416. }
  29417. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  29418. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  29419. v := m.addaccount_balance
  29420. if v == nil {
  29421. return
  29422. }
  29423. return *v, true
  29424. }
  29425. // ResetAccountBalance resets all changes to the "account_balance" field.
  29426. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  29427. m.account_balance = nil
  29428. m.addaccount_balance = nil
  29429. }
  29430. // SetConsumeToken sets the "consume_token" field.
  29431. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  29432. m.consume_token = &u
  29433. m.addconsume_token = nil
  29434. }
  29435. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  29436. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  29437. v := m.consume_token
  29438. if v == nil {
  29439. return
  29440. }
  29441. return *v, true
  29442. }
  29443. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  29444. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29446. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  29447. if !m.op.Is(OpUpdateOne) {
  29448. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  29449. }
  29450. if m.id == nil || m.oldValue == nil {
  29451. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  29452. }
  29453. oldValue, err := m.oldValue(ctx)
  29454. if err != nil {
  29455. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  29456. }
  29457. return oldValue.ConsumeToken, nil
  29458. }
  29459. // AddConsumeToken adds u to the "consume_token" field.
  29460. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  29461. if m.addconsume_token != nil {
  29462. *m.addconsume_token += u
  29463. } else {
  29464. m.addconsume_token = &u
  29465. }
  29466. }
  29467. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  29468. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  29469. v := m.addconsume_token
  29470. if v == nil {
  29471. return
  29472. }
  29473. return *v, true
  29474. }
  29475. // ResetConsumeToken resets all changes to the "consume_token" field.
  29476. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  29477. m.consume_token = nil
  29478. m.addconsume_token = nil
  29479. }
  29480. // SetActiveUser sets the "active_user" field.
  29481. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  29482. m.active_user = &u
  29483. m.addactive_user = nil
  29484. }
  29485. // ActiveUser returns the value of the "active_user" field in the mutation.
  29486. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  29487. v := m.active_user
  29488. if v == nil {
  29489. return
  29490. }
  29491. return *v, true
  29492. }
  29493. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  29494. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29496. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  29497. if !m.op.Is(OpUpdateOne) {
  29498. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  29499. }
  29500. if m.id == nil || m.oldValue == nil {
  29501. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  29502. }
  29503. oldValue, err := m.oldValue(ctx)
  29504. if err != nil {
  29505. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  29506. }
  29507. return oldValue.ActiveUser, nil
  29508. }
  29509. // AddActiveUser adds u to the "active_user" field.
  29510. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  29511. if m.addactive_user != nil {
  29512. *m.addactive_user += u
  29513. } else {
  29514. m.addactive_user = &u
  29515. }
  29516. }
  29517. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  29518. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  29519. v := m.addactive_user
  29520. if v == nil {
  29521. return
  29522. }
  29523. return *v, true
  29524. }
  29525. // ResetActiveUser resets all changes to the "active_user" field.
  29526. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  29527. m.active_user = nil
  29528. m.addactive_user = nil
  29529. }
  29530. // SetNewUser sets the "new_user" field.
  29531. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  29532. m.new_user = &i
  29533. m.addnew_user = nil
  29534. }
  29535. // NewUser returns the value of the "new_user" field in the mutation.
  29536. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  29537. v := m.new_user
  29538. if v == nil {
  29539. return
  29540. }
  29541. return *v, true
  29542. }
  29543. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  29544. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29546. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  29547. if !m.op.Is(OpUpdateOne) {
  29548. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  29549. }
  29550. if m.id == nil || m.oldValue == nil {
  29551. return v, errors.New("OldNewUser requires an ID field in the mutation")
  29552. }
  29553. oldValue, err := m.oldValue(ctx)
  29554. if err != nil {
  29555. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  29556. }
  29557. return oldValue.NewUser, nil
  29558. }
  29559. // AddNewUser adds i to the "new_user" field.
  29560. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  29561. if m.addnew_user != nil {
  29562. *m.addnew_user += i
  29563. } else {
  29564. m.addnew_user = &i
  29565. }
  29566. }
  29567. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  29568. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  29569. v := m.addnew_user
  29570. if v == nil {
  29571. return
  29572. }
  29573. return *v, true
  29574. }
  29575. // ResetNewUser resets all changes to the "new_user" field.
  29576. func (m *UsageStatisticHourMutation) ResetNewUser() {
  29577. m.new_user = nil
  29578. m.addnew_user = nil
  29579. }
  29580. // SetLabelDist sets the "label_dist" field.
  29581. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  29582. m.label_dist = &ctd
  29583. m.appendlabel_dist = nil
  29584. }
  29585. // LabelDist returns the value of the "label_dist" field in the mutation.
  29586. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  29587. v := m.label_dist
  29588. if v == nil {
  29589. return
  29590. }
  29591. return *v, true
  29592. }
  29593. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  29594. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29595. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29596. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  29597. if !m.op.Is(OpUpdateOne) {
  29598. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  29599. }
  29600. if m.id == nil || m.oldValue == nil {
  29601. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  29602. }
  29603. oldValue, err := m.oldValue(ctx)
  29604. if err != nil {
  29605. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  29606. }
  29607. return oldValue.LabelDist, nil
  29608. }
  29609. // AppendLabelDist adds ctd to the "label_dist" field.
  29610. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  29611. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  29612. }
  29613. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  29614. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  29615. if len(m.appendlabel_dist) == 0 {
  29616. return nil, false
  29617. }
  29618. return m.appendlabel_dist, true
  29619. }
  29620. // ResetLabelDist resets all changes to the "label_dist" field.
  29621. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  29622. m.label_dist = nil
  29623. m.appendlabel_dist = nil
  29624. }
  29625. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  29626. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  29627. m.predicates = append(m.predicates, ps...)
  29628. }
  29629. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  29630. // users can use type-assertion to append predicates that do not depend on any generated package.
  29631. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  29632. p := make([]predicate.UsageStatisticHour, len(ps))
  29633. for i := range ps {
  29634. p[i] = ps[i]
  29635. }
  29636. m.Where(p...)
  29637. }
  29638. // Op returns the operation name.
  29639. func (m *UsageStatisticHourMutation) Op() Op {
  29640. return m.op
  29641. }
  29642. // SetOp allows setting the mutation operation.
  29643. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  29644. m.op = op
  29645. }
  29646. // Type returns the node type of this mutation (UsageStatisticHour).
  29647. func (m *UsageStatisticHourMutation) Type() string {
  29648. return m.typ
  29649. }
  29650. // Fields returns all fields that were changed during this mutation. Note that in
  29651. // order to get all numeric fields that were incremented/decremented, call
  29652. // AddedFields().
  29653. func (m *UsageStatisticHourMutation) Fields() []string {
  29654. fields := make([]string, 0, 17)
  29655. if m.created_at != nil {
  29656. fields = append(fields, usagestatistichour.FieldCreatedAt)
  29657. }
  29658. if m.updated_at != nil {
  29659. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  29660. }
  29661. if m.status != nil {
  29662. fields = append(fields, usagestatistichour.FieldStatus)
  29663. }
  29664. if m.deleted_at != nil {
  29665. fields = append(fields, usagestatistichour.FieldDeletedAt)
  29666. }
  29667. if m.addtime != nil {
  29668. fields = append(fields, usagestatistichour.FieldAddtime)
  29669. }
  29670. if m._type != nil {
  29671. fields = append(fields, usagestatistichour.FieldType)
  29672. }
  29673. if m.bot_id != nil {
  29674. fields = append(fields, usagestatistichour.FieldBotID)
  29675. }
  29676. if m.organization_id != nil {
  29677. fields = append(fields, usagestatistichour.FieldOrganizationID)
  29678. }
  29679. if m.ai_response != nil {
  29680. fields = append(fields, usagestatistichour.FieldAiResponse)
  29681. }
  29682. if m.sop_run != nil {
  29683. fields = append(fields, usagestatistichour.FieldSopRun)
  29684. }
  29685. if m.total_friend != nil {
  29686. fields = append(fields, usagestatistichour.FieldTotalFriend)
  29687. }
  29688. if m.total_group != nil {
  29689. fields = append(fields, usagestatistichour.FieldTotalGroup)
  29690. }
  29691. if m.account_balance != nil {
  29692. fields = append(fields, usagestatistichour.FieldAccountBalance)
  29693. }
  29694. if m.consume_token != nil {
  29695. fields = append(fields, usagestatistichour.FieldConsumeToken)
  29696. }
  29697. if m.active_user != nil {
  29698. fields = append(fields, usagestatistichour.FieldActiveUser)
  29699. }
  29700. if m.new_user != nil {
  29701. fields = append(fields, usagestatistichour.FieldNewUser)
  29702. }
  29703. if m.label_dist != nil {
  29704. fields = append(fields, usagestatistichour.FieldLabelDist)
  29705. }
  29706. return fields
  29707. }
  29708. // Field returns the value of a field with the given name. The second boolean
  29709. // return value indicates that this field was not set, or was not defined in the
  29710. // schema.
  29711. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  29712. switch name {
  29713. case usagestatistichour.FieldCreatedAt:
  29714. return m.CreatedAt()
  29715. case usagestatistichour.FieldUpdatedAt:
  29716. return m.UpdatedAt()
  29717. case usagestatistichour.FieldStatus:
  29718. return m.Status()
  29719. case usagestatistichour.FieldDeletedAt:
  29720. return m.DeletedAt()
  29721. case usagestatistichour.FieldAddtime:
  29722. return m.Addtime()
  29723. case usagestatistichour.FieldType:
  29724. return m.GetType()
  29725. case usagestatistichour.FieldBotID:
  29726. return m.BotID()
  29727. case usagestatistichour.FieldOrganizationID:
  29728. return m.OrganizationID()
  29729. case usagestatistichour.FieldAiResponse:
  29730. return m.AiResponse()
  29731. case usagestatistichour.FieldSopRun:
  29732. return m.SopRun()
  29733. case usagestatistichour.FieldTotalFriend:
  29734. return m.TotalFriend()
  29735. case usagestatistichour.FieldTotalGroup:
  29736. return m.TotalGroup()
  29737. case usagestatistichour.FieldAccountBalance:
  29738. return m.AccountBalance()
  29739. case usagestatistichour.FieldConsumeToken:
  29740. return m.ConsumeToken()
  29741. case usagestatistichour.FieldActiveUser:
  29742. return m.ActiveUser()
  29743. case usagestatistichour.FieldNewUser:
  29744. return m.NewUser()
  29745. case usagestatistichour.FieldLabelDist:
  29746. return m.LabelDist()
  29747. }
  29748. return nil, false
  29749. }
  29750. // OldField returns the old value of the field from the database. An error is
  29751. // returned if the mutation operation is not UpdateOne, or the query to the
  29752. // database failed.
  29753. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29754. switch name {
  29755. case usagestatistichour.FieldCreatedAt:
  29756. return m.OldCreatedAt(ctx)
  29757. case usagestatistichour.FieldUpdatedAt:
  29758. return m.OldUpdatedAt(ctx)
  29759. case usagestatistichour.FieldStatus:
  29760. return m.OldStatus(ctx)
  29761. case usagestatistichour.FieldDeletedAt:
  29762. return m.OldDeletedAt(ctx)
  29763. case usagestatistichour.FieldAddtime:
  29764. return m.OldAddtime(ctx)
  29765. case usagestatistichour.FieldType:
  29766. return m.OldType(ctx)
  29767. case usagestatistichour.FieldBotID:
  29768. return m.OldBotID(ctx)
  29769. case usagestatistichour.FieldOrganizationID:
  29770. return m.OldOrganizationID(ctx)
  29771. case usagestatistichour.FieldAiResponse:
  29772. return m.OldAiResponse(ctx)
  29773. case usagestatistichour.FieldSopRun:
  29774. return m.OldSopRun(ctx)
  29775. case usagestatistichour.FieldTotalFriend:
  29776. return m.OldTotalFriend(ctx)
  29777. case usagestatistichour.FieldTotalGroup:
  29778. return m.OldTotalGroup(ctx)
  29779. case usagestatistichour.FieldAccountBalance:
  29780. return m.OldAccountBalance(ctx)
  29781. case usagestatistichour.FieldConsumeToken:
  29782. return m.OldConsumeToken(ctx)
  29783. case usagestatistichour.FieldActiveUser:
  29784. return m.OldActiveUser(ctx)
  29785. case usagestatistichour.FieldNewUser:
  29786. return m.OldNewUser(ctx)
  29787. case usagestatistichour.FieldLabelDist:
  29788. return m.OldLabelDist(ctx)
  29789. }
  29790. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  29791. }
  29792. // SetField sets the value of a field with the given name. It returns an error if
  29793. // the field is not defined in the schema, or if the type mismatched the field
  29794. // type.
  29795. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  29796. switch name {
  29797. case usagestatistichour.FieldCreatedAt:
  29798. v, ok := value.(time.Time)
  29799. if !ok {
  29800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29801. }
  29802. m.SetCreatedAt(v)
  29803. return nil
  29804. case usagestatistichour.FieldUpdatedAt:
  29805. v, ok := value.(time.Time)
  29806. if !ok {
  29807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29808. }
  29809. m.SetUpdatedAt(v)
  29810. return nil
  29811. case usagestatistichour.FieldStatus:
  29812. v, ok := value.(uint8)
  29813. if !ok {
  29814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29815. }
  29816. m.SetStatus(v)
  29817. return nil
  29818. case usagestatistichour.FieldDeletedAt:
  29819. v, ok := value.(time.Time)
  29820. if !ok {
  29821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29822. }
  29823. m.SetDeletedAt(v)
  29824. return nil
  29825. case usagestatistichour.FieldAddtime:
  29826. v, ok := value.(uint64)
  29827. if !ok {
  29828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29829. }
  29830. m.SetAddtime(v)
  29831. return nil
  29832. case usagestatistichour.FieldType:
  29833. v, ok := value.(int)
  29834. if !ok {
  29835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29836. }
  29837. m.SetType(v)
  29838. return nil
  29839. case usagestatistichour.FieldBotID:
  29840. v, ok := value.(string)
  29841. if !ok {
  29842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29843. }
  29844. m.SetBotID(v)
  29845. return nil
  29846. case usagestatistichour.FieldOrganizationID:
  29847. v, ok := value.(uint64)
  29848. if !ok {
  29849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29850. }
  29851. m.SetOrganizationID(v)
  29852. return nil
  29853. case usagestatistichour.FieldAiResponse:
  29854. v, ok := value.(uint64)
  29855. if !ok {
  29856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29857. }
  29858. m.SetAiResponse(v)
  29859. return nil
  29860. case usagestatistichour.FieldSopRun:
  29861. v, ok := value.(uint64)
  29862. if !ok {
  29863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29864. }
  29865. m.SetSopRun(v)
  29866. return nil
  29867. case usagestatistichour.FieldTotalFriend:
  29868. v, ok := value.(uint64)
  29869. if !ok {
  29870. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29871. }
  29872. m.SetTotalFriend(v)
  29873. return nil
  29874. case usagestatistichour.FieldTotalGroup:
  29875. v, ok := value.(uint64)
  29876. if !ok {
  29877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29878. }
  29879. m.SetTotalGroup(v)
  29880. return nil
  29881. case usagestatistichour.FieldAccountBalance:
  29882. v, ok := value.(uint64)
  29883. if !ok {
  29884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29885. }
  29886. m.SetAccountBalance(v)
  29887. return nil
  29888. case usagestatistichour.FieldConsumeToken:
  29889. v, ok := value.(uint64)
  29890. if !ok {
  29891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29892. }
  29893. m.SetConsumeToken(v)
  29894. return nil
  29895. case usagestatistichour.FieldActiveUser:
  29896. v, ok := value.(uint64)
  29897. if !ok {
  29898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29899. }
  29900. m.SetActiveUser(v)
  29901. return nil
  29902. case usagestatistichour.FieldNewUser:
  29903. v, ok := value.(int64)
  29904. if !ok {
  29905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29906. }
  29907. m.SetNewUser(v)
  29908. return nil
  29909. case usagestatistichour.FieldLabelDist:
  29910. v, ok := value.([]custom_types.LabelDist)
  29911. if !ok {
  29912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29913. }
  29914. m.SetLabelDist(v)
  29915. return nil
  29916. }
  29917. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  29918. }
  29919. // AddedFields returns all numeric fields that were incremented/decremented during
  29920. // this mutation.
  29921. func (m *UsageStatisticHourMutation) AddedFields() []string {
  29922. var fields []string
  29923. if m.addstatus != nil {
  29924. fields = append(fields, usagestatistichour.FieldStatus)
  29925. }
  29926. if m.addaddtime != nil {
  29927. fields = append(fields, usagestatistichour.FieldAddtime)
  29928. }
  29929. if m.add_type != nil {
  29930. fields = append(fields, usagestatistichour.FieldType)
  29931. }
  29932. if m.addorganization_id != nil {
  29933. fields = append(fields, usagestatistichour.FieldOrganizationID)
  29934. }
  29935. if m.addai_response != nil {
  29936. fields = append(fields, usagestatistichour.FieldAiResponse)
  29937. }
  29938. if m.addsop_run != nil {
  29939. fields = append(fields, usagestatistichour.FieldSopRun)
  29940. }
  29941. if m.addtotal_friend != nil {
  29942. fields = append(fields, usagestatistichour.FieldTotalFriend)
  29943. }
  29944. if m.addtotal_group != nil {
  29945. fields = append(fields, usagestatistichour.FieldTotalGroup)
  29946. }
  29947. if m.addaccount_balance != nil {
  29948. fields = append(fields, usagestatistichour.FieldAccountBalance)
  29949. }
  29950. if m.addconsume_token != nil {
  29951. fields = append(fields, usagestatistichour.FieldConsumeToken)
  29952. }
  29953. if m.addactive_user != nil {
  29954. fields = append(fields, usagestatistichour.FieldActiveUser)
  29955. }
  29956. if m.addnew_user != nil {
  29957. fields = append(fields, usagestatistichour.FieldNewUser)
  29958. }
  29959. return fields
  29960. }
  29961. // AddedField returns the numeric value that was incremented/decremented on a field
  29962. // with the given name. The second boolean return value indicates that this field
  29963. // was not set, or was not defined in the schema.
  29964. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  29965. switch name {
  29966. case usagestatistichour.FieldStatus:
  29967. return m.AddedStatus()
  29968. case usagestatistichour.FieldAddtime:
  29969. return m.AddedAddtime()
  29970. case usagestatistichour.FieldType:
  29971. return m.AddedType()
  29972. case usagestatistichour.FieldOrganizationID:
  29973. return m.AddedOrganizationID()
  29974. case usagestatistichour.FieldAiResponse:
  29975. return m.AddedAiResponse()
  29976. case usagestatistichour.FieldSopRun:
  29977. return m.AddedSopRun()
  29978. case usagestatistichour.FieldTotalFriend:
  29979. return m.AddedTotalFriend()
  29980. case usagestatistichour.FieldTotalGroup:
  29981. return m.AddedTotalGroup()
  29982. case usagestatistichour.FieldAccountBalance:
  29983. return m.AddedAccountBalance()
  29984. case usagestatistichour.FieldConsumeToken:
  29985. return m.AddedConsumeToken()
  29986. case usagestatistichour.FieldActiveUser:
  29987. return m.AddedActiveUser()
  29988. case usagestatistichour.FieldNewUser:
  29989. return m.AddedNewUser()
  29990. }
  29991. return nil, false
  29992. }
  29993. // AddField adds the value to the field with the given name. It returns an error if
  29994. // the field is not defined in the schema, or if the type mismatched the field
  29995. // type.
  29996. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  29997. switch name {
  29998. case usagestatistichour.FieldStatus:
  29999. v, ok := value.(int8)
  30000. if !ok {
  30001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30002. }
  30003. m.AddStatus(v)
  30004. return nil
  30005. case usagestatistichour.FieldAddtime:
  30006. v, ok := value.(int64)
  30007. if !ok {
  30008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30009. }
  30010. m.AddAddtime(v)
  30011. return nil
  30012. case usagestatistichour.FieldType:
  30013. v, ok := value.(int)
  30014. if !ok {
  30015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30016. }
  30017. m.AddType(v)
  30018. return nil
  30019. case usagestatistichour.FieldOrganizationID:
  30020. v, ok := value.(int64)
  30021. if !ok {
  30022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30023. }
  30024. m.AddOrganizationID(v)
  30025. return nil
  30026. case usagestatistichour.FieldAiResponse:
  30027. v, ok := value.(int64)
  30028. if !ok {
  30029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30030. }
  30031. m.AddAiResponse(v)
  30032. return nil
  30033. case usagestatistichour.FieldSopRun:
  30034. v, ok := value.(int64)
  30035. if !ok {
  30036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30037. }
  30038. m.AddSopRun(v)
  30039. return nil
  30040. case usagestatistichour.FieldTotalFriend:
  30041. v, ok := value.(int64)
  30042. if !ok {
  30043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30044. }
  30045. m.AddTotalFriend(v)
  30046. return nil
  30047. case usagestatistichour.FieldTotalGroup:
  30048. v, ok := value.(int64)
  30049. if !ok {
  30050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30051. }
  30052. m.AddTotalGroup(v)
  30053. return nil
  30054. case usagestatistichour.FieldAccountBalance:
  30055. v, ok := value.(int64)
  30056. if !ok {
  30057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30058. }
  30059. m.AddAccountBalance(v)
  30060. return nil
  30061. case usagestatistichour.FieldConsumeToken:
  30062. v, ok := value.(int64)
  30063. if !ok {
  30064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30065. }
  30066. m.AddConsumeToken(v)
  30067. return nil
  30068. case usagestatistichour.FieldActiveUser:
  30069. v, ok := value.(int64)
  30070. if !ok {
  30071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30072. }
  30073. m.AddActiveUser(v)
  30074. return nil
  30075. case usagestatistichour.FieldNewUser:
  30076. v, ok := value.(int64)
  30077. if !ok {
  30078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30079. }
  30080. m.AddNewUser(v)
  30081. return nil
  30082. }
  30083. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  30084. }
  30085. // ClearedFields returns all nullable fields that were cleared during this
  30086. // mutation.
  30087. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  30088. var fields []string
  30089. if m.FieldCleared(usagestatistichour.FieldStatus) {
  30090. fields = append(fields, usagestatistichour.FieldStatus)
  30091. }
  30092. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  30093. fields = append(fields, usagestatistichour.FieldDeletedAt)
  30094. }
  30095. if m.FieldCleared(usagestatistichour.FieldBotID) {
  30096. fields = append(fields, usagestatistichour.FieldBotID)
  30097. }
  30098. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  30099. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30100. }
  30101. return fields
  30102. }
  30103. // FieldCleared returns a boolean indicating if a field with the given name was
  30104. // cleared in this mutation.
  30105. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  30106. _, ok := m.clearedFields[name]
  30107. return ok
  30108. }
  30109. // ClearField clears the value of the field with the given name. It returns an
  30110. // error if the field is not defined in the schema.
  30111. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  30112. switch name {
  30113. case usagestatistichour.FieldStatus:
  30114. m.ClearStatus()
  30115. return nil
  30116. case usagestatistichour.FieldDeletedAt:
  30117. m.ClearDeletedAt()
  30118. return nil
  30119. case usagestatistichour.FieldBotID:
  30120. m.ClearBotID()
  30121. return nil
  30122. case usagestatistichour.FieldOrganizationID:
  30123. m.ClearOrganizationID()
  30124. return nil
  30125. }
  30126. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  30127. }
  30128. // ResetField resets all changes in the mutation for the field with the given name.
  30129. // It returns an error if the field is not defined in the schema.
  30130. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  30131. switch name {
  30132. case usagestatistichour.FieldCreatedAt:
  30133. m.ResetCreatedAt()
  30134. return nil
  30135. case usagestatistichour.FieldUpdatedAt:
  30136. m.ResetUpdatedAt()
  30137. return nil
  30138. case usagestatistichour.FieldStatus:
  30139. m.ResetStatus()
  30140. return nil
  30141. case usagestatistichour.FieldDeletedAt:
  30142. m.ResetDeletedAt()
  30143. return nil
  30144. case usagestatistichour.FieldAddtime:
  30145. m.ResetAddtime()
  30146. return nil
  30147. case usagestatistichour.FieldType:
  30148. m.ResetType()
  30149. return nil
  30150. case usagestatistichour.FieldBotID:
  30151. m.ResetBotID()
  30152. return nil
  30153. case usagestatistichour.FieldOrganizationID:
  30154. m.ResetOrganizationID()
  30155. return nil
  30156. case usagestatistichour.FieldAiResponse:
  30157. m.ResetAiResponse()
  30158. return nil
  30159. case usagestatistichour.FieldSopRun:
  30160. m.ResetSopRun()
  30161. return nil
  30162. case usagestatistichour.FieldTotalFriend:
  30163. m.ResetTotalFriend()
  30164. return nil
  30165. case usagestatistichour.FieldTotalGroup:
  30166. m.ResetTotalGroup()
  30167. return nil
  30168. case usagestatistichour.FieldAccountBalance:
  30169. m.ResetAccountBalance()
  30170. return nil
  30171. case usagestatistichour.FieldConsumeToken:
  30172. m.ResetConsumeToken()
  30173. return nil
  30174. case usagestatistichour.FieldActiveUser:
  30175. m.ResetActiveUser()
  30176. return nil
  30177. case usagestatistichour.FieldNewUser:
  30178. m.ResetNewUser()
  30179. return nil
  30180. case usagestatistichour.FieldLabelDist:
  30181. m.ResetLabelDist()
  30182. return nil
  30183. }
  30184. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  30185. }
  30186. // AddedEdges returns all edge names that were set/added in this mutation.
  30187. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  30188. edges := make([]string, 0, 0)
  30189. return edges
  30190. }
  30191. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30192. // name in this mutation.
  30193. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  30194. return nil
  30195. }
  30196. // RemovedEdges returns all edge names that were removed in this mutation.
  30197. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  30198. edges := make([]string, 0, 0)
  30199. return edges
  30200. }
  30201. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30202. // the given name in this mutation.
  30203. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  30204. return nil
  30205. }
  30206. // ClearedEdges returns all edge names that were cleared in this mutation.
  30207. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  30208. edges := make([]string, 0, 0)
  30209. return edges
  30210. }
  30211. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30212. // was cleared in this mutation.
  30213. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  30214. return false
  30215. }
  30216. // ClearEdge clears the value of the edge with the given name. It returns an error
  30217. // if that edge is not defined in the schema.
  30218. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  30219. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  30220. }
  30221. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30222. // It returns an error if the edge is not defined in the schema.
  30223. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  30224. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  30225. }
  30226. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  30227. type UsageStatisticMonthMutation struct {
  30228. config
  30229. op Op
  30230. typ string
  30231. id *uint64
  30232. created_at *time.Time
  30233. updated_at *time.Time
  30234. status *uint8
  30235. addstatus *int8
  30236. deleted_at *time.Time
  30237. addtime *uint64
  30238. addaddtime *int64
  30239. _type *int
  30240. add_type *int
  30241. bot_id *string
  30242. organization_id *uint64
  30243. addorganization_id *int64
  30244. ai_response *uint64
  30245. addai_response *int64
  30246. sop_run *uint64
  30247. addsop_run *int64
  30248. total_friend *uint64
  30249. addtotal_friend *int64
  30250. total_group *uint64
  30251. addtotal_group *int64
  30252. account_balance *uint64
  30253. addaccount_balance *int64
  30254. consume_token *uint64
  30255. addconsume_token *int64
  30256. active_user *uint64
  30257. addactive_user *int64
  30258. new_user *int64
  30259. addnew_user *int64
  30260. label_dist *[]custom_types.LabelDist
  30261. appendlabel_dist []custom_types.LabelDist
  30262. clearedFields map[string]struct{}
  30263. done bool
  30264. oldValue func(context.Context) (*UsageStatisticMonth, error)
  30265. predicates []predicate.UsageStatisticMonth
  30266. }
  30267. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  30268. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  30269. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  30270. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  30271. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  30272. m := &UsageStatisticMonthMutation{
  30273. config: c,
  30274. op: op,
  30275. typ: TypeUsageStatisticMonth,
  30276. clearedFields: make(map[string]struct{}),
  30277. }
  30278. for _, opt := range opts {
  30279. opt(m)
  30280. }
  30281. return m
  30282. }
  30283. // withUsageStatisticMonthID sets the ID field of the mutation.
  30284. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  30285. return func(m *UsageStatisticMonthMutation) {
  30286. var (
  30287. err error
  30288. once sync.Once
  30289. value *UsageStatisticMonth
  30290. )
  30291. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  30292. once.Do(func() {
  30293. if m.done {
  30294. err = errors.New("querying old values post mutation is not allowed")
  30295. } else {
  30296. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  30297. }
  30298. })
  30299. return value, err
  30300. }
  30301. m.id = &id
  30302. }
  30303. }
  30304. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  30305. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  30306. return func(m *UsageStatisticMonthMutation) {
  30307. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  30308. return node, nil
  30309. }
  30310. m.id = &node.ID
  30311. }
  30312. }
  30313. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30314. // executed in a transaction (ent.Tx), a transactional client is returned.
  30315. func (m UsageStatisticMonthMutation) Client() *Client {
  30316. client := &Client{config: m.config}
  30317. client.init()
  30318. return client
  30319. }
  30320. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30321. // it returns an error otherwise.
  30322. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  30323. if _, ok := m.driver.(*txDriver); !ok {
  30324. return nil, errors.New("ent: mutation is not running in a transaction")
  30325. }
  30326. tx := &Tx{config: m.config}
  30327. tx.init()
  30328. return tx, nil
  30329. }
  30330. // SetID sets the value of the id field. Note that this
  30331. // operation is only accepted on creation of UsageStatisticMonth entities.
  30332. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  30333. m.id = &id
  30334. }
  30335. // ID returns the ID value in the mutation. Note that the ID is only available
  30336. // if it was provided to the builder or after it was returned from the database.
  30337. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  30338. if m.id == nil {
  30339. return
  30340. }
  30341. return *m.id, true
  30342. }
  30343. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30344. // That means, if the mutation is applied within a transaction with an isolation level such
  30345. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30346. // or updated by the mutation.
  30347. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  30348. switch {
  30349. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30350. id, exists := m.ID()
  30351. if exists {
  30352. return []uint64{id}, nil
  30353. }
  30354. fallthrough
  30355. case m.op.Is(OpUpdate | OpDelete):
  30356. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  30357. default:
  30358. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30359. }
  30360. }
  30361. // SetCreatedAt sets the "created_at" field.
  30362. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  30363. m.created_at = &t
  30364. }
  30365. // CreatedAt returns the value of the "created_at" field in the mutation.
  30366. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  30367. v := m.created_at
  30368. if v == nil {
  30369. return
  30370. }
  30371. return *v, true
  30372. }
  30373. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  30374. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  30375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30376. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30377. if !m.op.Is(OpUpdateOne) {
  30378. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30379. }
  30380. if m.id == nil || m.oldValue == nil {
  30381. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30382. }
  30383. oldValue, err := m.oldValue(ctx)
  30384. if err != nil {
  30385. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30386. }
  30387. return oldValue.CreatedAt, nil
  30388. }
  30389. // ResetCreatedAt resets all changes to the "created_at" field.
  30390. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  30391. m.created_at = nil
  30392. }
  30393. // SetUpdatedAt sets the "updated_at" field.
  30394. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  30395. m.updated_at = &t
  30396. }
  30397. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30398. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  30399. v := m.updated_at
  30400. if v == nil {
  30401. return
  30402. }
  30403. return *v, true
  30404. }
  30405. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  30406. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  30407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30408. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30409. if !m.op.Is(OpUpdateOne) {
  30410. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30411. }
  30412. if m.id == nil || m.oldValue == nil {
  30413. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30414. }
  30415. oldValue, err := m.oldValue(ctx)
  30416. if err != nil {
  30417. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30418. }
  30419. return oldValue.UpdatedAt, nil
  30420. }
  30421. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30422. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  30423. m.updated_at = nil
  30424. }
  30425. // SetStatus sets the "status" field.
  30426. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  30427. m.status = &u
  30428. m.addstatus = nil
  30429. }
  30430. // Status returns the value of the "status" field in the mutation.
  30431. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  30432. v := m.status
  30433. if v == nil {
  30434. return
  30435. }
  30436. return *v, true
  30437. }
  30438. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  30439. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  30440. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30441. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  30442. if !m.op.Is(OpUpdateOne) {
  30443. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  30444. }
  30445. if m.id == nil || m.oldValue == nil {
  30446. return v, errors.New("OldStatus requires an ID field in the mutation")
  30447. }
  30448. oldValue, err := m.oldValue(ctx)
  30449. if err != nil {
  30450. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  30451. }
  30452. return oldValue.Status, nil
  30453. }
  30454. // AddStatus adds u to the "status" field.
  30455. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  30456. if m.addstatus != nil {
  30457. *m.addstatus += u
  30458. } else {
  30459. m.addstatus = &u
  30460. }
  30461. }
  30462. // AddedStatus returns the value that was added to the "status" field in this mutation.
  30463. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  30464. v := m.addstatus
  30465. if v == nil {
  30466. return
  30467. }
  30468. return *v, true
  30469. }
  30470. // ClearStatus clears the value of the "status" field.
  30471. func (m *UsageStatisticMonthMutation) ClearStatus() {
  30472. m.status = nil
  30473. m.addstatus = nil
  30474. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  30475. }
  30476. // StatusCleared returns if the "status" field was cleared in this mutation.
  30477. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  30478. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  30479. return ok
  30480. }
  30481. // ResetStatus resets all changes to the "status" field.
  30482. func (m *UsageStatisticMonthMutation) ResetStatus() {
  30483. m.status = nil
  30484. m.addstatus = nil
  30485. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  30486. }
  30487. // SetDeletedAt sets the "deleted_at" field.
  30488. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  30489. m.deleted_at = &t
  30490. }
  30491. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30492. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  30493. v := m.deleted_at
  30494. if v == nil {
  30495. return
  30496. }
  30497. return *v, true
  30498. }
  30499. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  30500. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  30501. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30502. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30503. if !m.op.Is(OpUpdateOne) {
  30504. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30505. }
  30506. if m.id == nil || m.oldValue == nil {
  30507. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30508. }
  30509. oldValue, err := m.oldValue(ctx)
  30510. if err != nil {
  30511. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30512. }
  30513. return oldValue.DeletedAt, nil
  30514. }
  30515. // ClearDeletedAt clears the value of the "deleted_at" field.
  30516. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  30517. m.deleted_at = nil
  30518. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  30519. }
  30520. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30521. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  30522. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  30523. return ok
  30524. }
  30525. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30526. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  30527. m.deleted_at = nil
  30528. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  30529. }
  30530. // SetAddtime sets the "addtime" field.
  30531. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  30532. m.addtime = &u
  30533. m.addaddtime = nil
  30534. }
  30535. // Addtime returns the value of the "addtime" field in the mutation.
  30536. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  30537. v := m.addtime
  30538. if v == nil {
  30539. return
  30540. }
  30541. return *v, true
  30542. }
  30543. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  30544. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  30545. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30546. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  30547. if !m.op.Is(OpUpdateOne) {
  30548. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  30549. }
  30550. if m.id == nil || m.oldValue == nil {
  30551. return v, errors.New("OldAddtime requires an ID field in the mutation")
  30552. }
  30553. oldValue, err := m.oldValue(ctx)
  30554. if err != nil {
  30555. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  30556. }
  30557. return oldValue.Addtime, nil
  30558. }
  30559. // AddAddtime adds u to the "addtime" field.
  30560. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  30561. if m.addaddtime != nil {
  30562. *m.addaddtime += u
  30563. } else {
  30564. m.addaddtime = &u
  30565. }
  30566. }
  30567. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  30568. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  30569. v := m.addaddtime
  30570. if v == nil {
  30571. return
  30572. }
  30573. return *v, true
  30574. }
  30575. // ResetAddtime resets all changes to the "addtime" field.
  30576. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  30577. m.addtime = nil
  30578. m.addaddtime = nil
  30579. }
  30580. // SetType sets the "type" field.
  30581. func (m *UsageStatisticMonthMutation) SetType(i int) {
  30582. m._type = &i
  30583. m.add_type = nil
  30584. }
  30585. // GetType returns the value of the "type" field in the mutation.
  30586. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  30587. v := m._type
  30588. if v == nil {
  30589. return
  30590. }
  30591. return *v, true
  30592. }
  30593. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  30594. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  30595. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30596. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  30597. if !m.op.Is(OpUpdateOne) {
  30598. return v, errors.New("OldType is only allowed on UpdateOne operations")
  30599. }
  30600. if m.id == nil || m.oldValue == nil {
  30601. return v, errors.New("OldType requires an ID field in the mutation")
  30602. }
  30603. oldValue, err := m.oldValue(ctx)
  30604. if err != nil {
  30605. return v, fmt.Errorf("querying old value for OldType: %w", err)
  30606. }
  30607. return oldValue.Type, nil
  30608. }
  30609. // AddType adds i to the "type" field.
  30610. func (m *UsageStatisticMonthMutation) AddType(i int) {
  30611. if m.add_type != nil {
  30612. *m.add_type += i
  30613. } else {
  30614. m.add_type = &i
  30615. }
  30616. }
  30617. // AddedType returns the value that was added to the "type" field in this mutation.
  30618. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  30619. v := m.add_type
  30620. if v == nil {
  30621. return
  30622. }
  30623. return *v, true
  30624. }
  30625. // ResetType resets all changes to the "type" field.
  30626. func (m *UsageStatisticMonthMutation) ResetType() {
  30627. m._type = nil
  30628. m.add_type = nil
  30629. }
  30630. // SetBotID sets the "bot_id" field.
  30631. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  30632. m.bot_id = &s
  30633. }
  30634. // BotID returns the value of the "bot_id" field in the mutation.
  30635. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  30636. v := m.bot_id
  30637. if v == nil {
  30638. return
  30639. }
  30640. return *v, true
  30641. }
  30642. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  30643. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  30644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30645. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  30646. if !m.op.Is(OpUpdateOne) {
  30647. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  30648. }
  30649. if m.id == nil || m.oldValue == nil {
  30650. return v, errors.New("OldBotID requires an ID field in the mutation")
  30651. }
  30652. oldValue, err := m.oldValue(ctx)
  30653. if err != nil {
  30654. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  30655. }
  30656. return oldValue.BotID, nil
  30657. }
  30658. // ClearBotID clears the value of the "bot_id" field.
  30659. func (m *UsageStatisticMonthMutation) ClearBotID() {
  30660. m.bot_id = nil
  30661. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  30662. }
  30663. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  30664. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  30665. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  30666. return ok
  30667. }
  30668. // ResetBotID resets all changes to the "bot_id" field.
  30669. func (m *UsageStatisticMonthMutation) ResetBotID() {
  30670. m.bot_id = nil
  30671. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  30672. }
  30673. // SetOrganizationID sets the "organization_id" field.
  30674. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  30675. m.organization_id = &u
  30676. m.addorganization_id = nil
  30677. }
  30678. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30679. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  30680. v := m.organization_id
  30681. if v == nil {
  30682. return
  30683. }
  30684. return *v, true
  30685. }
  30686. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  30687. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  30688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30689. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30690. if !m.op.Is(OpUpdateOne) {
  30691. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30692. }
  30693. if m.id == nil || m.oldValue == nil {
  30694. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30695. }
  30696. oldValue, err := m.oldValue(ctx)
  30697. if err != nil {
  30698. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30699. }
  30700. return oldValue.OrganizationID, nil
  30701. }
  30702. // AddOrganizationID adds u to the "organization_id" field.
  30703. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  30704. if m.addorganization_id != nil {
  30705. *m.addorganization_id += u
  30706. } else {
  30707. m.addorganization_id = &u
  30708. }
  30709. }
  30710. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30711. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  30712. v := m.addorganization_id
  30713. if v == nil {
  30714. return
  30715. }
  30716. return *v, true
  30717. }
  30718. // ClearOrganizationID clears the value of the "organization_id" field.
  30719. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  30720. m.organization_id = nil
  30721. m.addorganization_id = nil
  30722. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  30723. }
  30724. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  30725. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  30726. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  30727. return ok
  30728. }
  30729. // ResetOrganizationID resets all changes to the "organization_id" field.
  30730. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  30731. m.organization_id = nil
  30732. m.addorganization_id = nil
  30733. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  30734. }
  30735. // SetAiResponse sets the "ai_response" field.
  30736. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  30737. m.ai_response = &u
  30738. m.addai_response = nil
  30739. }
  30740. // AiResponse returns the value of the "ai_response" field in the mutation.
  30741. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  30742. v := m.ai_response
  30743. if v == nil {
  30744. return
  30745. }
  30746. return *v, true
  30747. }
  30748. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  30749. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  30750. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30751. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  30752. if !m.op.Is(OpUpdateOne) {
  30753. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  30754. }
  30755. if m.id == nil || m.oldValue == nil {
  30756. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  30757. }
  30758. oldValue, err := m.oldValue(ctx)
  30759. if err != nil {
  30760. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  30761. }
  30762. return oldValue.AiResponse, nil
  30763. }
  30764. // AddAiResponse adds u to the "ai_response" field.
  30765. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  30766. if m.addai_response != nil {
  30767. *m.addai_response += u
  30768. } else {
  30769. m.addai_response = &u
  30770. }
  30771. }
  30772. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  30773. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  30774. v := m.addai_response
  30775. if v == nil {
  30776. return
  30777. }
  30778. return *v, true
  30779. }
  30780. // ResetAiResponse resets all changes to the "ai_response" field.
  30781. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  30782. m.ai_response = nil
  30783. m.addai_response = nil
  30784. }
  30785. // SetSopRun sets the "sop_run" field.
  30786. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  30787. m.sop_run = &u
  30788. m.addsop_run = nil
  30789. }
  30790. // SopRun returns the value of the "sop_run" field in the mutation.
  30791. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  30792. v := m.sop_run
  30793. if v == nil {
  30794. return
  30795. }
  30796. return *v, true
  30797. }
  30798. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  30799. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  30800. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30801. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  30802. if !m.op.Is(OpUpdateOne) {
  30803. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  30804. }
  30805. if m.id == nil || m.oldValue == nil {
  30806. return v, errors.New("OldSopRun requires an ID field in the mutation")
  30807. }
  30808. oldValue, err := m.oldValue(ctx)
  30809. if err != nil {
  30810. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  30811. }
  30812. return oldValue.SopRun, nil
  30813. }
  30814. // AddSopRun adds u to the "sop_run" field.
  30815. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  30816. if m.addsop_run != nil {
  30817. *m.addsop_run += u
  30818. } else {
  30819. m.addsop_run = &u
  30820. }
  30821. }
  30822. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  30823. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  30824. v := m.addsop_run
  30825. if v == nil {
  30826. return
  30827. }
  30828. return *v, true
  30829. }
  30830. // ResetSopRun resets all changes to the "sop_run" field.
  30831. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  30832. m.sop_run = nil
  30833. m.addsop_run = nil
  30834. }
  30835. // SetTotalFriend sets the "total_friend" field.
  30836. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  30837. m.total_friend = &u
  30838. m.addtotal_friend = nil
  30839. }
  30840. // TotalFriend returns the value of the "total_friend" field in the mutation.
  30841. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  30842. v := m.total_friend
  30843. if v == nil {
  30844. return
  30845. }
  30846. return *v, true
  30847. }
  30848. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  30849. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  30850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30851. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  30852. if !m.op.Is(OpUpdateOne) {
  30853. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  30854. }
  30855. if m.id == nil || m.oldValue == nil {
  30856. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  30857. }
  30858. oldValue, err := m.oldValue(ctx)
  30859. if err != nil {
  30860. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  30861. }
  30862. return oldValue.TotalFriend, nil
  30863. }
  30864. // AddTotalFriend adds u to the "total_friend" field.
  30865. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  30866. if m.addtotal_friend != nil {
  30867. *m.addtotal_friend += u
  30868. } else {
  30869. m.addtotal_friend = &u
  30870. }
  30871. }
  30872. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  30873. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  30874. v := m.addtotal_friend
  30875. if v == nil {
  30876. return
  30877. }
  30878. return *v, true
  30879. }
  30880. // ResetTotalFriend resets all changes to the "total_friend" field.
  30881. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  30882. m.total_friend = nil
  30883. m.addtotal_friend = nil
  30884. }
  30885. // SetTotalGroup sets the "total_group" field.
  30886. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  30887. m.total_group = &u
  30888. m.addtotal_group = nil
  30889. }
  30890. // TotalGroup returns the value of the "total_group" field in the mutation.
  30891. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  30892. v := m.total_group
  30893. if v == nil {
  30894. return
  30895. }
  30896. return *v, true
  30897. }
  30898. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  30899. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  30900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30901. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  30902. if !m.op.Is(OpUpdateOne) {
  30903. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  30904. }
  30905. if m.id == nil || m.oldValue == nil {
  30906. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  30907. }
  30908. oldValue, err := m.oldValue(ctx)
  30909. if err != nil {
  30910. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  30911. }
  30912. return oldValue.TotalGroup, nil
  30913. }
  30914. // AddTotalGroup adds u to the "total_group" field.
  30915. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  30916. if m.addtotal_group != nil {
  30917. *m.addtotal_group += u
  30918. } else {
  30919. m.addtotal_group = &u
  30920. }
  30921. }
  30922. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  30923. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  30924. v := m.addtotal_group
  30925. if v == nil {
  30926. return
  30927. }
  30928. return *v, true
  30929. }
  30930. // ResetTotalGroup resets all changes to the "total_group" field.
  30931. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  30932. m.total_group = nil
  30933. m.addtotal_group = nil
  30934. }
  30935. // SetAccountBalance sets the "account_balance" field.
  30936. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  30937. m.account_balance = &u
  30938. m.addaccount_balance = nil
  30939. }
  30940. // AccountBalance returns the value of the "account_balance" field in the mutation.
  30941. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  30942. v := m.account_balance
  30943. if v == nil {
  30944. return
  30945. }
  30946. return *v, true
  30947. }
  30948. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  30949. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  30950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30951. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  30952. if !m.op.Is(OpUpdateOne) {
  30953. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  30954. }
  30955. if m.id == nil || m.oldValue == nil {
  30956. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  30957. }
  30958. oldValue, err := m.oldValue(ctx)
  30959. if err != nil {
  30960. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  30961. }
  30962. return oldValue.AccountBalance, nil
  30963. }
  30964. // AddAccountBalance adds u to the "account_balance" field.
  30965. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  30966. if m.addaccount_balance != nil {
  30967. *m.addaccount_balance += u
  30968. } else {
  30969. m.addaccount_balance = &u
  30970. }
  30971. }
  30972. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  30973. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  30974. v := m.addaccount_balance
  30975. if v == nil {
  30976. return
  30977. }
  30978. return *v, true
  30979. }
  30980. // ResetAccountBalance resets all changes to the "account_balance" field.
  30981. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  30982. m.account_balance = nil
  30983. m.addaccount_balance = nil
  30984. }
  30985. // SetConsumeToken sets the "consume_token" field.
  30986. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  30987. m.consume_token = &u
  30988. m.addconsume_token = nil
  30989. }
  30990. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  30991. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  30992. v := m.consume_token
  30993. if v == nil {
  30994. return
  30995. }
  30996. return *v, true
  30997. }
  30998. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  30999. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31001. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31002. if !m.op.Is(OpUpdateOne) {
  31003. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31004. }
  31005. if m.id == nil || m.oldValue == nil {
  31006. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31007. }
  31008. oldValue, err := m.oldValue(ctx)
  31009. if err != nil {
  31010. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31011. }
  31012. return oldValue.ConsumeToken, nil
  31013. }
  31014. // AddConsumeToken adds u to the "consume_token" field.
  31015. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  31016. if m.addconsume_token != nil {
  31017. *m.addconsume_token += u
  31018. } else {
  31019. m.addconsume_token = &u
  31020. }
  31021. }
  31022. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31023. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  31024. v := m.addconsume_token
  31025. if v == nil {
  31026. return
  31027. }
  31028. return *v, true
  31029. }
  31030. // ResetConsumeToken resets all changes to the "consume_token" field.
  31031. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  31032. m.consume_token = nil
  31033. m.addconsume_token = nil
  31034. }
  31035. // SetActiveUser sets the "active_user" field.
  31036. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  31037. m.active_user = &u
  31038. m.addactive_user = nil
  31039. }
  31040. // ActiveUser returns the value of the "active_user" field in the mutation.
  31041. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  31042. v := m.active_user
  31043. if v == nil {
  31044. return
  31045. }
  31046. return *v, true
  31047. }
  31048. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  31049. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31051. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  31052. if !m.op.Is(OpUpdateOne) {
  31053. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  31054. }
  31055. if m.id == nil || m.oldValue == nil {
  31056. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  31057. }
  31058. oldValue, err := m.oldValue(ctx)
  31059. if err != nil {
  31060. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  31061. }
  31062. return oldValue.ActiveUser, nil
  31063. }
  31064. // AddActiveUser adds u to the "active_user" field.
  31065. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  31066. if m.addactive_user != nil {
  31067. *m.addactive_user += u
  31068. } else {
  31069. m.addactive_user = &u
  31070. }
  31071. }
  31072. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  31073. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  31074. v := m.addactive_user
  31075. if v == nil {
  31076. return
  31077. }
  31078. return *v, true
  31079. }
  31080. // ResetActiveUser resets all changes to the "active_user" field.
  31081. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  31082. m.active_user = nil
  31083. m.addactive_user = nil
  31084. }
  31085. // SetNewUser sets the "new_user" field.
  31086. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  31087. m.new_user = &i
  31088. m.addnew_user = nil
  31089. }
  31090. // NewUser returns the value of the "new_user" field in the mutation.
  31091. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  31092. v := m.new_user
  31093. if v == nil {
  31094. return
  31095. }
  31096. return *v, true
  31097. }
  31098. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  31099. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31100. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31101. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  31102. if !m.op.Is(OpUpdateOne) {
  31103. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  31104. }
  31105. if m.id == nil || m.oldValue == nil {
  31106. return v, errors.New("OldNewUser requires an ID field in the mutation")
  31107. }
  31108. oldValue, err := m.oldValue(ctx)
  31109. if err != nil {
  31110. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  31111. }
  31112. return oldValue.NewUser, nil
  31113. }
  31114. // AddNewUser adds i to the "new_user" field.
  31115. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  31116. if m.addnew_user != nil {
  31117. *m.addnew_user += i
  31118. } else {
  31119. m.addnew_user = &i
  31120. }
  31121. }
  31122. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  31123. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  31124. v := m.addnew_user
  31125. if v == nil {
  31126. return
  31127. }
  31128. return *v, true
  31129. }
  31130. // ResetNewUser resets all changes to the "new_user" field.
  31131. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  31132. m.new_user = nil
  31133. m.addnew_user = nil
  31134. }
  31135. // SetLabelDist sets the "label_dist" field.
  31136. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  31137. m.label_dist = &ctd
  31138. m.appendlabel_dist = nil
  31139. }
  31140. // LabelDist returns the value of the "label_dist" field in the mutation.
  31141. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  31142. v := m.label_dist
  31143. if v == nil {
  31144. return
  31145. }
  31146. return *v, true
  31147. }
  31148. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  31149. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31151. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  31152. if !m.op.Is(OpUpdateOne) {
  31153. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  31154. }
  31155. if m.id == nil || m.oldValue == nil {
  31156. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  31157. }
  31158. oldValue, err := m.oldValue(ctx)
  31159. if err != nil {
  31160. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  31161. }
  31162. return oldValue.LabelDist, nil
  31163. }
  31164. // AppendLabelDist adds ctd to the "label_dist" field.
  31165. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  31166. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  31167. }
  31168. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  31169. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  31170. if len(m.appendlabel_dist) == 0 {
  31171. return nil, false
  31172. }
  31173. return m.appendlabel_dist, true
  31174. }
  31175. // ResetLabelDist resets all changes to the "label_dist" field.
  31176. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  31177. m.label_dist = nil
  31178. m.appendlabel_dist = nil
  31179. }
  31180. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  31181. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  31182. m.predicates = append(m.predicates, ps...)
  31183. }
  31184. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  31185. // users can use type-assertion to append predicates that do not depend on any generated package.
  31186. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  31187. p := make([]predicate.UsageStatisticMonth, len(ps))
  31188. for i := range ps {
  31189. p[i] = ps[i]
  31190. }
  31191. m.Where(p...)
  31192. }
  31193. // Op returns the operation name.
  31194. func (m *UsageStatisticMonthMutation) Op() Op {
  31195. return m.op
  31196. }
  31197. // SetOp allows setting the mutation operation.
  31198. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  31199. m.op = op
  31200. }
  31201. // Type returns the node type of this mutation (UsageStatisticMonth).
  31202. func (m *UsageStatisticMonthMutation) Type() string {
  31203. return m.typ
  31204. }
  31205. // Fields returns all fields that were changed during this mutation. Note that in
  31206. // order to get all numeric fields that were incremented/decremented, call
  31207. // AddedFields().
  31208. func (m *UsageStatisticMonthMutation) Fields() []string {
  31209. fields := make([]string, 0, 17)
  31210. if m.created_at != nil {
  31211. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  31212. }
  31213. if m.updated_at != nil {
  31214. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  31215. }
  31216. if m.status != nil {
  31217. fields = append(fields, usagestatisticmonth.FieldStatus)
  31218. }
  31219. if m.deleted_at != nil {
  31220. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  31221. }
  31222. if m.addtime != nil {
  31223. fields = append(fields, usagestatisticmonth.FieldAddtime)
  31224. }
  31225. if m._type != nil {
  31226. fields = append(fields, usagestatisticmonth.FieldType)
  31227. }
  31228. if m.bot_id != nil {
  31229. fields = append(fields, usagestatisticmonth.FieldBotID)
  31230. }
  31231. if m.organization_id != nil {
  31232. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  31233. }
  31234. if m.ai_response != nil {
  31235. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  31236. }
  31237. if m.sop_run != nil {
  31238. fields = append(fields, usagestatisticmonth.FieldSopRun)
  31239. }
  31240. if m.total_friend != nil {
  31241. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  31242. }
  31243. if m.total_group != nil {
  31244. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  31245. }
  31246. if m.account_balance != nil {
  31247. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  31248. }
  31249. if m.consume_token != nil {
  31250. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  31251. }
  31252. if m.active_user != nil {
  31253. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  31254. }
  31255. if m.new_user != nil {
  31256. fields = append(fields, usagestatisticmonth.FieldNewUser)
  31257. }
  31258. if m.label_dist != nil {
  31259. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  31260. }
  31261. return fields
  31262. }
  31263. // Field returns the value of a field with the given name. The second boolean
  31264. // return value indicates that this field was not set, or was not defined in the
  31265. // schema.
  31266. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  31267. switch name {
  31268. case usagestatisticmonth.FieldCreatedAt:
  31269. return m.CreatedAt()
  31270. case usagestatisticmonth.FieldUpdatedAt:
  31271. return m.UpdatedAt()
  31272. case usagestatisticmonth.FieldStatus:
  31273. return m.Status()
  31274. case usagestatisticmonth.FieldDeletedAt:
  31275. return m.DeletedAt()
  31276. case usagestatisticmonth.FieldAddtime:
  31277. return m.Addtime()
  31278. case usagestatisticmonth.FieldType:
  31279. return m.GetType()
  31280. case usagestatisticmonth.FieldBotID:
  31281. return m.BotID()
  31282. case usagestatisticmonth.FieldOrganizationID:
  31283. return m.OrganizationID()
  31284. case usagestatisticmonth.FieldAiResponse:
  31285. return m.AiResponse()
  31286. case usagestatisticmonth.FieldSopRun:
  31287. return m.SopRun()
  31288. case usagestatisticmonth.FieldTotalFriend:
  31289. return m.TotalFriend()
  31290. case usagestatisticmonth.FieldTotalGroup:
  31291. return m.TotalGroup()
  31292. case usagestatisticmonth.FieldAccountBalance:
  31293. return m.AccountBalance()
  31294. case usagestatisticmonth.FieldConsumeToken:
  31295. return m.ConsumeToken()
  31296. case usagestatisticmonth.FieldActiveUser:
  31297. return m.ActiveUser()
  31298. case usagestatisticmonth.FieldNewUser:
  31299. return m.NewUser()
  31300. case usagestatisticmonth.FieldLabelDist:
  31301. return m.LabelDist()
  31302. }
  31303. return nil, false
  31304. }
  31305. // OldField returns the old value of the field from the database. An error is
  31306. // returned if the mutation operation is not UpdateOne, or the query to the
  31307. // database failed.
  31308. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31309. switch name {
  31310. case usagestatisticmonth.FieldCreatedAt:
  31311. return m.OldCreatedAt(ctx)
  31312. case usagestatisticmonth.FieldUpdatedAt:
  31313. return m.OldUpdatedAt(ctx)
  31314. case usagestatisticmonth.FieldStatus:
  31315. return m.OldStatus(ctx)
  31316. case usagestatisticmonth.FieldDeletedAt:
  31317. return m.OldDeletedAt(ctx)
  31318. case usagestatisticmonth.FieldAddtime:
  31319. return m.OldAddtime(ctx)
  31320. case usagestatisticmonth.FieldType:
  31321. return m.OldType(ctx)
  31322. case usagestatisticmonth.FieldBotID:
  31323. return m.OldBotID(ctx)
  31324. case usagestatisticmonth.FieldOrganizationID:
  31325. return m.OldOrganizationID(ctx)
  31326. case usagestatisticmonth.FieldAiResponse:
  31327. return m.OldAiResponse(ctx)
  31328. case usagestatisticmonth.FieldSopRun:
  31329. return m.OldSopRun(ctx)
  31330. case usagestatisticmonth.FieldTotalFriend:
  31331. return m.OldTotalFriend(ctx)
  31332. case usagestatisticmonth.FieldTotalGroup:
  31333. return m.OldTotalGroup(ctx)
  31334. case usagestatisticmonth.FieldAccountBalance:
  31335. return m.OldAccountBalance(ctx)
  31336. case usagestatisticmonth.FieldConsumeToken:
  31337. return m.OldConsumeToken(ctx)
  31338. case usagestatisticmonth.FieldActiveUser:
  31339. return m.OldActiveUser(ctx)
  31340. case usagestatisticmonth.FieldNewUser:
  31341. return m.OldNewUser(ctx)
  31342. case usagestatisticmonth.FieldLabelDist:
  31343. return m.OldLabelDist(ctx)
  31344. }
  31345. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  31346. }
  31347. // SetField sets the value of a field with the given name. It returns an error if
  31348. // the field is not defined in the schema, or if the type mismatched the field
  31349. // type.
  31350. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  31351. switch name {
  31352. case usagestatisticmonth.FieldCreatedAt:
  31353. v, ok := value.(time.Time)
  31354. if !ok {
  31355. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31356. }
  31357. m.SetCreatedAt(v)
  31358. return nil
  31359. case usagestatisticmonth.FieldUpdatedAt:
  31360. v, ok := value.(time.Time)
  31361. if !ok {
  31362. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31363. }
  31364. m.SetUpdatedAt(v)
  31365. return nil
  31366. case usagestatisticmonth.FieldStatus:
  31367. v, ok := value.(uint8)
  31368. if !ok {
  31369. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31370. }
  31371. m.SetStatus(v)
  31372. return nil
  31373. case usagestatisticmonth.FieldDeletedAt:
  31374. v, ok := value.(time.Time)
  31375. if !ok {
  31376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31377. }
  31378. m.SetDeletedAt(v)
  31379. return nil
  31380. case usagestatisticmonth.FieldAddtime:
  31381. v, ok := value.(uint64)
  31382. if !ok {
  31383. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31384. }
  31385. m.SetAddtime(v)
  31386. return nil
  31387. case usagestatisticmonth.FieldType:
  31388. v, ok := value.(int)
  31389. if !ok {
  31390. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31391. }
  31392. m.SetType(v)
  31393. return nil
  31394. case usagestatisticmonth.FieldBotID:
  31395. v, ok := value.(string)
  31396. if !ok {
  31397. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31398. }
  31399. m.SetBotID(v)
  31400. return nil
  31401. case usagestatisticmonth.FieldOrganizationID:
  31402. v, ok := value.(uint64)
  31403. if !ok {
  31404. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31405. }
  31406. m.SetOrganizationID(v)
  31407. return nil
  31408. case usagestatisticmonth.FieldAiResponse:
  31409. v, ok := value.(uint64)
  31410. if !ok {
  31411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31412. }
  31413. m.SetAiResponse(v)
  31414. return nil
  31415. case usagestatisticmonth.FieldSopRun:
  31416. v, ok := value.(uint64)
  31417. if !ok {
  31418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31419. }
  31420. m.SetSopRun(v)
  31421. return nil
  31422. case usagestatisticmonth.FieldTotalFriend:
  31423. v, ok := value.(uint64)
  31424. if !ok {
  31425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31426. }
  31427. m.SetTotalFriend(v)
  31428. return nil
  31429. case usagestatisticmonth.FieldTotalGroup:
  31430. v, ok := value.(uint64)
  31431. if !ok {
  31432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31433. }
  31434. m.SetTotalGroup(v)
  31435. return nil
  31436. case usagestatisticmonth.FieldAccountBalance:
  31437. v, ok := value.(uint64)
  31438. if !ok {
  31439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31440. }
  31441. m.SetAccountBalance(v)
  31442. return nil
  31443. case usagestatisticmonth.FieldConsumeToken:
  31444. v, ok := value.(uint64)
  31445. if !ok {
  31446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31447. }
  31448. m.SetConsumeToken(v)
  31449. return nil
  31450. case usagestatisticmonth.FieldActiveUser:
  31451. v, ok := value.(uint64)
  31452. if !ok {
  31453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31454. }
  31455. m.SetActiveUser(v)
  31456. return nil
  31457. case usagestatisticmonth.FieldNewUser:
  31458. v, ok := value.(int64)
  31459. if !ok {
  31460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31461. }
  31462. m.SetNewUser(v)
  31463. return nil
  31464. case usagestatisticmonth.FieldLabelDist:
  31465. v, ok := value.([]custom_types.LabelDist)
  31466. if !ok {
  31467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31468. }
  31469. m.SetLabelDist(v)
  31470. return nil
  31471. }
  31472. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  31473. }
  31474. // AddedFields returns all numeric fields that were incremented/decremented during
  31475. // this mutation.
  31476. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  31477. var fields []string
  31478. if m.addstatus != nil {
  31479. fields = append(fields, usagestatisticmonth.FieldStatus)
  31480. }
  31481. if m.addaddtime != nil {
  31482. fields = append(fields, usagestatisticmonth.FieldAddtime)
  31483. }
  31484. if m.add_type != nil {
  31485. fields = append(fields, usagestatisticmonth.FieldType)
  31486. }
  31487. if m.addorganization_id != nil {
  31488. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  31489. }
  31490. if m.addai_response != nil {
  31491. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  31492. }
  31493. if m.addsop_run != nil {
  31494. fields = append(fields, usagestatisticmonth.FieldSopRun)
  31495. }
  31496. if m.addtotal_friend != nil {
  31497. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  31498. }
  31499. if m.addtotal_group != nil {
  31500. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  31501. }
  31502. if m.addaccount_balance != nil {
  31503. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  31504. }
  31505. if m.addconsume_token != nil {
  31506. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  31507. }
  31508. if m.addactive_user != nil {
  31509. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  31510. }
  31511. if m.addnew_user != nil {
  31512. fields = append(fields, usagestatisticmonth.FieldNewUser)
  31513. }
  31514. return fields
  31515. }
  31516. // AddedField returns the numeric value that was incremented/decremented on a field
  31517. // with the given name. The second boolean return value indicates that this field
  31518. // was not set, or was not defined in the schema.
  31519. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  31520. switch name {
  31521. case usagestatisticmonth.FieldStatus:
  31522. return m.AddedStatus()
  31523. case usagestatisticmonth.FieldAddtime:
  31524. return m.AddedAddtime()
  31525. case usagestatisticmonth.FieldType:
  31526. return m.AddedType()
  31527. case usagestatisticmonth.FieldOrganizationID:
  31528. return m.AddedOrganizationID()
  31529. case usagestatisticmonth.FieldAiResponse:
  31530. return m.AddedAiResponse()
  31531. case usagestatisticmonth.FieldSopRun:
  31532. return m.AddedSopRun()
  31533. case usagestatisticmonth.FieldTotalFriend:
  31534. return m.AddedTotalFriend()
  31535. case usagestatisticmonth.FieldTotalGroup:
  31536. return m.AddedTotalGroup()
  31537. case usagestatisticmonth.FieldAccountBalance:
  31538. return m.AddedAccountBalance()
  31539. case usagestatisticmonth.FieldConsumeToken:
  31540. return m.AddedConsumeToken()
  31541. case usagestatisticmonth.FieldActiveUser:
  31542. return m.AddedActiveUser()
  31543. case usagestatisticmonth.FieldNewUser:
  31544. return m.AddedNewUser()
  31545. }
  31546. return nil, false
  31547. }
  31548. // AddField adds the value to the field with the given name. It returns an error if
  31549. // the field is not defined in the schema, or if the type mismatched the field
  31550. // type.
  31551. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  31552. switch name {
  31553. case usagestatisticmonth.FieldStatus:
  31554. v, ok := value.(int8)
  31555. if !ok {
  31556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31557. }
  31558. m.AddStatus(v)
  31559. return nil
  31560. case usagestatisticmonth.FieldAddtime:
  31561. v, ok := value.(int64)
  31562. if !ok {
  31563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31564. }
  31565. m.AddAddtime(v)
  31566. return nil
  31567. case usagestatisticmonth.FieldType:
  31568. v, ok := value.(int)
  31569. if !ok {
  31570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31571. }
  31572. m.AddType(v)
  31573. return nil
  31574. case usagestatisticmonth.FieldOrganizationID:
  31575. v, ok := value.(int64)
  31576. if !ok {
  31577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31578. }
  31579. m.AddOrganizationID(v)
  31580. return nil
  31581. case usagestatisticmonth.FieldAiResponse:
  31582. v, ok := value.(int64)
  31583. if !ok {
  31584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31585. }
  31586. m.AddAiResponse(v)
  31587. return nil
  31588. case usagestatisticmonth.FieldSopRun:
  31589. v, ok := value.(int64)
  31590. if !ok {
  31591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31592. }
  31593. m.AddSopRun(v)
  31594. return nil
  31595. case usagestatisticmonth.FieldTotalFriend:
  31596. v, ok := value.(int64)
  31597. if !ok {
  31598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31599. }
  31600. m.AddTotalFriend(v)
  31601. return nil
  31602. case usagestatisticmonth.FieldTotalGroup:
  31603. v, ok := value.(int64)
  31604. if !ok {
  31605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31606. }
  31607. m.AddTotalGroup(v)
  31608. return nil
  31609. case usagestatisticmonth.FieldAccountBalance:
  31610. v, ok := value.(int64)
  31611. if !ok {
  31612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31613. }
  31614. m.AddAccountBalance(v)
  31615. return nil
  31616. case usagestatisticmonth.FieldConsumeToken:
  31617. v, ok := value.(int64)
  31618. if !ok {
  31619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31620. }
  31621. m.AddConsumeToken(v)
  31622. return nil
  31623. case usagestatisticmonth.FieldActiveUser:
  31624. v, ok := value.(int64)
  31625. if !ok {
  31626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31627. }
  31628. m.AddActiveUser(v)
  31629. return nil
  31630. case usagestatisticmonth.FieldNewUser:
  31631. v, ok := value.(int64)
  31632. if !ok {
  31633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31634. }
  31635. m.AddNewUser(v)
  31636. return nil
  31637. }
  31638. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  31639. }
  31640. // ClearedFields returns all nullable fields that were cleared during this
  31641. // mutation.
  31642. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  31643. var fields []string
  31644. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  31645. fields = append(fields, usagestatisticmonth.FieldStatus)
  31646. }
  31647. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  31648. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  31649. }
  31650. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  31651. fields = append(fields, usagestatisticmonth.FieldBotID)
  31652. }
  31653. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  31654. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  31655. }
  31656. return fields
  31657. }
  31658. // FieldCleared returns a boolean indicating if a field with the given name was
  31659. // cleared in this mutation.
  31660. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  31661. _, ok := m.clearedFields[name]
  31662. return ok
  31663. }
  31664. // ClearField clears the value of the field with the given name. It returns an
  31665. // error if the field is not defined in the schema.
  31666. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  31667. switch name {
  31668. case usagestatisticmonth.FieldStatus:
  31669. m.ClearStatus()
  31670. return nil
  31671. case usagestatisticmonth.FieldDeletedAt:
  31672. m.ClearDeletedAt()
  31673. return nil
  31674. case usagestatisticmonth.FieldBotID:
  31675. m.ClearBotID()
  31676. return nil
  31677. case usagestatisticmonth.FieldOrganizationID:
  31678. m.ClearOrganizationID()
  31679. return nil
  31680. }
  31681. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  31682. }
  31683. // ResetField resets all changes in the mutation for the field with the given name.
  31684. // It returns an error if the field is not defined in the schema.
  31685. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  31686. switch name {
  31687. case usagestatisticmonth.FieldCreatedAt:
  31688. m.ResetCreatedAt()
  31689. return nil
  31690. case usagestatisticmonth.FieldUpdatedAt:
  31691. m.ResetUpdatedAt()
  31692. return nil
  31693. case usagestatisticmonth.FieldStatus:
  31694. m.ResetStatus()
  31695. return nil
  31696. case usagestatisticmonth.FieldDeletedAt:
  31697. m.ResetDeletedAt()
  31698. return nil
  31699. case usagestatisticmonth.FieldAddtime:
  31700. m.ResetAddtime()
  31701. return nil
  31702. case usagestatisticmonth.FieldType:
  31703. m.ResetType()
  31704. return nil
  31705. case usagestatisticmonth.FieldBotID:
  31706. m.ResetBotID()
  31707. return nil
  31708. case usagestatisticmonth.FieldOrganizationID:
  31709. m.ResetOrganizationID()
  31710. return nil
  31711. case usagestatisticmonth.FieldAiResponse:
  31712. m.ResetAiResponse()
  31713. return nil
  31714. case usagestatisticmonth.FieldSopRun:
  31715. m.ResetSopRun()
  31716. return nil
  31717. case usagestatisticmonth.FieldTotalFriend:
  31718. m.ResetTotalFriend()
  31719. return nil
  31720. case usagestatisticmonth.FieldTotalGroup:
  31721. m.ResetTotalGroup()
  31722. return nil
  31723. case usagestatisticmonth.FieldAccountBalance:
  31724. m.ResetAccountBalance()
  31725. return nil
  31726. case usagestatisticmonth.FieldConsumeToken:
  31727. m.ResetConsumeToken()
  31728. return nil
  31729. case usagestatisticmonth.FieldActiveUser:
  31730. m.ResetActiveUser()
  31731. return nil
  31732. case usagestatisticmonth.FieldNewUser:
  31733. m.ResetNewUser()
  31734. return nil
  31735. case usagestatisticmonth.FieldLabelDist:
  31736. m.ResetLabelDist()
  31737. return nil
  31738. }
  31739. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  31740. }
  31741. // AddedEdges returns all edge names that were set/added in this mutation.
  31742. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  31743. edges := make([]string, 0, 0)
  31744. return edges
  31745. }
  31746. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31747. // name in this mutation.
  31748. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  31749. return nil
  31750. }
  31751. // RemovedEdges returns all edge names that were removed in this mutation.
  31752. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  31753. edges := make([]string, 0, 0)
  31754. return edges
  31755. }
  31756. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31757. // the given name in this mutation.
  31758. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  31759. return nil
  31760. }
  31761. // ClearedEdges returns all edge names that were cleared in this mutation.
  31762. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  31763. edges := make([]string, 0, 0)
  31764. return edges
  31765. }
  31766. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31767. // was cleared in this mutation.
  31768. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  31769. return false
  31770. }
  31771. // ClearEdge clears the value of the edge with the given name. It returns an error
  31772. // if that edge is not defined in the schema.
  31773. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  31774. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  31775. }
  31776. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31777. // It returns an error if the edge is not defined in the schema.
  31778. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  31779. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  31780. }
  31781. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  31782. type UsageTotalMutation struct {
  31783. config
  31784. op Op
  31785. typ string
  31786. id *uint64
  31787. created_at *time.Time
  31788. updated_at *time.Time
  31789. status *uint8
  31790. addstatus *int8
  31791. _type *int
  31792. add_type *int
  31793. bot_id *string
  31794. total_tokens *uint64
  31795. addtotal_tokens *int64
  31796. start_index *uint64
  31797. addstart_index *int64
  31798. end_index *uint64
  31799. addend_index *int64
  31800. organization_id *uint64
  31801. addorganization_id *int64
  31802. clearedFields map[string]struct{}
  31803. done bool
  31804. oldValue func(context.Context) (*UsageTotal, error)
  31805. predicates []predicate.UsageTotal
  31806. }
  31807. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  31808. // usagetotalOption allows management of the mutation configuration using functional options.
  31809. type usagetotalOption func(*UsageTotalMutation)
  31810. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  31811. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  31812. m := &UsageTotalMutation{
  31813. config: c,
  31814. op: op,
  31815. typ: TypeUsageTotal,
  31816. clearedFields: make(map[string]struct{}),
  31817. }
  31818. for _, opt := range opts {
  31819. opt(m)
  31820. }
  31821. return m
  31822. }
  31823. // withUsageTotalID sets the ID field of the mutation.
  31824. func withUsageTotalID(id uint64) usagetotalOption {
  31825. return func(m *UsageTotalMutation) {
  31826. var (
  31827. err error
  31828. once sync.Once
  31829. value *UsageTotal
  31830. )
  31831. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  31832. once.Do(func() {
  31833. if m.done {
  31834. err = errors.New("querying old values post mutation is not allowed")
  31835. } else {
  31836. value, err = m.Client().UsageTotal.Get(ctx, id)
  31837. }
  31838. })
  31839. return value, err
  31840. }
  31841. m.id = &id
  31842. }
  31843. }
  31844. // withUsageTotal sets the old UsageTotal of the mutation.
  31845. func withUsageTotal(node *UsageTotal) usagetotalOption {
  31846. return func(m *UsageTotalMutation) {
  31847. m.oldValue = func(context.Context) (*UsageTotal, error) {
  31848. return node, nil
  31849. }
  31850. m.id = &node.ID
  31851. }
  31852. }
  31853. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31854. // executed in a transaction (ent.Tx), a transactional client is returned.
  31855. func (m UsageTotalMutation) Client() *Client {
  31856. client := &Client{config: m.config}
  31857. client.init()
  31858. return client
  31859. }
  31860. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31861. // it returns an error otherwise.
  31862. func (m UsageTotalMutation) Tx() (*Tx, error) {
  31863. if _, ok := m.driver.(*txDriver); !ok {
  31864. return nil, errors.New("ent: mutation is not running in a transaction")
  31865. }
  31866. tx := &Tx{config: m.config}
  31867. tx.init()
  31868. return tx, nil
  31869. }
  31870. // SetID sets the value of the id field. Note that this
  31871. // operation is only accepted on creation of UsageTotal entities.
  31872. func (m *UsageTotalMutation) SetID(id uint64) {
  31873. m.id = &id
  31874. }
  31875. // ID returns the ID value in the mutation. Note that the ID is only available
  31876. // if it was provided to the builder or after it was returned from the database.
  31877. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  31878. if m.id == nil {
  31879. return
  31880. }
  31881. return *m.id, true
  31882. }
  31883. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31884. // That means, if the mutation is applied within a transaction with an isolation level such
  31885. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31886. // or updated by the mutation.
  31887. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  31888. switch {
  31889. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31890. id, exists := m.ID()
  31891. if exists {
  31892. return []uint64{id}, nil
  31893. }
  31894. fallthrough
  31895. case m.op.Is(OpUpdate | OpDelete):
  31896. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  31897. default:
  31898. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31899. }
  31900. }
  31901. // SetCreatedAt sets the "created_at" field.
  31902. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  31903. m.created_at = &t
  31904. }
  31905. // CreatedAt returns the value of the "created_at" field in the mutation.
  31906. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  31907. v := m.created_at
  31908. if v == nil {
  31909. return
  31910. }
  31911. return *v, true
  31912. }
  31913. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  31914. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  31915. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31916. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31917. if !m.op.Is(OpUpdateOne) {
  31918. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31919. }
  31920. if m.id == nil || m.oldValue == nil {
  31921. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31922. }
  31923. oldValue, err := m.oldValue(ctx)
  31924. if err != nil {
  31925. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31926. }
  31927. return oldValue.CreatedAt, nil
  31928. }
  31929. // ResetCreatedAt resets all changes to the "created_at" field.
  31930. func (m *UsageTotalMutation) ResetCreatedAt() {
  31931. m.created_at = nil
  31932. }
  31933. // SetUpdatedAt sets the "updated_at" field.
  31934. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  31935. m.updated_at = &t
  31936. }
  31937. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31938. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  31939. v := m.updated_at
  31940. if v == nil {
  31941. return
  31942. }
  31943. return *v, true
  31944. }
  31945. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  31946. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  31947. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31948. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31949. if !m.op.Is(OpUpdateOne) {
  31950. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31951. }
  31952. if m.id == nil || m.oldValue == nil {
  31953. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31954. }
  31955. oldValue, err := m.oldValue(ctx)
  31956. if err != nil {
  31957. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31958. }
  31959. return oldValue.UpdatedAt, nil
  31960. }
  31961. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31962. func (m *UsageTotalMutation) ResetUpdatedAt() {
  31963. m.updated_at = nil
  31964. }
  31965. // SetStatus sets the "status" field.
  31966. func (m *UsageTotalMutation) SetStatus(u uint8) {
  31967. m.status = &u
  31968. m.addstatus = nil
  31969. }
  31970. // Status returns the value of the "status" field in the mutation.
  31971. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  31972. v := m.status
  31973. if v == nil {
  31974. return
  31975. }
  31976. return *v, true
  31977. }
  31978. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  31979. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  31980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31981. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31982. if !m.op.Is(OpUpdateOne) {
  31983. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31984. }
  31985. if m.id == nil || m.oldValue == nil {
  31986. return v, errors.New("OldStatus requires an ID field in the mutation")
  31987. }
  31988. oldValue, err := m.oldValue(ctx)
  31989. if err != nil {
  31990. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31991. }
  31992. return oldValue.Status, nil
  31993. }
  31994. // AddStatus adds u to the "status" field.
  31995. func (m *UsageTotalMutation) AddStatus(u int8) {
  31996. if m.addstatus != nil {
  31997. *m.addstatus += u
  31998. } else {
  31999. m.addstatus = &u
  32000. }
  32001. }
  32002. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32003. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  32004. v := m.addstatus
  32005. if v == nil {
  32006. return
  32007. }
  32008. return *v, true
  32009. }
  32010. // ClearStatus clears the value of the "status" field.
  32011. func (m *UsageTotalMutation) ClearStatus() {
  32012. m.status = nil
  32013. m.addstatus = nil
  32014. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  32015. }
  32016. // StatusCleared returns if the "status" field was cleared in this mutation.
  32017. func (m *UsageTotalMutation) StatusCleared() bool {
  32018. _, ok := m.clearedFields[usagetotal.FieldStatus]
  32019. return ok
  32020. }
  32021. // ResetStatus resets all changes to the "status" field.
  32022. func (m *UsageTotalMutation) ResetStatus() {
  32023. m.status = nil
  32024. m.addstatus = nil
  32025. delete(m.clearedFields, usagetotal.FieldStatus)
  32026. }
  32027. // SetType sets the "type" field.
  32028. func (m *UsageTotalMutation) SetType(i int) {
  32029. m._type = &i
  32030. m.add_type = nil
  32031. }
  32032. // GetType returns the value of the "type" field in the mutation.
  32033. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  32034. v := m._type
  32035. if v == nil {
  32036. return
  32037. }
  32038. return *v, true
  32039. }
  32040. // OldType returns the old "type" field's value of the UsageTotal entity.
  32041. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32042. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32043. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  32044. if !m.op.Is(OpUpdateOne) {
  32045. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32046. }
  32047. if m.id == nil || m.oldValue == nil {
  32048. return v, errors.New("OldType requires an ID field in the mutation")
  32049. }
  32050. oldValue, err := m.oldValue(ctx)
  32051. if err != nil {
  32052. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32053. }
  32054. return oldValue.Type, nil
  32055. }
  32056. // AddType adds i to the "type" field.
  32057. func (m *UsageTotalMutation) AddType(i int) {
  32058. if m.add_type != nil {
  32059. *m.add_type += i
  32060. } else {
  32061. m.add_type = &i
  32062. }
  32063. }
  32064. // AddedType returns the value that was added to the "type" field in this mutation.
  32065. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  32066. v := m.add_type
  32067. if v == nil {
  32068. return
  32069. }
  32070. return *v, true
  32071. }
  32072. // ClearType clears the value of the "type" field.
  32073. func (m *UsageTotalMutation) ClearType() {
  32074. m._type = nil
  32075. m.add_type = nil
  32076. m.clearedFields[usagetotal.FieldType] = struct{}{}
  32077. }
  32078. // TypeCleared returns if the "type" field was cleared in this mutation.
  32079. func (m *UsageTotalMutation) TypeCleared() bool {
  32080. _, ok := m.clearedFields[usagetotal.FieldType]
  32081. return ok
  32082. }
  32083. // ResetType resets all changes to the "type" field.
  32084. func (m *UsageTotalMutation) ResetType() {
  32085. m._type = nil
  32086. m.add_type = nil
  32087. delete(m.clearedFields, usagetotal.FieldType)
  32088. }
  32089. // SetBotID sets the "bot_id" field.
  32090. func (m *UsageTotalMutation) SetBotID(s string) {
  32091. m.bot_id = &s
  32092. }
  32093. // BotID returns the value of the "bot_id" field in the mutation.
  32094. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  32095. v := m.bot_id
  32096. if v == nil {
  32097. return
  32098. }
  32099. return *v, true
  32100. }
  32101. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  32102. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32104. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  32105. if !m.op.Is(OpUpdateOne) {
  32106. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32107. }
  32108. if m.id == nil || m.oldValue == nil {
  32109. return v, errors.New("OldBotID requires an ID field in the mutation")
  32110. }
  32111. oldValue, err := m.oldValue(ctx)
  32112. if err != nil {
  32113. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32114. }
  32115. return oldValue.BotID, nil
  32116. }
  32117. // ResetBotID resets all changes to the "bot_id" field.
  32118. func (m *UsageTotalMutation) ResetBotID() {
  32119. m.bot_id = nil
  32120. }
  32121. // SetTotalTokens sets the "total_tokens" field.
  32122. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  32123. m.total_tokens = &u
  32124. m.addtotal_tokens = nil
  32125. }
  32126. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  32127. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  32128. v := m.total_tokens
  32129. if v == nil {
  32130. return
  32131. }
  32132. return *v, true
  32133. }
  32134. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  32135. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32137. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  32138. if !m.op.Is(OpUpdateOne) {
  32139. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  32140. }
  32141. if m.id == nil || m.oldValue == nil {
  32142. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  32143. }
  32144. oldValue, err := m.oldValue(ctx)
  32145. if err != nil {
  32146. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  32147. }
  32148. return oldValue.TotalTokens, nil
  32149. }
  32150. // AddTotalTokens adds u to the "total_tokens" field.
  32151. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  32152. if m.addtotal_tokens != nil {
  32153. *m.addtotal_tokens += u
  32154. } else {
  32155. m.addtotal_tokens = &u
  32156. }
  32157. }
  32158. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  32159. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  32160. v := m.addtotal_tokens
  32161. if v == nil {
  32162. return
  32163. }
  32164. return *v, true
  32165. }
  32166. // ClearTotalTokens clears the value of the "total_tokens" field.
  32167. func (m *UsageTotalMutation) ClearTotalTokens() {
  32168. m.total_tokens = nil
  32169. m.addtotal_tokens = nil
  32170. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  32171. }
  32172. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  32173. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  32174. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  32175. return ok
  32176. }
  32177. // ResetTotalTokens resets all changes to the "total_tokens" field.
  32178. func (m *UsageTotalMutation) ResetTotalTokens() {
  32179. m.total_tokens = nil
  32180. m.addtotal_tokens = nil
  32181. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  32182. }
  32183. // SetStartIndex sets the "start_index" field.
  32184. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  32185. m.start_index = &u
  32186. m.addstart_index = nil
  32187. }
  32188. // StartIndex returns the value of the "start_index" field in the mutation.
  32189. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  32190. v := m.start_index
  32191. if v == nil {
  32192. return
  32193. }
  32194. return *v, true
  32195. }
  32196. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  32197. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32199. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  32200. if !m.op.Is(OpUpdateOne) {
  32201. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  32202. }
  32203. if m.id == nil || m.oldValue == nil {
  32204. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  32205. }
  32206. oldValue, err := m.oldValue(ctx)
  32207. if err != nil {
  32208. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  32209. }
  32210. return oldValue.StartIndex, nil
  32211. }
  32212. // AddStartIndex adds u to the "start_index" field.
  32213. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  32214. if m.addstart_index != nil {
  32215. *m.addstart_index += u
  32216. } else {
  32217. m.addstart_index = &u
  32218. }
  32219. }
  32220. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  32221. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  32222. v := m.addstart_index
  32223. if v == nil {
  32224. return
  32225. }
  32226. return *v, true
  32227. }
  32228. // ClearStartIndex clears the value of the "start_index" field.
  32229. func (m *UsageTotalMutation) ClearStartIndex() {
  32230. m.start_index = nil
  32231. m.addstart_index = nil
  32232. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  32233. }
  32234. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  32235. func (m *UsageTotalMutation) StartIndexCleared() bool {
  32236. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  32237. return ok
  32238. }
  32239. // ResetStartIndex resets all changes to the "start_index" field.
  32240. func (m *UsageTotalMutation) ResetStartIndex() {
  32241. m.start_index = nil
  32242. m.addstart_index = nil
  32243. delete(m.clearedFields, usagetotal.FieldStartIndex)
  32244. }
  32245. // SetEndIndex sets the "end_index" field.
  32246. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  32247. m.end_index = &u
  32248. m.addend_index = nil
  32249. }
  32250. // EndIndex returns the value of the "end_index" field in the mutation.
  32251. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  32252. v := m.end_index
  32253. if v == nil {
  32254. return
  32255. }
  32256. return *v, true
  32257. }
  32258. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  32259. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32261. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  32262. if !m.op.Is(OpUpdateOne) {
  32263. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  32264. }
  32265. if m.id == nil || m.oldValue == nil {
  32266. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  32267. }
  32268. oldValue, err := m.oldValue(ctx)
  32269. if err != nil {
  32270. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  32271. }
  32272. return oldValue.EndIndex, nil
  32273. }
  32274. // AddEndIndex adds u to the "end_index" field.
  32275. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  32276. if m.addend_index != nil {
  32277. *m.addend_index += u
  32278. } else {
  32279. m.addend_index = &u
  32280. }
  32281. }
  32282. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  32283. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  32284. v := m.addend_index
  32285. if v == nil {
  32286. return
  32287. }
  32288. return *v, true
  32289. }
  32290. // ClearEndIndex clears the value of the "end_index" field.
  32291. func (m *UsageTotalMutation) ClearEndIndex() {
  32292. m.end_index = nil
  32293. m.addend_index = nil
  32294. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  32295. }
  32296. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  32297. func (m *UsageTotalMutation) EndIndexCleared() bool {
  32298. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  32299. return ok
  32300. }
  32301. // ResetEndIndex resets all changes to the "end_index" field.
  32302. func (m *UsageTotalMutation) ResetEndIndex() {
  32303. m.end_index = nil
  32304. m.addend_index = nil
  32305. delete(m.clearedFields, usagetotal.FieldEndIndex)
  32306. }
  32307. // SetOrganizationID sets the "organization_id" field.
  32308. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  32309. m.organization_id = &u
  32310. m.addorganization_id = nil
  32311. }
  32312. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32313. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  32314. v := m.organization_id
  32315. if v == nil {
  32316. return
  32317. }
  32318. return *v, true
  32319. }
  32320. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  32321. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32322. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32323. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32324. if !m.op.Is(OpUpdateOne) {
  32325. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32326. }
  32327. if m.id == nil || m.oldValue == nil {
  32328. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32329. }
  32330. oldValue, err := m.oldValue(ctx)
  32331. if err != nil {
  32332. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32333. }
  32334. return oldValue.OrganizationID, nil
  32335. }
  32336. // AddOrganizationID adds u to the "organization_id" field.
  32337. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  32338. if m.addorganization_id != nil {
  32339. *m.addorganization_id += u
  32340. } else {
  32341. m.addorganization_id = &u
  32342. }
  32343. }
  32344. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32345. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  32346. v := m.addorganization_id
  32347. if v == nil {
  32348. return
  32349. }
  32350. return *v, true
  32351. }
  32352. // ClearOrganizationID clears the value of the "organization_id" field.
  32353. func (m *UsageTotalMutation) ClearOrganizationID() {
  32354. m.organization_id = nil
  32355. m.addorganization_id = nil
  32356. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  32357. }
  32358. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  32359. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  32360. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  32361. return ok
  32362. }
  32363. // ResetOrganizationID resets all changes to the "organization_id" field.
  32364. func (m *UsageTotalMutation) ResetOrganizationID() {
  32365. m.organization_id = nil
  32366. m.addorganization_id = nil
  32367. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  32368. }
  32369. // Where appends a list predicates to the UsageTotalMutation builder.
  32370. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  32371. m.predicates = append(m.predicates, ps...)
  32372. }
  32373. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  32374. // users can use type-assertion to append predicates that do not depend on any generated package.
  32375. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  32376. p := make([]predicate.UsageTotal, len(ps))
  32377. for i := range ps {
  32378. p[i] = ps[i]
  32379. }
  32380. m.Where(p...)
  32381. }
  32382. // Op returns the operation name.
  32383. func (m *UsageTotalMutation) Op() Op {
  32384. return m.op
  32385. }
  32386. // SetOp allows setting the mutation operation.
  32387. func (m *UsageTotalMutation) SetOp(op Op) {
  32388. m.op = op
  32389. }
  32390. // Type returns the node type of this mutation (UsageTotal).
  32391. func (m *UsageTotalMutation) Type() string {
  32392. return m.typ
  32393. }
  32394. // Fields returns all fields that were changed during this mutation. Note that in
  32395. // order to get all numeric fields that were incremented/decremented, call
  32396. // AddedFields().
  32397. func (m *UsageTotalMutation) Fields() []string {
  32398. fields := make([]string, 0, 9)
  32399. if m.created_at != nil {
  32400. fields = append(fields, usagetotal.FieldCreatedAt)
  32401. }
  32402. if m.updated_at != nil {
  32403. fields = append(fields, usagetotal.FieldUpdatedAt)
  32404. }
  32405. if m.status != nil {
  32406. fields = append(fields, usagetotal.FieldStatus)
  32407. }
  32408. if m._type != nil {
  32409. fields = append(fields, usagetotal.FieldType)
  32410. }
  32411. if m.bot_id != nil {
  32412. fields = append(fields, usagetotal.FieldBotID)
  32413. }
  32414. if m.total_tokens != nil {
  32415. fields = append(fields, usagetotal.FieldTotalTokens)
  32416. }
  32417. if m.start_index != nil {
  32418. fields = append(fields, usagetotal.FieldStartIndex)
  32419. }
  32420. if m.end_index != nil {
  32421. fields = append(fields, usagetotal.FieldEndIndex)
  32422. }
  32423. if m.organization_id != nil {
  32424. fields = append(fields, usagetotal.FieldOrganizationID)
  32425. }
  32426. return fields
  32427. }
  32428. // Field returns the value of a field with the given name. The second boolean
  32429. // return value indicates that this field was not set, or was not defined in the
  32430. // schema.
  32431. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  32432. switch name {
  32433. case usagetotal.FieldCreatedAt:
  32434. return m.CreatedAt()
  32435. case usagetotal.FieldUpdatedAt:
  32436. return m.UpdatedAt()
  32437. case usagetotal.FieldStatus:
  32438. return m.Status()
  32439. case usagetotal.FieldType:
  32440. return m.GetType()
  32441. case usagetotal.FieldBotID:
  32442. return m.BotID()
  32443. case usagetotal.FieldTotalTokens:
  32444. return m.TotalTokens()
  32445. case usagetotal.FieldStartIndex:
  32446. return m.StartIndex()
  32447. case usagetotal.FieldEndIndex:
  32448. return m.EndIndex()
  32449. case usagetotal.FieldOrganizationID:
  32450. return m.OrganizationID()
  32451. }
  32452. return nil, false
  32453. }
  32454. // OldField returns the old value of the field from the database. An error is
  32455. // returned if the mutation operation is not UpdateOne, or the query to the
  32456. // database failed.
  32457. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32458. switch name {
  32459. case usagetotal.FieldCreatedAt:
  32460. return m.OldCreatedAt(ctx)
  32461. case usagetotal.FieldUpdatedAt:
  32462. return m.OldUpdatedAt(ctx)
  32463. case usagetotal.FieldStatus:
  32464. return m.OldStatus(ctx)
  32465. case usagetotal.FieldType:
  32466. return m.OldType(ctx)
  32467. case usagetotal.FieldBotID:
  32468. return m.OldBotID(ctx)
  32469. case usagetotal.FieldTotalTokens:
  32470. return m.OldTotalTokens(ctx)
  32471. case usagetotal.FieldStartIndex:
  32472. return m.OldStartIndex(ctx)
  32473. case usagetotal.FieldEndIndex:
  32474. return m.OldEndIndex(ctx)
  32475. case usagetotal.FieldOrganizationID:
  32476. return m.OldOrganizationID(ctx)
  32477. }
  32478. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  32479. }
  32480. // SetField sets the value of a field with the given name. It returns an error if
  32481. // the field is not defined in the schema, or if the type mismatched the field
  32482. // type.
  32483. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  32484. switch name {
  32485. case usagetotal.FieldCreatedAt:
  32486. v, ok := value.(time.Time)
  32487. if !ok {
  32488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32489. }
  32490. m.SetCreatedAt(v)
  32491. return nil
  32492. case usagetotal.FieldUpdatedAt:
  32493. v, ok := value.(time.Time)
  32494. if !ok {
  32495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32496. }
  32497. m.SetUpdatedAt(v)
  32498. return nil
  32499. case usagetotal.FieldStatus:
  32500. v, ok := value.(uint8)
  32501. if !ok {
  32502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32503. }
  32504. m.SetStatus(v)
  32505. return nil
  32506. case usagetotal.FieldType:
  32507. v, ok := value.(int)
  32508. if !ok {
  32509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32510. }
  32511. m.SetType(v)
  32512. return nil
  32513. case usagetotal.FieldBotID:
  32514. v, ok := value.(string)
  32515. if !ok {
  32516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32517. }
  32518. m.SetBotID(v)
  32519. return nil
  32520. case usagetotal.FieldTotalTokens:
  32521. v, ok := value.(uint64)
  32522. if !ok {
  32523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32524. }
  32525. m.SetTotalTokens(v)
  32526. return nil
  32527. case usagetotal.FieldStartIndex:
  32528. v, ok := value.(uint64)
  32529. if !ok {
  32530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32531. }
  32532. m.SetStartIndex(v)
  32533. return nil
  32534. case usagetotal.FieldEndIndex:
  32535. v, ok := value.(uint64)
  32536. if !ok {
  32537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32538. }
  32539. m.SetEndIndex(v)
  32540. return nil
  32541. case usagetotal.FieldOrganizationID:
  32542. v, ok := value.(uint64)
  32543. if !ok {
  32544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32545. }
  32546. m.SetOrganizationID(v)
  32547. return nil
  32548. }
  32549. return fmt.Errorf("unknown UsageTotal field %s", name)
  32550. }
  32551. // AddedFields returns all numeric fields that were incremented/decremented during
  32552. // this mutation.
  32553. func (m *UsageTotalMutation) AddedFields() []string {
  32554. var fields []string
  32555. if m.addstatus != nil {
  32556. fields = append(fields, usagetotal.FieldStatus)
  32557. }
  32558. if m.add_type != nil {
  32559. fields = append(fields, usagetotal.FieldType)
  32560. }
  32561. if m.addtotal_tokens != nil {
  32562. fields = append(fields, usagetotal.FieldTotalTokens)
  32563. }
  32564. if m.addstart_index != nil {
  32565. fields = append(fields, usagetotal.FieldStartIndex)
  32566. }
  32567. if m.addend_index != nil {
  32568. fields = append(fields, usagetotal.FieldEndIndex)
  32569. }
  32570. if m.addorganization_id != nil {
  32571. fields = append(fields, usagetotal.FieldOrganizationID)
  32572. }
  32573. return fields
  32574. }
  32575. // AddedField returns the numeric value that was incremented/decremented on a field
  32576. // with the given name. The second boolean return value indicates that this field
  32577. // was not set, or was not defined in the schema.
  32578. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  32579. switch name {
  32580. case usagetotal.FieldStatus:
  32581. return m.AddedStatus()
  32582. case usagetotal.FieldType:
  32583. return m.AddedType()
  32584. case usagetotal.FieldTotalTokens:
  32585. return m.AddedTotalTokens()
  32586. case usagetotal.FieldStartIndex:
  32587. return m.AddedStartIndex()
  32588. case usagetotal.FieldEndIndex:
  32589. return m.AddedEndIndex()
  32590. case usagetotal.FieldOrganizationID:
  32591. return m.AddedOrganizationID()
  32592. }
  32593. return nil, false
  32594. }
  32595. // AddField adds the value to the field with the given name. It returns an error if
  32596. // the field is not defined in the schema, or if the type mismatched the field
  32597. // type.
  32598. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  32599. switch name {
  32600. case usagetotal.FieldStatus:
  32601. v, ok := value.(int8)
  32602. if !ok {
  32603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32604. }
  32605. m.AddStatus(v)
  32606. return nil
  32607. case usagetotal.FieldType:
  32608. v, ok := value.(int)
  32609. if !ok {
  32610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32611. }
  32612. m.AddType(v)
  32613. return nil
  32614. case usagetotal.FieldTotalTokens:
  32615. v, ok := value.(int64)
  32616. if !ok {
  32617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32618. }
  32619. m.AddTotalTokens(v)
  32620. return nil
  32621. case usagetotal.FieldStartIndex:
  32622. v, ok := value.(int64)
  32623. if !ok {
  32624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32625. }
  32626. m.AddStartIndex(v)
  32627. return nil
  32628. case usagetotal.FieldEndIndex:
  32629. v, ok := value.(int64)
  32630. if !ok {
  32631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32632. }
  32633. m.AddEndIndex(v)
  32634. return nil
  32635. case usagetotal.FieldOrganizationID:
  32636. v, ok := value.(int64)
  32637. if !ok {
  32638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32639. }
  32640. m.AddOrganizationID(v)
  32641. return nil
  32642. }
  32643. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  32644. }
  32645. // ClearedFields returns all nullable fields that were cleared during this
  32646. // mutation.
  32647. func (m *UsageTotalMutation) ClearedFields() []string {
  32648. var fields []string
  32649. if m.FieldCleared(usagetotal.FieldStatus) {
  32650. fields = append(fields, usagetotal.FieldStatus)
  32651. }
  32652. if m.FieldCleared(usagetotal.FieldType) {
  32653. fields = append(fields, usagetotal.FieldType)
  32654. }
  32655. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  32656. fields = append(fields, usagetotal.FieldTotalTokens)
  32657. }
  32658. if m.FieldCleared(usagetotal.FieldStartIndex) {
  32659. fields = append(fields, usagetotal.FieldStartIndex)
  32660. }
  32661. if m.FieldCleared(usagetotal.FieldEndIndex) {
  32662. fields = append(fields, usagetotal.FieldEndIndex)
  32663. }
  32664. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  32665. fields = append(fields, usagetotal.FieldOrganizationID)
  32666. }
  32667. return fields
  32668. }
  32669. // FieldCleared returns a boolean indicating if a field with the given name was
  32670. // cleared in this mutation.
  32671. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  32672. _, ok := m.clearedFields[name]
  32673. return ok
  32674. }
  32675. // ClearField clears the value of the field with the given name. It returns an
  32676. // error if the field is not defined in the schema.
  32677. func (m *UsageTotalMutation) ClearField(name string) error {
  32678. switch name {
  32679. case usagetotal.FieldStatus:
  32680. m.ClearStatus()
  32681. return nil
  32682. case usagetotal.FieldType:
  32683. m.ClearType()
  32684. return nil
  32685. case usagetotal.FieldTotalTokens:
  32686. m.ClearTotalTokens()
  32687. return nil
  32688. case usagetotal.FieldStartIndex:
  32689. m.ClearStartIndex()
  32690. return nil
  32691. case usagetotal.FieldEndIndex:
  32692. m.ClearEndIndex()
  32693. return nil
  32694. case usagetotal.FieldOrganizationID:
  32695. m.ClearOrganizationID()
  32696. return nil
  32697. }
  32698. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  32699. }
  32700. // ResetField resets all changes in the mutation for the field with the given name.
  32701. // It returns an error if the field is not defined in the schema.
  32702. func (m *UsageTotalMutation) ResetField(name string) error {
  32703. switch name {
  32704. case usagetotal.FieldCreatedAt:
  32705. m.ResetCreatedAt()
  32706. return nil
  32707. case usagetotal.FieldUpdatedAt:
  32708. m.ResetUpdatedAt()
  32709. return nil
  32710. case usagetotal.FieldStatus:
  32711. m.ResetStatus()
  32712. return nil
  32713. case usagetotal.FieldType:
  32714. m.ResetType()
  32715. return nil
  32716. case usagetotal.FieldBotID:
  32717. m.ResetBotID()
  32718. return nil
  32719. case usagetotal.FieldTotalTokens:
  32720. m.ResetTotalTokens()
  32721. return nil
  32722. case usagetotal.FieldStartIndex:
  32723. m.ResetStartIndex()
  32724. return nil
  32725. case usagetotal.FieldEndIndex:
  32726. m.ResetEndIndex()
  32727. return nil
  32728. case usagetotal.FieldOrganizationID:
  32729. m.ResetOrganizationID()
  32730. return nil
  32731. }
  32732. return fmt.Errorf("unknown UsageTotal field %s", name)
  32733. }
  32734. // AddedEdges returns all edge names that were set/added in this mutation.
  32735. func (m *UsageTotalMutation) AddedEdges() []string {
  32736. edges := make([]string, 0, 0)
  32737. return edges
  32738. }
  32739. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32740. // name in this mutation.
  32741. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  32742. return nil
  32743. }
  32744. // RemovedEdges returns all edge names that were removed in this mutation.
  32745. func (m *UsageTotalMutation) RemovedEdges() []string {
  32746. edges := make([]string, 0, 0)
  32747. return edges
  32748. }
  32749. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32750. // the given name in this mutation.
  32751. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  32752. return nil
  32753. }
  32754. // ClearedEdges returns all edge names that were cleared in this mutation.
  32755. func (m *UsageTotalMutation) ClearedEdges() []string {
  32756. edges := make([]string, 0, 0)
  32757. return edges
  32758. }
  32759. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32760. // was cleared in this mutation.
  32761. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  32762. return false
  32763. }
  32764. // ClearEdge clears the value of the edge with the given name. It returns an error
  32765. // if that edge is not defined in the schema.
  32766. func (m *UsageTotalMutation) ClearEdge(name string) error {
  32767. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  32768. }
  32769. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32770. // It returns an error if the edge is not defined in the schema.
  32771. func (m *UsageTotalMutation) ResetEdge(name string) error {
  32772. return fmt.Errorf("unknown UsageTotal edge %s", name)
  32773. }
  32774. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  32775. type WorkExperienceMutation struct {
  32776. config
  32777. op Op
  32778. typ string
  32779. id *uint64
  32780. created_at *time.Time
  32781. updated_at *time.Time
  32782. deleted_at *time.Time
  32783. start_date *time.Time
  32784. end_date *time.Time
  32785. company *string
  32786. experience *string
  32787. organization_id *uint64
  32788. addorganization_id *int64
  32789. clearedFields map[string]struct{}
  32790. employee *uint64
  32791. clearedemployee bool
  32792. done bool
  32793. oldValue func(context.Context) (*WorkExperience, error)
  32794. predicates []predicate.WorkExperience
  32795. }
  32796. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  32797. // workexperienceOption allows management of the mutation configuration using functional options.
  32798. type workexperienceOption func(*WorkExperienceMutation)
  32799. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  32800. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  32801. m := &WorkExperienceMutation{
  32802. config: c,
  32803. op: op,
  32804. typ: TypeWorkExperience,
  32805. clearedFields: make(map[string]struct{}),
  32806. }
  32807. for _, opt := range opts {
  32808. opt(m)
  32809. }
  32810. return m
  32811. }
  32812. // withWorkExperienceID sets the ID field of the mutation.
  32813. func withWorkExperienceID(id uint64) workexperienceOption {
  32814. return func(m *WorkExperienceMutation) {
  32815. var (
  32816. err error
  32817. once sync.Once
  32818. value *WorkExperience
  32819. )
  32820. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  32821. once.Do(func() {
  32822. if m.done {
  32823. err = errors.New("querying old values post mutation is not allowed")
  32824. } else {
  32825. value, err = m.Client().WorkExperience.Get(ctx, id)
  32826. }
  32827. })
  32828. return value, err
  32829. }
  32830. m.id = &id
  32831. }
  32832. }
  32833. // withWorkExperience sets the old WorkExperience of the mutation.
  32834. func withWorkExperience(node *WorkExperience) workexperienceOption {
  32835. return func(m *WorkExperienceMutation) {
  32836. m.oldValue = func(context.Context) (*WorkExperience, error) {
  32837. return node, nil
  32838. }
  32839. m.id = &node.ID
  32840. }
  32841. }
  32842. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32843. // executed in a transaction (ent.Tx), a transactional client is returned.
  32844. func (m WorkExperienceMutation) Client() *Client {
  32845. client := &Client{config: m.config}
  32846. client.init()
  32847. return client
  32848. }
  32849. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32850. // it returns an error otherwise.
  32851. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  32852. if _, ok := m.driver.(*txDriver); !ok {
  32853. return nil, errors.New("ent: mutation is not running in a transaction")
  32854. }
  32855. tx := &Tx{config: m.config}
  32856. tx.init()
  32857. return tx, nil
  32858. }
  32859. // SetID sets the value of the id field. Note that this
  32860. // operation is only accepted on creation of WorkExperience entities.
  32861. func (m *WorkExperienceMutation) SetID(id uint64) {
  32862. m.id = &id
  32863. }
  32864. // ID returns the ID value in the mutation. Note that the ID is only available
  32865. // if it was provided to the builder or after it was returned from the database.
  32866. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  32867. if m.id == nil {
  32868. return
  32869. }
  32870. return *m.id, true
  32871. }
  32872. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32873. // That means, if the mutation is applied within a transaction with an isolation level such
  32874. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32875. // or updated by the mutation.
  32876. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  32877. switch {
  32878. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32879. id, exists := m.ID()
  32880. if exists {
  32881. return []uint64{id}, nil
  32882. }
  32883. fallthrough
  32884. case m.op.Is(OpUpdate | OpDelete):
  32885. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  32886. default:
  32887. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32888. }
  32889. }
  32890. // SetCreatedAt sets the "created_at" field.
  32891. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  32892. m.created_at = &t
  32893. }
  32894. // CreatedAt returns the value of the "created_at" field in the mutation.
  32895. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  32896. v := m.created_at
  32897. if v == nil {
  32898. return
  32899. }
  32900. return *v, true
  32901. }
  32902. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  32903. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  32904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32905. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32906. if !m.op.Is(OpUpdateOne) {
  32907. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32908. }
  32909. if m.id == nil || m.oldValue == nil {
  32910. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32911. }
  32912. oldValue, err := m.oldValue(ctx)
  32913. if err != nil {
  32914. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32915. }
  32916. return oldValue.CreatedAt, nil
  32917. }
  32918. // ResetCreatedAt resets all changes to the "created_at" field.
  32919. func (m *WorkExperienceMutation) ResetCreatedAt() {
  32920. m.created_at = nil
  32921. }
  32922. // SetUpdatedAt sets the "updated_at" field.
  32923. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  32924. m.updated_at = &t
  32925. }
  32926. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32927. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  32928. v := m.updated_at
  32929. if v == nil {
  32930. return
  32931. }
  32932. return *v, true
  32933. }
  32934. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  32935. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  32936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32937. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32938. if !m.op.Is(OpUpdateOne) {
  32939. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32940. }
  32941. if m.id == nil || m.oldValue == nil {
  32942. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32943. }
  32944. oldValue, err := m.oldValue(ctx)
  32945. if err != nil {
  32946. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32947. }
  32948. return oldValue.UpdatedAt, nil
  32949. }
  32950. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32951. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  32952. m.updated_at = nil
  32953. }
  32954. // SetDeletedAt sets the "deleted_at" field.
  32955. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  32956. m.deleted_at = &t
  32957. }
  32958. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32959. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  32960. v := m.deleted_at
  32961. if v == nil {
  32962. return
  32963. }
  32964. return *v, true
  32965. }
  32966. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  32967. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  32968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32969. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32970. if !m.op.Is(OpUpdateOne) {
  32971. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32972. }
  32973. if m.id == nil || m.oldValue == nil {
  32974. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32975. }
  32976. oldValue, err := m.oldValue(ctx)
  32977. if err != nil {
  32978. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32979. }
  32980. return oldValue.DeletedAt, nil
  32981. }
  32982. // ClearDeletedAt clears the value of the "deleted_at" field.
  32983. func (m *WorkExperienceMutation) ClearDeletedAt() {
  32984. m.deleted_at = nil
  32985. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  32986. }
  32987. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32988. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  32989. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  32990. return ok
  32991. }
  32992. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32993. func (m *WorkExperienceMutation) ResetDeletedAt() {
  32994. m.deleted_at = nil
  32995. delete(m.clearedFields, workexperience.FieldDeletedAt)
  32996. }
  32997. // SetEmployeeID sets the "employee_id" field.
  32998. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  32999. m.employee = &u
  33000. }
  33001. // EmployeeID returns the value of the "employee_id" field in the mutation.
  33002. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  33003. v := m.employee
  33004. if v == nil {
  33005. return
  33006. }
  33007. return *v, true
  33008. }
  33009. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  33010. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  33011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33012. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  33013. if !m.op.Is(OpUpdateOne) {
  33014. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  33015. }
  33016. if m.id == nil || m.oldValue == nil {
  33017. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  33018. }
  33019. oldValue, err := m.oldValue(ctx)
  33020. if err != nil {
  33021. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  33022. }
  33023. return oldValue.EmployeeID, nil
  33024. }
  33025. // ResetEmployeeID resets all changes to the "employee_id" field.
  33026. func (m *WorkExperienceMutation) ResetEmployeeID() {
  33027. m.employee = nil
  33028. }
  33029. // SetStartDate sets the "start_date" field.
  33030. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  33031. m.start_date = &t
  33032. }
  33033. // StartDate returns the value of the "start_date" field in the mutation.
  33034. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  33035. v := m.start_date
  33036. if v == nil {
  33037. return
  33038. }
  33039. return *v, true
  33040. }
  33041. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  33042. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  33043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33044. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  33045. if !m.op.Is(OpUpdateOne) {
  33046. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  33047. }
  33048. if m.id == nil || m.oldValue == nil {
  33049. return v, errors.New("OldStartDate requires an ID field in the mutation")
  33050. }
  33051. oldValue, err := m.oldValue(ctx)
  33052. if err != nil {
  33053. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  33054. }
  33055. return oldValue.StartDate, nil
  33056. }
  33057. // ResetStartDate resets all changes to the "start_date" field.
  33058. func (m *WorkExperienceMutation) ResetStartDate() {
  33059. m.start_date = nil
  33060. }
  33061. // SetEndDate sets the "end_date" field.
  33062. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  33063. m.end_date = &t
  33064. }
  33065. // EndDate returns the value of the "end_date" field in the mutation.
  33066. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  33067. v := m.end_date
  33068. if v == nil {
  33069. return
  33070. }
  33071. return *v, true
  33072. }
  33073. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  33074. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  33075. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33076. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  33077. if !m.op.Is(OpUpdateOne) {
  33078. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  33079. }
  33080. if m.id == nil || m.oldValue == nil {
  33081. return v, errors.New("OldEndDate requires an ID field in the mutation")
  33082. }
  33083. oldValue, err := m.oldValue(ctx)
  33084. if err != nil {
  33085. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  33086. }
  33087. return oldValue.EndDate, nil
  33088. }
  33089. // ResetEndDate resets all changes to the "end_date" field.
  33090. func (m *WorkExperienceMutation) ResetEndDate() {
  33091. m.end_date = nil
  33092. }
  33093. // SetCompany sets the "company" field.
  33094. func (m *WorkExperienceMutation) SetCompany(s string) {
  33095. m.company = &s
  33096. }
  33097. // Company returns the value of the "company" field in the mutation.
  33098. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  33099. v := m.company
  33100. if v == nil {
  33101. return
  33102. }
  33103. return *v, true
  33104. }
  33105. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  33106. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  33107. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33108. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  33109. if !m.op.Is(OpUpdateOne) {
  33110. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  33111. }
  33112. if m.id == nil || m.oldValue == nil {
  33113. return v, errors.New("OldCompany requires an ID field in the mutation")
  33114. }
  33115. oldValue, err := m.oldValue(ctx)
  33116. if err != nil {
  33117. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  33118. }
  33119. return oldValue.Company, nil
  33120. }
  33121. // ResetCompany resets all changes to the "company" field.
  33122. func (m *WorkExperienceMutation) ResetCompany() {
  33123. m.company = nil
  33124. }
  33125. // SetExperience sets the "experience" field.
  33126. func (m *WorkExperienceMutation) SetExperience(s string) {
  33127. m.experience = &s
  33128. }
  33129. // Experience returns the value of the "experience" field in the mutation.
  33130. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  33131. v := m.experience
  33132. if v == nil {
  33133. return
  33134. }
  33135. return *v, true
  33136. }
  33137. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  33138. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  33139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33140. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  33141. if !m.op.Is(OpUpdateOne) {
  33142. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  33143. }
  33144. if m.id == nil || m.oldValue == nil {
  33145. return v, errors.New("OldExperience requires an ID field in the mutation")
  33146. }
  33147. oldValue, err := m.oldValue(ctx)
  33148. if err != nil {
  33149. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  33150. }
  33151. return oldValue.Experience, nil
  33152. }
  33153. // ResetExperience resets all changes to the "experience" field.
  33154. func (m *WorkExperienceMutation) ResetExperience() {
  33155. m.experience = nil
  33156. }
  33157. // SetOrganizationID sets the "organization_id" field.
  33158. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  33159. m.organization_id = &u
  33160. m.addorganization_id = nil
  33161. }
  33162. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33163. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  33164. v := m.organization_id
  33165. if v == nil {
  33166. return
  33167. }
  33168. return *v, true
  33169. }
  33170. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  33171. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  33172. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33173. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33174. if !m.op.Is(OpUpdateOne) {
  33175. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33176. }
  33177. if m.id == nil || m.oldValue == nil {
  33178. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33179. }
  33180. oldValue, err := m.oldValue(ctx)
  33181. if err != nil {
  33182. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33183. }
  33184. return oldValue.OrganizationID, nil
  33185. }
  33186. // AddOrganizationID adds u to the "organization_id" field.
  33187. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  33188. if m.addorganization_id != nil {
  33189. *m.addorganization_id += u
  33190. } else {
  33191. m.addorganization_id = &u
  33192. }
  33193. }
  33194. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33195. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  33196. v := m.addorganization_id
  33197. if v == nil {
  33198. return
  33199. }
  33200. return *v, true
  33201. }
  33202. // ResetOrganizationID resets all changes to the "organization_id" field.
  33203. func (m *WorkExperienceMutation) ResetOrganizationID() {
  33204. m.organization_id = nil
  33205. m.addorganization_id = nil
  33206. }
  33207. // ClearEmployee clears the "employee" edge to the Employee entity.
  33208. func (m *WorkExperienceMutation) ClearEmployee() {
  33209. m.clearedemployee = true
  33210. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  33211. }
  33212. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  33213. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  33214. return m.clearedemployee
  33215. }
  33216. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  33217. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  33218. // EmployeeID instead. It exists only for internal usage by the builders.
  33219. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  33220. if id := m.employee; id != nil {
  33221. ids = append(ids, *id)
  33222. }
  33223. return
  33224. }
  33225. // ResetEmployee resets all changes to the "employee" edge.
  33226. func (m *WorkExperienceMutation) ResetEmployee() {
  33227. m.employee = nil
  33228. m.clearedemployee = false
  33229. }
  33230. // Where appends a list predicates to the WorkExperienceMutation builder.
  33231. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  33232. m.predicates = append(m.predicates, ps...)
  33233. }
  33234. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  33235. // users can use type-assertion to append predicates that do not depend on any generated package.
  33236. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  33237. p := make([]predicate.WorkExperience, len(ps))
  33238. for i := range ps {
  33239. p[i] = ps[i]
  33240. }
  33241. m.Where(p...)
  33242. }
  33243. // Op returns the operation name.
  33244. func (m *WorkExperienceMutation) Op() Op {
  33245. return m.op
  33246. }
  33247. // SetOp allows setting the mutation operation.
  33248. func (m *WorkExperienceMutation) SetOp(op Op) {
  33249. m.op = op
  33250. }
  33251. // Type returns the node type of this mutation (WorkExperience).
  33252. func (m *WorkExperienceMutation) Type() string {
  33253. return m.typ
  33254. }
  33255. // Fields returns all fields that were changed during this mutation. Note that in
  33256. // order to get all numeric fields that were incremented/decremented, call
  33257. // AddedFields().
  33258. func (m *WorkExperienceMutation) Fields() []string {
  33259. fields := make([]string, 0, 9)
  33260. if m.created_at != nil {
  33261. fields = append(fields, workexperience.FieldCreatedAt)
  33262. }
  33263. if m.updated_at != nil {
  33264. fields = append(fields, workexperience.FieldUpdatedAt)
  33265. }
  33266. if m.deleted_at != nil {
  33267. fields = append(fields, workexperience.FieldDeletedAt)
  33268. }
  33269. if m.employee != nil {
  33270. fields = append(fields, workexperience.FieldEmployeeID)
  33271. }
  33272. if m.start_date != nil {
  33273. fields = append(fields, workexperience.FieldStartDate)
  33274. }
  33275. if m.end_date != nil {
  33276. fields = append(fields, workexperience.FieldEndDate)
  33277. }
  33278. if m.company != nil {
  33279. fields = append(fields, workexperience.FieldCompany)
  33280. }
  33281. if m.experience != nil {
  33282. fields = append(fields, workexperience.FieldExperience)
  33283. }
  33284. if m.organization_id != nil {
  33285. fields = append(fields, workexperience.FieldOrganizationID)
  33286. }
  33287. return fields
  33288. }
  33289. // Field returns the value of a field with the given name. The second boolean
  33290. // return value indicates that this field was not set, or was not defined in the
  33291. // schema.
  33292. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  33293. switch name {
  33294. case workexperience.FieldCreatedAt:
  33295. return m.CreatedAt()
  33296. case workexperience.FieldUpdatedAt:
  33297. return m.UpdatedAt()
  33298. case workexperience.FieldDeletedAt:
  33299. return m.DeletedAt()
  33300. case workexperience.FieldEmployeeID:
  33301. return m.EmployeeID()
  33302. case workexperience.FieldStartDate:
  33303. return m.StartDate()
  33304. case workexperience.FieldEndDate:
  33305. return m.EndDate()
  33306. case workexperience.FieldCompany:
  33307. return m.Company()
  33308. case workexperience.FieldExperience:
  33309. return m.Experience()
  33310. case workexperience.FieldOrganizationID:
  33311. return m.OrganizationID()
  33312. }
  33313. return nil, false
  33314. }
  33315. // OldField returns the old value of the field from the database. An error is
  33316. // returned if the mutation operation is not UpdateOne, or the query to the
  33317. // database failed.
  33318. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33319. switch name {
  33320. case workexperience.FieldCreatedAt:
  33321. return m.OldCreatedAt(ctx)
  33322. case workexperience.FieldUpdatedAt:
  33323. return m.OldUpdatedAt(ctx)
  33324. case workexperience.FieldDeletedAt:
  33325. return m.OldDeletedAt(ctx)
  33326. case workexperience.FieldEmployeeID:
  33327. return m.OldEmployeeID(ctx)
  33328. case workexperience.FieldStartDate:
  33329. return m.OldStartDate(ctx)
  33330. case workexperience.FieldEndDate:
  33331. return m.OldEndDate(ctx)
  33332. case workexperience.FieldCompany:
  33333. return m.OldCompany(ctx)
  33334. case workexperience.FieldExperience:
  33335. return m.OldExperience(ctx)
  33336. case workexperience.FieldOrganizationID:
  33337. return m.OldOrganizationID(ctx)
  33338. }
  33339. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  33340. }
  33341. // SetField sets the value of a field with the given name. It returns an error if
  33342. // the field is not defined in the schema, or if the type mismatched the field
  33343. // type.
  33344. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  33345. switch name {
  33346. case workexperience.FieldCreatedAt:
  33347. v, ok := value.(time.Time)
  33348. if !ok {
  33349. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33350. }
  33351. m.SetCreatedAt(v)
  33352. return nil
  33353. case workexperience.FieldUpdatedAt:
  33354. v, ok := value.(time.Time)
  33355. if !ok {
  33356. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33357. }
  33358. m.SetUpdatedAt(v)
  33359. return nil
  33360. case workexperience.FieldDeletedAt:
  33361. v, ok := value.(time.Time)
  33362. if !ok {
  33363. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33364. }
  33365. m.SetDeletedAt(v)
  33366. return nil
  33367. case workexperience.FieldEmployeeID:
  33368. v, ok := value.(uint64)
  33369. if !ok {
  33370. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33371. }
  33372. m.SetEmployeeID(v)
  33373. return nil
  33374. case workexperience.FieldStartDate:
  33375. v, ok := value.(time.Time)
  33376. if !ok {
  33377. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33378. }
  33379. m.SetStartDate(v)
  33380. return nil
  33381. case workexperience.FieldEndDate:
  33382. v, ok := value.(time.Time)
  33383. if !ok {
  33384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33385. }
  33386. m.SetEndDate(v)
  33387. return nil
  33388. case workexperience.FieldCompany:
  33389. v, ok := value.(string)
  33390. if !ok {
  33391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33392. }
  33393. m.SetCompany(v)
  33394. return nil
  33395. case workexperience.FieldExperience:
  33396. v, ok := value.(string)
  33397. if !ok {
  33398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33399. }
  33400. m.SetExperience(v)
  33401. return nil
  33402. case workexperience.FieldOrganizationID:
  33403. v, ok := value.(uint64)
  33404. if !ok {
  33405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33406. }
  33407. m.SetOrganizationID(v)
  33408. return nil
  33409. }
  33410. return fmt.Errorf("unknown WorkExperience field %s", name)
  33411. }
  33412. // AddedFields returns all numeric fields that were incremented/decremented during
  33413. // this mutation.
  33414. func (m *WorkExperienceMutation) AddedFields() []string {
  33415. var fields []string
  33416. if m.addorganization_id != nil {
  33417. fields = append(fields, workexperience.FieldOrganizationID)
  33418. }
  33419. return fields
  33420. }
  33421. // AddedField returns the numeric value that was incremented/decremented on a field
  33422. // with the given name. The second boolean return value indicates that this field
  33423. // was not set, or was not defined in the schema.
  33424. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  33425. switch name {
  33426. case workexperience.FieldOrganizationID:
  33427. return m.AddedOrganizationID()
  33428. }
  33429. return nil, false
  33430. }
  33431. // AddField adds the value to the field with the given name. It returns an error if
  33432. // the field is not defined in the schema, or if the type mismatched the field
  33433. // type.
  33434. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  33435. switch name {
  33436. case workexperience.FieldOrganizationID:
  33437. v, ok := value.(int64)
  33438. if !ok {
  33439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33440. }
  33441. m.AddOrganizationID(v)
  33442. return nil
  33443. }
  33444. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  33445. }
  33446. // ClearedFields returns all nullable fields that were cleared during this
  33447. // mutation.
  33448. func (m *WorkExperienceMutation) ClearedFields() []string {
  33449. var fields []string
  33450. if m.FieldCleared(workexperience.FieldDeletedAt) {
  33451. fields = append(fields, workexperience.FieldDeletedAt)
  33452. }
  33453. return fields
  33454. }
  33455. // FieldCleared returns a boolean indicating if a field with the given name was
  33456. // cleared in this mutation.
  33457. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  33458. _, ok := m.clearedFields[name]
  33459. return ok
  33460. }
  33461. // ClearField clears the value of the field with the given name. It returns an
  33462. // error if the field is not defined in the schema.
  33463. func (m *WorkExperienceMutation) ClearField(name string) error {
  33464. switch name {
  33465. case workexperience.FieldDeletedAt:
  33466. m.ClearDeletedAt()
  33467. return nil
  33468. }
  33469. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  33470. }
  33471. // ResetField resets all changes in the mutation for the field with the given name.
  33472. // It returns an error if the field is not defined in the schema.
  33473. func (m *WorkExperienceMutation) ResetField(name string) error {
  33474. switch name {
  33475. case workexperience.FieldCreatedAt:
  33476. m.ResetCreatedAt()
  33477. return nil
  33478. case workexperience.FieldUpdatedAt:
  33479. m.ResetUpdatedAt()
  33480. return nil
  33481. case workexperience.FieldDeletedAt:
  33482. m.ResetDeletedAt()
  33483. return nil
  33484. case workexperience.FieldEmployeeID:
  33485. m.ResetEmployeeID()
  33486. return nil
  33487. case workexperience.FieldStartDate:
  33488. m.ResetStartDate()
  33489. return nil
  33490. case workexperience.FieldEndDate:
  33491. m.ResetEndDate()
  33492. return nil
  33493. case workexperience.FieldCompany:
  33494. m.ResetCompany()
  33495. return nil
  33496. case workexperience.FieldExperience:
  33497. m.ResetExperience()
  33498. return nil
  33499. case workexperience.FieldOrganizationID:
  33500. m.ResetOrganizationID()
  33501. return nil
  33502. }
  33503. return fmt.Errorf("unknown WorkExperience field %s", name)
  33504. }
  33505. // AddedEdges returns all edge names that were set/added in this mutation.
  33506. func (m *WorkExperienceMutation) AddedEdges() []string {
  33507. edges := make([]string, 0, 1)
  33508. if m.employee != nil {
  33509. edges = append(edges, workexperience.EdgeEmployee)
  33510. }
  33511. return edges
  33512. }
  33513. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33514. // name in this mutation.
  33515. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  33516. switch name {
  33517. case workexperience.EdgeEmployee:
  33518. if id := m.employee; id != nil {
  33519. return []ent.Value{*id}
  33520. }
  33521. }
  33522. return nil
  33523. }
  33524. // RemovedEdges returns all edge names that were removed in this mutation.
  33525. func (m *WorkExperienceMutation) RemovedEdges() []string {
  33526. edges := make([]string, 0, 1)
  33527. return edges
  33528. }
  33529. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33530. // the given name in this mutation.
  33531. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  33532. return nil
  33533. }
  33534. // ClearedEdges returns all edge names that were cleared in this mutation.
  33535. func (m *WorkExperienceMutation) ClearedEdges() []string {
  33536. edges := make([]string, 0, 1)
  33537. if m.clearedemployee {
  33538. edges = append(edges, workexperience.EdgeEmployee)
  33539. }
  33540. return edges
  33541. }
  33542. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33543. // was cleared in this mutation.
  33544. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  33545. switch name {
  33546. case workexperience.EdgeEmployee:
  33547. return m.clearedemployee
  33548. }
  33549. return false
  33550. }
  33551. // ClearEdge clears the value of the edge with the given name. It returns an error
  33552. // if that edge is not defined in the schema.
  33553. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  33554. switch name {
  33555. case workexperience.EdgeEmployee:
  33556. m.ClearEmployee()
  33557. return nil
  33558. }
  33559. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  33560. }
  33561. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33562. // It returns an error if the edge is not defined in the schema.
  33563. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  33564. switch name {
  33565. case workexperience.EdgeEmployee:
  33566. m.ResetEmployee()
  33567. return nil
  33568. }
  33569. return fmt.Errorf("unknown WorkExperience edge %s", name)
  33570. }
  33571. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  33572. type WpChatroomMutation struct {
  33573. config
  33574. op Op
  33575. typ string
  33576. id *uint64
  33577. created_at *time.Time
  33578. updated_at *time.Time
  33579. status *uint8
  33580. addstatus *int8
  33581. wx_wxid *string
  33582. chatroom_id *string
  33583. nickname *string
  33584. owner *string
  33585. avatar *string
  33586. member_list *[]string
  33587. appendmember_list []string
  33588. clearedFields map[string]struct{}
  33589. done bool
  33590. oldValue func(context.Context) (*WpChatroom, error)
  33591. predicates []predicate.WpChatroom
  33592. }
  33593. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  33594. // wpchatroomOption allows management of the mutation configuration using functional options.
  33595. type wpchatroomOption func(*WpChatroomMutation)
  33596. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  33597. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  33598. m := &WpChatroomMutation{
  33599. config: c,
  33600. op: op,
  33601. typ: TypeWpChatroom,
  33602. clearedFields: make(map[string]struct{}),
  33603. }
  33604. for _, opt := range opts {
  33605. opt(m)
  33606. }
  33607. return m
  33608. }
  33609. // withWpChatroomID sets the ID field of the mutation.
  33610. func withWpChatroomID(id uint64) wpchatroomOption {
  33611. return func(m *WpChatroomMutation) {
  33612. var (
  33613. err error
  33614. once sync.Once
  33615. value *WpChatroom
  33616. )
  33617. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  33618. once.Do(func() {
  33619. if m.done {
  33620. err = errors.New("querying old values post mutation is not allowed")
  33621. } else {
  33622. value, err = m.Client().WpChatroom.Get(ctx, id)
  33623. }
  33624. })
  33625. return value, err
  33626. }
  33627. m.id = &id
  33628. }
  33629. }
  33630. // withWpChatroom sets the old WpChatroom of the mutation.
  33631. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  33632. return func(m *WpChatroomMutation) {
  33633. m.oldValue = func(context.Context) (*WpChatroom, error) {
  33634. return node, nil
  33635. }
  33636. m.id = &node.ID
  33637. }
  33638. }
  33639. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33640. // executed in a transaction (ent.Tx), a transactional client is returned.
  33641. func (m WpChatroomMutation) Client() *Client {
  33642. client := &Client{config: m.config}
  33643. client.init()
  33644. return client
  33645. }
  33646. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33647. // it returns an error otherwise.
  33648. func (m WpChatroomMutation) Tx() (*Tx, error) {
  33649. if _, ok := m.driver.(*txDriver); !ok {
  33650. return nil, errors.New("ent: mutation is not running in a transaction")
  33651. }
  33652. tx := &Tx{config: m.config}
  33653. tx.init()
  33654. return tx, nil
  33655. }
  33656. // SetID sets the value of the id field. Note that this
  33657. // operation is only accepted on creation of WpChatroom entities.
  33658. func (m *WpChatroomMutation) SetID(id uint64) {
  33659. m.id = &id
  33660. }
  33661. // ID returns the ID value in the mutation. Note that the ID is only available
  33662. // if it was provided to the builder or after it was returned from the database.
  33663. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  33664. if m.id == nil {
  33665. return
  33666. }
  33667. return *m.id, true
  33668. }
  33669. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33670. // That means, if the mutation is applied within a transaction with an isolation level such
  33671. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33672. // or updated by the mutation.
  33673. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  33674. switch {
  33675. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33676. id, exists := m.ID()
  33677. if exists {
  33678. return []uint64{id}, nil
  33679. }
  33680. fallthrough
  33681. case m.op.Is(OpUpdate | OpDelete):
  33682. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  33683. default:
  33684. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33685. }
  33686. }
  33687. // SetCreatedAt sets the "created_at" field.
  33688. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  33689. m.created_at = &t
  33690. }
  33691. // CreatedAt returns the value of the "created_at" field in the mutation.
  33692. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  33693. v := m.created_at
  33694. if v == nil {
  33695. return
  33696. }
  33697. return *v, true
  33698. }
  33699. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  33700. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  33701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33702. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33703. if !m.op.Is(OpUpdateOne) {
  33704. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33705. }
  33706. if m.id == nil || m.oldValue == nil {
  33707. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33708. }
  33709. oldValue, err := m.oldValue(ctx)
  33710. if err != nil {
  33711. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33712. }
  33713. return oldValue.CreatedAt, nil
  33714. }
  33715. // ResetCreatedAt resets all changes to the "created_at" field.
  33716. func (m *WpChatroomMutation) ResetCreatedAt() {
  33717. m.created_at = nil
  33718. }
  33719. // SetUpdatedAt sets the "updated_at" field.
  33720. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  33721. m.updated_at = &t
  33722. }
  33723. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33724. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  33725. v := m.updated_at
  33726. if v == nil {
  33727. return
  33728. }
  33729. return *v, true
  33730. }
  33731. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  33732. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  33733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33734. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33735. if !m.op.Is(OpUpdateOne) {
  33736. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33737. }
  33738. if m.id == nil || m.oldValue == nil {
  33739. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33740. }
  33741. oldValue, err := m.oldValue(ctx)
  33742. if err != nil {
  33743. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33744. }
  33745. return oldValue.UpdatedAt, nil
  33746. }
  33747. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33748. func (m *WpChatroomMutation) ResetUpdatedAt() {
  33749. m.updated_at = nil
  33750. }
  33751. // SetStatus sets the "status" field.
  33752. func (m *WpChatroomMutation) SetStatus(u uint8) {
  33753. m.status = &u
  33754. m.addstatus = nil
  33755. }
  33756. // Status returns the value of the "status" field in the mutation.
  33757. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  33758. v := m.status
  33759. if v == nil {
  33760. return
  33761. }
  33762. return *v, true
  33763. }
  33764. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  33765. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  33766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33767. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33768. if !m.op.Is(OpUpdateOne) {
  33769. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33770. }
  33771. if m.id == nil || m.oldValue == nil {
  33772. return v, errors.New("OldStatus requires an ID field in the mutation")
  33773. }
  33774. oldValue, err := m.oldValue(ctx)
  33775. if err != nil {
  33776. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33777. }
  33778. return oldValue.Status, nil
  33779. }
  33780. // AddStatus adds u to the "status" field.
  33781. func (m *WpChatroomMutation) AddStatus(u int8) {
  33782. if m.addstatus != nil {
  33783. *m.addstatus += u
  33784. } else {
  33785. m.addstatus = &u
  33786. }
  33787. }
  33788. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33789. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  33790. v := m.addstatus
  33791. if v == nil {
  33792. return
  33793. }
  33794. return *v, true
  33795. }
  33796. // ClearStatus clears the value of the "status" field.
  33797. func (m *WpChatroomMutation) ClearStatus() {
  33798. m.status = nil
  33799. m.addstatus = nil
  33800. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  33801. }
  33802. // StatusCleared returns if the "status" field was cleared in this mutation.
  33803. func (m *WpChatroomMutation) StatusCleared() bool {
  33804. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  33805. return ok
  33806. }
  33807. // ResetStatus resets all changes to the "status" field.
  33808. func (m *WpChatroomMutation) ResetStatus() {
  33809. m.status = nil
  33810. m.addstatus = nil
  33811. delete(m.clearedFields, wpchatroom.FieldStatus)
  33812. }
  33813. // SetWxWxid sets the "wx_wxid" field.
  33814. func (m *WpChatroomMutation) SetWxWxid(s string) {
  33815. m.wx_wxid = &s
  33816. }
  33817. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  33818. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  33819. v := m.wx_wxid
  33820. if v == nil {
  33821. return
  33822. }
  33823. return *v, true
  33824. }
  33825. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  33826. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  33827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33828. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  33829. if !m.op.Is(OpUpdateOne) {
  33830. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  33831. }
  33832. if m.id == nil || m.oldValue == nil {
  33833. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  33834. }
  33835. oldValue, err := m.oldValue(ctx)
  33836. if err != nil {
  33837. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  33838. }
  33839. return oldValue.WxWxid, nil
  33840. }
  33841. // ResetWxWxid resets all changes to the "wx_wxid" field.
  33842. func (m *WpChatroomMutation) ResetWxWxid() {
  33843. m.wx_wxid = nil
  33844. }
  33845. // SetChatroomID sets the "chatroom_id" field.
  33846. func (m *WpChatroomMutation) SetChatroomID(s string) {
  33847. m.chatroom_id = &s
  33848. }
  33849. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  33850. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  33851. v := m.chatroom_id
  33852. if v == nil {
  33853. return
  33854. }
  33855. return *v, true
  33856. }
  33857. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  33858. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  33859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33860. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  33861. if !m.op.Is(OpUpdateOne) {
  33862. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  33863. }
  33864. if m.id == nil || m.oldValue == nil {
  33865. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  33866. }
  33867. oldValue, err := m.oldValue(ctx)
  33868. if err != nil {
  33869. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  33870. }
  33871. return oldValue.ChatroomID, nil
  33872. }
  33873. // ResetChatroomID resets all changes to the "chatroom_id" field.
  33874. func (m *WpChatroomMutation) ResetChatroomID() {
  33875. m.chatroom_id = nil
  33876. }
  33877. // SetNickname sets the "nickname" field.
  33878. func (m *WpChatroomMutation) SetNickname(s string) {
  33879. m.nickname = &s
  33880. }
  33881. // Nickname returns the value of the "nickname" field in the mutation.
  33882. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  33883. v := m.nickname
  33884. if v == nil {
  33885. return
  33886. }
  33887. return *v, true
  33888. }
  33889. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  33890. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  33891. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33892. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  33893. if !m.op.Is(OpUpdateOne) {
  33894. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  33895. }
  33896. if m.id == nil || m.oldValue == nil {
  33897. return v, errors.New("OldNickname requires an ID field in the mutation")
  33898. }
  33899. oldValue, err := m.oldValue(ctx)
  33900. if err != nil {
  33901. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  33902. }
  33903. return oldValue.Nickname, nil
  33904. }
  33905. // ResetNickname resets all changes to the "nickname" field.
  33906. func (m *WpChatroomMutation) ResetNickname() {
  33907. m.nickname = nil
  33908. }
  33909. // SetOwner sets the "owner" field.
  33910. func (m *WpChatroomMutation) SetOwner(s string) {
  33911. m.owner = &s
  33912. }
  33913. // Owner returns the value of the "owner" field in the mutation.
  33914. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  33915. v := m.owner
  33916. if v == nil {
  33917. return
  33918. }
  33919. return *v, true
  33920. }
  33921. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  33922. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  33923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33924. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  33925. if !m.op.Is(OpUpdateOne) {
  33926. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  33927. }
  33928. if m.id == nil || m.oldValue == nil {
  33929. return v, errors.New("OldOwner requires an ID field in the mutation")
  33930. }
  33931. oldValue, err := m.oldValue(ctx)
  33932. if err != nil {
  33933. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  33934. }
  33935. return oldValue.Owner, nil
  33936. }
  33937. // ResetOwner resets all changes to the "owner" field.
  33938. func (m *WpChatroomMutation) ResetOwner() {
  33939. m.owner = nil
  33940. }
  33941. // SetAvatar sets the "avatar" field.
  33942. func (m *WpChatroomMutation) SetAvatar(s string) {
  33943. m.avatar = &s
  33944. }
  33945. // Avatar returns the value of the "avatar" field in the mutation.
  33946. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  33947. v := m.avatar
  33948. if v == nil {
  33949. return
  33950. }
  33951. return *v, true
  33952. }
  33953. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  33954. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  33955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33956. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  33957. if !m.op.Is(OpUpdateOne) {
  33958. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  33959. }
  33960. if m.id == nil || m.oldValue == nil {
  33961. return v, errors.New("OldAvatar requires an ID field in the mutation")
  33962. }
  33963. oldValue, err := m.oldValue(ctx)
  33964. if err != nil {
  33965. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  33966. }
  33967. return oldValue.Avatar, nil
  33968. }
  33969. // ResetAvatar resets all changes to the "avatar" field.
  33970. func (m *WpChatroomMutation) ResetAvatar() {
  33971. m.avatar = nil
  33972. }
  33973. // SetMemberList sets the "member_list" field.
  33974. func (m *WpChatroomMutation) SetMemberList(s []string) {
  33975. m.member_list = &s
  33976. m.appendmember_list = nil
  33977. }
  33978. // MemberList returns the value of the "member_list" field in the mutation.
  33979. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  33980. v := m.member_list
  33981. if v == nil {
  33982. return
  33983. }
  33984. return *v, true
  33985. }
  33986. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  33987. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  33988. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33989. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  33990. if !m.op.Is(OpUpdateOne) {
  33991. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  33992. }
  33993. if m.id == nil || m.oldValue == nil {
  33994. return v, errors.New("OldMemberList requires an ID field in the mutation")
  33995. }
  33996. oldValue, err := m.oldValue(ctx)
  33997. if err != nil {
  33998. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  33999. }
  34000. return oldValue.MemberList, nil
  34001. }
  34002. // AppendMemberList adds s to the "member_list" field.
  34003. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  34004. m.appendmember_list = append(m.appendmember_list, s...)
  34005. }
  34006. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  34007. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  34008. if len(m.appendmember_list) == 0 {
  34009. return nil, false
  34010. }
  34011. return m.appendmember_list, true
  34012. }
  34013. // ResetMemberList resets all changes to the "member_list" field.
  34014. func (m *WpChatroomMutation) ResetMemberList() {
  34015. m.member_list = nil
  34016. m.appendmember_list = nil
  34017. }
  34018. // Where appends a list predicates to the WpChatroomMutation builder.
  34019. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  34020. m.predicates = append(m.predicates, ps...)
  34021. }
  34022. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  34023. // users can use type-assertion to append predicates that do not depend on any generated package.
  34024. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  34025. p := make([]predicate.WpChatroom, len(ps))
  34026. for i := range ps {
  34027. p[i] = ps[i]
  34028. }
  34029. m.Where(p...)
  34030. }
  34031. // Op returns the operation name.
  34032. func (m *WpChatroomMutation) Op() Op {
  34033. return m.op
  34034. }
  34035. // SetOp allows setting the mutation operation.
  34036. func (m *WpChatroomMutation) SetOp(op Op) {
  34037. m.op = op
  34038. }
  34039. // Type returns the node type of this mutation (WpChatroom).
  34040. func (m *WpChatroomMutation) Type() string {
  34041. return m.typ
  34042. }
  34043. // Fields returns all fields that were changed during this mutation. Note that in
  34044. // order to get all numeric fields that were incremented/decremented, call
  34045. // AddedFields().
  34046. func (m *WpChatroomMutation) Fields() []string {
  34047. fields := make([]string, 0, 9)
  34048. if m.created_at != nil {
  34049. fields = append(fields, wpchatroom.FieldCreatedAt)
  34050. }
  34051. if m.updated_at != nil {
  34052. fields = append(fields, wpchatroom.FieldUpdatedAt)
  34053. }
  34054. if m.status != nil {
  34055. fields = append(fields, wpchatroom.FieldStatus)
  34056. }
  34057. if m.wx_wxid != nil {
  34058. fields = append(fields, wpchatroom.FieldWxWxid)
  34059. }
  34060. if m.chatroom_id != nil {
  34061. fields = append(fields, wpchatroom.FieldChatroomID)
  34062. }
  34063. if m.nickname != nil {
  34064. fields = append(fields, wpchatroom.FieldNickname)
  34065. }
  34066. if m.owner != nil {
  34067. fields = append(fields, wpchatroom.FieldOwner)
  34068. }
  34069. if m.avatar != nil {
  34070. fields = append(fields, wpchatroom.FieldAvatar)
  34071. }
  34072. if m.member_list != nil {
  34073. fields = append(fields, wpchatroom.FieldMemberList)
  34074. }
  34075. return fields
  34076. }
  34077. // Field returns the value of a field with the given name. The second boolean
  34078. // return value indicates that this field was not set, or was not defined in the
  34079. // schema.
  34080. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  34081. switch name {
  34082. case wpchatroom.FieldCreatedAt:
  34083. return m.CreatedAt()
  34084. case wpchatroom.FieldUpdatedAt:
  34085. return m.UpdatedAt()
  34086. case wpchatroom.FieldStatus:
  34087. return m.Status()
  34088. case wpchatroom.FieldWxWxid:
  34089. return m.WxWxid()
  34090. case wpchatroom.FieldChatroomID:
  34091. return m.ChatroomID()
  34092. case wpchatroom.FieldNickname:
  34093. return m.Nickname()
  34094. case wpchatroom.FieldOwner:
  34095. return m.Owner()
  34096. case wpchatroom.FieldAvatar:
  34097. return m.Avatar()
  34098. case wpchatroom.FieldMemberList:
  34099. return m.MemberList()
  34100. }
  34101. return nil, false
  34102. }
  34103. // OldField returns the old value of the field from the database. An error is
  34104. // returned if the mutation operation is not UpdateOne, or the query to the
  34105. // database failed.
  34106. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34107. switch name {
  34108. case wpchatroom.FieldCreatedAt:
  34109. return m.OldCreatedAt(ctx)
  34110. case wpchatroom.FieldUpdatedAt:
  34111. return m.OldUpdatedAt(ctx)
  34112. case wpchatroom.FieldStatus:
  34113. return m.OldStatus(ctx)
  34114. case wpchatroom.FieldWxWxid:
  34115. return m.OldWxWxid(ctx)
  34116. case wpchatroom.FieldChatroomID:
  34117. return m.OldChatroomID(ctx)
  34118. case wpchatroom.FieldNickname:
  34119. return m.OldNickname(ctx)
  34120. case wpchatroom.FieldOwner:
  34121. return m.OldOwner(ctx)
  34122. case wpchatroom.FieldAvatar:
  34123. return m.OldAvatar(ctx)
  34124. case wpchatroom.FieldMemberList:
  34125. return m.OldMemberList(ctx)
  34126. }
  34127. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  34128. }
  34129. // SetField sets the value of a field with the given name. It returns an error if
  34130. // the field is not defined in the schema, or if the type mismatched the field
  34131. // type.
  34132. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  34133. switch name {
  34134. case wpchatroom.FieldCreatedAt:
  34135. v, ok := value.(time.Time)
  34136. if !ok {
  34137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34138. }
  34139. m.SetCreatedAt(v)
  34140. return nil
  34141. case wpchatroom.FieldUpdatedAt:
  34142. v, ok := value.(time.Time)
  34143. if !ok {
  34144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34145. }
  34146. m.SetUpdatedAt(v)
  34147. return nil
  34148. case wpchatroom.FieldStatus:
  34149. v, ok := value.(uint8)
  34150. if !ok {
  34151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34152. }
  34153. m.SetStatus(v)
  34154. return nil
  34155. case wpchatroom.FieldWxWxid:
  34156. v, ok := value.(string)
  34157. if !ok {
  34158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34159. }
  34160. m.SetWxWxid(v)
  34161. return nil
  34162. case wpchatroom.FieldChatroomID:
  34163. v, ok := value.(string)
  34164. if !ok {
  34165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34166. }
  34167. m.SetChatroomID(v)
  34168. return nil
  34169. case wpchatroom.FieldNickname:
  34170. v, ok := value.(string)
  34171. if !ok {
  34172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34173. }
  34174. m.SetNickname(v)
  34175. return nil
  34176. case wpchatroom.FieldOwner:
  34177. v, ok := value.(string)
  34178. if !ok {
  34179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34180. }
  34181. m.SetOwner(v)
  34182. return nil
  34183. case wpchatroom.FieldAvatar:
  34184. v, ok := value.(string)
  34185. if !ok {
  34186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34187. }
  34188. m.SetAvatar(v)
  34189. return nil
  34190. case wpchatroom.FieldMemberList:
  34191. v, ok := value.([]string)
  34192. if !ok {
  34193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34194. }
  34195. m.SetMemberList(v)
  34196. return nil
  34197. }
  34198. return fmt.Errorf("unknown WpChatroom field %s", name)
  34199. }
  34200. // AddedFields returns all numeric fields that were incremented/decremented during
  34201. // this mutation.
  34202. func (m *WpChatroomMutation) AddedFields() []string {
  34203. var fields []string
  34204. if m.addstatus != nil {
  34205. fields = append(fields, wpchatroom.FieldStatus)
  34206. }
  34207. return fields
  34208. }
  34209. // AddedField returns the numeric value that was incremented/decremented on a field
  34210. // with the given name. The second boolean return value indicates that this field
  34211. // was not set, or was not defined in the schema.
  34212. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  34213. switch name {
  34214. case wpchatroom.FieldStatus:
  34215. return m.AddedStatus()
  34216. }
  34217. return nil, false
  34218. }
  34219. // AddField adds the value to the field with the given name. It returns an error if
  34220. // the field is not defined in the schema, or if the type mismatched the field
  34221. // type.
  34222. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  34223. switch name {
  34224. case wpchatroom.FieldStatus:
  34225. v, ok := value.(int8)
  34226. if !ok {
  34227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34228. }
  34229. m.AddStatus(v)
  34230. return nil
  34231. }
  34232. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  34233. }
  34234. // ClearedFields returns all nullable fields that were cleared during this
  34235. // mutation.
  34236. func (m *WpChatroomMutation) ClearedFields() []string {
  34237. var fields []string
  34238. if m.FieldCleared(wpchatroom.FieldStatus) {
  34239. fields = append(fields, wpchatroom.FieldStatus)
  34240. }
  34241. return fields
  34242. }
  34243. // FieldCleared returns a boolean indicating if a field with the given name was
  34244. // cleared in this mutation.
  34245. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  34246. _, ok := m.clearedFields[name]
  34247. return ok
  34248. }
  34249. // ClearField clears the value of the field with the given name. It returns an
  34250. // error if the field is not defined in the schema.
  34251. func (m *WpChatroomMutation) ClearField(name string) error {
  34252. switch name {
  34253. case wpchatroom.FieldStatus:
  34254. m.ClearStatus()
  34255. return nil
  34256. }
  34257. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  34258. }
  34259. // ResetField resets all changes in the mutation for the field with the given name.
  34260. // It returns an error if the field is not defined in the schema.
  34261. func (m *WpChatroomMutation) ResetField(name string) error {
  34262. switch name {
  34263. case wpchatroom.FieldCreatedAt:
  34264. m.ResetCreatedAt()
  34265. return nil
  34266. case wpchatroom.FieldUpdatedAt:
  34267. m.ResetUpdatedAt()
  34268. return nil
  34269. case wpchatroom.FieldStatus:
  34270. m.ResetStatus()
  34271. return nil
  34272. case wpchatroom.FieldWxWxid:
  34273. m.ResetWxWxid()
  34274. return nil
  34275. case wpchatroom.FieldChatroomID:
  34276. m.ResetChatroomID()
  34277. return nil
  34278. case wpchatroom.FieldNickname:
  34279. m.ResetNickname()
  34280. return nil
  34281. case wpchatroom.FieldOwner:
  34282. m.ResetOwner()
  34283. return nil
  34284. case wpchatroom.FieldAvatar:
  34285. m.ResetAvatar()
  34286. return nil
  34287. case wpchatroom.FieldMemberList:
  34288. m.ResetMemberList()
  34289. return nil
  34290. }
  34291. return fmt.Errorf("unknown WpChatroom field %s", name)
  34292. }
  34293. // AddedEdges returns all edge names that were set/added in this mutation.
  34294. func (m *WpChatroomMutation) AddedEdges() []string {
  34295. edges := make([]string, 0, 0)
  34296. return edges
  34297. }
  34298. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34299. // name in this mutation.
  34300. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  34301. return nil
  34302. }
  34303. // RemovedEdges returns all edge names that were removed in this mutation.
  34304. func (m *WpChatroomMutation) RemovedEdges() []string {
  34305. edges := make([]string, 0, 0)
  34306. return edges
  34307. }
  34308. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34309. // the given name in this mutation.
  34310. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  34311. return nil
  34312. }
  34313. // ClearedEdges returns all edge names that were cleared in this mutation.
  34314. func (m *WpChatroomMutation) ClearedEdges() []string {
  34315. edges := make([]string, 0, 0)
  34316. return edges
  34317. }
  34318. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34319. // was cleared in this mutation.
  34320. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  34321. return false
  34322. }
  34323. // ClearEdge clears the value of the edge with the given name. It returns an error
  34324. // if that edge is not defined in the schema.
  34325. func (m *WpChatroomMutation) ClearEdge(name string) error {
  34326. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  34327. }
  34328. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34329. // It returns an error if the edge is not defined in the schema.
  34330. func (m *WpChatroomMutation) ResetEdge(name string) error {
  34331. return fmt.Errorf("unknown WpChatroom edge %s", name)
  34332. }
  34333. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  34334. type WpChatroomMemberMutation struct {
  34335. config
  34336. op Op
  34337. typ string
  34338. id *uint64
  34339. created_at *time.Time
  34340. updated_at *time.Time
  34341. status *uint8
  34342. addstatus *int8
  34343. wx_wxid *string
  34344. wxid *string
  34345. nickname *string
  34346. avatar *string
  34347. clearedFields map[string]struct{}
  34348. done bool
  34349. oldValue func(context.Context) (*WpChatroomMember, error)
  34350. predicates []predicate.WpChatroomMember
  34351. }
  34352. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  34353. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  34354. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  34355. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  34356. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  34357. m := &WpChatroomMemberMutation{
  34358. config: c,
  34359. op: op,
  34360. typ: TypeWpChatroomMember,
  34361. clearedFields: make(map[string]struct{}),
  34362. }
  34363. for _, opt := range opts {
  34364. opt(m)
  34365. }
  34366. return m
  34367. }
  34368. // withWpChatroomMemberID sets the ID field of the mutation.
  34369. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  34370. return func(m *WpChatroomMemberMutation) {
  34371. var (
  34372. err error
  34373. once sync.Once
  34374. value *WpChatroomMember
  34375. )
  34376. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  34377. once.Do(func() {
  34378. if m.done {
  34379. err = errors.New("querying old values post mutation is not allowed")
  34380. } else {
  34381. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  34382. }
  34383. })
  34384. return value, err
  34385. }
  34386. m.id = &id
  34387. }
  34388. }
  34389. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  34390. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  34391. return func(m *WpChatroomMemberMutation) {
  34392. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  34393. return node, nil
  34394. }
  34395. m.id = &node.ID
  34396. }
  34397. }
  34398. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34399. // executed in a transaction (ent.Tx), a transactional client is returned.
  34400. func (m WpChatroomMemberMutation) Client() *Client {
  34401. client := &Client{config: m.config}
  34402. client.init()
  34403. return client
  34404. }
  34405. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34406. // it returns an error otherwise.
  34407. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  34408. if _, ok := m.driver.(*txDriver); !ok {
  34409. return nil, errors.New("ent: mutation is not running in a transaction")
  34410. }
  34411. tx := &Tx{config: m.config}
  34412. tx.init()
  34413. return tx, nil
  34414. }
  34415. // SetID sets the value of the id field. Note that this
  34416. // operation is only accepted on creation of WpChatroomMember entities.
  34417. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  34418. m.id = &id
  34419. }
  34420. // ID returns the ID value in the mutation. Note that the ID is only available
  34421. // if it was provided to the builder or after it was returned from the database.
  34422. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  34423. if m.id == nil {
  34424. return
  34425. }
  34426. return *m.id, true
  34427. }
  34428. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34429. // That means, if the mutation is applied within a transaction with an isolation level such
  34430. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34431. // or updated by the mutation.
  34432. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  34433. switch {
  34434. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34435. id, exists := m.ID()
  34436. if exists {
  34437. return []uint64{id}, nil
  34438. }
  34439. fallthrough
  34440. case m.op.Is(OpUpdate | OpDelete):
  34441. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  34442. default:
  34443. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34444. }
  34445. }
  34446. // SetCreatedAt sets the "created_at" field.
  34447. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  34448. m.created_at = &t
  34449. }
  34450. // CreatedAt returns the value of the "created_at" field in the mutation.
  34451. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  34452. v := m.created_at
  34453. if v == nil {
  34454. return
  34455. }
  34456. return *v, true
  34457. }
  34458. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  34459. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  34460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34461. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34462. if !m.op.Is(OpUpdateOne) {
  34463. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34464. }
  34465. if m.id == nil || m.oldValue == nil {
  34466. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34467. }
  34468. oldValue, err := m.oldValue(ctx)
  34469. if err != nil {
  34470. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34471. }
  34472. return oldValue.CreatedAt, nil
  34473. }
  34474. // ResetCreatedAt resets all changes to the "created_at" field.
  34475. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  34476. m.created_at = nil
  34477. }
  34478. // SetUpdatedAt sets the "updated_at" field.
  34479. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  34480. m.updated_at = &t
  34481. }
  34482. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34483. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  34484. v := m.updated_at
  34485. if v == nil {
  34486. return
  34487. }
  34488. return *v, true
  34489. }
  34490. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  34491. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  34492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34493. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34494. if !m.op.Is(OpUpdateOne) {
  34495. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34496. }
  34497. if m.id == nil || m.oldValue == nil {
  34498. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34499. }
  34500. oldValue, err := m.oldValue(ctx)
  34501. if err != nil {
  34502. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34503. }
  34504. return oldValue.UpdatedAt, nil
  34505. }
  34506. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34507. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  34508. m.updated_at = nil
  34509. }
  34510. // SetStatus sets the "status" field.
  34511. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  34512. m.status = &u
  34513. m.addstatus = nil
  34514. }
  34515. // Status returns the value of the "status" field in the mutation.
  34516. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  34517. v := m.status
  34518. if v == nil {
  34519. return
  34520. }
  34521. return *v, true
  34522. }
  34523. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  34524. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  34525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34526. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  34527. if !m.op.Is(OpUpdateOne) {
  34528. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  34529. }
  34530. if m.id == nil || m.oldValue == nil {
  34531. return v, errors.New("OldStatus requires an ID field in the mutation")
  34532. }
  34533. oldValue, err := m.oldValue(ctx)
  34534. if err != nil {
  34535. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  34536. }
  34537. return oldValue.Status, nil
  34538. }
  34539. // AddStatus adds u to the "status" field.
  34540. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  34541. if m.addstatus != nil {
  34542. *m.addstatus += u
  34543. } else {
  34544. m.addstatus = &u
  34545. }
  34546. }
  34547. // AddedStatus returns the value that was added to the "status" field in this mutation.
  34548. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  34549. v := m.addstatus
  34550. if v == nil {
  34551. return
  34552. }
  34553. return *v, true
  34554. }
  34555. // ClearStatus clears the value of the "status" field.
  34556. func (m *WpChatroomMemberMutation) ClearStatus() {
  34557. m.status = nil
  34558. m.addstatus = nil
  34559. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  34560. }
  34561. // StatusCleared returns if the "status" field was cleared in this mutation.
  34562. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  34563. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  34564. return ok
  34565. }
  34566. // ResetStatus resets all changes to the "status" field.
  34567. func (m *WpChatroomMemberMutation) ResetStatus() {
  34568. m.status = nil
  34569. m.addstatus = nil
  34570. delete(m.clearedFields, wpchatroommember.FieldStatus)
  34571. }
  34572. // SetWxWxid sets the "wx_wxid" field.
  34573. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  34574. m.wx_wxid = &s
  34575. }
  34576. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  34577. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  34578. v := m.wx_wxid
  34579. if v == nil {
  34580. return
  34581. }
  34582. return *v, true
  34583. }
  34584. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  34585. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  34586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34587. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  34588. if !m.op.Is(OpUpdateOne) {
  34589. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  34590. }
  34591. if m.id == nil || m.oldValue == nil {
  34592. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  34593. }
  34594. oldValue, err := m.oldValue(ctx)
  34595. if err != nil {
  34596. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  34597. }
  34598. return oldValue.WxWxid, nil
  34599. }
  34600. // ResetWxWxid resets all changes to the "wx_wxid" field.
  34601. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  34602. m.wx_wxid = nil
  34603. }
  34604. // SetWxid sets the "wxid" field.
  34605. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  34606. m.wxid = &s
  34607. }
  34608. // Wxid returns the value of the "wxid" field in the mutation.
  34609. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  34610. v := m.wxid
  34611. if v == nil {
  34612. return
  34613. }
  34614. return *v, true
  34615. }
  34616. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  34617. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  34618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34619. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  34620. if !m.op.Is(OpUpdateOne) {
  34621. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  34622. }
  34623. if m.id == nil || m.oldValue == nil {
  34624. return v, errors.New("OldWxid requires an ID field in the mutation")
  34625. }
  34626. oldValue, err := m.oldValue(ctx)
  34627. if err != nil {
  34628. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  34629. }
  34630. return oldValue.Wxid, nil
  34631. }
  34632. // ResetWxid resets all changes to the "wxid" field.
  34633. func (m *WpChatroomMemberMutation) ResetWxid() {
  34634. m.wxid = nil
  34635. }
  34636. // SetNickname sets the "nickname" field.
  34637. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  34638. m.nickname = &s
  34639. }
  34640. // Nickname returns the value of the "nickname" field in the mutation.
  34641. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  34642. v := m.nickname
  34643. if v == nil {
  34644. return
  34645. }
  34646. return *v, true
  34647. }
  34648. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  34649. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  34650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34651. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  34652. if !m.op.Is(OpUpdateOne) {
  34653. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  34654. }
  34655. if m.id == nil || m.oldValue == nil {
  34656. return v, errors.New("OldNickname requires an ID field in the mutation")
  34657. }
  34658. oldValue, err := m.oldValue(ctx)
  34659. if err != nil {
  34660. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  34661. }
  34662. return oldValue.Nickname, nil
  34663. }
  34664. // ResetNickname resets all changes to the "nickname" field.
  34665. func (m *WpChatroomMemberMutation) ResetNickname() {
  34666. m.nickname = nil
  34667. }
  34668. // SetAvatar sets the "avatar" field.
  34669. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  34670. m.avatar = &s
  34671. }
  34672. // Avatar returns the value of the "avatar" field in the mutation.
  34673. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  34674. v := m.avatar
  34675. if v == nil {
  34676. return
  34677. }
  34678. return *v, true
  34679. }
  34680. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  34681. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  34682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34683. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  34684. if !m.op.Is(OpUpdateOne) {
  34685. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  34686. }
  34687. if m.id == nil || m.oldValue == nil {
  34688. return v, errors.New("OldAvatar requires an ID field in the mutation")
  34689. }
  34690. oldValue, err := m.oldValue(ctx)
  34691. if err != nil {
  34692. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  34693. }
  34694. return oldValue.Avatar, nil
  34695. }
  34696. // ResetAvatar resets all changes to the "avatar" field.
  34697. func (m *WpChatroomMemberMutation) ResetAvatar() {
  34698. m.avatar = nil
  34699. }
  34700. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  34701. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  34702. m.predicates = append(m.predicates, ps...)
  34703. }
  34704. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  34705. // users can use type-assertion to append predicates that do not depend on any generated package.
  34706. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  34707. p := make([]predicate.WpChatroomMember, len(ps))
  34708. for i := range ps {
  34709. p[i] = ps[i]
  34710. }
  34711. m.Where(p...)
  34712. }
  34713. // Op returns the operation name.
  34714. func (m *WpChatroomMemberMutation) Op() Op {
  34715. return m.op
  34716. }
  34717. // SetOp allows setting the mutation operation.
  34718. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  34719. m.op = op
  34720. }
  34721. // Type returns the node type of this mutation (WpChatroomMember).
  34722. func (m *WpChatroomMemberMutation) Type() string {
  34723. return m.typ
  34724. }
  34725. // Fields returns all fields that were changed during this mutation. Note that in
  34726. // order to get all numeric fields that were incremented/decremented, call
  34727. // AddedFields().
  34728. func (m *WpChatroomMemberMutation) Fields() []string {
  34729. fields := make([]string, 0, 7)
  34730. if m.created_at != nil {
  34731. fields = append(fields, wpchatroommember.FieldCreatedAt)
  34732. }
  34733. if m.updated_at != nil {
  34734. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  34735. }
  34736. if m.status != nil {
  34737. fields = append(fields, wpchatroommember.FieldStatus)
  34738. }
  34739. if m.wx_wxid != nil {
  34740. fields = append(fields, wpchatroommember.FieldWxWxid)
  34741. }
  34742. if m.wxid != nil {
  34743. fields = append(fields, wpchatroommember.FieldWxid)
  34744. }
  34745. if m.nickname != nil {
  34746. fields = append(fields, wpchatroommember.FieldNickname)
  34747. }
  34748. if m.avatar != nil {
  34749. fields = append(fields, wpchatroommember.FieldAvatar)
  34750. }
  34751. return fields
  34752. }
  34753. // Field returns the value of a field with the given name. The second boolean
  34754. // return value indicates that this field was not set, or was not defined in the
  34755. // schema.
  34756. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  34757. switch name {
  34758. case wpchatroommember.FieldCreatedAt:
  34759. return m.CreatedAt()
  34760. case wpchatroommember.FieldUpdatedAt:
  34761. return m.UpdatedAt()
  34762. case wpchatroommember.FieldStatus:
  34763. return m.Status()
  34764. case wpchatroommember.FieldWxWxid:
  34765. return m.WxWxid()
  34766. case wpchatroommember.FieldWxid:
  34767. return m.Wxid()
  34768. case wpchatroommember.FieldNickname:
  34769. return m.Nickname()
  34770. case wpchatroommember.FieldAvatar:
  34771. return m.Avatar()
  34772. }
  34773. return nil, false
  34774. }
  34775. // OldField returns the old value of the field from the database. An error is
  34776. // returned if the mutation operation is not UpdateOne, or the query to the
  34777. // database failed.
  34778. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34779. switch name {
  34780. case wpchatroommember.FieldCreatedAt:
  34781. return m.OldCreatedAt(ctx)
  34782. case wpchatroommember.FieldUpdatedAt:
  34783. return m.OldUpdatedAt(ctx)
  34784. case wpchatroommember.FieldStatus:
  34785. return m.OldStatus(ctx)
  34786. case wpchatroommember.FieldWxWxid:
  34787. return m.OldWxWxid(ctx)
  34788. case wpchatroommember.FieldWxid:
  34789. return m.OldWxid(ctx)
  34790. case wpchatroommember.FieldNickname:
  34791. return m.OldNickname(ctx)
  34792. case wpchatroommember.FieldAvatar:
  34793. return m.OldAvatar(ctx)
  34794. }
  34795. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  34796. }
  34797. // SetField sets the value of a field with the given name. It returns an error if
  34798. // the field is not defined in the schema, or if the type mismatched the field
  34799. // type.
  34800. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  34801. switch name {
  34802. case wpchatroommember.FieldCreatedAt:
  34803. v, ok := value.(time.Time)
  34804. if !ok {
  34805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34806. }
  34807. m.SetCreatedAt(v)
  34808. return nil
  34809. case wpchatroommember.FieldUpdatedAt:
  34810. v, ok := value.(time.Time)
  34811. if !ok {
  34812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34813. }
  34814. m.SetUpdatedAt(v)
  34815. return nil
  34816. case wpchatroommember.FieldStatus:
  34817. v, ok := value.(uint8)
  34818. if !ok {
  34819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34820. }
  34821. m.SetStatus(v)
  34822. return nil
  34823. case wpchatroommember.FieldWxWxid:
  34824. v, ok := value.(string)
  34825. if !ok {
  34826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34827. }
  34828. m.SetWxWxid(v)
  34829. return nil
  34830. case wpchatroommember.FieldWxid:
  34831. v, ok := value.(string)
  34832. if !ok {
  34833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34834. }
  34835. m.SetWxid(v)
  34836. return nil
  34837. case wpchatroommember.FieldNickname:
  34838. v, ok := value.(string)
  34839. if !ok {
  34840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34841. }
  34842. m.SetNickname(v)
  34843. return nil
  34844. case wpchatroommember.FieldAvatar:
  34845. v, ok := value.(string)
  34846. if !ok {
  34847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34848. }
  34849. m.SetAvatar(v)
  34850. return nil
  34851. }
  34852. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  34853. }
  34854. // AddedFields returns all numeric fields that were incremented/decremented during
  34855. // this mutation.
  34856. func (m *WpChatroomMemberMutation) AddedFields() []string {
  34857. var fields []string
  34858. if m.addstatus != nil {
  34859. fields = append(fields, wpchatroommember.FieldStatus)
  34860. }
  34861. return fields
  34862. }
  34863. // AddedField returns the numeric value that was incremented/decremented on a field
  34864. // with the given name. The second boolean return value indicates that this field
  34865. // was not set, or was not defined in the schema.
  34866. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  34867. switch name {
  34868. case wpchatroommember.FieldStatus:
  34869. return m.AddedStatus()
  34870. }
  34871. return nil, false
  34872. }
  34873. // AddField adds the value to the field with the given name. It returns an error if
  34874. // the field is not defined in the schema, or if the type mismatched the field
  34875. // type.
  34876. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  34877. switch name {
  34878. case wpchatroommember.FieldStatus:
  34879. v, ok := value.(int8)
  34880. if !ok {
  34881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34882. }
  34883. m.AddStatus(v)
  34884. return nil
  34885. }
  34886. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  34887. }
  34888. // ClearedFields returns all nullable fields that were cleared during this
  34889. // mutation.
  34890. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  34891. var fields []string
  34892. if m.FieldCleared(wpchatroommember.FieldStatus) {
  34893. fields = append(fields, wpchatroommember.FieldStatus)
  34894. }
  34895. return fields
  34896. }
  34897. // FieldCleared returns a boolean indicating if a field with the given name was
  34898. // cleared in this mutation.
  34899. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  34900. _, ok := m.clearedFields[name]
  34901. return ok
  34902. }
  34903. // ClearField clears the value of the field with the given name. It returns an
  34904. // error if the field is not defined in the schema.
  34905. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  34906. switch name {
  34907. case wpchatroommember.FieldStatus:
  34908. m.ClearStatus()
  34909. return nil
  34910. }
  34911. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  34912. }
  34913. // ResetField resets all changes in the mutation for the field with the given name.
  34914. // It returns an error if the field is not defined in the schema.
  34915. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  34916. switch name {
  34917. case wpchatroommember.FieldCreatedAt:
  34918. m.ResetCreatedAt()
  34919. return nil
  34920. case wpchatroommember.FieldUpdatedAt:
  34921. m.ResetUpdatedAt()
  34922. return nil
  34923. case wpchatroommember.FieldStatus:
  34924. m.ResetStatus()
  34925. return nil
  34926. case wpchatroommember.FieldWxWxid:
  34927. m.ResetWxWxid()
  34928. return nil
  34929. case wpchatroommember.FieldWxid:
  34930. m.ResetWxid()
  34931. return nil
  34932. case wpchatroommember.FieldNickname:
  34933. m.ResetNickname()
  34934. return nil
  34935. case wpchatroommember.FieldAvatar:
  34936. m.ResetAvatar()
  34937. return nil
  34938. }
  34939. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  34940. }
  34941. // AddedEdges returns all edge names that were set/added in this mutation.
  34942. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  34943. edges := make([]string, 0, 0)
  34944. return edges
  34945. }
  34946. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34947. // name in this mutation.
  34948. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  34949. return nil
  34950. }
  34951. // RemovedEdges returns all edge names that were removed in this mutation.
  34952. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  34953. edges := make([]string, 0, 0)
  34954. return edges
  34955. }
  34956. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34957. // the given name in this mutation.
  34958. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  34959. return nil
  34960. }
  34961. // ClearedEdges returns all edge names that were cleared in this mutation.
  34962. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  34963. edges := make([]string, 0, 0)
  34964. return edges
  34965. }
  34966. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34967. // was cleared in this mutation.
  34968. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  34969. return false
  34970. }
  34971. // ClearEdge clears the value of the edge with the given name. It returns an error
  34972. // if that edge is not defined in the schema.
  34973. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  34974. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  34975. }
  34976. // ResetEdge resets all changes to the edge with the given name in this mutation.
  34977. // It returns an error if the edge is not defined in the schema.
  34978. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  34979. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  34980. }
  34981. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  34982. type WxMutation struct {
  34983. config
  34984. op Op
  34985. typ string
  34986. id *uint64
  34987. created_at *time.Time
  34988. updated_at *time.Time
  34989. status *uint8
  34990. addstatus *int8
  34991. deleted_at *time.Time
  34992. port *string
  34993. process_id *string
  34994. callback *string
  34995. wxid *string
  34996. account *string
  34997. nickname *string
  34998. tel *string
  34999. head_big *string
  35000. organization_id *uint64
  35001. addorganization_id *int64
  35002. api_base *string
  35003. api_key *string
  35004. allow_list *[]string
  35005. appendallow_list []string
  35006. group_allow_list *[]string
  35007. appendgroup_allow_list []string
  35008. block_list *[]string
  35009. appendblock_list []string
  35010. group_block_list *[]string
  35011. appendgroup_block_list []string
  35012. clearedFields map[string]struct{}
  35013. server *uint64
  35014. clearedserver bool
  35015. agent *uint64
  35016. clearedagent bool
  35017. done bool
  35018. oldValue func(context.Context) (*Wx, error)
  35019. predicates []predicate.Wx
  35020. }
  35021. var _ ent.Mutation = (*WxMutation)(nil)
  35022. // wxOption allows management of the mutation configuration using functional options.
  35023. type wxOption func(*WxMutation)
  35024. // newWxMutation creates new mutation for the Wx entity.
  35025. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  35026. m := &WxMutation{
  35027. config: c,
  35028. op: op,
  35029. typ: TypeWx,
  35030. clearedFields: make(map[string]struct{}),
  35031. }
  35032. for _, opt := range opts {
  35033. opt(m)
  35034. }
  35035. return m
  35036. }
  35037. // withWxID sets the ID field of the mutation.
  35038. func withWxID(id uint64) wxOption {
  35039. return func(m *WxMutation) {
  35040. var (
  35041. err error
  35042. once sync.Once
  35043. value *Wx
  35044. )
  35045. m.oldValue = func(ctx context.Context) (*Wx, error) {
  35046. once.Do(func() {
  35047. if m.done {
  35048. err = errors.New("querying old values post mutation is not allowed")
  35049. } else {
  35050. value, err = m.Client().Wx.Get(ctx, id)
  35051. }
  35052. })
  35053. return value, err
  35054. }
  35055. m.id = &id
  35056. }
  35057. }
  35058. // withWx sets the old Wx of the mutation.
  35059. func withWx(node *Wx) wxOption {
  35060. return func(m *WxMutation) {
  35061. m.oldValue = func(context.Context) (*Wx, error) {
  35062. return node, nil
  35063. }
  35064. m.id = &node.ID
  35065. }
  35066. }
  35067. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35068. // executed in a transaction (ent.Tx), a transactional client is returned.
  35069. func (m WxMutation) Client() *Client {
  35070. client := &Client{config: m.config}
  35071. client.init()
  35072. return client
  35073. }
  35074. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35075. // it returns an error otherwise.
  35076. func (m WxMutation) Tx() (*Tx, error) {
  35077. if _, ok := m.driver.(*txDriver); !ok {
  35078. return nil, errors.New("ent: mutation is not running in a transaction")
  35079. }
  35080. tx := &Tx{config: m.config}
  35081. tx.init()
  35082. return tx, nil
  35083. }
  35084. // SetID sets the value of the id field. Note that this
  35085. // operation is only accepted on creation of Wx entities.
  35086. func (m *WxMutation) SetID(id uint64) {
  35087. m.id = &id
  35088. }
  35089. // ID returns the ID value in the mutation. Note that the ID is only available
  35090. // if it was provided to the builder or after it was returned from the database.
  35091. func (m *WxMutation) ID() (id uint64, exists bool) {
  35092. if m.id == nil {
  35093. return
  35094. }
  35095. return *m.id, true
  35096. }
  35097. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35098. // That means, if the mutation is applied within a transaction with an isolation level such
  35099. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35100. // or updated by the mutation.
  35101. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  35102. switch {
  35103. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35104. id, exists := m.ID()
  35105. if exists {
  35106. return []uint64{id}, nil
  35107. }
  35108. fallthrough
  35109. case m.op.Is(OpUpdate | OpDelete):
  35110. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  35111. default:
  35112. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35113. }
  35114. }
  35115. // SetCreatedAt sets the "created_at" field.
  35116. func (m *WxMutation) SetCreatedAt(t time.Time) {
  35117. m.created_at = &t
  35118. }
  35119. // CreatedAt returns the value of the "created_at" field in the mutation.
  35120. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  35121. v := m.created_at
  35122. if v == nil {
  35123. return
  35124. }
  35125. return *v, true
  35126. }
  35127. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  35128. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  35129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35130. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35131. if !m.op.Is(OpUpdateOne) {
  35132. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35133. }
  35134. if m.id == nil || m.oldValue == nil {
  35135. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35136. }
  35137. oldValue, err := m.oldValue(ctx)
  35138. if err != nil {
  35139. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35140. }
  35141. return oldValue.CreatedAt, nil
  35142. }
  35143. // ResetCreatedAt resets all changes to the "created_at" field.
  35144. func (m *WxMutation) ResetCreatedAt() {
  35145. m.created_at = nil
  35146. }
  35147. // SetUpdatedAt sets the "updated_at" field.
  35148. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  35149. m.updated_at = &t
  35150. }
  35151. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35152. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  35153. v := m.updated_at
  35154. if v == nil {
  35155. return
  35156. }
  35157. return *v, true
  35158. }
  35159. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  35160. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  35161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35162. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35163. if !m.op.Is(OpUpdateOne) {
  35164. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35165. }
  35166. if m.id == nil || m.oldValue == nil {
  35167. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35168. }
  35169. oldValue, err := m.oldValue(ctx)
  35170. if err != nil {
  35171. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35172. }
  35173. return oldValue.UpdatedAt, nil
  35174. }
  35175. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35176. func (m *WxMutation) ResetUpdatedAt() {
  35177. m.updated_at = nil
  35178. }
  35179. // SetStatus sets the "status" field.
  35180. func (m *WxMutation) SetStatus(u uint8) {
  35181. m.status = &u
  35182. m.addstatus = nil
  35183. }
  35184. // Status returns the value of the "status" field in the mutation.
  35185. func (m *WxMutation) Status() (r uint8, exists bool) {
  35186. v := m.status
  35187. if v == nil {
  35188. return
  35189. }
  35190. return *v, true
  35191. }
  35192. // OldStatus returns the old "status" field's value of the Wx entity.
  35193. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  35194. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35195. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35196. if !m.op.Is(OpUpdateOne) {
  35197. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  35198. }
  35199. if m.id == nil || m.oldValue == nil {
  35200. return v, errors.New("OldStatus requires an ID field in the mutation")
  35201. }
  35202. oldValue, err := m.oldValue(ctx)
  35203. if err != nil {
  35204. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  35205. }
  35206. return oldValue.Status, nil
  35207. }
  35208. // AddStatus adds u to the "status" field.
  35209. func (m *WxMutation) AddStatus(u int8) {
  35210. if m.addstatus != nil {
  35211. *m.addstatus += u
  35212. } else {
  35213. m.addstatus = &u
  35214. }
  35215. }
  35216. // AddedStatus returns the value that was added to the "status" field in this mutation.
  35217. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  35218. v := m.addstatus
  35219. if v == nil {
  35220. return
  35221. }
  35222. return *v, true
  35223. }
  35224. // ClearStatus clears the value of the "status" field.
  35225. func (m *WxMutation) ClearStatus() {
  35226. m.status = nil
  35227. m.addstatus = nil
  35228. m.clearedFields[wx.FieldStatus] = struct{}{}
  35229. }
  35230. // StatusCleared returns if the "status" field was cleared in this mutation.
  35231. func (m *WxMutation) StatusCleared() bool {
  35232. _, ok := m.clearedFields[wx.FieldStatus]
  35233. return ok
  35234. }
  35235. // ResetStatus resets all changes to the "status" field.
  35236. func (m *WxMutation) ResetStatus() {
  35237. m.status = nil
  35238. m.addstatus = nil
  35239. delete(m.clearedFields, wx.FieldStatus)
  35240. }
  35241. // SetDeletedAt sets the "deleted_at" field.
  35242. func (m *WxMutation) SetDeletedAt(t time.Time) {
  35243. m.deleted_at = &t
  35244. }
  35245. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35246. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  35247. v := m.deleted_at
  35248. if v == nil {
  35249. return
  35250. }
  35251. return *v, true
  35252. }
  35253. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  35254. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  35255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35256. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35257. if !m.op.Is(OpUpdateOne) {
  35258. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35259. }
  35260. if m.id == nil || m.oldValue == nil {
  35261. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35262. }
  35263. oldValue, err := m.oldValue(ctx)
  35264. if err != nil {
  35265. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35266. }
  35267. return oldValue.DeletedAt, nil
  35268. }
  35269. // ClearDeletedAt clears the value of the "deleted_at" field.
  35270. func (m *WxMutation) ClearDeletedAt() {
  35271. m.deleted_at = nil
  35272. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  35273. }
  35274. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35275. func (m *WxMutation) DeletedAtCleared() bool {
  35276. _, ok := m.clearedFields[wx.FieldDeletedAt]
  35277. return ok
  35278. }
  35279. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35280. func (m *WxMutation) ResetDeletedAt() {
  35281. m.deleted_at = nil
  35282. delete(m.clearedFields, wx.FieldDeletedAt)
  35283. }
  35284. // SetServerID sets the "server_id" field.
  35285. func (m *WxMutation) SetServerID(u uint64) {
  35286. m.server = &u
  35287. }
  35288. // ServerID returns the value of the "server_id" field in the mutation.
  35289. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  35290. v := m.server
  35291. if v == nil {
  35292. return
  35293. }
  35294. return *v, true
  35295. }
  35296. // OldServerID returns the old "server_id" field's value of the Wx entity.
  35297. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  35298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35299. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  35300. if !m.op.Is(OpUpdateOne) {
  35301. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  35302. }
  35303. if m.id == nil || m.oldValue == nil {
  35304. return v, errors.New("OldServerID requires an ID field in the mutation")
  35305. }
  35306. oldValue, err := m.oldValue(ctx)
  35307. if err != nil {
  35308. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  35309. }
  35310. return oldValue.ServerID, nil
  35311. }
  35312. // ClearServerID clears the value of the "server_id" field.
  35313. func (m *WxMutation) ClearServerID() {
  35314. m.server = nil
  35315. m.clearedFields[wx.FieldServerID] = struct{}{}
  35316. }
  35317. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  35318. func (m *WxMutation) ServerIDCleared() bool {
  35319. _, ok := m.clearedFields[wx.FieldServerID]
  35320. return ok
  35321. }
  35322. // ResetServerID resets all changes to the "server_id" field.
  35323. func (m *WxMutation) ResetServerID() {
  35324. m.server = nil
  35325. delete(m.clearedFields, wx.FieldServerID)
  35326. }
  35327. // SetPort sets the "port" field.
  35328. func (m *WxMutation) SetPort(s string) {
  35329. m.port = &s
  35330. }
  35331. // Port returns the value of the "port" field in the mutation.
  35332. func (m *WxMutation) Port() (r string, exists bool) {
  35333. v := m.port
  35334. if v == nil {
  35335. return
  35336. }
  35337. return *v, true
  35338. }
  35339. // OldPort returns the old "port" field's value of the Wx entity.
  35340. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  35341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35342. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  35343. if !m.op.Is(OpUpdateOne) {
  35344. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  35345. }
  35346. if m.id == nil || m.oldValue == nil {
  35347. return v, errors.New("OldPort requires an ID field in the mutation")
  35348. }
  35349. oldValue, err := m.oldValue(ctx)
  35350. if err != nil {
  35351. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  35352. }
  35353. return oldValue.Port, nil
  35354. }
  35355. // ResetPort resets all changes to the "port" field.
  35356. func (m *WxMutation) ResetPort() {
  35357. m.port = nil
  35358. }
  35359. // SetProcessID sets the "process_id" field.
  35360. func (m *WxMutation) SetProcessID(s string) {
  35361. m.process_id = &s
  35362. }
  35363. // ProcessID returns the value of the "process_id" field in the mutation.
  35364. func (m *WxMutation) ProcessID() (r string, exists bool) {
  35365. v := m.process_id
  35366. if v == nil {
  35367. return
  35368. }
  35369. return *v, true
  35370. }
  35371. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  35372. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  35373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35374. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  35375. if !m.op.Is(OpUpdateOne) {
  35376. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  35377. }
  35378. if m.id == nil || m.oldValue == nil {
  35379. return v, errors.New("OldProcessID requires an ID field in the mutation")
  35380. }
  35381. oldValue, err := m.oldValue(ctx)
  35382. if err != nil {
  35383. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  35384. }
  35385. return oldValue.ProcessID, nil
  35386. }
  35387. // ResetProcessID resets all changes to the "process_id" field.
  35388. func (m *WxMutation) ResetProcessID() {
  35389. m.process_id = nil
  35390. }
  35391. // SetCallback sets the "callback" field.
  35392. func (m *WxMutation) SetCallback(s string) {
  35393. m.callback = &s
  35394. }
  35395. // Callback returns the value of the "callback" field in the mutation.
  35396. func (m *WxMutation) Callback() (r string, exists bool) {
  35397. v := m.callback
  35398. if v == nil {
  35399. return
  35400. }
  35401. return *v, true
  35402. }
  35403. // OldCallback returns the old "callback" field's value of the Wx entity.
  35404. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  35405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35406. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  35407. if !m.op.Is(OpUpdateOne) {
  35408. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  35409. }
  35410. if m.id == nil || m.oldValue == nil {
  35411. return v, errors.New("OldCallback requires an ID field in the mutation")
  35412. }
  35413. oldValue, err := m.oldValue(ctx)
  35414. if err != nil {
  35415. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  35416. }
  35417. return oldValue.Callback, nil
  35418. }
  35419. // ResetCallback resets all changes to the "callback" field.
  35420. func (m *WxMutation) ResetCallback() {
  35421. m.callback = nil
  35422. }
  35423. // SetWxid sets the "wxid" field.
  35424. func (m *WxMutation) SetWxid(s string) {
  35425. m.wxid = &s
  35426. }
  35427. // Wxid returns the value of the "wxid" field in the mutation.
  35428. func (m *WxMutation) Wxid() (r string, exists bool) {
  35429. v := m.wxid
  35430. if v == nil {
  35431. return
  35432. }
  35433. return *v, true
  35434. }
  35435. // OldWxid returns the old "wxid" field's value of the Wx entity.
  35436. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  35437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35438. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  35439. if !m.op.Is(OpUpdateOne) {
  35440. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  35441. }
  35442. if m.id == nil || m.oldValue == nil {
  35443. return v, errors.New("OldWxid requires an ID field in the mutation")
  35444. }
  35445. oldValue, err := m.oldValue(ctx)
  35446. if err != nil {
  35447. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  35448. }
  35449. return oldValue.Wxid, nil
  35450. }
  35451. // ResetWxid resets all changes to the "wxid" field.
  35452. func (m *WxMutation) ResetWxid() {
  35453. m.wxid = nil
  35454. }
  35455. // SetAccount sets the "account" field.
  35456. func (m *WxMutation) SetAccount(s string) {
  35457. m.account = &s
  35458. }
  35459. // Account returns the value of the "account" field in the mutation.
  35460. func (m *WxMutation) Account() (r string, exists bool) {
  35461. v := m.account
  35462. if v == nil {
  35463. return
  35464. }
  35465. return *v, true
  35466. }
  35467. // OldAccount returns the old "account" field's value of the Wx entity.
  35468. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  35469. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35470. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  35471. if !m.op.Is(OpUpdateOne) {
  35472. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  35473. }
  35474. if m.id == nil || m.oldValue == nil {
  35475. return v, errors.New("OldAccount requires an ID field in the mutation")
  35476. }
  35477. oldValue, err := m.oldValue(ctx)
  35478. if err != nil {
  35479. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  35480. }
  35481. return oldValue.Account, nil
  35482. }
  35483. // ResetAccount resets all changes to the "account" field.
  35484. func (m *WxMutation) ResetAccount() {
  35485. m.account = nil
  35486. }
  35487. // SetNickname sets the "nickname" field.
  35488. func (m *WxMutation) SetNickname(s string) {
  35489. m.nickname = &s
  35490. }
  35491. // Nickname returns the value of the "nickname" field in the mutation.
  35492. func (m *WxMutation) Nickname() (r string, exists bool) {
  35493. v := m.nickname
  35494. if v == nil {
  35495. return
  35496. }
  35497. return *v, true
  35498. }
  35499. // OldNickname returns the old "nickname" field's value of the Wx entity.
  35500. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  35501. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35502. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  35503. if !m.op.Is(OpUpdateOne) {
  35504. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  35505. }
  35506. if m.id == nil || m.oldValue == nil {
  35507. return v, errors.New("OldNickname requires an ID field in the mutation")
  35508. }
  35509. oldValue, err := m.oldValue(ctx)
  35510. if err != nil {
  35511. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  35512. }
  35513. return oldValue.Nickname, nil
  35514. }
  35515. // ResetNickname resets all changes to the "nickname" field.
  35516. func (m *WxMutation) ResetNickname() {
  35517. m.nickname = nil
  35518. }
  35519. // SetTel sets the "tel" field.
  35520. func (m *WxMutation) SetTel(s string) {
  35521. m.tel = &s
  35522. }
  35523. // Tel returns the value of the "tel" field in the mutation.
  35524. func (m *WxMutation) Tel() (r string, exists bool) {
  35525. v := m.tel
  35526. if v == nil {
  35527. return
  35528. }
  35529. return *v, true
  35530. }
  35531. // OldTel returns the old "tel" field's value of the Wx entity.
  35532. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  35533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35534. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  35535. if !m.op.Is(OpUpdateOne) {
  35536. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  35537. }
  35538. if m.id == nil || m.oldValue == nil {
  35539. return v, errors.New("OldTel requires an ID field in the mutation")
  35540. }
  35541. oldValue, err := m.oldValue(ctx)
  35542. if err != nil {
  35543. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  35544. }
  35545. return oldValue.Tel, nil
  35546. }
  35547. // ResetTel resets all changes to the "tel" field.
  35548. func (m *WxMutation) ResetTel() {
  35549. m.tel = nil
  35550. }
  35551. // SetHeadBig sets the "head_big" field.
  35552. func (m *WxMutation) SetHeadBig(s string) {
  35553. m.head_big = &s
  35554. }
  35555. // HeadBig returns the value of the "head_big" field in the mutation.
  35556. func (m *WxMutation) HeadBig() (r string, exists bool) {
  35557. v := m.head_big
  35558. if v == nil {
  35559. return
  35560. }
  35561. return *v, true
  35562. }
  35563. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  35564. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  35565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35566. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  35567. if !m.op.Is(OpUpdateOne) {
  35568. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  35569. }
  35570. if m.id == nil || m.oldValue == nil {
  35571. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  35572. }
  35573. oldValue, err := m.oldValue(ctx)
  35574. if err != nil {
  35575. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  35576. }
  35577. return oldValue.HeadBig, nil
  35578. }
  35579. // ResetHeadBig resets all changes to the "head_big" field.
  35580. func (m *WxMutation) ResetHeadBig() {
  35581. m.head_big = nil
  35582. }
  35583. // SetOrganizationID sets the "organization_id" field.
  35584. func (m *WxMutation) SetOrganizationID(u uint64) {
  35585. m.organization_id = &u
  35586. m.addorganization_id = nil
  35587. }
  35588. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35589. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  35590. v := m.organization_id
  35591. if v == nil {
  35592. return
  35593. }
  35594. return *v, true
  35595. }
  35596. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  35597. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  35598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35599. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35600. if !m.op.Is(OpUpdateOne) {
  35601. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35602. }
  35603. if m.id == nil || m.oldValue == nil {
  35604. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35605. }
  35606. oldValue, err := m.oldValue(ctx)
  35607. if err != nil {
  35608. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35609. }
  35610. return oldValue.OrganizationID, nil
  35611. }
  35612. // AddOrganizationID adds u to the "organization_id" field.
  35613. func (m *WxMutation) AddOrganizationID(u int64) {
  35614. if m.addorganization_id != nil {
  35615. *m.addorganization_id += u
  35616. } else {
  35617. m.addorganization_id = &u
  35618. }
  35619. }
  35620. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35621. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  35622. v := m.addorganization_id
  35623. if v == nil {
  35624. return
  35625. }
  35626. return *v, true
  35627. }
  35628. // ClearOrganizationID clears the value of the "organization_id" field.
  35629. func (m *WxMutation) ClearOrganizationID() {
  35630. m.organization_id = nil
  35631. m.addorganization_id = nil
  35632. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  35633. }
  35634. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  35635. func (m *WxMutation) OrganizationIDCleared() bool {
  35636. _, ok := m.clearedFields[wx.FieldOrganizationID]
  35637. return ok
  35638. }
  35639. // ResetOrganizationID resets all changes to the "organization_id" field.
  35640. func (m *WxMutation) ResetOrganizationID() {
  35641. m.organization_id = nil
  35642. m.addorganization_id = nil
  35643. delete(m.clearedFields, wx.FieldOrganizationID)
  35644. }
  35645. // SetAgentID sets the "agent_id" field.
  35646. func (m *WxMutation) SetAgentID(u uint64) {
  35647. m.agent = &u
  35648. }
  35649. // AgentID returns the value of the "agent_id" field in the mutation.
  35650. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  35651. v := m.agent
  35652. if v == nil {
  35653. return
  35654. }
  35655. return *v, true
  35656. }
  35657. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  35658. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  35659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35660. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  35661. if !m.op.Is(OpUpdateOne) {
  35662. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  35663. }
  35664. if m.id == nil || m.oldValue == nil {
  35665. return v, errors.New("OldAgentID requires an ID field in the mutation")
  35666. }
  35667. oldValue, err := m.oldValue(ctx)
  35668. if err != nil {
  35669. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  35670. }
  35671. return oldValue.AgentID, nil
  35672. }
  35673. // ResetAgentID resets all changes to the "agent_id" field.
  35674. func (m *WxMutation) ResetAgentID() {
  35675. m.agent = nil
  35676. }
  35677. // SetAPIBase sets the "api_base" field.
  35678. func (m *WxMutation) SetAPIBase(s string) {
  35679. m.api_base = &s
  35680. }
  35681. // APIBase returns the value of the "api_base" field in the mutation.
  35682. func (m *WxMutation) APIBase() (r string, exists bool) {
  35683. v := m.api_base
  35684. if v == nil {
  35685. return
  35686. }
  35687. return *v, true
  35688. }
  35689. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  35690. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  35691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35692. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  35693. if !m.op.Is(OpUpdateOne) {
  35694. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  35695. }
  35696. if m.id == nil || m.oldValue == nil {
  35697. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  35698. }
  35699. oldValue, err := m.oldValue(ctx)
  35700. if err != nil {
  35701. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  35702. }
  35703. return oldValue.APIBase, nil
  35704. }
  35705. // ClearAPIBase clears the value of the "api_base" field.
  35706. func (m *WxMutation) ClearAPIBase() {
  35707. m.api_base = nil
  35708. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  35709. }
  35710. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  35711. func (m *WxMutation) APIBaseCleared() bool {
  35712. _, ok := m.clearedFields[wx.FieldAPIBase]
  35713. return ok
  35714. }
  35715. // ResetAPIBase resets all changes to the "api_base" field.
  35716. func (m *WxMutation) ResetAPIBase() {
  35717. m.api_base = nil
  35718. delete(m.clearedFields, wx.FieldAPIBase)
  35719. }
  35720. // SetAPIKey sets the "api_key" field.
  35721. func (m *WxMutation) SetAPIKey(s string) {
  35722. m.api_key = &s
  35723. }
  35724. // APIKey returns the value of the "api_key" field in the mutation.
  35725. func (m *WxMutation) APIKey() (r string, exists bool) {
  35726. v := m.api_key
  35727. if v == nil {
  35728. return
  35729. }
  35730. return *v, true
  35731. }
  35732. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  35733. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  35734. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35735. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  35736. if !m.op.Is(OpUpdateOne) {
  35737. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  35738. }
  35739. if m.id == nil || m.oldValue == nil {
  35740. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  35741. }
  35742. oldValue, err := m.oldValue(ctx)
  35743. if err != nil {
  35744. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  35745. }
  35746. return oldValue.APIKey, nil
  35747. }
  35748. // ClearAPIKey clears the value of the "api_key" field.
  35749. func (m *WxMutation) ClearAPIKey() {
  35750. m.api_key = nil
  35751. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  35752. }
  35753. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  35754. func (m *WxMutation) APIKeyCleared() bool {
  35755. _, ok := m.clearedFields[wx.FieldAPIKey]
  35756. return ok
  35757. }
  35758. // ResetAPIKey resets all changes to the "api_key" field.
  35759. func (m *WxMutation) ResetAPIKey() {
  35760. m.api_key = nil
  35761. delete(m.clearedFields, wx.FieldAPIKey)
  35762. }
  35763. // SetAllowList sets the "allow_list" field.
  35764. func (m *WxMutation) SetAllowList(s []string) {
  35765. m.allow_list = &s
  35766. m.appendallow_list = nil
  35767. }
  35768. // AllowList returns the value of the "allow_list" field in the mutation.
  35769. func (m *WxMutation) AllowList() (r []string, exists bool) {
  35770. v := m.allow_list
  35771. if v == nil {
  35772. return
  35773. }
  35774. return *v, true
  35775. }
  35776. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  35777. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  35778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35779. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  35780. if !m.op.Is(OpUpdateOne) {
  35781. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  35782. }
  35783. if m.id == nil || m.oldValue == nil {
  35784. return v, errors.New("OldAllowList requires an ID field in the mutation")
  35785. }
  35786. oldValue, err := m.oldValue(ctx)
  35787. if err != nil {
  35788. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  35789. }
  35790. return oldValue.AllowList, nil
  35791. }
  35792. // AppendAllowList adds s to the "allow_list" field.
  35793. func (m *WxMutation) AppendAllowList(s []string) {
  35794. m.appendallow_list = append(m.appendallow_list, s...)
  35795. }
  35796. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  35797. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  35798. if len(m.appendallow_list) == 0 {
  35799. return nil, false
  35800. }
  35801. return m.appendallow_list, true
  35802. }
  35803. // ResetAllowList resets all changes to the "allow_list" field.
  35804. func (m *WxMutation) ResetAllowList() {
  35805. m.allow_list = nil
  35806. m.appendallow_list = nil
  35807. }
  35808. // SetGroupAllowList sets the "group_allow_list" field.
  35809. func (m *WxMutation) SetGroupAllowList(s []string) {
  35810. m.group_allow_list = &s
  35811. m.appendgroup_allow_list = nil
  35812. }
  35813. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  35814. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  35815. v := m.group_allow_list
  35816. if v == nil {
  35817. return
  35818. }
  35819. return *v, true
  35820. }
  35821. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  35822. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  35823. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35824. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  35825. if !m.op.Is(OpUpdateOne) {
  35826. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  35827. }
  35828. if m.id == nil || m.oldValue == nil {
  35829. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  35830. }
  35831. oldValue, err := m.oldValue(ctx)
  35832. if err != nil {
  35833. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  35834. }
  35835. return oldValue.GroupAllowList, nil
  35836. }
  35837. // AppendGroupAllowList adds s to the "group_allow_list" field.
  35838. func (m *WxMutation) AppendGroupAllowList(s []string) {
  35839. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  35840. }
  35841. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  35842. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  35843. if len(m.appendgroup_allow_list) == 0 {
  35844. return nil, false
  35845. }
  35846. return m.appendgroup_allow_list, true
  35847. }
  35848. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  35849. func (m *WxMutation) ResetGroupAllowList() {
  35850. m.group_allow_list = nil
  35851. m.appendgroup_allow_list = nil
  35852. }
  35853. // SetBlockList sets the "block_list" field.
  35854. func (m *WxMutation) SetBlockList(s []string) {
  35855. m.block_list = &s
  35856. m.appendblock_list = nil
  35857. }
  35858. // BlockList returns the value of the "block_list" field in the mutation.
  35859. func (m *WxMutation) BlockList() (r []string, exists bool) {
  35860. v := m.block_list
  35861. if v == nil {
  35862. return
  35863. }
  35864. return *v, true
  35865. }
  35866. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  35867. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  35868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35869. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  35870. if !m.op.Is(OpUpdateOne) {
  35871. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  35872. }
  35873. if m.id == nil || m.oldValue == nil {
  35874. return v, errors.New("OldBlockList requires an ID field in the mutation")
  35875. }
  35876. oldValue, err := m.oldValue(ctx)
  35877. if err != nil {
  35878. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  35879. }
  35880. return oldValue.BlockList, nil
  35881. }
  35882. // AppendBlockList adds s to the "block_list" field.
  35883. func (m *WxMutation) AppendBlockList(s []string) {
  35884. m.appendblock_list = append(m.appendblock_list, s...)
  35885. }
  35886. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  35887. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  35888. if len(m.appendblock_list) == 0 {
  35889. return nil, false
  35890. }
  35891. return m.appendblock_list, true
  35892. }
  35893. // ResetBlockList resets all changes to the "block_list" field.
  35894. func (m *WxMutation) ResetBlockList() {
  35895. m.block_list = nil
  35896. m.appendblock_list = nil
  35897. }
  35898. // SetGroupBlockList sets the "group_block_list" field.
  35899. func (m *WxMutation) SetGroupBlockList(s []string) {
  35900. m.group_block_list = &s
  35901. m.appendgroup_block_list = nil
  35902. }
  35903. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  35904. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  35905. v := m.group_block_list
  35906. if v == nil {
  35907. return
  35908. }
  35909. return *v, true
  35910. }
  35911. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  35912. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  35913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35914. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  35915. if !m.op.Is(OpUpdateOne) {
  35916. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  35917. }
  35918. if m.id == nil || m.oldValue == nil {
  35919. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  35920. }
  35921. oldValue, err := m.oldValue(ctx)
  35922. if err != nil {
  35923. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  35924. }
  35925. return oldValue.GroupBlockList, nil
  35926. }
  35927. // AppendGroupBlockList adds s to the "group_block_list" field.
  35928. func (m *WxMutation) AppendGroupBlockList(s []string) {
  35929. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  35930. }
  35931. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  35932. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  35933. if len(m.appendgroup_block_list) == 0 {
  35934. return nil, false
  35935. }
  35936. return m.appendgroup_block_list, true
  35937. }
  35938. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  35939. func (m *WxMutation) ResetGroupBlockList() {
  35940. m.group_block_list = nil
  35941. m.appendgroup_block_list = nil
  35942. }
  35943. // ClearServer clears the "server" edge to the Server entity.
  35944. func (m *WxMutation) ClearServer() {
  35945. m.clearedserver = true
  35946. m.clearedFields[wx.FieldServerID] = struct{}{}
  35947. }
  35948. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  35949. func (m *WxMutation) ServerCleared() bool {
  35950. return m.ServerIDCleared() || m.clearedserver
  35951. }
  35952. // ServerIDs returns the "server" edge IDs in the mutation.
  35953. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  35954. // ServerID instead. It exists only for internal usage by the builders.
  35955. func (m *WxMutation) ServerIDs() (ids []uint64) {
  35956. if id := m.server; id != nil {
  35957. ids = append(ids, *id)
  35958. }
  35959. return
  35960. }
  35961. // ResetServer resets all changes to the "server" edge.
  35962. func (m *WxMutation) ResetServer() {
  35963. m.server = nil
  35964. m.clearedserver = false
  35965. }
  35966. // ClearAgent clears the "agent" edge to the Agent entity.
  35967. func (m *WxMutation) ClearAgent() {
  35968. m.clearedagent = true
  35969. m.clearedFields[wx.FieldAgentID] = struct{}{}
  35970. }
  35971. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  35972. func (m *WxMutation) AgentCleared() bool {
  35973. return m.clearedagent
  35974. }
  35975. // AgentIDs returns the "agent" edge IDs in the mutation.
  35976. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  35977. // AgentID instead. It exists only for internal usage by the builders.
  35978. func (m *WxMutation) AgentIDs() (ids []uint64) {
  35979. if id := m.agent; id != nil {
  35980. ids = append(ids, *id)
  35981. }
  35982. return
  35983. }
  35984. // ResetAgent resets all changes to the "agent" edge.
  35985. func (m *WxMutation) ResetAgent() {
  35986. m.agent = nil
  35987. m.clearedagent = false
  35988. }
  35989. // Where appends a list predicates to the WxMutation builder.
  35990. func (m *WxMutation) Where(ps ...predicate.Wx) {
  35991. m.predicates = append(m.predicates, ps...)
  35992. }
  35993. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  35994. // users can use type-assertion to append predicates that do not depend on any generated package.
  35995. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  35996. p := make([]predicate.Wx, len(ps))
  35997. for i := range ps {
  35998. p[i] = ps[i]
  35999. }
  36000. m.Where(p...)
  36001. }
  36002. // Op returns the operation name.
  36003. func (m *WxMutation) Op() Op {
  36004. return m.op
  36005. }
  36006. // SetOp allows setting the mutation operation.
  36007. func (m *WxMutation) SetOp(op Op) {
  36008. m.op = op
  36009. }
  36010. // Type returns the node type of this mutation (Wx).
  36011. func (m *WxMutation) Type() string {
  36012. return m.typ
  36013. }
  36014. // Fields returns all fields that were changed during this mutation. Note that in
  36015. // order to get all numeric fields that were incremented/decremented, call
  36016. // AddedFields().
  36017. func (m *WxMutation) Fields() []string {
  36018. fields := make([]string, 0, 21)
  36019. if m.created_at != nil {
  36020. fields = append(fields, wx.FieldCreatedAt)
  36021. }
  36022. if m.updated_at != nil {
  36023. fields = append(fields, wx.FieldUpdatedAt)
  36024. }
  36025. if m.status != nil {
  36026. fields = append(fields, wx.FieldStatus)
  36027. }
  36028. if m.deleted_at != nil {
  36029. fields = append(fields, wx.FieldDeletedAt)
  36030. }
  36031. if m.server != nil {
  36032. fields = append(fields, wx.FieldServerID)
  36033. }
  36034. if m.port != nil {
  36035. fields = append(fields, wx.FieldPort)
  36036. }
  36037. if m.process_id != nil {
  36038. fields = append(fields, wx.FieldProcessID)
  36039. }
  36040. if m.callback != nil {
  36041. fields = append(fields, wx.FieldCallback)
  36042. }
  36043. if m.wxid != nil {
  36044. fields = append(fields, wx.FieldWxid)
  36045. }
  36046. if m.account != nil {
  36047. fields = append(fields, wx.FieldAccount)
  36048. }
  36049. if m.nickname != nil {
  36050. fields = append(fields, wx.FieldNickname)
  36051. }
  36052. if m.tel != nil {
  36053. fields = append(fields, wx.FieldTel)
  36054. }
  36055. if m.head_big != nil {
  36056. fields = append(fields, wx.FieldHeadBig)
  36057. }
  36058. if m.organization_id != nil {
  36059. fields = append(fields, wx.FieldOrganizationID)
  36060. }
  36061. if m.agent != nil {
  36062. fields = append(fields, wx.FieldAgentID)
  36063. }
  36064. if m.api_base != nil {
  36065. fields = append(fields, wx.FieldAPIBase)
  36066. }
  36067. if m.api_key != nil {
  36068. fields = append(fields, wx.FieldAPIKey)
  36069. }
  36070. if m.allow_list != nil {
  36071. fields = append(fields, wx.FieldAllowList)
  36072. }
  36073. if m.group_allow_list != nil {
  36074. fields = append(fields, wx.FieldGroupAllowList)
  36075. }
  36076. if m.block_list != nil {
  36077. fields = append(fields, wx.FieldBlockList)
  36078. }
  36079. if m.group_block_list != nil {
  36080. fields = append(fields, wx.FieldGroupBlockList)
  36081. }
  36082. return fields
  36083. }
  36084. // Field returns the value of a field with the given name. The second boolean
  36085. // return value indicates that this field was not set, or was not defined in the
  36086. // schema.
  36087. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  36088. switch name {
  36089. case wx.FieldCreatedAt:
  36090. return m.CreatedAt()
  36091. case wx.FieldUpdatedAt:
  36092. return m.UpdatedAt()
  36093. case wx.FieldStatus:
  36094. return m.Status()
  36095. case wx.FieldDeletedAt:
  36096. return m.DeletedAt()
  36097. case wx.FieldServerID:
  36098. return m.ServerID()
  36099. case wx.FieldPort:
  36100. return m.Port()
  36101. case wx.FieldProcessID:
  36102. return m.ProcessID()
  36103. case wx.FieldCallback:
  36104. return m.Callback()
  36105. case wx.FieldWxid:
  36106. return m.Wxid()
  36107. case wx.FieldAccount:
  36108. return m.Account()
  36109. case wx.FieldNickname:
  36110. return m.Nickname()
  36111. case wx.FieldTel:
  36112. return m.Tel()
  36113. case wx.FieldHeadBig:
  36114. return m.HeadBig()
  36115. case wx.FieldOrganizationID:
  36116. return m.OrganizationID()
  36117. case wx.FieldAgentID:
  36118. return m.AgentID()
  36119. case wx.FieldAPIBase:
  36120. return m.APIBase()
  36121. case wx.FieldAPIKey:
  36122. return m.APIKey()
  36123. case wx.FieldAllowList:
  36124. return m.AllowList()
  36125. case wx.FieldGroupAllowList:
  36126. return m.GroupAllowList()
  36127. case wx.FieldBlockList:
  36128. return m.BlockList()
  36129. case wx.FieldGroupBlockList:
  36130. return m.GroupBlockList()
  36131. }
  36132. return nil, false
  36133. }
  36134. // OldField returns the old value of the field from the database. An error is
  36135. // returned if the mutation operation is not UpdateOne, or the query to the
  36136. // database failed.
  36137. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36138. switch name {
  36139. case wx.FieldCreatedAt:
  36140. return m.OldCreatedAt(ctx)
  36141. case wx.FieldUpdatedAt:
  36142. return m.OldUpdatedAt(ctx)
  36143. case wx.FieldStatus:
  36144. return m.OldStatus(ctx)
  36145. case wx.FieldDeletedAt:
  36146. return m.OldDeletedAt(ctx)
  36147. case wx.FieldServerID:
  36148. return m.OldServerID(ctx)
  36149. case wx.FieldPort:
  36150. return m.OldPort(ctx)
  36151. case wx.FieldProcessID:
  36152. return m.OldProcessID(ctx)
  36153. case wx.FieldCallback:
  36154. return m.OldCallback(ctx)
  36155. case wx.FieldWxid:
  36156. return m.OldWxid(ctx)
  36157. case wx.FieldAccount:
  36158. return m.OldAccount(ctx)
  36159. case wx.FieldNickname:
  36160. return m.OldNickname(ctx)
  36161. case wx.FieldTel:
  36162. return m.OldTel(ctx)
  36163. case wx.FieldHeadBig:
  36164. return m.OldHeadBig(ctx)
  36165. case wx.FieldOrganizationID:
  36166. return m.OldOrganizationID(ctx)
  36167. case wx.FieldAgentID:
  36168. return m.OldAgentID(ctx)
  36169. case wx.FieldAPIBase:
  36170. return m.OldAPIBase(ctx)
  36171. case wx.FieldAPIKey:
  36172. return m.OldAPIKey(ctx)
  36173. case wx.FieldAllowList:
  36174. return m.OldAllowList(ctx)
  36175. case wx.FieldGroupAllowList:
  36176. return m.OldGroupAllowList(ctx)
  36177. case wx.FieldBlockList:
  36178. return m.OldBlockList(ctx)
  36179. case wx.FieldGroupBlockList:
  36180. return m.OldGroupBlockList(ctx)
  36181. }
  36182. return nil, fmt.Errorf("unknown Wx field %s", name)
  36183. }
  36184. // SetField sets the value of a field with the given name. It returns an error if
  36185. // the field is not defined in the schema, or if the type mismatched the field
  36186. // type.
  36187. func (m *WxMutation) SetField(name string, value ent.Value) error {
  36188. switch name {
  36189. case wx.FieldCreatedAt:
  36190. v, ok := value.(time.Time)
  36191. if !ok {
  36192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36193. }
  36194. m.SetCreatedAt(v)
  36195. return nil
  36196. case wx.FieldUpdatedAt:
  36197. v, ok := value.(time.Time)
  36198. if !ok {
  36199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36200. }
  36201. m.SetUpdatedAt(v)
  36202. return nil
  36203. case wx.FieldStatus:
  36204. v, ok := value.(uint8)
  36205. if !ok {
  36206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36207. }
  36208. m.SetStatus(v)
  36209. return nil
  36210. case wx.FieldDeletedAt:
  36211. v, ok := value.(time.Time)
  36212. if !ok {
  36213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36214. }
  36215. m.SetDeletedAt(v)
  36216. return nil
  36217. case wx.FieldServerID:
  36218. v, ok := value.(uint64)
  36219. if !ok {
  36220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36221. }
  36222. m.SetServerID(v)
  36223. return nil
  36224. case wx.FieldPort:
  36225. v, ok := value.(string)
  36226. if !ok {
  36227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36228. }
  36229. m.SetPort(v)
  36230. return nil
  36231. case wx.FieldProcessID:
  36232. v, ok := value.(string)
  36233. if !ok {
  36234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36235. }
  36236. m.SetProcessID(v)
  36237. return nil
  36238. case wx.FieldCallback:
  36239. v, ok := value.(string)
  36240. if !ok {
  36241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36242. }
  36243. m.SetCallback(v)
  36244. return nil
  36245. case wx.FieldWxid:
  36246. v, ok := value.(string)
  36247. if !ok {
  36248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36249. }
  36250. m.SetWxid(v)
  36251. return nil
  36252. case wx.FieldAccount:
  36253. v, ok := value.(string)
  36254. if !ok {
  36255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36256. }
  36257. m.SetAccount(v)
  36258. return nil
  36259. case wx.FieldNickname:
  36260. v, ok := value.(string)
  36261. if !ok {
  36262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36263. }
  36264. m.SetNickname(v)
  36265. return nil
  36266. case wx.FieldTel:
  36267. v, ok := value.(string)
  36268. if !ok {
  36269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36270. }
  36271. m.SetTel(v)
  36272. return nil
  36273. case wx.FieldHeadBig:
  36274. v, ok := value.(string)
  36275. if !ok {
  36276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36277. }
  36278. m.SetHeadBig(v)
  36279. return nil
  36280. case wx.FieldOrganizationID:
  36281. v, ok := value.(uint64)
  36282. if !ok {
  36283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36284. }
  36285. m.SetOrganizationID(v)
  36286. return nil
  36287. case wx.FieldAgentID:
  36288. v, ok := value.(uint64)
  36289. if !ok {
  36290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36291. }
  36292. m.SetAgentID(v)
  36293. return nil
  36294. case wx.FieldAPIBase:
  36295. v, ok := value.(string)
  36296. if !ok {
  36297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36298. }
  36299. m.SetAPIBase(v)
  36300. return nil
  36301. case wx.FieldAPIKey:
  36302. v, ok := value.(string)
  36303. if !ok {
  36304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36305. }
  36306. m.SetAPIKey(v)
  36307. return nil
  36308. case wx.FieldAllowList:
  36309. v, ok := value.([]string)
  36310. if !ok {
  36311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36312. }
  36313. m.SetAllowList(v)
  36314. return nil
  36315. case wx.FieldGroupAllowList:
  36316. v, ok := value.([]string)
  36317. if !ok {
  36318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36319. }
  36320. m.SetGroupAllowList(v)
  36321. return nil
  36322. case wx.FieldBlockList:
  36323. v, ok := value.([]string)
  36324. if !ok {
  36325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36326. }
  36327. m.SetBlockList(v)
  36328. return nil
  36329. case wx.FieldGroupBlockList:
  36330. v, ok := value.([]string)
  36331. if !ok {
  36332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36333. }
  36334. m.SetGroupBlockList(v)
  36335. return nil
  36336. }
  36337. return fmt.Errorf("unknown Wx field %s", name)
  36338. }
  36339. // AddedFields returns all numeric fields that were incremented/decremented during
  36340. // this mutation.
  36341. func (m *WxMutation) AddedFields() []string {
  36342. var fields []string
  36343. if m.addstatus != nil {
  36344. fields = append(fields, wx.FieldStatus)
  36345. }
  36346. if m.addorganization_id != nil {
  36347. fields = append(fields, wx.FieldOrganizationID)
  36348. }
  36349. return fields
  36350. }
  36351. // AddedField returns the numeric value that was incremented/decremented on a field
  36352. // with the given name. The second boolean return value indicates that this field
  36353. // was not set, or was not defined in the schema.
  36354. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  36355. switch name {
  36356. case wx.FieldStatus:
  36357. return m.AddedStatus()
  36358. case wx.FieldOrganizationID:
  36359. return m.AddedOrganizationID()
  36360. }
  36361. return nil, false
  36362. }
  36363. // AddField adds the value to the field with the given name. It returns an error if
  36364. // the field is not defined in the schema, or if the type mismatched the field
  36365. // type.
  36366. func (m *WxMutation) AddField(name string, value ent.Value) error {
  36367. switch name {
  36368. case wx.FieldStatus:
  36369. v, ok := value.(int8)
  36370. if !ok {
  36371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36372. }
  36373. m.AddStatus(v)
  36374. return nil
  36375. case wx.FieldOrganizationID:
  36376. v, ok := value.(int64)
  36377. if !ok {
  36378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36379. }
  36380. m.AddOrganizationID(v)
  36381. return nil
  36382. }
  36383. return fmt.Errorf("unknown Wx numeric field %s", name)
  36384. }
  36385. // ClearedFields returns all nullable fields that were cleared during this
  36386. // mutation.
  36387. func (m *WxMutation) ClearedFields() []string {
  36388. var fields []string
  36389. if m.FieldCleared(wx.FieldStatus) {
  36390. fields = append(fields, wx.FieldStatus)
  36391. }
  36392. if m.FieldCleared(wx.FieldDeletedAt) {
  36393. fields = append(fields, wx.FieldDeletedAt)
  36394. }
  36395. if m.FieldCleared(wx.FieldServerID) {
  36396. fields = append(fields, wx.FieldServerID)
  36397. }
  36398. if m.FieldCleared(wx.FieldOrganizationID) {
  36399. fields = append(fields, wx.FieldOrganizationID)
  36400. }
  36401. if m.FieldCleared(wx.FieldAPIBase) {
  36402. fields = append(fields, wx.FieldAPIBase)
  36403. }
  36404. if m.FieldCleared(wx.FieldAPIKey) {
  36405. fields = append(fields, wx.FieldAPIKey)
  36406. }
  36407. return fields
  36408. }
  36409. // FieldCleared returns a boolean indicating if a field with the given name was
  36410. // cleared in this mutation.
  36411. func (m *WxMutation) FieldCleared(name string) bool {
  36412. _, ok := m.clearedFields[name]
  36413. return ok
  36414. }
  36415. // ClearField clears the value of the field with the given name. It returns an
  36416. // error if the field is not defined in the schema.
  36417. func (m *WxMutation) ClearField(name string) error {
  36418. switch name {
  36419. case wx.FieldStatus:
  36420. m.ClearStatus()
  36421. return nil
  36422. case wx.FieldDeletedAt:
  36423. m.ClearDeletedAt()
  36424. return nil
  36425. case wx.FieldServerID:
  36426. m.ClearServerID()
  36427. return nil
  36428. case wx.FieldOrganizationID:
  36429. m.ClearOrganizationID()
  36430. return nil
  36431. case wx.FieldAPIBase:
  36432. m.ClearAPIBase()
  36433. return nil
  36434. case wx.FieldAPIKey:
  36435. m.ClearAPIKey()
  36436. return nil
  36437. }
  36438. return fmt.Errorf("unknown Wx nullable field %s", name)
  36439. }
  36440. // ResetField resets all changes in the mutation for the field with the given name.
  36441. // It returns an error if the field is not defined in the schema.
  36442. func (m *WxMutation) ResetField(name string) error {
  36443. switch name {
  36444. case wx.FieldCreatedAt:
  36445. m.ResetCreatedAt()
  36446. return nil
  36447. case wx.FieldUpdatedAt:
  36448. m.ResetUpdatedAt()
  36449. return nil
  36450. case wx.FieldStatus:
  36451. m.ResetStatus()
  36452. return nil
  36453. case wx.FieldDeletedAt:
  36454. m.ResetDeletedAt()
  36455. return nil
  36456. case wx.FieldServerID:
  36457. m.ResetServerID()
  36458. return nil
  36459. case wx.FieldPort:
  36460. m.ResetPort()
  36461. return nil
  36462. case wx.FieldProcessID:
  36463. m.ResetProcessID()
  36464. return nil
  36465. case wx.FieldCallback:
  36466. m.ResetCallback()
  36467. return nil
  36468. case wx.FieldWxid:
  36469. m.ResetWxid()
  36470. return nil
  36471. case wx.FieldAccount:
  36472. m.ResetAccount()
  36473. return nil
  36474. case wx.FieldNickname:
  36475. m.ResetNickname()
  36476. return nil
  36477. case wx.FieldTel:
  36478. m.ResetTel()
  36479. return nil
  36480. case wx.FieldHeadBig:
  36481. m.ResetHeadBig()
  36482. return nil
  36483. case wx.FieldOrganizationID:
  36484. m.ResetOrganizationID()
  36485. return nil
  36486. case wx.FieldAgentID:
  36487. m.ResetAgentID()
  36488. return nil
  36489. case wx.FieldAPIBase:
  36490. m.ResetAPIBase()
  36491. return nil
  36492. case wx.FieldAPIKey:
  36493. m.ResetAPIKey()
  36494. return nil
  36495. case wx.FieldAllowList:
  36496. m.ResetAllowList()
  36497. return nil
  36498. case wx.FieldGroupAllowList:
  36499. m.ResetGroupAllowList()
  36500. return nil
  36501. case wx.FieldBlockList:
  36502. m.ResetBlockList()
  36503. return nil
  36504. case wx.FieldGroupBlockList:
  36505. m.ResetGroupBlockList()
  36506. return nil
  36507. }
  36508. return fmt.Errorf("unknown Wx field %s", name)
  36509. }
  36510. // AddedEdges returns all edge names that were set/added in this mutation.
  36511. func (m *WxMutation) AddedEdges() []string {
  36512. edges := make([]string, 0, 2)
  36513. if m.server != nil {
  36514. edges = append(edges, wx.EdgeServer)
  36515. }
  36516. if m.agent != nil {
  36517. edges = append(edges, wx.EdgeAgent)
  36518. }
  36519. return edges
  36520. }
  36521. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36522. // name in this mutation.
  36523. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  36524. switch name {
  36525. case wx.EdgeServer:
  36526. if id := m.server; id != nil {
  36527. return []ent.Value{*id}
  36528. }
  36529. case wx.EdgeAgent:
  36530. if id := m.agent; id != nil {
  36531. return []ent.Value{*id}
  36532. }
  36533. }
  36534. return nil
  36535. }
  36536. // RemovedEdges returns all edge names that were removed in this mutation.
  36537. func (m *WxMutation) RemovedEdges() []string {
  36538. edges := make([]string, 0, 2)
  36539. return edges
  36540. }
  36541. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36542. // the given name in this mutation.
  36543. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  36544. return nil
  36545. }
  36546. // ClearedEdges returns all edge names that were cleared in this mutation.
  36547. func (m *WxMutation) ClearedEdges() []string {
  36548. edges := make([]string, 0, 2)
  36549. if m.clearedserver {
  36550. edges = append(edges, wx.EdgeServer)
  36551. }
  36552. if m.clearedagent {
  36553. edges = append(edges, wx.EdgeAgent)
  36554. }
  36555. return edges
  36556. }
  36557. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36558. // was cleared in this mutation.
  36559. func (m *WxMutation) EdgeCleared(name string) bool {
  36560. switch name {
  36561. case wx.EdgeServer:
  36562. return m.clearedserver
  36563. case wx.EdgeAgent:
  36564. return m.clearedagent
  36565. }
  36566. return false
  36567. }
  36568. // ClearEdge clears the value of the edge with the given name. It returns an error
  36569. // if that edge is not defined in the schema.
  36570. func (m *WxMutation) ClearEdge(name string) error {
  36571. switch name {
  36572. case wx.EdgeServer:
  36573. m.ClearServer()
  36574. return nil
  36575. case wx.EdgeAgent:
  36576. m.ClearAgent()
  36577. return nil
  36578. }
  36579. return fmt.Errorf("unknown Wx unique edge %s", name)
  36580. }
  36581. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36582. // It returns an error if the edge is not defined in the schema.
  36583. func (m *WxMutation) ResetEdge(name string) error {
  36584. switch name {
  36585. case wx.EdgeServer:
  36586. m.ResetServer()
  36587. return nil
  36588. case wx.EdgeAgent:
  36589. m.ResetAgent()
  36590. return nil
  36591. }
  36592. return fmt.Errorf("unknown Wx edge %s", name)
  36593. }
  36594. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  36595. type WxCardMutation struct {
  36596. config
  36597. op Op
  36598. typ string
  36599. id *uint64
  36600. created_at *time.Time
  36601. updated_at *time.Time
  36602. deleted_at *time.Time
  36603. user_id *uint64
  36604. adduser_id *int64
  36605. wx_user_id *uint64
  36606. addwx_user_id *int64
  36607. avatar *string
  36608. logo *string
  36609. name *string
  36610. company *string
  36611. address *string
  36612. phone *string
  36613. official_account *string
  36614. wechat_account *string
  36615. email *string
  36616. api_base *string
  36617. api_key *string
  36618. ai_info *string
  36619. intro *string
  36620. clearedFields map[string]struct{}
  36621. done bool
  36622. oldValue func(context.Context) (*WxCard, error)
  36623. predicates []predicate.WxCard
  36624. }
  36625. var _ ent.Mutation = (*WxCardMutation)(nil)
  36626. // wxcardOption allows management of the mutation configuration using functional options.
  36627. type wxcardOption func(*WxCardMutation)
  36628. // newWxCardMutation creates new mutation for the WxCard entity.
  36629. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  36630. m := &WxCardMutation{
  36631. config: c,
  36632. op: op,
  36633. typ: TypeWxCard,
  36634. clearedFields: make(map[string]struct{}),
  36635. }
  36636. for _, opt := range opts {
  36637. opt(m)
  36638. }
  36639. return m
  36640. }
  36641. // withWxCardID sets the ID field of the mutation.
  36642. func withWxCardID(id uint64) wxcardOption {
  36643. return func(m *WxCardMutation) {
  36644. var (
  36645. err error
  36646. once sync.Once
  36647. value *WxCard
  36648. )
  36649. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  36650. once.Do(func() {
  36651. if m.done {
  36652. err = errors.New("querying old values post mutation is not allowed")
  36653. } else {
  36654. value, err = m.Client().WxCard.Get(ctx, id)
  36655. }
  36656. })
  36657. return value, err
  36658. }
  36659. m.id = &id
  36660. }
  36661. }
  36662. // withWxCard sets the old WxCard of the mutation.
  36663. func withWxCard(node *WxCard) wxcardOption {
  36664. return func(m *WxCardMutation) {
  36665. m.oldValue = func(context.Context) (*WxCard, error) {
  36666. return node, nil
  36667. }
  36668. m.id = &node.ID
  36669. }
  36670. }
  36671. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36672. // executed in a transaction (ent.Tx), a transactional client is returned.
  36673. func (m WxCardMutation) Client() *Client {
  36674. client := &Client{config: m.config}
  36675. client.init()
  36676. return client
  36677. }
  36678. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36679. // it returns an error otherwise.
  36680. func (m WxCardMutation) Tx() (*Tx, error) {
  36681. if _, ok := m.driver.(*txDriver); !ok {
  36682. return nil, errors.New("ent: mutation is not running in a transaction")
  36683. }
  36684. tx := &Tx{config: m.config}
  36685. tx.init()
  36686. return tx, nil
  36687. }
  36688. // SetID sets the value of the id field. Note that this
  36689. // operation is only accepted on creation of WxCard entities.
  36690. func (m *WxCardMutation) SetID(id uint64) {
  36691. m.id = &id
  36692. }
  36693. // ID returns the ID value in the mutation. Note that the ID is only available
  36694. // if it was provided to the builder or after it was returned from the database.
  36695. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  36696. if m.id == nil {
  36697. return
  36698. }
  36699. return *m.id, true
  36700. }
  36701. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36702. // That means, if the mutation is applied within a transaction with an isolation level such
  36703. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36704. // or updated by the mutation.
  36705. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  36706. switch {
  36707. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36708. id, exists := m.ID()
  36709. if exists {
  36710. return []uint64{id}, nil
  36711. }
  36712. fallthrough
  36713. case m.op.Is(OpUpdate | OpDelete):
  36714. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  36715. default:
  36716. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36717. }
  36718. }
  36719. // SetCreatedAt sets the "created_at" field.
  36720. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  36721. m.created_at = &t
  36722. }
  36723. // CreatedAt returns the value of the "created_at" field in the mutation.
  36724. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  36725. v := m.created_at
  36726. if v == nil {
  36727. return
  36728. }
  36729. return *v, true
  36730. }
  36731. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  36732. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  36733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36734. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36735. if !m.op.Is(OpUpdateOne) {
  36736. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36737. }
  36738. if m.id == nil || m.oldValue == nil {
  36739. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36740. }
  36741. oldValue, err := m.oldValue(ctx)
  36742. if err != nil {
  36743. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36744. }
  36745. return oldValue.CreatedAt, nil
  36746. }
  36747. // ResetCreatedAt resets all changes to the "created_at" field.
  36748. func (m *WxCardMutation) ResetCreatedAt() {
  36749. m.created_at = nil
  36750. }
  36751. // SetUpdatedAt sets the "updated_at" field.
  36752. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  36753. m.updated_at = &t
  36754. }
  36755. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36756. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  36757. v := m.updated_at
  36758. if v == nil {
  36759. return
  36760. }
  36761. return *v, true
  36762. }
  36763. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  36764. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  36765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36766. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36767. if !m.op.Is(OpUpdateOne) {
  36768. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36769. }
  36770. if m.id == nil || m.oldValue == nil {
  36771. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36772. }
  36773. oldValue, err := m.oldValue(ctx)
  36774. if err != nil {
  36775. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36776. }
  36777. return oldValue.UpdatedAt, nil
  36778. }
  36779. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36780. func (m *WxCardMutation) ResetUpdatedAt() {
  36781. m.updated_at = nil
  36782. }
  36783. // SetDeletedAt sets the "deleted_at" field.
  36784. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  36785. m.deleted_at = &t
  36786. }
  36787. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36788. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  36789. v := m.deleted_at
  36790. if v == nil {
  36791. return
  36792. }
  36793. return *v, true
  36794. }
  36795. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  36796. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  36797. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36798. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36799. if !m.op.Is(OpUpdateOne) {
  36800. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36801. }
  36802. if m.id == nil || m.oldValue == nil {
  36803. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36804. }
  36805. oldValue, err := m.oldValue(ctx)
  36806. if err != nil {
  36807. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36808. }
  36809. return oldValue.DeletedAt, nil
  36810. }
  36811. // ClearDeletedAt clears the value of the "deleted_at" field.
  36812. func (m *WxCardMutation) ClearDeletedAt() {
  36813. m.deleted_at = nil
  36814. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  36815. }
  36816. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36817. func (m *WxCardMutation) DeletedAtCleared() bool {
  36818. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  36819. return ok
  36820. }
  36821. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36822. func (m *WxCardMutation) ResetDeletedAt() {
  36823. m.deleted_at = nil
  36824. delete(m.clearedFields, wxcard.FieldDeletedAt)
  36825. }
  36826. // SetUserID sets the "user_id" field.
  36827. func (m *WxCardMutation) SetUserID(u uint64) {
  36828. m.user_id = &u
  36829. m.adduser_id = nil
  36830. }
  36831. // UserID returns the value of the "user_id" field in the mutation.
  36832. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  36833. v := m.user_id
  36834. if v == nil {
  36835. return
  36836. }
  36837. return *v, true
  36838. }
  36839. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  36840. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  36841. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36842. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  36843. if !m.op.Is(OpUpdateOne) {
  36844. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  36845. }
  36846. if m.id == nil || m.oldValue == nil {
  36847. return v, errors.New("OldUserID requires an ID field in the mutation")
  36848. }
  36849. oldValue, err := m.oldValue(ctx)
  36850. if err != nil {
  36851. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  36852. }
  36853. return oldValue.UserID, nil
  36854. }
  36855. // AddUserID adds u to the "user_id" field.
  36856. func (m *WxCardMutation) AddUserID(u int64) {
  36857. if m.adduser_id != nil {
  36858. *m.adduser_id += u
  36859. } else {
  36860. m.adduser_id = &u
  36861. }
  36862. }
  36863. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  36864. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  36865. v := m.adduser_id
  36866. if v == nil {
  36867. return
  36868. }
  36869. return *v, true
  36870. }
  36871. // ClearUserID clears the value of the "user_id" field.
  36872. func (m *WxCardMutation) ClearUserID() {
  36873. m.user_id = nil
  36874. m.adduser_id = nil
  36875. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  36876. }
  36877. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  36878. func (m *WxCardMutation) UserIDCleared() bool {
  36879. _, ok := m.clearedFields[wxcard.FieldUserID]
  36880. return ok
  36881. }
  36882. // ResetUserID resets all changes to the "user_id" field.
  36883. func (m *WxCardMutation) ResetUserID() {
  36884. m.user_id = nil
  36885. m.adduser_id = nil
  36886. delete(m.clearedFields, wxcard.FieldUserID)
  36887. }
  36888. // SetWxUserID sets the "wx_user_id" field.
  36889. func (m *WxCardMutation) SetWxUserID(u uint64) {
  36890. m.wx_user_id = &u
  36891. m.addwx_user_id = nil
  36892. }
  36893. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  36894. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  36895. v := m.wx_user_id
  36896. if v == nil {
  36897. return
  36898. }
  36899. return *v, true
  36900. }
  36901. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  36902. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  36903. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36904. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  36905. if !m.op.Is(OpUpdateOne) {
  36906. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  36907. }
  36908. if m.id == nil || m.oldValue == nil {
  36909. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  36910. }
  36911. oldValue, err := m.oldValue(ctx)
  36912. if err != nil {
  36913. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  36914. }
  36915. return oldValue.WxUserID, nil
  36916. }
  36917. // AddWxUserID adds u to the "wx_user_id" field.
  36918. func (m *WxCardMutation) AddWxUserID(u int64) {
  36919. if m.addwx_user_id != nil {
  36920. *m.addwx_user_id += u
  36921. } else {
  36922. m.addwx_user_id = &u
  36923. }
  36924. }
  36925. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  36926. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  36927. v := m.addwx_user_id
  36928. if v == nil {
  36929. return
  36930. }
  36931. return *v, true
  36932. }
  36933. // ClearWxUserID clears the value of the "wx_user_id" field.
  36934. func (m *WxCardMutation) ClearWxUserID() {
  36935. m.wx_user_id = nil
  36936. m.addwx_user_id = nil
  36937. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  36938. }
  36939. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  36940. func (m *WxCardMutation) WxUserIDCleared() bool {
  36941. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  36942. return ok
  36943. }
  36944. // ResetWxUserID resets all changes to the "wx_user_id" field.
  36945. func (m *WxCardMutation) ResetWxUserID() {
  36946. m.wx_user_id = nil
  36947. m.addwx_user_id = nil
  36948. delete(m.clearedFields, wxcard.FieldWxUserID)
  36949. }
  36950. // SetAvatar sets the "avatar" field.
  36951. func (m *WxCardMutation) SetAvatar(s string) {
  36952. m.avatar = &s
  36953. }
  36954. // Avatar returns the value of the "avatar" field in the mutation.
  36955. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  36956. v := m.avatar
  36957. if v == nil {
  36958. return
  36959. }
  36960. return *v, true
  36961. }
  36962. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  36963. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  36964. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36965. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  36966. if !m.op.Is(OpUpdateOne) {
  36967. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  36968. }
  36969. if m.id == nil || m.oldValue == nil {
  36970. return v, errors.New("OldAvatar requires an ID field in the mutation")
  36971. }
  36972. oldValue, err := m.oldValue(ctx)
  36973. if err != nil {
  36974. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  36975. }
  36976. return oldValue.Avatar, nil
  36977. }
  36978. // ResetAvatar resets all changes to the "avatar" field.
  36979. func (m *WxCardMutation) ResetAvatar() {
  36980. m.avatar = nil
  36981. }
  36982. // SetLogo sets the "logo" field.
  36983. func (m *WxCardMutation) SetLogo(s string) {
  36984. m.logo = &s
  36985. }
  36986. // Logo returns the value of the "logo" field in the mutation.
  36987. func (m *WxCardMutation) Logo() (r string, exists bool) {
  36988. v := m.logo
  36989. if v == nil {
  36990. return
  36991. }
  36992. return *v, true
  36993. }
  36994. // OldLogo returns the old "logo" field's value of the WxCard entity.
  36995. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  36996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36997. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  36998. if !m.op.Is(OpUpdateOne) {
  36999. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  37000. }
  37001. if m.id == nil || m.oldValue == nil {
  37002. return v, errors.New("OldLogo requires an ID field in the mutation")
  37003. }
  37004. oldValue, err := m.oldValue(ctx)
  37005. if err != nil {
  37006. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  37007. }
  37008. return oldValue.Logo, nil
  37009. }
  37010. // ResetLogo resets all changes to the "logo" field.
  37011. func (m *WxCardMutation) ResetLogo() {
  37012. m.logo = nil
  37013. }
  37014. // SetName sets the "name" field.
  37015. func (m *WxCardMutation) SetName(s string) {
  37016. m.name = &s
  37017. }
  37018. // Name returns the value of the "name" field in the mutation.
  37019. func (m *WxCardMutation) Name() (r string, exists bool) {
  37020. v := m.name
  37021. if v == nil {
  37022. return
  37023. }
  37024. return *v, true
  37025. }
  37026. // OldName returns the old "name" field's value of the WxCard entity.
  37027. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37029. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  37030. if !m.op.Is(OpUpdateOne) {
  37031. return v, errors.New("OldName is only allowed on UpdateOne operations")
  37032. }
  37033. if m.id == nil || m.oldValue == nil {
  37034. return v, errors.New("OldName requires an ID field in the mutation")
  37035. }
  37036. oldValue, err := m.oldValue(ctx)
  37037. if err != nil {
  37038. return v, fmt.Errorf("querying old value for OldName: %w", err)
  37039. }
  37040. return oldValue.Name, nil
  37041. }
  37042. // ResetName resets all changes to the "name" field.
  37043. func (m *WxCardMutation) ResetName() {
  37044. m.name = nil
  37045. }
  37046. // SetCompany sets the "company" field.
  37047. func (m *WxCardMutation) SetCompany(s string) {
  37048. m.company = &s
  37049. }
  37050. // Company returns the value of the "company" field in the mutation.
  37051. func (m *WxCardMutation) Company() (r string, exists bool) {
  37052. v := m.company
  37053. if v == nil {
  37054. return
  37055. }
  37056. return *v, true
  37057. }
  37058. // OldCompany returns the old "company" field's value of the WxCard entity.
  37059. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37061. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  37062. if !m.op.Is(OpUpdateOne) {
  37063. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  37064. }
  37065. if m.id == nil || m.oldValue == nil {
  37066. return v, errors.New("OldCompany requires an ID field in the mutation")
  37067. }
  37068. oldValue, err := m.oldValue(ctx)
  37069. if err != nil {
  37070. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  37071. }
  37072. return oldValue.Company, nil
  37073. }
  37074. // ResetCompany resets all changes to the "company" field.
  37075. func (m *WxCardMutation) ResetCompany() {
  37076. m.company = nil
  37077. }
  37078. // SetAddress sets the "address" field.
  37079. func (m *WxCardMutation) SetAddress(s string) {
  37080. m.address = &s
  37081. }
  37082. // Address returns the value of the "address" field in the mutation.
  37083. func (m *WxCardMutation) Address() (r string, exists bool) {
  37084. v := m.address
  37085. if v == nil {
  37086. return
  37087. }
  37088. return *v, true
  37089. }
  37090. // OldAddress returns the old "address" field's value of the WxCard entity.
  37091. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37093. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  37094. if !m.op.Is(OpUpdateOne) {
  37095. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  37096. }
  37097. if m.id == nil || m.oldValue == nil {
  37098. return v, errors.New("OldAddress requires an ID field in the mutation")
  37099. }
  37100. oldValue, err := m.oldValue(ctx)
  37101. if err != nil {
  37102. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  37103. }
  37104. return oldValue.Address, nil
  37105. }
  37106. // ResetAddress resets all changes to the "address" field.
  37107. func (m *WxCardMutation) ResetAddress() {
  37108. m.address = nil
  37109. }
  37110. // SetPhone sets the "phone" field.
  37111. func (m *WxCardMutation) SetPhone(s string) {
  37112. m.phone = &s
  37113. }
  37114. // Phone returns the value of the "phone" field in the mutation.
  37115. func (m *WxCardMutation) Phone() (r string, exists bool) {
  37116. v := m.phone
  37117. if v == nil {
  37118. return
  37119. }
  37120. return *v, true
  37121. }
  37122. // OldPhone returns the old "phone" field's value of the WxCard entity.
  37123. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37125. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  37126. if !m.op.Is(OpUpdateOne) {
  37127. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  37128. }
  37129. if m.id == nil || m.oldValue == nil {
  37130. return v, errors.New("OldPhone requires an ID field in the mutation")
  37131. }
  37132. oldValue, err := m.oldValue(ctx)
  37133. if err != nil {
  37134. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  37135. }
  37136. return oldValue.Phone, nil
  37137. }
  37138. // ResetPhone resets all changes to the "phone" field.
  37139. func (m *WxCardMutation) ResetPhone() {
  37140. m.phone = nil
  37141. }
  37142. // SetOfficialAccount sets the "official_account" field.
  37143. func (m *WxCardMutation) SetOfficialAccount(s string) {
  37144. m.official_account = &s
  37145. }
  37146. // OfficialAccount returns the value of the "official_account" field in the mutation.
  37147. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  37148. v := m.official_account
  37149. if v == nil {
  37150. return
  37151. }
  37152. return *v, true
  37153. }
  37154. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  37155. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37157. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  37158. if !m.op.Is(OpUpdateOne) {
  37159. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  37160. }
  37161. if m.id == nil || m.oldValue == nil {
  37162. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  37163. }
  37164. oldValue, err := m.oldValue(ctx)
  37165. if err != nil {
  37166. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  37167. }
  37168. return oldValue.OfficialAccount, nil
  37169. }
  37170. // ResetOfficialAccount resets all changes to the "official_account" field.
  37171. func (m *WxCardMutation) ResetOfficialAccount() {
  37172. m.official_account = nil
  37173. }
  37174. // SetWechatAccount sets the "wechat_account" field.
  37175. func (m *WxCardMutation) SetWechatAccount(s string) {
  37176. m.wechat_account = &s
  37177. }
  37178. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  37179. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  37180. v := m.wechat_account
  37181. if v == nil {
  37182. return
  37183. }
  37184. return *v, true
  37185. }
  37186. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  37187. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37189. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  37190. if !m.op.Is(OpUpdateOne) {
  37191. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  37192. }
  37193. if m.id == nil || m.oldValue == nil {
  37194. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  37195. }
  37196. oldValue, err := m.oldValue(ctx)
  37197. if err != nil {
  37198. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  37199. }
  37200. return oldValue.WechatAccount, nil
  37201. }
  37202. // ResetWechatAccount resets all changes to the "wechat_account" field.
  37203. func (m *WxCardMutation) ResetWechatAccount() {
  37204. m.wechat_account = nil
  37205. }
  37206. // SetEmail sets the "email" field.
  37207. func (m *WxCardMutation) SetEmail(s string) {
  37208. m.email = &s
  37209. }
  37210. // Email returns the value of the "email" field in the mutation.
  37211. func (m *WxCardMutation) Email() (r string, exists bool) {
  37212. v := m.email
  37213. if v == nil {
  37214. return
  37215. }
  37216. return *v, true
  37217. }
  37218. // OldEmail returns the old "email" field's value of the WxCard entity.
  37219. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37221. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  37222. if !m.op.Is(OpUpdateOne) {
  37223. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  37224. }
  37225. if m.id == nil || m.oldValue == nil {
  37226. return v, errors.New("OldEmail requires an ID field in the mutation")
  37227. }
  37228. oldValue, err := m.oldValue(ctx)
  37229. if err != nil {
  37230. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  37231. }
  37232. return oldValue.Email, nil
  37233. }
  37234. // ClearEmail clears the value of the "email" field.
  37235. func (m *WxCardMutation) ClearEmail() {
  37236. m.email = nil
  37237. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  37238. }
  37239. // EmailCleared returns if the "email" field was cleared in this mutation.
  37240. func (m *WxCardMutation) EmailCleared() bool {
  37241. _, ok := m.clearedFields[wxcard.FieldEmail]
  37242. return ok
  37243. }
  37244. // ResetEmail resets all changes to the "email" field.
  37245. func (m *WxCardMutation) ResetEmail() {
  37246. m.email = nil
  37247. delete(m.clearedFields, wxcard.FieldEmail)
  37248. }
  37249. // SetAPIBase sets the "api_base" field.
  37250. func (m *WxCardMutation) SetAPIBase(s string) {
  37251. m.api_base = &s
  37252. }
  37253. // APIBase returns the value of the "api_base" field in the mutation.
  37254. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  37255. v := m.api_base
  37256. if v == nil {
  37257. return
  37258. }
  37259. return *v, true
  37260. }
  37261. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  37262. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37264. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  37265. if !m.op.Is(OpUpdateOne) {
  37266. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  37267. }
  37268. if m.id == nil || m.oldValue == nil {
  37269. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  37270. }
  37271. oldValue, err := m.oldValue(ctx)
  37272. if err != nil {
  37273. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  37274. }
  37275. return oldValue.APIBase, nil
  37276. }
  37277. // ClearAPIBase clears the value of the "api_base" field.
  37278. func (m *WxCardMutation) ClearAPIBase() {
  37279. m.api_base = nil
  37280. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  37281. }
  37282. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  37283. func (m *WxCardMutation) APIBaseCleared() bool {
  37284. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  37285. return ok
  37286. }
  37287. // ResetAPIBase resets all changes to the "api_base" field.
  37288. func (m *WxCardMutation) ResetAPIBase() {
  37289. m.api_base = nil
  37290. delete(m.clearedFields, wxcard.FieldAPIBase)
  37291. }
  37292. // SetAPIKey sets the "api_key" field.
  37293. func (m *WxCardMutation) SetAPIKey(s string) {
  37294. m.api_key = &s
  37295. }
  37296. // APIKey returns the value of the "api_key" field in the mutation.
  37297. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  37298. v := m.api_key
  37299. if v == nil {
  37300. return
  37301. }
  37302. return *v, true
  37303. }
  37304. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  37305. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37307. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  37308. if !m.op.Is(OpUpdateOne) {
  37309. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  37310. }
  37311. if m.id == nil || m.oldValue == nil {
  37312. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  37313. }
  37314. oldValue, err := m.oldValue(ctx)
  37315. if err != nil {
  37316. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  37317. }
  37318. return oldValue.APIKey, nil
  37319. }
  37320. // ClearAPIKey clears the value of the "api_key" field.
  37321. func (m *WxCardMutation) ClearAPIKey() {
  37322. m.api_key = nil
  37323. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  37324. }
  37325. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  37326. func (m *WxCardMutation) APIKeyCleared() bool {
  37327. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  37328. return ok
  37329. }
  37330. // ResetAPIKey resets all changes to the "api_key" field.
  37331. func (m *WxCardMutation) ResetAPIKey() {
  37332. m.api_key = nil
  37333. delete(m.clearedFields, wxcard.FieldAPIKey)
  37334. }
  37335. // SetAiInfo sets the "ai_info" field.
  37336. func (m *WxCardMutation) SetAiInfo(s string) {
  37337. m.ai_info = &s
  37338. }
  37339. // AiInfo returns the value of the "ai_info" field in the mutation.
  37340. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  37341. v := m.ai_info
  37342. if v == nil {
  37343. return
  37344. }
  37345. return *v, true
  37346. }
  37347. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  37348. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37350. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  37351. if !m.op.Is(OpUpdateOne) {
  37352. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  37353. }
  37354. if m.id == nil || m.oldValue == nil {
  37355. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  37356. }
  37357. oldValue, err := m.oldValue(ctx)
  37358. if err != nil {
  37359. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  37360. }
  37361. return oldValue.AiInfo, nil
  37362. }
  37363. // ClearAiInfo clears the value of the "ai_info" field.
  37364. func (m *WxCardMutation) ClearAiInfo() {
  37365. m.ai_info = nil
  37366. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  37367. }
  37368. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  37369. func (m *WxCardMutation) AiInfoCleared() bool {
  37370. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  37371. return ok
  37372. }
  37373. // ResetAiInfo resets all changes to the "ai_info" field.
  37374. func (m *WxCardMutation) ResetAiInfo() {
  37375. m.ai_info = nil
  37376. delete(m.clearedFields, wxcard.FieldAiInfo)
  37377. }
  37378. // SetIntro sets the "intro" field.
  37379. func (m *WxCardMutation) SetIntro(s string) {
  37380. m.intro = &s
  37381. }
  37382. // Intro returns the value of the "intro" field in the mutation.
  37383. func (m *WxCardMutation) Intro() (r string, exists bool) {
  37384. v := m.intro
  37385. if v == nil {
  37386. return
  37387. }
  37388. return *v, true
  37389. }
  37390. // OldIntro returns the old "intro" field's value of the WxCard entity.
  37391. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  37392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37393. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  37394. if !m.op.Is(OpUpdateOne) {
  37395. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  37396. }
  37397. if m.id == nil || m.oldValue == nil {
  37398. return v, errors.New("OldIntro requires an ID field in the mutation")
  37399. }
  37400. oldValue, err := m.oldValue(ctx)
  37401. if err != nil {
  37402. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  37403. }
  37404. return oldValue.Intro, nil
  37405. }
  37406. // ClearIntro clears the value of the "intro" field.
  37407. func (m *WxCardMutation) ClearIntro() {
  37408. m.intro = nil
  37409. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  37410. }
  37411. // IntroCleared returns if the "intro" field was cleared in this mutation.
  37412. func (m *WxCardMutation) IntroCleared() bool {
  37413. _, ok := m.clearedFields[wxcard.FieldIntro]
  37414. return ok
  37415. }
  37416. // ResetIntro resets all changes to the "intro" field.
  37417. func (m *WxCardMutation) ResetIntro() {
  37418. m.intro = nil
  37419. delete(m.clearedFields, wxcard.FieldIntro)
  37420. }
  37421. // Where appends a list predicates to the WxCardMutation builder.
  37422. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  37423. m.predicates = append(m.predicates, ps...)
  37424. }
  37425. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  37426. // users can use type-assertion to append predicates that do not depend on any generated package.
  37427. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  37428. p := make([]predicate.WxCard, len(ps))
  37429. for i := range ps {
  37430. p[i] = ps[i]
  37431. }
  37432. m.Where(p...)
  37433. }
  37434. // Op returns the operation name.
  37435. func (m *WxCardMutation) Op() Op {
  37436. return m.op
  37437. }
  37438. // SetOp allows setting the mutation operation.
  37439. func (m *WxCardMutation) SetOp(op Op) {
  37440. m.op = op
  37441. }
  37442. // Type returns the node type of this mutation (WxCard).
  37443. func (m *WxCardMutation) Type() string {
  37444. return m.typ
  37445. }
  37446. // Fields returns all fields that were changed during this mutation. Note that in
  37447. // order to get all numeric fields that were incremented/decremented, call
  37448. // AddedFields().
  37449. func (m *WxCardMutation) Fields() []string {
  37450. fields := make([]string, 0, 18)
  37451. if m.created_at != nil {
  37452. fields = append(fields, wxcard.FieldCreatedAt)
  37453. }
  37454. if m.updated_at != nil {
  37455. fields = append(fields, wxcard.FieldUpdatedAt)
  37456. }
  37457. if m.deleted_at != nil {
  37458. fields = append(fields, wxcard.FieldDeletedAt)
  37459. }
  37460. if m.user_id != nil {
  37461. fields = append(fields, wxcard.FieldUserID)
  37462. }
  37463. if m.wx_user_id != nil {
  37464. fields = append(fields, wxcard.FieldWxUserID)
  37465. }
  37466. if m.avatar != nil {
  37467. fields = append(fields, wxcard.FieldAvatar)
  37468. }
  37469. if m.logo != nil {
  37470. fields = append(fields, wxcard.FieldLogo)
  37471. }
  37472. if m.name != nil {
  37473. fields = append(fields, wxcard.FieldName)
  37474. }
  37475. if m.company != nil {
  37476. fields = append(fields, wxcard.FieldCompany)
  37477. }
  37478. if m.address != nil {
  37479. fields = append(fields, wxcard.FieldAddress)
  37480. }
  37481. if m.phone != nil {
  37482. fields = append(fields, wxcard.FieldPhone)
  37483. }
  37484. if m.official_account != nil {
  37485. fields = append(fields, wxcard.FieldOfficialAccount)
  37486. }
  37487. if m.wechat_account != nil {
  37488. fields = append(fields, wxcard.FieldWechatAccount)
  37489. }
  37490. if m.email != nil {
  37491. fields = append(fields, wxcard.FieldEmail)
  37492. }
  37493. if m.api_base != nil {
  37494. fields = append(fields, wxcard.FieldAPIBase)
  37495. }
  37496. if m.api_key != nil {
  37497. fields = append(fields, wxcard.FieldAPIKey)
  37498. }
  37499. if m.ai_info != nil {
  37500. fields = append(fields, wxcard.FieldAiInfo)
  37501. }
  37502. if m.intro != nil {
  37503. fields = append(fields, wxcard.FieldIntro)
  37504. }
  37505. return fields
  37506. }
  37507. // Field returns the value of a field with the given name. The second boolean
  37508. // return value indicates that this field was not set, or was not defined in the
  37509. // schema.
  37510. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  37511. switch name {
  37512. case wxcard.FieldCreatedAt:
  37513. return m.CreatedAt()
  37514. case wxcard.FieldUpdatedAt:
  37515. return m.UpdatedAt()
  37516. case wxcard.FieldDeletedAt:
  37517. return m.DeletedAt()
  37518. case wxcard.FieldUserID:
  37519. return m.UserID()
  37520. case wxcard.FieldWxUserID:
  37521. return m.WxUserID()
  37522. case wxcard.FieldAvatar:
  37523. return m.Avatar()
  37524. case wxcard.FieldLogo:
  37525. return m.Logo()
  37526. case wxcard.FieldName:
  37527. return m.Name()
  37528. case wxcard.FieldCompany:
  37529. return m.Company()
  37530. case wxcard.FieldAddress:
  37531. return m.Address()
  37532. case wxcard.FieldPhone:
  37533. return m.Phone()
  37534. case wxcard.FieldOfficialAccount:
  37535. return m.OfficialAccount()
  37536. case wxcard.FieldWechatAccount:
  37537. return m.WechatAccount()
  37538. case wxcard.FieldEmail:
  37539. return m.Email()
  37540. case wxcard.FieldAPIBase:
  37541. return m.APIBase()
  37542. case wxcard.FieldAPIKey:
  37543. return m.APIKey()
  37544. case wxcard.FieldAiInfo:
  37545. return m.AiInfo()
  37546. case wxcard.FieldIntro:
  37547. return m.Intro()
  37548. }
  37549. return nil, false
  37550. }
  37551. // OldField returns the old value of the field from the database. An error is
  37552. // returned if the mutation operation is not UpdateOne, or the query to the
  37553. // database failed.
  37554. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37555. switch name {
  37556. case wxcard.FieldCreatedAt:
  37557. return m.OldCreatedAt(ctx)
  37558. case wxcard.FieldUpdatedAt:
  37559. return m.OldUpdatedAt(ctx)
  37560. case wxcard.FieldDeletedAt:
  37561. return m.OldDeletedAt(ctx)
  37562. case wxcard.FieldUserID:
  37563. return m.OldUserID(ctx)
  37564. case wxcard.FieldWxUserID:
  37565. return m.OldWxUserID(ctx)
  37566. case wxcard.FieldAvatar:
  37567. return m.OldAvatar(ctx)
  37568. case wxcard.FieldLogo:
  37569. return m.OldLogo(ctx)
  37570. case wxcard.FieldName:
  37571. return m.OldName(ctx)
  37572. case wxcard.FieldCompany:
  37573. return m.OldCompany(ctx)
  37574. case wxcard.FieldAddress:
  37575. return m.OldAddress(ctx)
  37576. case wxcard.FieldPhone:
  37577. return m.OldPhone(ctx)
  37578. case wxcard.FieldOfficialAccount:
  37579. return m.OldOfficialAccount(ctx)
  37580. case wxcard.FieldWechatAccount:
  37581. return m.OldWechatAccount(ctx)
  37582. case wxcard.FieldEmail:
  37583. return m.OldEmail(ctx)
  37584. case wxcard.FieldAPIBase:
  37585. return m.OldAPIBase(ctx)
  37586. case wxcard.FieldAPIKey:
  37587. return m.OldAPIKey(ctx)
  37588. case wxcard.FieldAiInfo:
  37589. return m.OldAiInfo(ctx)
  37590. case wxcard.FieldIntro:
  37591. return m.OldIntro(ctx)
  37592. }
  37593. return nil, fmt.Errorf("unknown WxCard field %s", name)
  37594. }
  37595. // SetField sets the value of a field with the given name. It returns an error if
  37596. // the field is not defined in the schema, or if the type mismatched the field
  37597. // type.
  37598. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  37599. switch name {
  37600. case wxcard.FieldCreatedAt:
  37601. v, ok := value.(time.Time)
  37602. if !ok {
  37603. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37604. }
  37605. m.SetCreatedAt(v)
  37606. return nil
  37607. case wxcard.FieldUpdatedAt:
  37608. v, ok := value.(time.Time)
  37609. if !ok {
  37610. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37611. }
  37612. m.SetUpdatedAt(v)
  37613. return nil
  37614. case wxcard.FieldDeletedAt:
  37615. v, ok := value.(time.Time)
  37616. if !ok {
  37617. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37618. }
  37619. m.SetDeletedAt(v)
  37620. return nil
  37621. case wxcard.FieldUserID:
  37622. v, ok := value.(uint64)
  37623. if !ok {
  37624. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37625. }
  37626. m.SetUserID(v)
  37627. return nil
  37628. case wxcard.FieldWxUserID:
  37629. v, ok := value.(uint64)
  37630. if !ok {
  37631. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37632. }
  37633. m.SetWxUserID(v)
  37634. return nil
  37635. case wxcard.FieldAvatar:
  37636. v, ok := value.(string)
  37637. if !ok {
  37638. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37639. }
  37640. m.SetAvatar(v)
  37641. return nil
  37642. case wxcard.FieldLogo:
  37643. v, ok := value.(string)
  37644. if !ok {
  37645. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37646. }
  37647. m.SetLogo(v)
  37648. return nil
  37649. case wxcard.FieldName:
  37650. v, ok := value.(string)
  37651. if !ok {
  37652. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37653. }
  37654. m.SetName(v)
  37655. return nil
  37656. case wxcard.FieldCompany:
  37657. v, ok := value.(string)
  37658. if !ok {
  37659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37660. }
  37661. m.SetCompany(v)
  37662. return nil
  37663. case wxcard.FieldAddress:
  37664. v, ok := value.(string)
  37665. if !ok {
  37666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37667. }
  37668. m.SetAddress(v)
  37669. return nil
  37670. case wxcard.FieldPhone:
  37671. v, ok := value.(string)
  37672. if !ok {
  37673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37674. }
  37675. m.SetPhone(v)
  37676. return nil
  37677. case wxcard.FieldOfficialAccount:
  37678. v, ok := value.(string)
  37679. if !ok {
  37680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37681. }
  37682. m.SetOfficialAccount(v)
  37683. return nil
  37684. case wxcard.FieldWechatAccount:
  37685. v, ok := value.(string)
  37686. if !ok {
  37687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37688. }
  37689. m.SetWechatAccount(v)
  37690. return nil
  37691. case wxcard.FieldEmail:
  37692. v, ok := value.(string)
  37693. if !ok {
  37694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37695. }
  37696. m.SetEmail(v)
  37697. return nil
  37698. case wxcard.FieldAPIBase:
  37699. v, ok := value.(string)
  37700. if !ok {
  37701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37702. }
  37703. m.SetAPIBase(v)
  37704. return nil
  37705. case wxcard.FieldAPIKey:
  37706. v, ok := value.(string)
  37707. if !ok {
  37708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37709. }
  37710. m.SetAPIKey(v)
  37711. return nil
  37712. case wxcard.FieldAiInfo:
  37713. v, ok := value.(string)
  37714. if !ok {
  37715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37716. }
  37717. m.SetAiInfo(v)
  37718. return nil
  37719. case wxcard.FieldIntro:
  37720. v, ok := value.(string)
  37721. if !ok {
  37722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37723. }
  37724. m.SetIntro(v)
  37725. return nil
  37726. }
  37727. return fmt.Errorf("unknown WxCard field %s", name)
  37728. }
  37729. // AddedFields returns all numeric fields that were incremented/decremented during
  37730. // this mutation.
  37731. func (m *WxCardMutation) AddedFields() []string {
  37732. var fields []string
  37733. if m.adduser_id != nil {
  37734. fields = append(fields, wxcard.FieldUserID)
  37735. }
  37736. if m.addwx_user_id != nil {
  37737. fields = append(fields, wxcard.FieldWxUserID)
  37738. }
  37739. return fields
  37740. }
  37741. // AddedField returns the numeric value that was incremented/decremented on a field
  37742. // with the given name. The second boolean return value indicates that this field
  37743. // was not set, or was not defined in the schema.
  37744. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  37745. switch name {
  37746. case wxcard.FieldUserID:
  37747. return m.AddedUserID()
  37748. case wxcard.FieldWxUserID:
  37749. return m.AddedWxUserID()
  37750. }
  37751. return nil, false
  37752. }
  37753. // AddField adds the value to the field with the given name. It returns an error if
  37754. // the field is not defined in the schema, or if the type mismatched the field
  37755. // type.
  37756. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  37757. switch name {
  37758. case wxcard.FieldUserID:
  37759. v, ok := value.(int64)
  37760. if !ok {
  37761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37762. }
  37763. m.AddUserID(v)
  37764. return nil
  37765. case wxcard.FieldWxUserID:
  37766. v, ok := value.(int64)
  37767. if !ok {
  37768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37769. }
  37770. m.AddWxUserID(v)
  37771. return nil
  37772. }
  37773. return fmt.Errorf("unknown WxCard numeric field %s", name)
  37774. }
  37775. // ClearedFields returns all nullable fields that were cleared during this
  37776. // mutation.
  37777. func (m *WxCardMutation) ClearedFields() []string {
  37778. var fields []string
  37779. if m.FieldCleared(wxcard.FieldDeletedAt) {
  37780. fields = append(fields, wxcard.FieldDeletedAt)
  37781. }
  37782. if m.FieldCleared(wxcard.FieldUserID) {
  37783. fields = append(fields, wxcard.FieldUserID)
  37784. }
  37785. if m.FieldCleared(wxcard.FieldWxUserID) {
  37786. fields = append(fields, wxcard.FieldWxUserID)
  37787. }
  37788. if m.FieldCleared(wxcard.FieldEmail) {
  37789. fields = append(fields, wxcard.FieldEmail)
  37790. }
  37791. if m.FieldCleared(wxcard.FieldAPIBase) {
  37792. fields = append(fields, wxcard.FieldAPIBase)
  37793. }
  37794. if m.FieldCleared(wxcard.FieldAPIKey) {
  37795. fields = append(fields, wxcard.FieldAPIKey)
  37796. }
  37797. if m.FieldCleared(wxcard.FieldAiInfo) {
  37798. fields = append(fields, wxcard.FieldAiInfo)
  37799. }
  37800. if m.FieldCleared(wxcard.FieldIntro) {
  37801. fields = append(fields, wxcard.FieldIntro)
  37802. }
  37803. return fields
  37804. }
  37805. // FieldCleared returns a boolean indicating if a field with the given name was
  37806. // cleared in this mutation.
  37807. func (m *WxCardMutation) FieldCleared(name string) bool {
  37808. _, ok := m.clearedFields[name]
  37809. return ok
  37810. }
  37811. // ClearField clears the value of the field with the given name. It returns an
  37812. // error if the field is not defined in the schema.
  37813. func (m *WxCardMutation) ClearField(name string) error {
  37814. switch name {
  37815. case wxcard.FieldDeletedAt:
  37816. m.ClearDeletedAt()
  37817. return nil
  37818. case wxcard.FieldUserID:
  37819. m.ClearUserID()
  37820. return nil
  37821. case wxcard.FieldWxUserID:
  37822. m.ClearWxUserID()
  37823. return nil
  37824. case wxcard.FieldEmail:
  37825. m.ClearEmail()
  37826. return nil
  37827. case wxcard.FieldAPIBase:
  37828. m.ClearAPIBase()
  37829. return nil
  37830. case wxcard.FieldAPIKey:
  37831. m.ClearAPIKey()
  37832. return nil
  37833. case wxcard.FieldAiInfo:
  37834. m.ClearAiInfo()
  37835. return nil
  37836. case wxcard.FieldIntro:
  37837. m.ClearIntro()
  37838. return nil
  37839. }
  37840. return fmt.Errorf("unknown WxCard nullable field %s", name)
  37841. }
  37842. // ResetField resets all changes in the mutation for the field with the given name.
  37843. // It returns an error if the field is not defined in the schema.
  37844. func (m *WxCardMutation) ResetField(name string) error {
  37845. switch name {
  37846. case wxcard.FieldCreatedAt:
  37847. m.ResetCreatedAt()
  37848. return nil
  37849. case wxcard.FieldUpdatedAt:
  37850. m.ResetUpdatedAt()
  37851. return nil
  37852. case wxcard.FieldDeletedAt:
  37853. m.ResetDeletedAt()
  37854. return nil
  37855. case wxcard.FieldUserID:
  37856. m.ResetUserID()
  37857. return nil
  37858. case wxcard.FieldWxUserID:
  37859. m.ResetWxUserID()
  37860. return nil
  37861. case wxcard.FieldAvatar:
  37862. m.ResetAvatar()
  37863. return nil
  37864. case wxcard.FieldLogo:
  37865. m.ResetLogo()
  37866. return nil
  37867. case wxcard.FieldName:
  37868. m.ResetName()
  37869. return nil
  37870. case wxcard.FieldCompany:
  37871. m.ResetCompany()
  37872. return nil
  37873. case wxcard.FieldAddress:
  37874. m.ResetAddress()
  37875. return nil
  37876. case wxcard.FieldPhone:
  37877. m.ResetPhone()
  37878. return nil
  37879. case wxcard.FieldOfficialAccount:
  37880. m.ResetOfficialAccount()
  37881. return nil
  37882. case wxcard.FieldWechatAccount:
  37883. m.ResetWechatAccount()
  37884. return nil
  37885. case wxcard.FieldEmail:
  37886. m.ResetEmail()
  37887. return nil
  37888. case wxcard.FieldAPIBase:
  37889. m.ResetAPIBase()
  37890. return nil
  37891. case wxcard.FieldAPIKey:
  37892. m.ResetAPIKey()
  37893. return nil
  37894. case wxcard.FieldAiInfo:
  37895. m.ResetAiInfo()
  37896. return nil
  37897. case wxcard.FieldIntro:
  37898. m.ResetIntro()
  37899. return nil
  37900. }
  37901. return fmt.Errorf("unknown WxCard field %s", name)
  37902. }
  37903. // AddedEdges returns all edge names that were set/added in this mutation.
  37904. func (m *WxCardMutation) AddedEdges() []string {
  37905. edges := make([]string, 0, 0)
  37906. return edges
  37907. }
  37908. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37909. // name in this mutation.
  37910. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  37911. return nil
  37912. }
  37913. // RemovedEdges returns all edge names that were removed in this mutation.
  37914. func (m *WxCardMutation) RemovedEdges() []string {
  37915. edges := make([]string, 0, 0)
  37916. return edges
  37917. }
  37918. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37919. // the given name in this mutation.
  37920. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  37921. return nil
  37922. }
  37923. // ClearedEdges returns all edge names that were cleared in this mutation.
  37924. func (m *WxCardMutation) ClearedEdges() []string {
  37925. edges := make([]string, 0, 0)
  37926. return edges
  37927. }
  37928. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37929. // was cleared in this mutation.
  37930. func (m *WxCardMutation) EdgeCleared(name string) bool {
  37931. return false
  37932. }
  37933. // ClearEdge clears the value of the edge with the given name. It returns an error
  37934. // if that edge is not defined in the schema.
  37935. func (m *WxCardMutation) ClearEdge(name string) error {
  37936. return fmt.Errorf("unknown WxCard unique edge %s", name)
  37937. }
  37938. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37939. // It returns an error if the edge is not defined in the schema.
  37940. func (m *WxCardMutation) ResetEdge(name string) error {
  37941. return fmt.Errorf("unknown WxCard edge %s", name)
  37942. }
  37943. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  37944. type WxCardUserMutation struct {
  37945. config
  37946. op Op
  37947. typ string
  37948. id *uint64
  37949. created_at *time.Time
  37950. updated_at *time.Time
  37951. deleted_at *time.Time
  37952. wxid *string
  37953. account *string
  37954. avatar *string
  37955. nickname *string
  37956. remark *string
  37957. phone *string
  37958. open_id *string
  37959. union_id *string
  37960. session_key *string
  37961. is_vip *int
  37962. addis_vip *int
  37963. clearedFields map[string]struct{}
  37964. done bool
  37965. oldValue func(context.Context) (*WxCardUser, error)
  37966. predicates []predicate.WxCardUser
  37967. }
  37968. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  37969. // wxcarduserOption allows management of the mutation configuration using functional options.
  37970. type wxcarduserOption func(*WxCardUserMutation)
  37971. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  37972. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  37973. m := &WxCardUserMutation{
  37974. config: c,
  37975. op: op,
  37976. typ: TypeWxCardUser,
  37977. clearedFields: make(map[string]struct{}),
  37978. }
  37979. for _, opt := range opts {
  37980. opt(m)
  37981. }
  37982. return m
  37983. }
  37984. // withWxCardUserID sets the ID field of the mutation.
  37985. func withWxCardUserID(id uint64) wxcarduserOption {
  37986. return func(m *WxCardUserMutation) {
  37987. var (
  37988. err error
  37989. once sync.Once
  37990. value *WxCardUser
  37991. )
  37992. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  37993. once.Do(func() {
  37994. if m.done {
  37995. err = errors.New("querying old values post mutation is not allowed")
  37996. } else {
  37997. value, err = m.Client().WxCardUser.Get(ctx, id)
  37998. }
  37999. })
  38000. return value, err
  38001. }
  38002. m.id = &id
  38003. }
  38004. }
  38005. // withWxCardUser sets the old WxCardUser of the mutation.
  38006. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  38007. return func(m *WxCardUserMutation) {
  38008. m.oldValue = func(context.Context) (*WxCardUser, error) {
  38009. return node, nil
  38010. }
  38011. m.id = &node.ID
  38012. }
  38013. }
  38014. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38015. // executed in a transaction (ent.Tx), a transactional client is returned.
  38016. func (m WxCardUserMutation) Client() *Client {
  38017. client := &Client{config: m.config}
  38018. client.init()
  38019. return client
  38020. }
  38021. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38022. // it returns an error otherwise.
  38023. func (m WxCardUserMutation) Tx() (*Tx, error) {
  38024. if _, ok := m.driver.(*txDriver); !ok {
  38025. return nil, errors.New("ent: mutation is not running in a transaction")
  38026. }
  38027. tx := &Tx{config: m.config}
  38028. tx.init()
  38029. return tx, nil
  38030. }
  38031. // SetID sets the value of the id field. Note that this
  38032. // operation is only accepted on creation of WxCardUser entities.
  38033. func (m *WxCardUserMutation) SetID(id uint64) {
  38034. m.id = &id
  38035. }
  38036. // ID returns the ID value in the mutation. Note that the ID is only available
  38037. // if it was provided to the builder or after it was returned from the database.
  38038. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  38039. if m.id == nil {
  38040. return
  38041. }
  38042. return *m.id, true
  38043. }
  38044. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38045. // That means, if the mutation is applied within a transaction with an isolation level such
  38046. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38047. // or updated by the mutation.
  38048. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  38049. switch {
  38050. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38051. id, exists := m.ID()
  38052. if exists {
  38053. return []uint64{id}, nil
  38054. }
  38055. fallthrough
  38056. case m.op.Is(OpUpdate | OpDelete):
  38057. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  38058. default:
  38059. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38060. }
  38061. }
  38062. // SetCreatedAt sets the "created_at" field.
  38063. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  38064. m.created_at = &t
  38065. }
  38066. // CreatedAt returns the value of the "created_at" field in the mutation.
  38067. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  38068. v := m.created_at
  38069. if v == nil {
  38070. return
  38071. }
  38072. return *v, true
  38073. }
  38074. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  38075. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  38076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38077. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38078. if !m.op.Is(OpUpdateOne) {
  38079. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38080. }
  38081. if m.id == nil || m.oldValue == nil {
  38082. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38083. }
  38084. oldValue, err := m.oldValue(ctx)
  38085. if err != nil {
  38086. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38087. }
  38088. return oldValue.CreatedAt, nil
  38089. }
  38090. // ResetCreatedAt resets all changes to the "created_at" field.
  38091. func (m *WxCardUserMutation) ResetCreatedAt() {
  38092. m.created_at = nil
  38093. }
  38094. // SetUpdatedAt sets the "updated_at" field.
  38095. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  38096. m.updated_at = &t
  38097. }
  38098. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38099. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  38100. v := m.updated_at
  38101. if v == nil {
  38102. return
  38103. }
  38104. return *v, true
  38105. }
  38106. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  38107. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  38108. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38109. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38110. if !m.op.Is(OpUpdateOne) {
  38111. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38112. }
  38113. if m.id == nil || m.oldValue == nil {
  38114. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  38115. }
  38116. oldValue, err := m.oldValue(ctx)
  38117. if err != nil {
  38118. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  38119. }
  38120. return oldValue.UpdatedAt, nil
  38121. }
  38122. // ResetUpdatedAt resets all changes to the "updated_at" field.
  38123. func (m *WxCardUserMutation) ResetUpdatedAt() {
  38124. m.updated_at = nil
  38125. }
  38126. // SetDeletedAt sets the "deleted_at" field.
  38127. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  38128. m.deleted_at = &t
  38129. }
  38130. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  38131. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  38132. v := m.deleted_at
  38133. if v == nil {
  38134. return
  38135. }
  38136. return *v, true
  38137. }
  38138. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  38139. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  38140. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38141. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  38142. if !m.op.Is(OpUpdateOne) {
  38143. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  38144. }
  38145. if m.id == nil || m.oldValue == nil {
  38146. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  38147. }
  38148. oldValue, err := m.oldValue(ctx)
  38149. if err != nil {
  38150. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  38151. }
  38152. return oldValue.DeletedAt, nil
  38153. }
  38154. // ClearDeletedAt clears the value of the "deleted_at" field.
  38155. func (m *WxCardUserMutation) ClearDeletedAt() {
  38156. m.deleted_at = nil
  38157. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  38158. }
  38159. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  38160. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  38161. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  38162. return ok
  38163. }
  38164. // ResetDeletedAt resets all changes to the "deleted_at" field.
  38165. func (m *WxCardUserMutation) ResetDeletedAt() {
  38166. m.deleted_at = nil
  38167. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  38168. }
  38169. // SetWxid sets the "wxid" field.
  38170. func (m *WxCardUserMutation) SetWxid(s string) {
  38171. m.wxid = &s
  38172. }
  38173. // Wxid returns the value of the "wxid" field in the mutation.
  38174. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  38175. v := m.wxid
  38176. if v == nil {
  38177. return
  38178. }
  38179. return *v, true
  38180. }
  38181. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  38182. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  38183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38184. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  38185. if !m.op.Is(OpUpdateOne) {
  38186. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  38187. }
  38188. if m.id == nil || m.oldValue == nil {
  38189. return v, errors.New("OldWxid requires an ID field in the mutation")
  38190. }
  38191. oldValue, err := m.oldValue(ctx)
  38192. if err != nil {
  38193. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  38194. }
  38195. return oldValue.Wxid, nil
  38196. }
  38197. // ResetWxid resets all changes to the "wxid" field.
  38198. func (m *WxCardUserMutation) ResetWxid() {
  38199. m.wxid = nil
  38200. }
  38201. // SetAccount sets the "account" field.
  38202. func (m *WxCardUserMutation) SetAccount(s string) {
  38203. m.account = &s
  38204. }
  38205. // Account returns the value of the "account" field in the mutation.
  38206. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  38207. v := m.account
  38208. if v == nil {
  38209. return
  38210. }
  38211. return *v, true
  38212. }
  38213. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  38214. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  38215. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38216. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  38217. if !m.op.Is(OpUpdateOne) {
  38218. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  38219. }
  38220. if m.id == nil || m.oldValue == nil {
  38221. return v, errors.New("OldAccount requires an ID field in the mutation")
  38222. }
  38223. oldValue, err := m.oldValue(ctx)
  38224. if err != nil {
  38225. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  38226. }
  38227. return oldValue.Account, nil
  38228. }
  38229. // ResetAccount resets all changes to the "account" field.
  38230. func (m *WxCardUserMutation) ResetAccount() {
  38231. m.account = nil
  38232. }
  38233. // SetAvatar sets the "avatar" field.
  38234. func (m *WxCardUserMutation) SetAvatar(s string) {
  38235. m.avatar = &s
  38236. }
  38237. // Avatar returns the value of the "avatar" field in the mutation.
  38238. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  38239. v := m.avatar
  38240. if v == nil {
  38241. return
  38242. }
  38243. return *v, true
  38244. }
  38245. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  38246. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  38247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38248. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  38249. if !m.op.Is(OpUpdateOne) {
  38250. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  38251. }
  38252. if m.id == nil || m.oldValue == nil {
  38253. return v, errors.New("OldAvatar requires an ID field in the mutation")
  38254. }
  38255. oldValue, err := m.oldValue(ctx)
  38256. if err != nil {
  38257. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  38258. }
  38259. return oldValue.Avatar, nil
  38260. }
  38261. // ResetAvatar resets all changes to the "avatar" field.
  38262. func (m *WxCardUserMutation) ResetAvatar() {
  38263. m.avatar = nil
  38264. }
  38265. // SetNickname sets the "nickname" field.
  38266. func (m *WxCardUserMutation) SetNickname(s string) {
  38267. m.nickname = &s
  38268. }
  38269. // Nickname returns the value of the "nickname" field in the mutation.
  38270. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  38271. v := m.nickname
  38272. if v == nil {
  38273. return
  38274. }
  38275. return *v, true
  38276. }
  38277. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  38278. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  38279. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38280. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  38281. if !m.op.Is(OpUpdateOne) {
  38282. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  38283. }
  38284. if m.id == nil || m.oldValue == nil {
  38285. return v, errors.New("OldNickname requires an ID field in the mutation")
  38286. }
  38287. oldValue, err := m.oldValue(ctx)
  38288. if err != nil {
  38289. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  38290. }
  38291. return oldValue.Nickname, nil
  38292. }
  38293. // ResetNickname resets all changes to the "nickname" field.
  38294. func (m *WxCardUserMutation) ResetNickname() {
  38295. m.nickname = nil
  38296. }
  38297. // SetRemark sets the "remark" field.
  38298. func (m *WxCardUserMutation) SetRemark(s string) {
  38299. m.remark = &s
  38300. }
  38301. // Remark returns the value of the "remark" field in the mutation.
  38302. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  38303. v := m.remark
  38304. if v == nil {
  38305. return
  38306. }
  38307. return *v, true
  38308. }
  38309. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  38310. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  38311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38312. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  38313. if !m.op.Is(OpUpdateOne) {
  38314. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  38315. }
  38316. if m.id == nil || m.oldValue == nil {
  38317. return v, errors.New("OldRemark requires an ID field in the mutation")
  38318. }
  38319. oldValue, err := m.oldValue(ctx)
  38320. if err != nil {
  38321. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  38322. }
  38323. return oldValue.Remark, nil
  38324. }
  38325. // ResetRemark resets all changes to the "remark" field.
  38326. func (m *WxCardUserMutation) ResetRemark() {
  38327. m.remark = nil
  38328. }
  38329. // SetPhone sets the "phone" field.
  38330. func (m *WxCardUserMutation) SetPhone(s string) {
  38331. m.phone = &s
  38332. }
  38333. // Phone returns the value of the "phone" field in the mutation.
  38334. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  38335. v := m.phone
  38336. if v == nil {
  38337. return
  38338. }
  38339. return *v, true
  38340. }
  38341. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  38342. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  38343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38344. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  38345. if !m.op.Is(OpUpdateOne) {
  38346. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  38347. }
  38348. if m.id == nil || m.oldValue == nil {
  38349. return v, errors.New("OldPhone requires an ID field in the mutation")
  38350. }
  38351. oldValue, err := m.oldValue(ctx)
  38352. if err != nil {
  38353. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  38354. }
  38355. return oldValue.Phone, nil
  38356. }
  38357. // ResetPhone resets all changes to the "phone" field.
  38358. func (m *WxCardUserMutation) ResetPhone() {
  38359. m.phone = nil
  38360. }
  38361. // SetOpenID sets the "open_id" field.
  38362. func (m *WxCardUserMutation) SetOpenID(s string) {
  38363. m.open_id = &s
  38364. }
  38365. // OpenID returns the value of the "open_id" field in the mutation.
  38366. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  38367. v := m.open_id
  38368. if v == nil {
  38369. return
  38370. }
  38371. return *v, true
  38372. }
  38373. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  38374. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  38375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38376. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  38377. if !m.op.Is(OpUpdateOne) {
  38378. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  38379. }
  38380. if m.id == nil || m.oldValue == nil {
  38381. return v, errors.New("OldOpenID requires an ID field in the mutation")
  38382. }
  38383. oldValue, err := m.oldValue(ctx)
  38384. if err != nil {
  38385. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  38386. }
  38387. return oldValue.OpenID, nil
  38388. }
  38389. // ResetOpenID resets all changes to the "open_id" field.
  38390. func (m *WxCardUserMutation) ResetOpenID() {
  38391. m.open_id = nil
  38392. }
  38393. // SetUnionID sets the "union_id" field.
  38394. func (m *WxCardUserMutation) SetUnionID(s string) {
  38395. m.union_id = &s
  38396. }
  38397. // UnionID returns the value of the "union_id" field in the mutation.
  38398. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  38399. v := m.union_id
  38400. if v == nil {
  38401. return
  38402. }
  38403. return *v, true
  38404. }
  38405. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  38406. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  38407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38408. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  38409. if !m.op.Is(OpUpdateOne) {
  38410. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  38411. }
  38412. if m.id == nil || m.oldValue == nil {
  38413. return v, errors.New("OldUnionID requires an ID field in the mutation")
  38414. }
  38415. oldValue, err := m.oldValue(ctx)
  38416. if err != nil {
  38417. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  38418. }
  38419. return oldValue.UnionID, nil
  38420. }
  38421. // ResetUnionID resets all changes to the "union_id" field.
  38422. func (m *WxCardUserMutation) ResetUnionID() {
  38423. m.union_id = nil
  38424. }
  38425. // SetSessionKey sets the "session_key" field.
  38426. func (m *WxCardUserMutation) SetSessionKey(s string) {
  38427. m.session_key = &s
  38428. }
  38429. // SessionKey returns the value of the "session_key" field in the mutation.
  38430. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  38431. v := m.session_key
  38432. if v == nil {
  38433. return
  38434. }
  38435. return *v, true
  38436. }
  38437. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  38438. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  38439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38440. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  38441. if !m.op.Is(OpUpdateOne) {
  38442. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  38443. }
  38444. if m.id == nil || m.oldValue == nil {
  38445. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  38446. }
  38447. oldValue, err := m.oldValue(ctx)
  38448. if err != nil {
  38449. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  38450. }
  38451. return oldValue.SessionKey, nil
  38452. }
  38453. // ResetSessionKey resets all changes to the "session_key" field.
  38454. func (m *WxCardUserMutation) ResetSessionKey() {
  38455. m.session_key = nil
  38456. }
  38457. // SetIsVip sets the "is_vip" field.
  38458. func (m *WxCardUserMutation) SetIsVip(i int) {
  38459. m.is_vip = &i
  38460. m.addis_vip = nil
  38461. }
  38462. // IsVip returns the value of the "is_vip" field in the mutation.
  38463. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  38464. v := m.is_vip
  38465. if v == nil {
  38466. return
  38467. }
  38468. return *v, true
  38469. }
  38470. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  38471. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  38472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38473. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  38474. if !m.op.Is(OpUpdateOne) {
  38475. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  38476. }
  38477. if m.id == nil || m.oldValue == nil {
  38478. return v, errors.New("OldIsVip requires an ID field in the mutation")
  38479. }
  38480. oldValue, err := m.oldValue(ctx)
  38481. if err != nil {
  38482. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  38483. }
  38484. return oldValue.IsVip, nil
  38485. }
  38486. // AddIsVip adds i to the "is_vip" field.
  38487. func (m *WxCardUserMutation) AddIsVip(i int) {
  38488. if m.addis_vip != nil {
  38489. *m.addis_vip += i
  38490. } else {
  38491. m.addis_vip = &i
  38492. }
  38493. }
  38494. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  38495. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  38496. v := m.addis_vip
  38497. if v == nil {
  38498. return
  38499. }
  38500. return *v, true
  38501. }
  38502. // ResetIsVip resets all changes to the "is_vip" field.
  38503. func (m *WxCardUserMutation) ResetIsVip() {
  38504. m.is_vip = nil
  38505. m.addis_vip = nil
  38506. }
  38507. // Where appends a list predicates to the WxCardUserMutation builder.
  38508. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  38509. m.predicates = append(m.predicates, ps...)
  38510. }
  38511. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  38512. // users can use type-assertion to append predicates that do not depend on any generated package.
  38513. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  38514. p := make([]predicate.WxCardUser, len(ps))
  38515. for i := range ps {
  38516. p[i] = ps[i]
  38517. }
  38518. m.Where(p...)
  38519. }
  38520. // Op returns the operation name.
  38521. func (m *WxCardUserMutation) Op() Op {
  38522. return m.op
  38523. }
  38524. // SetOp allows setting the mutation operation.
  38525. func (m *WxCardUserMutation) SetOp(op Op) {
  38526. m.op = op
  38527. }
  38528. // Type returns the node type of this mutation (WxCardUser).
  38529. func (m *WxCardUserMutation) Type() string {
  38530. return m.typ
  38531. }
  38532. // Fields returns all fields that were changed during this mutation. Note that in
  38533. // order to get all numeric fields that were incremented/decremented, call
  38534. // AddedFields().
  38535. func (m *WxCardUserMutation) Fields() []string {
  38536. fields := make([]string, 0, 13)
  38537. if m.created_at != nil {
  38538. fields = append(fields, wxcarduser.FieldCreatedAt)
  38539. }
  38540. if m.updated_at != nil {
  38541. fields = append(fields, wxcarduser.FieldUpdatedAt)
  38542. }
  38543. if m.deleted_at != nil {
  38544. fields = append(fields, wxcarduser.FieldDeletedAt)
  38545. }
  38546. if m.wxid != nil {
  38547. fields = append(fields, wxcarduser.FieldWxid)
  38548. }
  38549. if m.account != nil {
  38550. fields = append(fields, wxcarduser.FieldAccount)
  38551. }
  38552. if m.avatar != nil {
  38553. fields = append(fields, wxcarduser.FieldAvatar)
  38554. }
  38555. if m.nickname != nil {
  38556. fields = append(fields, wxcarduser.FieldNickname)
  38557. }
  38558. if m.remark != nil {
  38559. fields = append(fields, wxcarduser.FieldRemark)
  38560. }
  38561. if m.phone != nil {
  38562. fields = append(fields, wxcarduser.FieldPhone)
  38563. }
  38564. if m.open_id != nil {
  38565. fields = append(fields, wxcarduser.FieldOpenID)
  38566. }
  38567. if m.union_id != nil {
  38568. fields = append(fields, wxcarduser.FieldUnionID)
  38569. }
  38570. if m.session_key != nil {
  38571. fields = append(fields, wxcarduser.FieldSessionKey)
  38572. }
  38573. if m.is_vip != nil {
  38574. fields = append(fields, wxcarduser.FieldIsVip)
  38575. }
  38576. return fields
  38577. }
  38578. // Field returns the value of a field with the given name. The second boolean
  38579. // return value indicates that this field was not set, or was not defined in the
  38580. // schema.
  38581. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  38582. switch name {
  38583. case wxcarduser.FieldCreatedAt:
  38584. return m.CreatedAt()
  38585. case wxcarduser.FieldUpdatedAt:
  38586. return m.UpdatedAt()
  38587. case wxcarduser.FieldDeletedAt:
  38588. return m.DeletedAt()
  38589. case wxcarduser.FieldWxid:
  38590. return m.Wxid()
  38591. case wxcarduser.FieldAccount:
  38592. return m.Account()
  38593. case wxcarduser.FieldAvatar:
  38594. return m.Avatar()
  38595. case wxcarduser.FieldNickname:
  38596. return m.Nickname()
  38597. case wxcarduser.FieldRemark:
  38598. return m.Remark()
  38599. case wxcarduser.FieldPhone:
  38600. return m.Phone()
  38601. case wxcarduser.FieldOpenID:
  38602. return m.OpenID()
  38603. case wxcarduser.FieldUnionID:
  38604. return m.UnionID()
  38605. case wxcarduser.FieldSessionKey:
  38606. return m.SessionKey()
  38607. case wxcarduser.FieldIsVip:
  38608. return m.IsVip()
  38609. }
  38610. return nil, false
  38611. }
  38612. // OldField returns the old value of the field from the database. An error is
  38613. // returned if the mutation operation is not UpdateOne, or the query to the
  38614. // database failed.
  38615. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38616. switch name {
  38617. case wxcarduser.FieldCreatedAt:
  38618. return m.OldCreatedAt(ctx)
  38619. case wxcarduser.FieldUpdatedAt:
  38620. return m.OldUpdatedAt(ctx)
  38621. case wxcarduser.FieldDeletedAt:
  38622. return m.OldDeletedAt(ctx)
  38623. case wxcarduser.FieldWxid:
  38624. return m.OldWxid(ctx)
  38625. case wxcarduser.FieldAccount:
  38626. return m.OldAccount(ctx)
  38627. case wxcarduser.FieldAvatar:
  38628. return m.OldAvatar(ctx)
  38629. case wxcarduser.FieldNickname:
  38630. return m.OldNickname(ctx)
  38631. case wxcarduser.FieldRemark:
  38632. return m.OldRemark(ctx)
  38633. case wxcarduser.FieldPhone:
  38634. return m.OldPhone(ctx)
  38635. case wxcarduser.FieldOpenID:
  38636. return m.OldOpenID(ctx)
  38637. case wxcarduser.FieldUnionID:
  38638. return m.OldUnionID(ctx)
  38639. case wxcarduser.FieldSessionKey:
  38640. return m.OldSessionKey(ctx)
  38641. case wxcarduser.FieldIsVip:
  38642. return m.OldIsVip(ctx)
  38643. }
  38644. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  38645. }
  38646. // SetField sets the value of a field with the given name. It returns an error if
  38647. // the field is not defined in the schema, or if the type mismatched the field
  38648. // type.
  38649. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  38650. switch name {
  38651. case wxcarduser.FieldCreatedAt:
  38652. v, ok := value.(time.Time)
  38653. if !ok {
  38654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38655. }
  38656. m.SetCreatedAt(v)
  38657. return nil
  38658. case wxcarduser.FieldUpdatedAt:
  38659. v, ok := value.(time.Time)
  38660. if !ok {
  38661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38662. }
  38663. m.SetUpdatedAt(v)
  38664. return nil
  38665. case wxcarduser.FieldDeletedAt:
  38666. v, ok := value.(time.Time)
  38667. if !ok {
  38668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38669. }
  38670. m.SetDeletedAt(v)
  38671. return nil
  38672. case wxcarduser.FieldWxid:
  38673. v, ok := value.(string)
  38674. if !ok {
  38675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38676. }
  38677. m.SetWxid(v)
  38678. return nil
  38679. case wxcarduser.FieldAccount:
  38680. v, ok := value.(string)
  38681. if !ok {
  38682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38683. }
  38684. m.SetAccount(v)
  38685. return nil
  38686. case wxcarduser.FieldAvatar:
  38687. v, ok := value.(string)
  38688. if !ok {
  38689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38690. }
  38691. m.SetAvatar(v)
  38692. return nil
  38693. case wxcarduser.FieldNickname:
  38694. v, ok := value.(string)
  38695. if !ok {
  38696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38697. }
  38698. m.SetNickname(v)
  38699. return nil
  38700. case wxcarduser.FieldRemark:
  38701. v, ok := value.(string)
  38702. if !ok {
  38703. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38704. }
  38705. m.SetRemark(v)
  38706. return nil
  38707. case wxcarduser.FieldPhone:
  38708. v, ok := value.(string)
  38709. if !ok {
  38710. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38711. }
  38712. m.SetPhone(v)
  38713. return nil
  38714. case wxcarduser.FieldOpenID:
  38715. v, ok := value.(string)
  38716. if !ok {
  38717. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38718. }
  38719. m.SetOpenID(v)
  38720. return nil
  38721. case wxcarduser.FieldUnionID:
  38722. v, ok := value.(string)
  38723. if !ok {
  38724. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38725. }
  38726. m.SetUnionID(v)
  38727. return nil
  38728. case wxcarduser.FieldSessionKey:
  38729. v, ok := value.(string)
  38730. if !ok {
  38731. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38732. }
  38733. m.SetSessionKey(v)
  38734. return nil
  38735. case wxcarduser.FieldIsVip:
  38736. v, ok := value.(int)
  38737. if !ok {
  38738. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38739. }
  38740. m.SetIsVip(v)
  38741. return nil
  38742. }
  38743. return fmt.Errorf("unknown WxCardUser field %s", name)
  38744. }
  38745. // AddedFields returns all numeric fields that were incremented/decremented during
  38746. // this mutation.
  38747. func (m *WxCardUserMutation) AddedFields() []string {
  38748. var fields []string
  38749. if m.addis_vip != nil {
  38750. fields = append(fields, wxcarduser.FieldIsVip)
  38751. }
  38752. return fields
  38753. }
  38754. // AddedField returns the numeric value that was incremented/decremented on a field
  38755. // with the given name. The second boolean return value indicates that this field
  38756. // was not set, or was not defined in the schema.
  38757. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  38758. switch name {
  38759. case wxcarduser.FieldIsVip:
  38760. return m.AddedIsVip()
  38761. }
  38762. return nil, false
  38763. }
  38764. // AddField adds the value to the field with the given name. It returns an error if
  38765. // the field is not defined in the schema, or if the type mismatched the field
  38766. // type.
  38767. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  38768. switch name {
  38769. case wxcarduser.FieldIsVip:
  38770. v, ok := value.(int)
  38771. if !ok {
  38772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38773. }
  38774. m.AddIsVip(v)
  38775. return nil
  38776. }
  38777. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  38778. }
  38779. // ClearedFields returns all nullable fields that were cleared during this
  38780. // mutation.
  38781. func (m *WxCardUserMutation) ClearedFields() []string {
  38782. var fields []string
  38783. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  38784. fields = append(fields, wxcarduser.FieldDeletedAt)
  38785. }
  38786. return fields
  38787. }
  38788. // FieldCleared returns a boolean indicating if a field with the given name was
  38789. // cleared in this mutation.
  38790. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  38791. _, ok := m.clearedFields[name]
  38792. return ok
  38793. }
  38794. // ClearField clears the value of the field with the given name. It returns an
  38795. // error if the field is not defined in the schema.
  38796. func (m *WxCardUserMutation) ClearField(name string) error {
  38797. switch name {
  38798. case wxcarduser.FieldDeletedAt:
  38799. m.ClearDeletedAt()
  38800. return nil
  38801. }
  38802. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  38803. }
  38804. // ResetField resets all changes in the mutation for the field with the given name.
  38805. // It returns an error if the field is not defined in the schema.
  38806. func (m *WxCardUserMutation) ResetField(name string) error {
  38807. switch name {
  38808. case wxcarduser.FieldCreatedAt:
  38809. m.ResetCreatedAt()
  38810. return nil
  38811. case wxcarduser.FieldUpdatedAt:
  38812. m.ResetUpdatedAt()
  38813. return nil
  38814. case wxcarduser.FieldDeletedAt:
  38815. m.ResetDeletedAt()
  38816. return nil
  38817. case wxcarduser.FieldWxid:
  38818. m.ResetWxid()
  38819. return nil
  38820. case wxcarduser.FieldAccount:
  38821. m.ResetAccount()
  38822. return nil
  38823. case wxcarduser.FieldAvatar:
  38824. m.ResetAvatar()
  38825. return nil
  38826. case wxcarduser.FieldNickname:
  38827. m.ResetNickname()
  38828. return nil
  38829. case wxcarduser.FieldRemark:
  38830. m.ResetRemark()
  38831. return nil
  38832. case wxcarduser.FieldPhone:
  38833. m.ResetPhone()
  38834. return nil
  38835. case wxcarduser.FieldOpenID:
  38836. m.ResetOpenID()
  38837. return nil
  38838. case wxcarduser.FieldUnionID:
  38839. m.ResetUnionID()
  38840. return nil
  38841. case wxcarduser.FieldSessionKey:
  38842. m.ResetSessionKey()
  38843. return nil
  38844. case wxcarduser.FieldIsVip:
  38845. m.ResetIsVip()
  38846. return nil
  38847. }
  38848. return fmt.Errorf("unknown WxCardUser field %s", name)
  38849. }
  38850. // AddedEdges returns all edge names that were set/added in this mutation.
  38851. func (m *WxCardUserMutation) AddedEdges() []string {
  38852. edges := make([]string, 0, 0)
  38853. return edges
  38854. }
  38855. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38856. // name in this mutation.
  38857. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  38858. return nil
  38859. }
  38860. // RemovedEdges returns all edge names that were removed in this mutation.
  38861. func (m *WxCardUserMutation) RemovedEdges() []string {
  38862. edges := make([]string, 0, 0)
  38863. return edges
  38864. }
  38865. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38866. // the given name in this mutation.
  38867. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  38868. return nil
  38869. }
  38870. // ClearedEdges returns all edge names that were cleared in this mutation.
  38871. func (m *WxCardUserMutation) ClearedEdges() []string {
  38872. edges := make([]string, 0, 0)
  38873. return edges
  38874. }
  38875. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38876. // was cleared in this mutation.
  38877. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  38878. return false
  38879. }
  38880. // ClearEdge clears the value of the edge with the given name. It returns an error
  38881. // if that edge is not defined in the schema.
  38882. func (m *WxCardUserMutation) ClearEdge(name string) error {
  38883. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  38884. }
  38885. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38886. // It returns an error if the edge is not defined in the schema.
  38887. func (m *WxCardUserMutation) ResetEdge(name string) error {
  38888. return fmt.Errorf("unknown WxCardUser edge %s", name)
  38889. }
  38890. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  38891. type WxCardVisitMutation struct {
  38892. config
  38893. op Op
  38894. typ string
  38895. id *uint64
  38896. created_at *time.Time
  38897. updated_at *time.Time
  38898. deleted_at *time.Time
  38899. user_id *uint64
  38900. adduser_id *int64
  38901. bot_id *uint64
  38902. addbot_id *int64
  38903. bot_type *uint8
  38904. addbot_type *int8
  38905. clearedFields map[string]struct{}
  38906. done bool
  38907. oldValue func(context.Context) (*WxCardVisit, error)
  38908. predicates []predicate.WxCardVisit
  38909. }
  38910. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  38911. // wxcardvisitOption allows management of the mutation configuration using functional options.
  38912. type wxcardvisitOption func(*WxCardVisitMutation)
  38913. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  38914. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  38915. m := &WxCardVisitMutation{
  38916. config: c,
  38917. op: op,
  38918. typ: TypeWxCardVisit,
  38919. clearedFields: make(map[string]struct{}),
  38920. }
  38921. for _, opt := range opts {
  38922. opt(m)
  38923. }
  38924. return m
  38925. }
  38926. // withWxCardVisitID sets the ID field of the mutation.
  38927. func withWxCardVisitID(id uint64) wxcardvisitOption {
  38928. return func(m *WxCardVisitMutation) {
  38929. var (
  38930. err error
  38931. once sync.Once
  38932. value *WxCardVisit
  38933. )
  38934. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  38935. once.Do(func() {
  38936. if m.done {
  38937. err = errors.New("querying old values post mutation is not allowed")
  38938. } else {
  38939. value, err = m.Client().WxCardVisit.Get(ctx, id)
  38940. }
  38941. })
  38942. return value, err
  38943. }
  38944. m.id = &id
  38945. }
  38946. }
  38947. // withWxCardVisit sets the old WxCardVisit of the mutation.
  38948. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  38949. return func(m *WxCardVisitMutation) {
  38950. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  38951. return node, nil
  38952. }
  38953. m.id = &node.ID
  38954. }
  38955. }
  38956. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38957. // executed in a transaction (ent.Tx), a transactional client is returned.
  38958. func (m WxCardVisitMutation) Client() *Client {
  38959. client := &Client{config: m.config}
  38960. client.init()
  38961. return client
  38962. }
  38963. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38964. // it returns an error otherwise.
  38965. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  38966. if _, ok := m.driver.(*txDriver); !ok {
  38967. return nil, errors.New("ent: mutation is not running in a transaction")
  38968. }
  38969. tx := &Tx{config: m.config}
  38970. tx.init()
  38971. return tx, nil
  38972. }
  38973. // SetID sets the value of the id field. Note that this
  38974. // operation is only accepted on creation of WxCardVisit entities.
  38975. func (m *WxCardVisitMutation) SetID(id uint64) {
  38976. m.id = &id
  38977. }
  38978. // ID returns the ID value in the mutation. Note that the ID is only available
  38979. // if it was provided to the builder or after it was returned from the database.
  38980. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  38981. if m.id == nil {
  38982. return
  38983. }
  38984. return *m.id, true
  38985. }
  38986. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38987. // That means, if the mutation is applied within a transaction with an isolation level such
  38988. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38989. // or updated by the mutation.
  38990. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  38991. switch {
  38992. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38993. id, exists := m.ID()
  38994. if exists {
  38995. return []uint64{id}, nil
  38996. }
  38997. fallthrough
  38998. case m.op.Is(OpUpdate | OpDelete):
  38999. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  39000. default:
  39001. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39002. }
  39003. }
  39004. // SetCreatedAt sets the "created_at" field.
  39005. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  39006. m.created_at = &t
  39007. }
  39008. // CreatedAt returns the value of the "created_at" field in the mutation.
  39009. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  39010. v := m.created_at
  39011. if v == nil {
  39012. return
  39013. }
  39014. return *v, true
  39015. }
  39016. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  39017. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  39018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39019. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39020. if !m.op.Is(OpUpdateOne) {
  39021. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39022. }
  39023. if m.id == nil || m.oldValue == nil {
  39024. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39025. }
  39026. oldValue, err := m.oldValue(ctx)
  39027. if err != nil {
  39028. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39029. }
  39030. return oldValue.CreatedAt, nil
  39031. }
  39032. // ResetCreatedAt resets all changes to the "created_at" field.
  39033. func (m *WxCardVisitMutation) ResetCreatedAt() {
  39034. m.created_at = nil
  39035. }
  39036. // SetUpdatedAt sets the "updated_at" field.
  39037. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  39038. m.updated_at = &t
  39039. }
  39040. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39041. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  39042. v := m.updated_at
  39043. if v == nil {
  39044. return
  39045. }
  39046. return *v, true
  39047. }
  39048. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  39049. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  39050. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39051. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39052. if !m.op.Is(OpUpdateOne) {
  39053. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39054. }
  39055. if m.id == nil || m.oldValue == nil {
  39056. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39057. }
  39058. oldValue, err := m.oldValue(ctx)
  39059. if err != nil {
  39060. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39061. }
  39062. return oldValue.UpdatedAt, nil
  39063. }
  39064. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39065. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  39066. m.updated_at = nil
  39067. }
  39068. // SetDeletedAt sets the "deleted_at" field.
  39069. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  39070. m.deleted_at = &t
  39071. }
  39072. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39073. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  39074. v := m.deleted_at
  39075. if v == nil {
  39076. return
  39077. }
  39078. return *v, true
  39079. }
  39080. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  39081. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  39082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39083. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39084. if !m.op.Is(OpUpdateOne) {
  39085. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39086. }
  39087. if m.id == nil || m.oldValue == nil {
  39088. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39089. }
  39090. oldValue, err := m.oldValue(ctx)
  39091. if err != nil {
  39092. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39093. }
  39094. return oldValue.DeletedAt, nil
  39095. }
  39096. // ClearDeletedAt clears the value of the "deleted_at" field.
  39097. func (m *WxCardVisitMutation) ClearDeletedAt() {
  39098. m.deleted_at = nil
  39099. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  39100. }
  39101. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39102. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  39103. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  39104. return ok
  39105. }
  39106. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39107. func (m *WxCardVisitMutation) ResetDeletedAt() {
  39108. m.deleted_at = nil
  39109. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  39110. }
  39111. // SetUserID sets the "user_id" field.
  39112. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  39113. m.user_id = &u
  39114. m.adduser_id = nil
  39115. }
  39116. // UserID returns the value of the "user_id" field in the mutation.
  39117. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  39118. v := m.user_id
  39119. if v == nil {
  39120. return
  39121. }
  39122. return *v, true
  39123. }
  39124. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  39125. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  39126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39127. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  39128. if !m.op.Is(OpUpdateOne) {
  39129. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  39130. }
  39131. if m.id == nil || m.oldValue == nil {
  39132. return v, errors.New("OldUserID requires an ID field in the mutation")
  39133. }
  39134. oldValue, err := m.oldValue(ctx)
  39135. if err != nil {
  39136. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  39137. }
  39138. return oldValue.UserID, nil
  39139. }
  39140. // AddUserID adds u to the "user_id" field.
  39141. func (m *WxCardVisitMutation) AddUserID(u int64) {
  39142. if m.adduser_id != nil {
  39143. *m.adduser_id += u
  39144. } else {
  39145. m.adduser_id = &u
  39146. }
  39147. }
  39148. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  39149. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  39150. v := m.adduser_id
  39151. if v == nil {
  39152. return
  39153. }
  39154. return *v, true
  39155. }
  39156. // ClearUserID clears the value of the "user_id" field.
  39157. func (m *WxCardVisitMutation) ClearUserID() {
  39158. m.user_id = nil
  39159. m.adduser_id = nil
  39160. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  39161. }
  39162. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  39163. func (m *WxCardVisitMutation) UserIDCleared() bool {
  39164. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  39165. return ok
  39166. }
  39167. // ResetUserID resets all changes to the "user_id" field.
  39168. func (m *WxCardVisitMutation) ResetUserID() {
  39169. m.user_id = nil
  39170. m.adduser_id = nil
  39171. delete(m.clearedFields, wxcardvisit.FieldUserID)
  39172. }
  39173. // SetBotID sets the "bot_id" field.
  39174. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  39175. m.bot_id = &u
  39176. m.addbot_id = nil
  39177. }
  39178. // BotID returns the value of the "bot_id" field in the mutation.
  39179. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  39180. v := m.bot_id
  39181. if v == nil {
  39182. return
  39183. }
  39184. return *v, true
  39185. }
  39186. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  39187. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  39188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39189. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  39190. if !m.op.Is(OpUpdateOne) {
  39191. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  39192. }
  39193. if m.id == nil || m.oldValue == nil {
  39194. return v, errors.New("OldBotID requires an ID field in the mutation")
  39195. }
  39196. oldValue, err := m.oldValue(ctx)
  39197. if err != nil {
  39198. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  39199. }
  39200. return oldValue.BotID, nil
  39201. }
  39202. // AddBotID adds u to the "bot_id" field.
  39203. func (m *WxCardVisitMutation) AddBotID(u int64) {
  39204. if m.addbot_id != nil {
  39205. *m.addbot_id += u
  39206. } else {
  39207. m.addbot_id = &u
  39208. }
  39209. }
  39210. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  39211. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  39212. v := m.addbot_id
  39213. if v == nil {
  39214. return
  39215. }
  39216. return *v, true
  39217. }
  39218. // ResetBotID resets all changes to the "bot_id" field.
  39219. func (m *WxCardVisitMutation) ResetBotID() {
  39220. m.bot_id = nil
  39221. m.addbot_id = nil
  39222. }
  39223. // SetBotType sets the "bot_type" field.
  39224. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  39225. m.bot_type = &u
  39226. m.addbot_type = nil
  39227. }
  39228. // BotType returns the value of the "bot_type" field in the mutation.
  39229. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  39230. v := m.bot_type
  39231. if v == nil {
  39232. return
  39233. }
  39234. return *v, true
  39235. }
  39236. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  39237. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  39238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39239. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  39240. if !m.op.Is(OpUpdateOne) {
  39241. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  39242. }
  39243. if m.id == nil || m.oldValue == nil {
  39244. return v, errors.New("OldBotType requires an ID field in the mutation")
  39245. }
  39246. oldValue, err := m.oldValue(ctx)
  39247. if err != nil {
  39248. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  39249. }
  39250. return oldValue.BotType, nil
  39251. }
  39252. // AddBotType adds u to the "bot_type" field.
  39253. func (m *WxCardVisitMutation) AddBotType(u int8) {
  39254. if m.addbot_type != nil {
  39255. *m.addbot_type += u
  39256. } else {
  39257. m.addbot_type = &u
  39258. }
  39259. }
  39260. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  39261. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  39262. v := m.addbot_type
  39263. if v == nil {
  39264. return
  39265. }
  39266. return *v, true
  39267. }
  39268. // ResetBotType resets all changes to the "bot_type" field.
  39269. func (m *WxCardVisitMutation) ResetBotType() {
  39270. m.bot_type = nil
  39271. m.addbot_type = nil
  39272. }
  39273. // Where appends a list predicates to the WxCardVisitMutation builder.
  39274. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  39275. m.predicates = append(m.predicates, ps...)
  39276. }
  39277. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  39278. // users can use type-assertion to append predicates that do not depend on any generated package.
  39279. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  39280. p := make([]predicate.WxCardVisit, len(ps))
  39281. for i := range ps {
  39282. p[i] = ps[i]
  39283. }
  39284. m.Where(p...)
  39285. }
  39286. // Op returns the operation name.
  39287. func (m *WxCardVisitMutation) Op() Op {
  39288. return m.op
  39289. }
  39290. // SetOp allows setting the mutation operation.
  39291. func (m *WxCardVisitMutation) SetOp(op Op) {
  39292. m.op = op
  39293. }
  39294. // Type returns the node type of this mutation (WxCardVisit).
  39295. func (m *WxCardVisitMutation) Type() string {
  39296. return m.typ
  39297. }
  39298. // Fields returns all fields that were changed during this mutation. Note that in
  39299. // order to get all numeric fields that were incremented/decremented, call
  39300. // AddedFields().
  39301. func (m *WxCardVisitMutation) Fields() []string {
  39302. fields := make([]string, 0, 6)
  39303. if m.created_at != nil {
  39304. fields = append(fields, wxcardvisit.FieldCreatedAt)
  39305. }
  39306. if m.updated_at != nil {
  39307. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  39308. }
  39309. if m.deleted_at != nil {
  39310. fields = append(fields, wxcardvisit.FieldDeletedAt)
  39311. }
  39312. if m.user_id != nil {
  39313. fields = append(fields, wxcardvisit.FieldUserID)
  39314. }
  39315. if m.bot_id != nil {
  39316. fields = append(fields, wxcardvisit.FieldBotID)
  39317. }
  39318. if m.bot_type != nil {
  39319. fields = append(fields, wxcardvisit.FieldBotType)
  39320. }
  39321. return fields
  39322. }
  39323. // Field returns the value of a field with the given name. The second boolean
  39324. // return value indicates that this field was not set, or was not defined in the
  39325. // schema.
  39326. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  39327. switch name {
  39328. case wxcardvisit.FieldCreatedAt:
  39329. return m.CreatedAt()
  39330. case wxcardvisit.FieldUpdatedAt:
  39331. return m.UpdatedAt()
  39332. case wxcardvisit.FieldDeletedAt:
  39333. return m.DeletedAt()
  39334. case wxcardvisit.FieldUserID:
  39335. return m.UserID()
  39336. case wxcardvisit.FieldBotID:
  39337. return m.BotID()
  39338. case wxcardvisit.FieldBotType:
  39339. return m.BotType()
  39340. }
  39341. return nil, false
  39342. }
  39343. // OldField returns the old value of the field from the database. An error is
  39344. // returned if the mutation operation is not UpdateOne, or the query to the
  39345. // database failed.
  39346. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39347. switch name {
  39348. case wxcardvisit.FieldCreatedAt:
  39349. return m.OldCreatedAt(ctx)
  39350. case wxcardvisit.FieldUpdatedAt:
  39351. return m.OldUpdatedAt(ctx)
  39352. case wxcardvisit.FieldDeletedAt:
  39353. return m.OldDeletedAt(ctx)
  39354. case wxcardvisit.FieldUserID:
  39355. return m.OldUserID(ctx)
  39356. case wxcardvisit.FieldBotID:
  39357. return m.OldBotID(ctx)
  39358. case wxcardvisit.FieldBotType:
  39359. return m.OldBotType(ctx)
  39360. }
  39361. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  39362. }
  39363. // SetField sets the value of a field with the given name. It returns an error if
  39364. // the field is not defined in the schema, or if the type mismatched the field
  39365. // type.
  39366. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  39367. switch name {
  39368. case wxcardvisit.FieldCreatedAt:
  39369. v, ok := value.(time.Time)
  39370. if !ok {
  39371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39372. }
  39373. m.SetCreatedAt(v)
  39374. return nil
  39375. case wxcardvisit.FieldUpdatedAt:
  39376. v, ok := value.(time.Time)
  39377. if !ok {
  39378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39379. }
  39380. m.SetUpdatedAt(v)
  39381. return nil
  39382. case wxcardvisit.FieldDeletedAt:
  39383. v, ok := value.(time.Time)
  39384. if !ok {
  39385. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39386. }
  39387. m.SetDeletedAt(v)
  39388. return nil
  39389. case wxcardvisit.FieldUserID:
  39390. v, ok := value.(uint64)
  39391. if !ok {
  39392. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39393. }
  39394. m.SetUserID(v)
  39395. return nil
  39396. case wxcardvisit.FieldBotID:
  39397. v, ok := value.(uint64)
  39398. if !ok {
  39399. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39400. }
  39401. m.SetBotID(v)
  39402. return nil
  39403. case wxcardvisit.FieldBotType:
  39404. v, ok := value.(uint8)
  39405. if !ok {
  39406. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39407. }
  39408. m.SetBotType(v)
  39409. return nil
  39410. }
  39411. return fmt.Errorf("unknown WxCardVisit field %s", name)
  39412. }
  39413. // AddedFields returns all numeric fields that were incremented/decremented during
  39414. // this mutation.
  39415. func (m *WxCardVisitMutation) AddedFields() []string {
  39416. var fields []string
  39417. if m.adduser_id != nil {
  39418. fields = append(fields, wxcardvisit.FieldUserID)
  39419. }
  39420. if m.addbot_id != nil {
  39421. fields = append(fields, wxcardvisit.FieldBotID)
  39422. }
  39423. if m.addbot_type != nil {
  39424. fields = append(fields, wxcardvisit.FieldBotType)
  39425. }
  39426. return fields
  39427. }
  39428. // AddedField returns the numeric value that was incremented/decremented on a field
  39429. // with the given name. The second boolean return value indicates that this field
  39430. // was not set, or was not defined in the schema.
  39431. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  39432. switch name {
  39433. case wxcardvisit.FieldUserID:
  39434. return m.AddedUserID()
  39435. case wxcardvisit.FieldBotID:
  39436. return m.AddedBotID()
  39437. case wxcardvisit.FieldBotType:
  39438. return m.AddedBotType()
  39439. }
  39440. return nil, false
  39441. }
  39442. // AddField adds the value to the field with the given name. It returns an error if
  39443. // the field is not defined in the schema, or if the type mismatched the field
  39444. // type.
  39445. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  39446. switch name {
  39447. case wxcardvisit.FieldUserID:
  39448. v, ok := value.(int64)
  39449. if !ok {
  39450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39451. }
  39452. m.AddUserID(v)
  39453. return nil
  39454. case wxcardvisit.FieldBotID:
  39455. v, ok := value.(int64)
  39456. if !ok {
  39457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39458. }
  39459. m.AddBotID(v)
  39460. return nil
  39461. case wxcardvisit.FieldBotType:
  39462. v, ok := value.(int8)
  39463. if !ok {
  39464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39465. }
  39466. m.AddBotType(v)
  39467. return nil
  39468. }
  39469. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  39470. }
  39471. // ClearedFields returns all nullable fields that were cleared during this
  39472. // mutation.
  39473. func (m *WxCardVisitMutation) ClearedFields() []string {
  39474. var fields []string
  39475. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  39476. fields = append(fields, wxcardvisit.FieldDeletedAt)
  39477. }
  39478. if m.FieldCleared(wxcardvisit.FieldUserID) {
  39479. fields = append(fields, wxcardvisit.FieldUserID)
  39480. }
  39481. return fields
  39482. }
  39483. // FieldCleared returns a boolean indicating if a field with the given name was
  39484. // cleared in this mutation.
  39485. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  39486. _, ok := m.clearedFields[name]
  39487. return ok
  39488. }
  39489. // ClearField clears the value of the field with the given name. It returns an
  39490. // error if the field is not defined in the schema.
  39491. func (m *WxCardVisitMutation) ClearField(name string) error {
  39492. switch name {
  39493. case wxcardvisit.FieldDeletedAt:
  39494. m.ClearDeletedAt()
  39495. return nil
  39496. case wxcardvisit.FieldUserID:
  39497. m.ClearUserID()
  39498. return nil
  39499. }
  39500. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  39501. }
  39502. // ResetField resets all changes in the mutation for the field with the given name.
  39503. // It returns an error if the field is not defined in the schema.
  39504. func (m *WxCardVisitMutation) ResetField(name string) error {
  39505. switch name {
  39506. case wxcardvisit.FieldCreatedAt:
  39507. m.ResetCreatedAt()
  39508. return nil
  39509. case wxcardvisit.FieldUpdatedAt:
  39510. m.ResetUpdatedAt()
  39511. return nil
  39512. case wxcardvisit.FieldDeletedAt:
  39513. m.ResetDeletedAt()
  39514. return nil
  39515. case wxcardvisit.FieldUserID:
  39516. m.ResetUserID()
  39517. return nil
  39518. case wxcardvisit.FieldBotID:
  39519. m.ResetBotID()
  39520. return nil
  39521. case wxcardvisit.FieldBotType:
  39522. m.ResetBotType()
  39523. return nil
  39524. }
  39525. return fmt.Errorf("unknown WxCardVisit field %s", name)
  39526. }
  39527. // AddedEdges returns all edge names that were set/added in this mutation.
  39528. func (m *WxCardVisitMutation) AddedEdges() []string {
  39529. edges := make([]string, 0, 0)
  39530. return edges
  39531. }
  39532. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  39533. // name in this mutation.
  39534. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  39535. return nil
  39536. }
  39537. // RemovedEdges returns all edge names that were removed in this mutation.
  39538. func (m *WxCardVisitMutation) RemovedEdges() []string {
  39539. edges := make([]string, 0, 0)
  39540. return edges
  39541. }
  39542. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39543. // the given name in this mutation.
  39544. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  39545. return nil
  39546. }
  39547. // ClearedEdges returns all edge names that were cleared in this mutation.
  39548. func (m *WxCardVisitMutation) ClearedEdges() []string {
  39549. edges := make([]string, 0, 0)
  39550. return edges
  39551. }
  39552. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39553. // was cleared in this mutation.
  39554. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  39555. return false
  39556. }
  39557. // ClearEdge clears the value of the edge with the given name. It returns an error
  39558. // if that edge is not defined in the schema.
  39559. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  39560. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  39561. }
  39562. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39563. // It returns an error if the edge is not defined in the schema.
  39564. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  39565. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  39566. }