mutation.go 1.3 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/agentbase"
  11. "wechat-api/ent/aliyunavatar"
  12. "wechat-api/ent/allocagent"
  13. "wechat-api/ent/batchmsg"
  14. "wechat-api/ent/category"
  15. "wechat-api/ent/chatrecords"
  16. "wechat-api/ent/chatsession"
  17. "wechat-api/ent/contact"
  18. "wechat-api/ent/creditbalance"
  19. "wechat-api/ent/creditusage"
  20. "wechat-api/ent/custom_types"
  21. "wechat-api/ent/employee"
  22. "wechat-api/ent/employeeconfig"
  23. "wechat-api/ent/label"
  24. "wechat-api/ent/labelrelationship"
  25. "wechat-api/ent/labeltagging"
  26. "wechat-api/ent/message"
  27. "wechat-api/ent/messagerecords"
  28. "wechat-api/ent/msg"
  29. "wechat-api/ent/payrecharge"
  30. "wechat-api/ent/predicate"
  31. "wechat-api/ent/server"
  32. "wechat-api/ent/sopnode"
  33. "wechat-api/ent/sopstage"
  34. "wechat-api/ent/soptask"
  35. "wechat-api/ent/token"
  36. "wechat-api/ent/tutorial"
  37. "wechat-api/ent/usagedetail"
  38. "wechat-api/ent/usagestatisticday"
  39. "wechat-api/ent/usagestatistichour"
  40. "wechat-api/ent/usagestatisticmonth"
  41. "wechat-api/ent/usagetotal"
  42. "wechat-api/ent/whatsapp"
  43. "wechat-api/ent/workexperience"
  44. "wechat-api/ent/wpchatroom"
  45. "wechat-api/ent/wpchatroommember"
  46. "wechat-api/ent/wx"
  47. "wechat-api/ent/wxcard"
  48. "wechat-api/ent/wxcarduser"
  49. "wechat-api/ent/wxcardvisit"
  50. "entgo.io/ent"
  51. "entgo.io/ent/dialect/sql"
  52. )
  53. const (
  54. // Operation types.
  55. OpCreate = ent.OpCreate
  56. OpDelete = ent.OpDelete
  57. OpDeleteOne = ent.OpDeleteOne
  58. OpUpdate = ent.OpUpdate
  59. OpUpdateOne = ent.OpUpdateOne
  60. // Node types.
  61. TypeAgent = "Agent"
  62. TypeAgentBase = "AgentBase"
  63. TypeAliyunAvatar = "AliyunAvatar"
  64. TypeAllocAgent = "AllocAgent"
  65. TypeBatchMsg = "BatchMsg"
  66. TypeCategory = "Category"
  67. TypeChatRecords = "ChatRecords"
  68. TypeChatSession = "ChatSession"
  69. TypeContact = "Contact"
  70. TypeCreditBalance = "CreditBalance"
  71. TypeCreditUsage = "CreditUsage"
  72. TypeEmployee = "Employee"
  73. TypeEmployeeConfig = "EmployeeConfig"
  74. TypeLabel = "Label"
  75. TypeLabelRelationship = "LabelRelationship"
  76. TypeLabelTagging = "LabelTagging"
  77. TypeMessage = "Message"
  78. TypeMessageRecords = "MessageRecords"
  79. TypeMsg = "Msg"
  80. TypePayRecharge = "PayRecharge"
  81. TypeServer = "Server"
  82. TypeSopNode = "SopNode"
  83. TypeSopStage = "SopStage"
  84. TypeSopTask = "SopTask"
  85. TypeToken = "Token"
  86. TypeTutorial = "Tutorial"
  87. TypeUsageDetail = "UsageDetail"
  88. TypeUsageStatisticDay = "UsageStatisticDay"
  89. TypeUsageStatisticHour = "UsageStatisticHour"
  90. TypeUsageStatisticMonth = "UsageStatisticMonth"
  91. TypeUsageTotal = "UsageTotal"
  92. TypeWhatsapp = "Whatsapp"
  93. TypeWorkExperience = "WorkExperience"
  94. TypeWpChatroom = "WpChatroom"
  95. TypeWpChatroomMember = "WpChatroomMember"
  96. TypeWx = "Wx"
  97. TypeWxCard = "WxCard"
  98. TypeWxCardUser = "WxCardUser"
  99. TypeWxCardVisit = "WxCardVisit"
  100. )
  101. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  102. type AgentMutation struct {
  103. config
  104. op Op
  105. typ string
  106. id *uint64
  107. created_at *time.Time
  108. updated_at *time.Time
  109. deleted_at *time.Time
  110. name *string
  111. role *string
  112. status *int
  113. addstatus *int
  114. background *string
  115. examples *string
  116. organization_id *uint64
  117. addorganization_id *int64
  118. dataset_id *string
  119. collection_id *string
  120. clearedFields map[string]struct{}
  121. wx_agent map[uint64]struct{}
  122. removedwx_agent map[uint64]struct{}
  123. clearedwx_agent bool
  124. token_agent map[uint64]struct{}
  125. removedtoken_agent map[uint64]struct{}
  126. clearedtoken_agent bool
  127. done bool
  128. oldValue func(context.Context) (*Agent, error)
  129. predicates []predicate.Agent
  130. }
  131. var _ ent.Mutation = (*AgentMutation)(nil)
  132. // agentOption allows management of the mutation configuration using functional options.
  133. type agentOption func(*AgentMutation)
  134. // newAgentMutation creates new mutation for the Agent entity.
  135. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  136. m := &AgentMutation{
  137. config: c,
  138. op: op,
  139. typ: TypeAgent,
  140. clearedFields: make(map[string]struct{}),
  141. }
  142. for _, opt := range opts {
  143. opt(m)
  144. }
  145. return m
  146. }
  147. // withAgentID sets the ID field of the mutation.
  148. func withAgentID(id uint64) agentOption {
  149. return func(m *AgentMutation) {
  150. var (
  151. err error
  152. once sync.Once
  153. value *Agent
  154. )
  155. m.oldValue = func(ctx context.Context) (*Agent, error) {
  156. once.Do(func() {
  157. if m.done {
  158. err = errors.New("querying old values post mutation is not allowed")
  159. } else {
  160. value, err = m.Client().Agent.Get(ctx, id)
  161. }
  162. })
  163. return value, err
  164. }
  165. m.id = &id
  166. }
  167. }
  168. // withAgent sets the old Agent of the mutation.
  169. func withAgent(node *Agent) agentOption {
  170. return func(m *AgentMutation) {
  171. m.oldValue = func(context.Context) (*Agent, error) {
  172. return node, nil
  173. }
  174. m.id = &node.ID
  175. }
  176. }
  177. // Client returns a new `ent.Client` from the mutation. If the mutation was
  178. // executed in a transaction (ent.Tx), a transactional client is returned.
  179. func (m AgentMutation) Client() *Client {
  180. client := &Client{config: m.config}
  181. client.init()
  182. return client
  183. }
  184. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  185. // it returns an error otherwise.
  186. func (m AgentMutation) Tx() (*Tx, error) {
  187. if _, ok := m.driver.(*txDriver); !ok {
  188. return nil, errors.New("ent: mutation is not running in a transaction")
  189. }
  190. tx := &Tx{config: m.config}
  191. tx.init()
  192. return tx, nil
  193. }
  194. // SetID sets the value of the id field. Note that this
  195. // operation is only accepted on creation of Agent entities.
  196. func (m *AgentMutation) SetID(id uint64) {
  197. m.id = &id
  198. }
  199. // ID returns the ID value in the mutation. Note that the ID is only available
  200. // if it was provided to the builder or after it was returned from the database.
  201. func (m *AgentMutation) ID() (id uint64, exists bool) {
  202. if m.id == nil {
  203. return
  204. }
  205. return *m.id, true
  206. }
  207. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  208. // That means, if the mutation is applied within a transaction with an isolation level such
  209. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  210. // or updated by the mutation.
  211. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  212. switch {
  213. case m.op.Is(OpUpdateOne | OpDeleteOne):
  214. id, exists := m.ID()
  215. if exists {
  216. return []uint64{id}, nil
  217. }
  218. fallthrough
  219. case m.op.Is(OpUpdate | OpDelete):
  220. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  221. default:
  222. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  223. }
  224. }
  225. // SetCreatedAt sets the "created_at" field.
  226. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  227. m.created_at = &t
  228. }
  229. // CreatedAt returns the value of the "created_at" field in the mutation.
  230. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  231. v := m.created_at
  232. if v == nil {
  233. return
  234. }
  235. return *v, true
  236. }
  237. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  238. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  240. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  241. if !m.op.Is(OpUpdateOne) {
  242. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  243. }
  244. if m.id == nil || m.oldValue == nil {
  245. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  246. }
  247. oldValue, err := m.oldValue(ctx)
  248. if err != nil {
  249. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  250. }
  251. return oldValue.CreatedAt, nil
  252. }
  253. // ResetCreatedAt resets all changes to the "created_at" field.
  254. func (m *AgentMutation) ResetCreatedAt() {
  255. m.created_at = nil
  256. }
  257. // SetUpdatedAt sets the "updated_at" field.
  258. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  259. m.updated_at = &t
  260. }
  261. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  262. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  263. v := m.updated_at
  264. if v == nil {
  265. return
  266. }
  267. return *v, true
  268. }
  269. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  270. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  272. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  273. if !m.op.Is(OpUpdateOne) {
  274. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  275. }
  276. if m.id == nil || m.oldValue == nil {
  277. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  278. }
  279. oldValue, err := m.oldValue(ctx)
  280. if err != nil {
  281. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  282. }
  283. return oldValue.UpdatedAt, nil
  284. }
  285. // ResetUpdatedAt resets all changes to the "updated_at" field.
  286. func (m *AgentMutation) ResetUpdatedAt() {
  287. m.updated_at = nil
  288. }
  289. // SetDeletedAt sets the "deleted_at" field.
  290. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  291. m.deleted_at = &t
  292. }
  293. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  294. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  295. v := m.deleted_at
  296. if v == nil {
  297. return
  298. }
  299. return *v, true
  300. }
  301. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  302. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  304. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  305. if !m.op.Is(OpUpdateOne) {
  306. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  307. }
  308. if m.id == nil || m.oldValue == nil {
  309. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  310. }
  311. oldValue, err := m.oldValue(ctx)
  312. if err != nil {
  313. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  314. }
  315. return oldValue.DeletedAt, nil
  316. }
  317. // ClearDeletedAt clears the value of the "deleted_at" field.
  318. func (m *AgentMutation) ClearDeletedAt() {
  319. m.deleted_at = nil
  320. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  321. }
  322. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  323. func (m *AgentMutation) DeletedAtCleared() bool {
  324. _, ok := m.clearedFields[agent.FieldDeletedAt]
  325. return ok
  326. }
  327. // ResetDeletedAt resets all changes to the "deleted_at" field.
  328. func (m *AgentMutation) ResetDeletedAt() {
  329. m.deleted_at = nil
  330. delete(m.clearedFields, agent.FieldDeletedAt)
  331. }
  332. // SetName sets the "name" field.
  333. func (m *AgentMutation) SetName(s string) {
  334. m.name = &s
  335. }
  336. // Name returns the value of the "name" field in the mutation.
  337. func (m *AgentMutation) Name() (r string, exists bool) {
  338. v := m.name
  339. if v == nil {
  340. return
  341. }
  342. return *v, true
  343. }
  344. // OldName returns the old "name" field's value of the Agent entity.
  345. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  346. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  347. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  348. if !m.op.Is(OpUpdateOne) {
  349. return v, errors.New("OldName is only allowed on UpdateOne operations")
  350. }
  351. if m.id == nil || m.oldValue == nil {
  352. return v, errors.New("OldName requires an ID field in the mutation")
  353. }
  354. oldValue, err := m.oldValue(ctx)
  355. if err != nil {
  356. return v, fmt.Errorf("querying old value for OldName: %w", err)
  357. }
  358. return oldValue.Name, nil
  359. }
  360. // ResetName resets all changes to the "name" field.
  361. func (m *AgentMutation) ResetName() {
  362. m.name = nil
  363. }
  364. // SetRole sets the "role" field.
  365. func (m *AgentMutation) SetRole(s string) {
  366. m.role = &s
  367. }
  368. // Role returns the value of the "role" field in the mutation.
  369. func (m *AgentMutation) Role() (r string, exists bool) {
  370. v := m.role
  371. if v == nil {
  372. return
  373. }
  374. return *v, true
  375. }
  376. // OldRole returns the old "role" field's value of the Agent entity.
  377. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  379. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  380. if !m.op.Is(OpUpdateOne) {
  381. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  382. }
  383. if m.id == nil || m.oldValue == nil {
  384. return v, errors.New("OldRole requires an ID field in the mutation")
  385. }
  386. oldValue, err := m.oldValue(ctx)
  387. if err != nil {
  388. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  389. }
  390. return oldValue.Role, nil
  391. }
  392. // ResetRole resets all changes to the "role" field.
  393. func (m *AgentMutation) ResetRole() {
  394. m.role = nil
  395. }
  396. // SetStatus sets the "status" field.
  397. func (m *AgentMutation) SetStatus(i int) {
  398. m.status = &i
  399. m.addstatus = nil
  400. }
  401. // Status returns the value of the "status" field in the mutation.
  402. func (m *AgentMutation) Status() (r int, exists bool) {
  403. v := m.status
  404. if v == nil {
  405. return
  406. }
  407. return *v, true
  408. }
  409. // OldStatus returns the old "status" field's value of the Agent entity.
  410. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  412. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  413. if !m.op.Is(OpUpdateOne) {
  414. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  415. }
  416. if m.id == nil || m.oldValue == nil {
  417. return v, errors.New("OldStatus requires an ID field in the mutation")
  418. }
  419. oldValue, err := m.oldValue(ctx)
  420. if err != nil {
  421. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  422. }
  423. return oldValue.Status, nil
  424. }
  425. // AddStatus adds i to the "status" field.
  426. func (m *AgentMutation) AddStatus(i int) {
  427. if m.addstatus != nil {
  428. *m.addstatus += i
  429. } else {
  430. m.addstatus = &i
  431. }
  432. }
  433. // AddedStatus returns the value that was added to the "status" field in this mutation.
  434. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  435. v := m.addstatus
  436. if v == nil {
  437. return
  438. }
  439. return *v, true
  440. }
  441. // ClearStatus clears the value of the "status" field.
  442. func (m *AgentMutation) ClearStatus() {
  443. m.status = nil
  444. m.addstatus = nil
  445. m.clearedFields[agent.FieldStatus] = struct{}{}
  446. }
  447. // StatusCleared returns if the "status" field was cleared in this mutation.
  448. func (m *AgentMutation) StatusCleared() bool {
  449. _, ok := m.clearedFields[agent.FieldStatus]
  450. return ok
  451. }
  452. // ResetStatus resets all changes to the "status" field.
  453. func (m *AgentMutation) ResetStatus() {
  454. m.status = nil
  455. m.addstatus = nil
  456. delete(m.clearedFields, agent.FieldStatus)
  457. }
  458. // SetBackground sets the "background" field.
  459. func (m *AgentMutation) SetBackground(s string) {
  460. m.background = &s
  461. }
  462. // Background returns the value of the "background" field in the mutation.
  463. func (m *AgentMutation) Background() (r string, exists bool) {
  464. v := m.background
  465. if v == nil {
  466. return
  467. }
  468. return *v, true
  469. }
  470. // OldBackground returns the old "background" field's value of the Agent entity.
  471. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  473. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  474. if !m.op.Is(OpUpdateOne) {
  475. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  476. }
  477. if m.id == nil || m.oldValue == nil {
  478. return v, errors.New("OldBackground requires an ID field in the mutation")
  479. }
  480. oldValue, err := m.oldValue(ctx)
  481. if err != nil {
  482. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  483. }
  484. return oldValue.Background, nil
  485. }
  486. // ClearBackground clears the value of the "background" field.
  487. func (m *AgentMutation) ClearBackground() {
  488. m.background = nil
  489. m.clearedFields[agent.FieldBackground] = struct{}{}
  490. }
  491. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  492. func (m *AgentMutation) BackgroundCleared() bool {
  493. _, ok := m.clearedFields[agent.FieldBackground]
  494. return ok
  495. }
  496. // ResetBackground resets all changes to the "background" field.
  497. func (m *AgentMutation) ResetBackground() {
  498. m.background = nil
  499. delete(m.clearedFields, agent.FieldBackground)
  500. }
  501. // SetExamples sets the "examples" field.
  502. func (m *AgentMutation) SetExamples(s string) {
  503. m.examples = &s
  504. }
  505. // Examples returns the value of the "examples" field in the mutation.
  506. func (m *AgentMutation) Examples() (r string, exists bool) {
  507. v := m.examples
  508. if v == nil {
  509. return
  510. }
  511. return *v, true
  512. }
  513. // OldExamples returns the old "examples" field's value of the Agent entity.
  514. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  515. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  516. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  517. if !m.op.Is(OpUpdateOne) {
  518. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  519. }
  520. if m.id == nil || m.oldValue == nil {
  521. return v, errors.New("OldExamples requires an ID field in the mutation")
  522. }
  523. oldValue, err := m.oldValue(ctx)
  524. if err != nil {
  525. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  526. }
  527. return oldValue.Examples, nil
  528. }
  529. // ClearExamples clears the value of the "examples" field.
  530. func (m *AgentMutation) ClearExamples() {
  531. m.examples = nil
  532. m.clearedFields[agent.FieldExamples] = struct{}{}
  533. }
  534. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  535. func (m *AgentMutation) ExamplesCleared() bool {
  536. _, ok := m.clearedFields[agent.FieldExamples]
  537. return ok
  538. }
  539. // ResetExamples resets all changes to the "examples" field.
  540. func (m *AgentMutation) ResetExamples() {
  541. m.examples = nil
  542. delete(m.clearedFields, agent.FieldExamples)
  543. }
  544. // SetOrganizationID sets the "organization_id" field.
  545. func (m *AgentMutation) SetOrganizationID(u uint64) {
  546. m.organization_id = &u
  547. m.addorganization_id = nil
  548. }
  549. // OrganizationID returns the value of the "organization_id" field in the mutation.
  550. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  551. v := m.organization_id
  552. if v == nil {
  553. return
  554. }
  555. return *v, true
  556. }
  557. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  558. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  560. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  561. if !m.op.Is(OpUpdateOne) {
  562. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  563. }
  564. if m.id == nil || m.oldValue == nil {
  565. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  566. }
  567. oldValue, err := m.oldValue(ctx)
  568. if err != nil {
  569. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  570. }
  571. return oldValue.OrganizationID, nil
  572. }
  573. // AddOrganizationID adds u to the "organization_id" field.
  574. func (m *AgentMutation) AddOrganizationID(u int64) {
  575. if m.addorganization_id != nil {
  576. *m.addorganization_id += u
  577. } else {
  578. m.addorganization_id = &u
  579. }
  580. }
  581. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  582. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  583. v := m.addorganization_id
  584. if v == nil {
  585. return
  586. }
  587. return *v, true
  588. }
  589. // ResetOrganizationID resets all changes to the "organization_id" field.
  590. func (m *AgentMutation) ResetOrganizationID() {
  591. m.organization_id = nil
  592. m.addorganization_id = nil
  593. }
  594. // SetDatasetID sets the "dataset_id" field.
  595. func (m *AgentMutation) SetDatasetID(s string) {
  596. m.dataset_id = &s
  597. }
  598. // DatasetID returns the value of the "dataset_id" field in the mutation.
  599. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  600. v := m.dataset_id
  601. if v == nil {
  602. return
  603. }
  604. return *v, true
  605. }
  606. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  607. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  609. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  610. if !m.op.Is(OpUpdateOne) {
  611. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  612. }
  613. if m.id == nil || m.oldValue == nil {
  614. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  615. }
  616. oldValue, err := m.oldValue(ctx)
  617. if err != nil {
  618. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  619. }
  620. return oldValue.DatasetID, nil
  621. }
  622. // ResetDatasetID resets all changes to the "dataset_id" field.
  623. func (m *AgentMutation) ResetDatasetID() {
  624. m.dataset_id = nil
  625. }
  626. // SetCollectionID sets the "collection_id" field.
  627. func (m *AgentMutation) SetCollectionID(s string) {
  628. m.collection_id = &s
  629. }
  630. // CollectionID returns the value of the "collection_id" field in the mutation.
  631. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  632. v := m.collection_id
  633. if v == nil {
  634. return
  635. }
  636. return *v, true
  637. }
  638. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  639. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  641. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  642. if !m.op.Is(OpUpdateOne) {
  643. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  644. }
  645. if m.id == nil || m.oldValue == nil {
  646. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  647. }
  648. oldValue, err := m.oldValue(ctx)
  649. if err != nil {
  650. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  651. }
  652. return oldValue.CollectionID, nil
  653. }
  654. // ResetCollectionID resets all changes to the "collection_id" field.
  655. func (m *AgentMutation) ResetCollectionID() {
  656. m.collection_id = nil
  657. }
  658. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  659. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  660. if m.wx_agent == nil {
  661. m.wx_agent = make(map[uint64]struct{})
  662. }
  663. for i := range ids {
  664. m.wx_agent[ids[i]] = struct{}{}
  665. }
  666. }
  667. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  668. func (m *AgentMutation) ClearWxAgent() {
  669. m.clearedwx_agent = true
  670. }
  671. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  672. func (m *AgentMutation) WxAgentCleared() bool {
  673. return m.clearedwx_agent
  674. }
  675. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  676. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  677. if m.removedwx_agent == nil {
  678. m.removedwx_agent = make(map[uint64]struct{})
  679. }
  680. for i := range ids {
  681. delete(m.wx_agent, ids[i])
  682. m.removedwx_agent[ids[i]] = struct{}{}
  683. }
  684. }
  685. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  686. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  687. for id := range m.removedwx_agent {
  688. ids = append(ids, id)
  689. }
  690. return
  691. }
  692. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  693. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  694. for id := range m.wx_agent {
  695. ids = append(ids, id)
  696. }
  697. return
  698. }
  699. // ResetWxAgent resets all changes to the "wx_agent" edge.
  700. func (m *AgentMutation) ResetWxAgent() {
  701. m.wx_agent = nil
  702. m.clearedwx_agent = false
  703. m.removedwx_agent = nil
  704. }
  705. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  706. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  707. if m.token_agent == nil {
  708. m.token_agent = make(map[uint64]struct{})
  709. }
  710. for i := range ids {
  711. m.token_agent[ids[i]] = struct{}{}
  712. }
  713. }
  714. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  715. func (m *AgentMutation) ClearTokenAgent() {
  716. m.clearedtoken_agent = true
  717. }
  718. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  719. func (m *AgentMutation) TokenAgentCleared() bool {
  720. return m.clearedtoken_agent
  721. }
  722. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  723. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  724. if m.removedtoken_agent == nil {
  725. m.removedtoken_agent = make(map[uint64]struct{})
  726. }
  727. for i := range ids {
  728. delete(m.token_agent, ids[i])
  729. m.removedtoken_agent[ids[i]] = struct{}{}
  730. }
  731. }
  732. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  733. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  734. for id := range m.removedtoken_agent {
  735. ids = append(ids, id)
  736. }
  737. return
  738. }
  739. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  740. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  741. for id := range m.token_agent {
  742. ids = append(ids, id)
  743. }
  744. return
  745. }
  746. // ResetTokenAgent resets all changes to the "token_agent" edge.
  747. func (m *AgentMutation) ResetTokenAgent() {
  748. m.token_agent = nil
  749. m.clearedtoken_agent = false
  750. m.removedtoken_agent = nil
  751. }
  752. // Where appends a list predicates to the AgentMutation builder.
  753. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  754. m.predicates = append(m.predicates, ps...)
  755. }
  756. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  757. // users can use type-assertion to append predicates that do not depend on any generated package.
  758. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  759. p := make([]predicate.Agent, len(ps))
  760. for i := range ps {
  761. p[i] = ps[i]
  762. }
  763. m.Where(p...)
  764. }
  765. // Op returns the operation name.
  766. func (m *AgentMutation) Op() Op {
  767. return m.op
  768. }
  769. // SetOp allows setting the mutation operation.
  770. func (m *AgentMutation) SetOp(op Op) {
  771. m.op = op
  772. }
  773. // Type returns the node type of this mutation (Agent).
  774. func (m *AgentMutation) Type() string {
  775. return m.typ
  776. }
  777. // Fields returns all fields that were changed during this mutation. Note that in
  778. // order to get all numeric fields that were incremented/decremented, call
  779. // AddedFields().
  780. func (m *AgentMutation) Fields() []string {
  781. fields := make([]string, 0, 11)
  782. if m.created_at != nil {
  783. fields = append(fields, agent.FieldCreatedAt)
  784. }
  785. if m.updated_at != nil {
  786. fields = append(fields, agent.FieldUpdatedAt)
  787. }
  788. if m.deleted_at != nil {
  789. fields = append(fields, agent.FieldDeletedAt)
  790. }
  791. if m.name != nil {
  792. fields = append(fields, agent.FieldName)
  793. }
  794. if m.role != nil {
  795. fields = append(fields, agent.FieldRole)
  796. }
  797. if m.status != nil {
  798. fields = append(fields, agent.FieldStatus)
  799. }
  800. if m.background != nil {
  801. fields = append(fields, agent.FieldBackground)
  802. }
  803. if m.examples != nil {
  804. fields = append(fields, agent.FieldExamples)
  805. }
  806. if m.organization_id != nil {
  807. fields = append(fields, agent.FieldOrganizationID)
  808. }
  809. if m.dataset_id != nil {
  810. fields = append(fields, agent.FieldDatasetID)
  811. }
  812. if m.collection_id != nil {
  813. fields = append(fields, agent.FieldCollectionID)
  814. }
  815. return fields
  816. }
  817. // Field returns the value of a field with the given name. The second boolean
  818. // return value indicates that this field was not set, or was not defined in the
  819. // schema.
  820. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  821. switch name {
  822. case agent.FieldCreatedAt:
  823. return m.CreatedAt()
  824. case agent.FieldUpdatedAt:
  825. return m.UpdatedAt()
  826. case agent.FieldDeletedAt:
  827. return m.DeletedAt()
  828. case agent.FieldName:
  829. return m.Name()
  830. case agent.FieldRole:
  831. return m.Role()
  832. case agent.FieldStatus:
  833. return m.Status()
  834. case agent.FieldBackground:
  835. return m.Background()
  836. case agent.FieldExamples:
  837. return m.Examples()
  838. case agent.FieldOrganizationID:
  839. return m.OrganizationID()
  840. case agent.FieldDatasetID:
  841. return m.DatasetID()
  842. case agent.FieldCollectionID:
  843. return m.CollectionID()
  844. }
  845. return nil, false
  846. }
  847. // OldField returns the old value of the field from the database. An error is
  848. // returned if the mutation operation is not UpdateOne, or the query to the
  849. // database failed.
  850. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  851. switch name {
  852. case agent.FieldCreatedAt:
  853. return m.OldCreatedAt(ctx)
  854. case agent.FieldUpdatedAt:
  855. return m.OldUpdatedAt(ctx)
  856. case agent.FieldDeletedAt:
  857. return m.OldDeletedAt(ctx)
  858. case agent.FieldName:
  859. return m.OldName(ctx)
  860. case agent.FieldRole:
  861. return m.OldRole(ctx)
  862. case agent.FieldStatus:
  863. return m.OldStatus(ctx)
  864. case agent.FieldBackground:
  865. return m.OldBackground(ctx)
  866. case agent.FieldExamples:
  867. return m.OldExamples(ctx)
  868. case agent.FieldOrganizationID:
  869. return m.OldOrganizationID(ctx)
  870. case agent.FieldDatasetID:
  871. return m.OldDatasetID(ctx)
  872. case agent.FieldCollectionID:
  873. return m.OldCollectionID(ctx)
  874. }
  875. return nil, fmt.Errorf("unknown Agent field %s", name)
  876. }
  877. // SetField sets the value of a field with the given name. It returns an error if
  878. // the field is not defined in the schema, or if the type mismatched the field
  879. // type.
  880. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  881. switch name {
  882. case agent.FieldCreatedAt:
  883. v, ok := value.(time.Time)
  884. if !ok {
  885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  886. }
  887. m.SetCreatedAt(v)
  888. return nil
  889. case agent.FieldUpdatedAt:
  890. v, ok := value.(time.Time)
  891. if !ok {
  892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  893. }
  894. m.SetUpdatedAt(v)
  895. return nil
  896. case agent.FieldDeletedAt:
  897. v, ok := value.(time.Time)
  898. if !ok {
  899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  900. }
  901. m.SetDeletedAt(v)
  902. return nil
  903. case agent.FieldName:
  904. v, ok := value.(string)
  905. if !ok {
  906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  907. }
  908. m.SetName(v)
  909. return nil
  910. case agent.FieldRole:
  911. v, ok := value.(string)
  912. if !ok {
  913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  914. }
  915. m.SetRole(v)
  916. return nil
  917. case agent.FieldStatus:
  918. v, ok := value.(int)
  919. if !ok {
  920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  921. }
  922. m.SetStatus(v)
  923. return nil
  924. case agent.FieldBackground:
  925. v, ok := value.(string)
  926. if !ok {
  927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  928. }
  929. m.SetBackground(v)
  930. return nil
  931. case agent.FieldExamples:
  932. v, ok := value.(string)
  933. if !ok {
  934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  935. }
  936. m.SetExamples(v)
  937. return nil
  938. case agent.FieldOrganizationID:
  939. v, ok := value.(uint64)
  940. if !ok {
  941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  942. }
  943. m.SetOrganizationID(v)
  944. return nil
  945. case agent.FieldDatasetID:
  946. v, ok := value.(string)
  947. if !ok {
  948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  949. }
  950. m.SetDatasetID(v)
  951. return nil
  952. case agent.FieldCollectionID:
  953. v, ok := value.(string)
  954. if !ok {
  955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  956. }
  957. m.SetCollectionID(v)
  958. return nil
  959. }
  960. return fmt.Errorf("unknown Agent field %s", name)
  961. }
  962. // AddedFields returns all numeric fields that were incremented/decremented during
  963. // this mutation.
  964. func (m *AgentMutation) AddedFields() []string {
  965. var fields []string
  966. if m.addstatus != nil {
  967. fields = append(fields, agent.FieldStatus)
  968. }
  969. if m.addorganization_id != nil {
  970. fields = append(fields, agent.FieldOrganizationID)
  971. }
  972. return fields
  973. }
  974. // AddedField returns the numeric value that was incremented/decremented on a field
  975. // with the given name. The second boolean return value indicates that this field
  976. // was not set, or was not defined in the schema.
  977. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  978. switch name {
  979. case agent.FieldStatus:
  980. return m.AddedStatus()
  981. case agent.FieldOrganizationID:
  982. return m.AddedOrganizationID()
  983. }
  984. return nil, false
  985. }
  986. // AddField adds the value to the field with the given name. It returns an error if
  987. // the field is not defined in the schema, or if the type mismatched the field
  988. // type.
  989. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  990. switch name {
  991. case agent.FieldStatus:
  992. v, ok := value.(int)
  993. if !ok {
  994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  995. }
  996. m.AddStatus(v)
  997. return nil
  998. case agent.FieldOrganizationID:
  999. v, ok := value.(int64)
  1000. if !ok {
  1001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1002. }
  1003. m.AddOrganizationID(v)
  1004. return nil
  1005. }
  1006. return fmt.Errorf("unknown Agent numeric field %s", name)
  1007. }
  1008. // ClearedFields returns all nullable fields that were cleared during this
  1009. // mutation.
  1010. func (m *AgentMutation) ClearedFields() []string {
  1011. var fields []string
  1012. if m.FieldCleared(agent.FieldDeletedAt) {
  1013. fields = append(fields, agent.FieldDeletedAt)
  1014. }
  1015. if m.FieldCleared(agent.FieldStatus) {
  1016. fields = append(fields, agent.FieldStatus)
  1017. }
  1018. if m.FieldCleared(agent.FieldBackground) {
  1019. fields = append(fields, agent.FieldBackground)
  1020. }
  1021. if m.FieldCleared(agent.FieldExamples) {
  1022. fields = append(fields, agent.FieldExamples)
  1023. }
  1024. return fields
  1025. }
  1026. // FieldCleared returns a boolean indicating if a field with the given name was
  1027. // cleared in this mutation.
  1028. func (m *AgentMutation) FieldCleared(name string) bool {
  1029. _, ok := m.clearedFields[name]
  1030. return ok
  1031. }
  1032. // ClearField clears the value of the field with the given name. It returns an
  1033. // error if the field is not defined in the schema.
  1034. func (m *AgentMutation) ClearField(name string) error {
  1035. switch name {
  1036. case agent.FieldDeletedAt:
  1037. m.ClearDeletedAt()
  1038. return nil
  1039. case agent.FieldStatus:
  1040. m.ClearStatus()
  1041. return nil
  1042. case agent.FieldBackground:
  1043. m.ClearBackground()
  1044. return nil
  1045. case agent.FieldExamples:
  1046. m.ClearExamples()
  1047. return nil
  1048. }
  1049. return fmt.Errorf("unknown Agent nullable field %s", name)
  1050. }
  1051. // ResetField resets all changes in the mutation for the field with the given name.
  1052. // It returns an error if the field is not defined in the schema.
  1053. func (m *AgentMutation) ResetField(name string) error {
  1054. switch name {
  1055. case agent.FieldCreatedAt:
  1056. m.ResetCreatedAt()
  1057. return nil
  1058. case agent.FieldUpdatedAt:
  1059. m.ResetUpdatedAt()
  1060. return nil
  1061. case agent.FieldDeletedAt:
  1062. m.ResetDeletedAt()
  1063. return nil
  1064. case agent.FieldName:
  1065. m.ResetName()
  1066. return nil
  1067. case agent.FieldRole:
  1068. m.ResetRole()
  1069. return nil
  1070. case agent.FieldStatus:
  1071. m.ResetStatus()
  1072. return nil
  1073. case agent.FieldBackground:
  1074. m.ResetBackground()
  1075. return nil
  1076. case agent.FieldExamples:
  1077. m.ResetExamples()
  1078. return nil
  1079. case agent.FieldOrganizationID:
  1080. m.ResetOrganizationID()
  1081. return nil
  1082. case agent.FieldDatasetID:
  1083. m.ResetDatasetID()
  1084. return nil
  1085. case agent.FieldCollectionID:
  1086. m.ResetCollectionID()
  1087. return nil
  1088. }
  1089. return fmt.Errorf("unknown Agent field %s", name)
  1090. }
  1091. // AddedEdges returns all edge names that were set/added in this mutation.
  1092. func (m *AgentMutation) AddedEdges() []string {
  1093. edges := make([]string, 0, 2)
  1094. if m.wx_agent != nil {
  1095. edges = append(edges, agent.EdgeWxAgent)
  1096. }
  1097. if m.token_agent != nil {
  1098. edges = append(edges, agent.EdgeTokenAgent)
  1099. }
  1100. return edges
  1101. }
  1102. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1103. // name in this mutation.
  1104. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1105. switch name {
  1106. case agent.EdgeWxAgent:
  1107. ids := make([]ent.Value, 0, len(m.wx_agent))
  1108. for id := range m.wx_agent {
  1109. ids = append(ids, id)
  1110. }
  1111. return ids
  1112. case agent.EdgeTokenAgent:
  1113. ids := make([]ent.Value, 0, len(m.token_agent))
  1114. for id := range m.token_agent {
  1115. ids = append(ids, id)
  1116. }
  1117. return ids
  1118. }
  1119. return nil
  1120. }
  1121. // RemovedEdges returns all edge names that were removed in this mutation.
  1122. func (m *AgentMutation) RemovedEdges() []string {
  1123. edges := make([]string, 0, 2)
  1124. if m.removedwx_agent != nil {
  1125. edges = append(edges, agent.EdgeWxAgent)
  1126. }
  1127. if m.removedtoken_agent != nil {
  1128. edges = append(edges, agent.EdgeTokenAgent)
  1129. }
  1130. return edges
  1131. }
  1132. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1133. // the given name in this mutation.
  1134. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1135. switch name {
  1136. case agent.EdgeWxAgent:
  1137. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1138. for id := range m.removedwx_agent {
  1139. ids = append(ids, id)
  1140. }
  1141. return ids
  1142. case agent.EdgeTokenAgent:
  1143. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1144. for id := range m.removedtoken_agent {
  1145. ids = append(ids, id)
  1146. }
  1147. return ids
  1148. }
  1149. return nil
  1150. }
  1151. // ClearedEdges returns all edge names that were cleared in this mutation.
  1152. func (m *AgentMutation) ClearedEdges() []string {
  1153. edges := make([]string, 0, 2)
  1154. if m.clearedwx_agent {
  1155. edges = append(edges, agent.EdgeWxAgent)
  1156. }
  1157. if m.clearedtoken_agent {
  1158. edges = append(edges, agent.EdgeTokenAgent)
  1159. }
  1160. return edges
  1161. }
  1162. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1163. // was cleared in this mutation.
  1164. func (m *AgentMutation) EdgeCleared(name string) bool {
  1165. switch name {
  1166. case agent.EdgeWxAgent:
  1167. return m.clearedwx_agent
  1168. case agent.EdgeTokenAgent:
  1169. return m.clearedtoken_agent
  1170. }
  1171. return false
  1172. }
  1173. // ClearEdge clears the value of the edge with the given name. It returns an error
  1174. // if that edge is not defined in the schema.
  1175. func (m *AgentMutation) ClearEdge(name string) error {
  1176. switch name {
  1177. }
  1178. return fmt.Errorf("unknown Agent unique edge %s", name)
  1179. }
  1180. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1181. // It returns an error if the edge is not defined in the schema.
  1182. func (m *AgentMutation) ResetEdge(name string) error {
  1183. switch name {
  1184. case agent.EdgeWxAgent:
  1185. m.ResetWxAgent()
  1186. return nil
  1187. case agent.EdgeTokenAgent:
  1188. m.ResetTokenAgent()
  1189. return nil
  1190. }
  1191. return fmt.Errorf("unknown Agent edge %s", name)
  1192. }
  1193. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1194. type AgentBaseMutation struct {
  1195. config
  1196. op Op
  1197. typ string
  1198. id *string
  1199. q *string
  1200. a *string
  1201. chunk_index *uint64
  1202. addchunk_index *int64
  1203. indexes *[]string
  1204. appendindexes []string
  1205. dataset_id *string
  1206. collection_id *string
  1207. source_name *string
  1208. can_write *[]bool
  1209. appendcan_write []bool
  1210. is_owner *[]bool
  1211. appendis_owner []bool
  1212. clearedFields map[string]struct{}
  1213. wx_agent map[uint64]struct{}
  1214. removedwx_agent map[uint64]struct{}
  1215. clearedwx_agent bool
  1216. done bool
  1217. oldValue func(context.Context) (*AgentBase, error)
  1218. predicates []predicate.AgentBase
  1219. }
  1220. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1221. // agentbaseOption allows management of the mutation configuration using functional options.
  1222. type agentbaseOption func(*AgentBaseMutation)
  1223. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1224. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1225. m := &AgentBaseMutation{
  1226. config: c,
  1227. op: op,
  1228. typ: TypeAgentBase,
  1229. clearedFields: make(map[string]struct{}),
  1230. }
  1231. for _, opt := range opts {
  1232. opt(m)
  1233. }
  1234. return m
  1235. }
  1236. // withAgentBaseID sets the ID field of the mutation.
  1237. func withAgentBaseID(id string) agentbaseOption {
  1238. return func(m *AgentBaseMutation) {
  1239. var (
  1240. err error
  1241. once sync.Once
  1242. value *AgentBase
  1243. )
  1244. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1245. once.Do(func() {
  1246. if m.done {
  1247. err = errors.New("querying old values post mutation is not allowed")
  1248. } else {
  1249. value, err = m.Client().AgentBase.Get(ctx, id)
  1250. }
  1251. })
  1252. return value, err
  1253. }
  1254. m.id = &id
  1255. }
  1256. }
  1257. // withAgentBase sets the old AgentBase of the mutation.
  1258. func withAgentBase(node *AgentBase) agentbaseOption {
  1259. return func(m *AgentBaseMutation) {
  1260. m.oldValue = func(context.Context) (*AgentBase, error) {
  1261. return node, nil
  1262. }
  1263. m.id = &node.ID
  1264. }
  1265. }
  1266. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1267. // executed in a transaction (ent.Tx), a transactional client is returned.
  1268. func (m AgentBaseMutation) Client() *Client {
  1269. client := &Client{config: m.config}
  1270. client.init()
  1271. return client
  1272. }
  1273. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1274. // it returns an error otherwise.
  1275. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1276. if _, ok := m.driver.(*txDriver); !ok {
  1277. return nil, errors.New("ent: mutation is not running in a transaction")
  1278. }
  1279. tx := &Tx{config: m.config}
  1280. tx.init()
  1281. return tx, nil
  1282. }
  1283. // SetID sets the value of the id field. Note that this
  1284. // operation is only accepted on creation of AgentBase entities.
  1285. func (m *AgentBaseMutation) SetID(id string) {
  1286. m.id = &id
  1287. }
  1288. // ID returns the ID value in the mutation. Note that the ID is only available
  1289. // if it was provided to the builder or after it was returned from the database.
  1290. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1291. if m.id == nil {
  1292. return
  1293. }
  1294. return *m.id, true
  1295. }
  1296. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1297. // That means, if the mutation is applied within a transaction with an isolation level such
  1298. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1299. // or updated by the mutation.
  1300. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1301. switch {
  1302. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1303. id, exists := m.ID()
  1304. if exists {
  1305. return []string{id}, nil
  1306. }
  1307. fallthrough
  1308. case m.op.Is(OpUpdate | OpDelete):
  1309. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1310. default:
  1311. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1312. }
  1313. }
  1314. // SetQ sets the "q" field.
  1315. func (m *AgentBaseMutation) SetQ(s string) {
  1316. m.q = &s
  1317. }
  1318. // Q returns the value of the "q" field in the mutation.
  1319. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1320. v := m.q
  1321. if v == nil {
  1322. return
  1323. }
  1324. return *v, true
  1325. }
  1326. // OldQ returns the old "q" field's value of the AgentBase entity.
  1327. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1329. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1330. if !m.op.Is(OpUpdateOne) {
  1331. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1332. }
  1333. if m.id == nil || m.oldValue == nil {
  1334. return v, errors.New("OldQ requires an ID field in the mutation")
  1335. }
  1336. oldValue, err := m.oldValue(ctx)
  1337. if err != nil {
  1338. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1339. }
  1340. return oldValue.Q, nil
  1341. }
  1342. // ClearQ clears the value of the "q" field.
  1343. func (m *AgentBaseMutation) ClearQ() {
  1344. m.q = nil
  1345. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1346. }
  1347. // QCleared returns if the "q" field was cleared in this mutation.
  1348. func (m *AgentBaseMutation) QCleared() bool {
  1349. _, ok := m.clearedFields[agentbase.FieldQ]
  1350. return ok
  1351. }
  1352. // ResetQ resets all changes to the "q" field.
  1353. func (m *AgentBaseMutation) ResetQ() {
  1354. m.q = nil
  1355. delete(m.clearedFields, agentbase.FieldQ)
  1356. }
  1357. // SetA sets the "a" field.
  1358. func (m *AgentBaseMutation) SetA(s string) {
  1359. m.a = &s
  1360. }
  1361. // A returns the value of the "a" field in the mutation.
  1362. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1363. v := m.a
  1364. if v == nil {
  1365. return
  1366. }
  1367. return *v, true
  1368. }
  1369. // OldA returns the old "a" field's value of the AgentBase entity.
  1370. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1372. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1373. if !m.op.Is(OpUpdateOne) {
  1374. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1375. }
  1376. if m.id == nil || m.oldValue == nil {
  1377. return v, errors.New("OldA requires an ID field in the mutation")
  1378. }
  1379. oldValue, err := m.oldValue(ctx)
  1380. if err != nil {
  1381. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1382. }
  1383. return oldValue.A, nil
  1384. }
  1385. // ClearA clears the value of the "a" field.
  1386. func (m *AgentBaseMutation) ClearA() {
  1387. m.a = nil
  1388. m.clearedFields[agentbase.FieldA] = struct{}{}
  1389. }
  1390. // ACleared returns if the "a" field was cleared in this mutation.
  1391. func (m *AgentBaseMutation) ACleared() bool {
  1392. _, ok := m.clearedFields[agentbase.FieldA]
  1393. return ok
  1394. }
  1395. // ResetA resets all changes to the "a" field.
  1396. func (m *AgentBaseMutation) ResetA() {
  1397. m.a = nil
  1398. delete(m.clearedFields, agentbase.FieldA)
  1399. }
  1400. // SetChunkIndex sets the "chunk_index" field.
  1401. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1402. m.chunk_index = &u
  1403. m.addchunk_index = nil
  1404. }
  1405. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1406. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1407. v := m.chunk_index
  1408. if v == nil {
  1409. return
  1410. }
  1411. return *v, true
  1412. }
  1413. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1414. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1416. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1417. if !m.op.Is(OpUpdateOne) {
  1418. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1419. }
  1420. if m.id == nil || m.oldValue == nil {
  1421. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1422. }
  1423. oldValue, err := m.oldValue(ctx)
  1424. if err != nil {
  1425. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1426. }
  1427. return oldValue.ChunkIndex, nil
  1428. }
  1429. // AddChunkIndex adds u to the "chunk_index" field.
  1430. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1431. if m.addchunk_index != nil {
  1432. *m.addchunk_index += u
  1433. } else {
  1434. m.addchunk_index = &u
  1435. }
  1436. }
  1437. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1438. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1439. v := m.addchunk_index
  1440. if v == nil {
  1441. return
  1442. }
  1443. return *v, true
  1444. }
  1445. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1446. func (m *AgentBaseMutation) ResetChunkIndex() {
  1447. m.chunk_index = nil
  1448. m.addchunk_index = nil
  1449. }
  1450. // SetIndexes sets the "indexes" field.
  1451. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1452. m.indexes = &s
  1453. m.appendindexes = nil
  1454. }
  1455. // Indexes returns the value of the "indexes" field in the mutation.
  1456. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1457. v := m.indexes
  1458. if v == nil {
  1459. return
  1460. }
  1461. return *v, true
  1462. }
  1463. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1464. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1466. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1467. if !m.op.Is(OpUpdateOne) {
  1468. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1469. }
  1470. if m.id == nil || m.oldValue == nil {
  1471. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1472. }
  1473. oldValue, err := m.oldValue(ctx)
  1474. if err != nil {
  1475. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1476. }
  1477. return oldValue.Indexes, nil
  1478. }
  1479. // AppendIndexes adds s to the "indexes" field.
  1480. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1481. m.appendindexes = append(m.appendindexes, s...)
  1482. }
  1483. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1484. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1485. if len(m.appendindexes) == 0 {
  1486. return nil, false
  1487. }
  1488. return m.appendindexes, true
  1489. }
  1490. // ClearIndexes clears the value of the "indexes" field.
  1491. func (m *AgentBaseMutation) ClearIndexes() {
  1492. m.indexes = nil
  1493. m.appendindexes = nil
  1494. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1495. }
  1496. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1497. func (m *AgentBaseMutation) IndexesCleared() bool {
  1498. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1499. return ok
  1500. }
  1501. // ResetIndexes resets all changes to the "indexes" field.
  1502. func (m *AgentBaseMutation) ResetIndexes() {
  1503. m.indexes = nil
  1504. m.appendindexes = nil
  1505. delete(m.clearedFields, agentbase.FieldIndexes)
  1506. }
  1507. // SetDatasetID sets the "dataset_id" field.
  1508. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1509. m.dataset_id = &s
  1510. }
  1511. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1512. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1513. v := m.dataset_id
  1514. if v == nil {
  1515. return
  1516. }
  1517. return *v, true
  1518. }
  1519. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1520. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1522. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1523. if !m.op.Is(OpUpdateOne) {
  1524. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1525. }
  1526. if m.id == nil || m.oldValue == nil {
  1527. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1528. }
  1529. oldValue, err := m.oldValue(ctx)
  1530. if err != nil {
  1531. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1532. }
  1533. return oldValue.DatasetID, nil
  1534. }
  1535. // ClearDatasetID clears the value of the "dataset_id" field.
  1536. func (m *AgentBaseMutation) ClearDatasetID() {
  1537. m.dataset_id = nil
  1538. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1539. }
  1540. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1541. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1542. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1543. return ok
  1544. }
  1545. // ResetDatasetID resets all changes to the "dataset_id" field.
  1546. func (m *AgentBaseMutation) ResetDatasetID() {
  1547. m.dataset_id = nil
  1548. delete(m.clearedFields, agentbase.FieldDatasetID)
  1549. }
  1550. // SetCollectionID sets the "collection_id" field.
  1551. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1552. m.collection_id = &s
  1553. }
  1554. // CollectionID returns the value of the "collection_id" field in the mutation.
  1555. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1556. v := m.collection_id
  1557. if v == nil {
  1558. return
  1559. }
  1560. return *v, true
  1561. }
  1562. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1563. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1565. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1566. if !m.op.Is(OpUpdateOne) {
  1567. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1568. }
  1569. if m.id == nil || m.oldValue == nil {
  1570. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1571. }
  1572. oldValue, err := m.oldValue(ctx)
  1573. if err != nil {
  1574. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1575. }
  1576. return oldValue.CollectionID, nil
  1577. }
  1578. // ClearCollectionID clears the value of the "collection_id" field.
  1579. func (m *AgentBaseMutation) ClearCollectionID() {
  1580. m.collection_id = nil
  1581. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1582. }
  1583. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1584. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1585. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1586. return ok
  1587. }
  1588. // ResetCollectionID resets all changes to the "collection_id" field.
  1589. func (m *AgentBaseMutation) ResetCollectionID() {
  1590. m.collection_id = nil
  1591. delete(m.clearedFields, agentbase.FieldCollectionID)
  1592. }
  1593. // SetSourceName sets the "source_name" field.
  1594. func (m *AgentBaseMutation) SetSourceName(s string) {
  1595. m.source_name = &s
  1596. }
  1597. // SourceName returns the value of the "source_name" field in the mutation.
  1598. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1599. v := m.source_name
  1600. if v == nil {
  1601. return
  1602. }
  1603. return *v, true
  1604. }
  1605. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1606. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1608. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1609. if !m.op.Is(OpUpdateOne) {
  1610. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1611. }
  1612. if m.id == nil || m.oldValue == nil {
  1613. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1614. }
  1615. oldValue, err := m.oldValue(ctx)
  1616. if err != nil {
  1617. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1618. }
  1619. return oldValue.SourceName, nil
  1620. }
  1621. // ClearSourceName clears the value of the "source_name" field.
  1622. func (m *AgentBaseMutation) ClearSourceName() {
  1623. m.source_name = nil
  1624. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1625. }
  1626. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1627. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1628. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1629. return ok
  1630. }
  1631. // ResetSourceName resets all changes to the "source_name" field.
  1632. func (m *AgentBaseMutation) ResetSourceName() {
  1633. m.source_name = nil
  1634. delete(m.clearedFields, agentbase.FieldSourceName)
  1635. }
  1636. // SetCanWrite sets the "can_write" field.
  1637. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1638. m.can_write = &b
  1639. m.appendcan_write = nil
  1640. }
  1641. // CanWrite returns the value of the "can_write" field in the mutation.
  1642. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1643. v := m.can_write
  1644. if v == nil {
  1645. return
  1646. }
  1647. return *v, true
  1648. }
  1649. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1650. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1652. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1653. if !m.op.Is(OpUpdateOne) {
  1654. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1655. }
  1656. if m.id == nil || m.oldValue == nil {
  1657. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1658. }
  1659. oldValue, err := m.oldValue(ctx)
  1660. if err != nil {
  1661. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1662. }
  1663. return oldValue.CanWrite, nil
  1664. }
  1665. // AppendCanWrite adds b to the "can_write" field.
  1666. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1667. m.appendcan_write = append(m.appendcan_write, b...)
  1668. }
  1669. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1670. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1671. if len(m.appendcan_write) == 0 {
  1672. return nil, false
  1673. }
  1674. return m.appendcan_write, true
  1675. }
  1676. // ClearCanWrite clears the value of the "can_write" field.
  1677. func (m *AgentBaseMutation) ClearCanWrite() {
  1678. m.can_write = nil
  1679. m.appendcan_write = nil
  1680. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1681. }
  1682. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1683. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1684. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1685. return ok
  1686. }
  1687. // ResetCanWrite resets all changes to the "can_write" field.
  1688. func (m *AgentBaseMutation) ResetCanWrite() {
  1689. m.can_write = nil
  1690. m.appendcan_write = nil
  1691. delete(m.clearedFields, agentbase.FieldCanWrite)
  1692. }
  1693. // SetIsOwner sets the "is_owner" field.
  1694. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1695. m.is_owner = &b
  1696. m.appendis_owner = nil
  1697. }
  1698. // IsOwner returns the value of the "is_owner" field in the mutation.
  1699. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1700. v := m.is_owner
  1701. if v == nil {
  1702. return
  1703. }
  1704. return *v, true
  1705. }
  1706. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1707. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1709. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1710. if !m.op.Is(OpUpdateOne) {
  1711. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1712. }
  1713. if m.id == nil || m.oldValue == nil {
  1714. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1715. }
  1716. oldValue, err := m.oldValue(ctx)
  1717. if err != nil {
  1718. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1719. }
  1720. return oldValue.IsOwner, nil
  1721. }
  1722. // AppendIsOwner adds b to the "is_owner" field.
  1723. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1724. m.appendis_owner = append(m.appendis_owner, b...)
  1725. }
  1726. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1727. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1728. if len(m.appendis_owner) == 0 {
  1729. return nil, false
  1730. }
  1731. return m.appendis_owner, true
  1732. }
  1733. // ClearIsOwner clears the value of the "is_owner" field.
  1734. func (m *AgentBaseMutation) ClearIsOwner() {
  1735. m.is_owner = nil
  1736. m.appendis_owner = nil
  1737. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1738. }
  1739. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1740. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1741. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1742. return ok
  1743. }
  1744. // ResetIsOwner resets all changes to the "is_owner" field.
  1745. func (m *AgentBaseMutation) ResetIsOwner() {
  1746. m.is_owner = nil
  1747. m.appendis_owner = nil
  1748. delete(m.clearedFields, agentbase.FieldIsOwner)
  1749. }
  1750. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1751. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1752. if m.wx_agent == nil {
  1753. m.wx_agent = make(map[uint64]struct{})
  1754. }
  1755. for i := range ids {
  1756. m.wx_agent[ids[i]] = struct{}{}
  1757. }
  1758. }
  1759. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1760. func (m *AgentBaseMutation) ClearWxAgent() {
  1761. m.clearedwx_agent = true
  1762. }
  1763. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1764. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1765. return m.clearedwx_agent
  1766. }
  1767. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1768. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1769. if m.removedwx_agent == nil {
  1770. m.removedwx_agent = make(map[uint64]struct{})
  1771. }
  1772. for i := range ids {
  1773. delete(m.wx_agent, ids[i])
  1774. m.removedwx_agent[ids[i]] = struct{}{}
  1775. }
  1776. }
  1777. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1778. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1779. for id := range m.removedwx_agent {
  1780. ids = append(ids, id)
  1781. }
  1782. return
  1783. }
  1784. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1785. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1786. for id := range m.wx_agent {
  1787. ids = append(ids, id)
  1788. }
  1789. return
  1790. }
  1791. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1792. func (m *AgentBaseMutation) ResetWxAgent() {
  1793. m.wx_agent = nil
  1794. m.clearedwx_agent = false
  1795. m.removedwx_agent = nil
  1796. }
  1797. // Where appends a list predicates to the AgentBaseMutation builder.
  1798. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1799. m.predicates = append(m.predicates, ps...)
  1800. }
  1801. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1802. // users can use type-assertion to append predicates that do not depend on any generated package.
  1803. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1804. p := make([]predicate.AgentBase, len(ps))
  1805. for i := range ps {
  1806. p[i] = ps[i]
  1807. }
  1808. m.Where(p...)
  1809. }
  1810. // Op returns the operation name.
  1811. func (m *AgentBaseMutation) Op() Op {
  1812. return m.op
  1813. }
  1814. // SetOp allows setting the mutation operation.
  1815. func (m *AgentBaseMutation) SetOp(op Op) {
  1816. m.op = op
  1817. }
  1818. // Type returns the node type of this mutation (AgentBase).
  1819. func (m *AgentBaseMutation) Type() string {
  1820. return m.typ
  1821. }
  1822. // Fields returns all fields that were changed during this mutation. Note that in
  1823. // order to get all numeric fields that were incremented/decremented, call
  1824. // AddedFields().
  1825. func (m *AgentBaseMutation) Fields() []string {
  1826. fields := make([]string, 0, 9)
  1827. if m.q != nil {
  1828. fields = append(fields, agentbase.FieldQ)
  1829. }
  1830. if m.a != nil {
  1831. fields = append(fields, agentbase.FieldA)
  1832. }
  1833. if m.chunk_index != nil {
  1834. fields = append(fields, agentbase.FieldChunkIndex)
  1835. }
  1836. if m.indexes != nil {
  1837. fields = append(fields, agentbase.FieldIndexes)
  1838. }
  1839. if m.dataset_id != nil {
  1840. fields = append(fields, agentbase.FieldDatasetID)
  1841. }
  1842. if m.collection_id != nil {
  1843. fields = append(fields, agentbase.FieldCollectionID)
  1844. }
  1845. if m.source_name != nil {
  1846. fields = append(fields, agentbase.FieldSourceName)
  1847. }
  1848. if m.can_write != nil {
  1849. fields = append(fields, agentbase.FieldCanWrite)
  1850. }
  1851. if m.is_owner != nil {
  1852. fields = append(fields, agentbase.FieldIsOwner)
  1853. }
  1854. return fields
  1855. }
  1856. // Field returns the value of a field with the given name. The second boolean
  1857. // return value indicates that this field was not set, or was not defined in the
  1858. // schema.
  1859. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1860. switch name {
  1861. case agentbase.FieldQ:
  1862. return m.Q()
  1863. case agentbase.FieldA:
  1864. return m.A()
  1865. case agentbase.FieldChunkIndex:
  1866. return m.ChunkIndex()
  1867. case agentbase.FieldIndexes:
  1868. return m.Indexes()
  1869. case agentbase.FieldDatasetID:
  1870. return m.DatasetID()
  1871. case agentbase.FieldCollectionID:
  1872. return m.CollectionID()
  1873. case agentbase.FieldSourceName:
  1874. return m.SourceName()
  1875. case agentbase.FieldCanWrite:
  1876. return m.CanWrite()
  1877. case agentbase.FieldIsOwner:
  1878. return m.IsOwner()
  1879. }
  1880. return nil, false
  1881. }
  1882. // OldField returns the old value of the field from the database. An error is
  1883. // returned if the mutation operation is not UpdateOne, or the query to the
  1884. // database failed.
  1885. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1886. switch name {
  1887. case agentbase.FieldQ:
  1888. return m.OldQ(ctx)
  1889. case agentbase.FieldA:
  1890. return m.OldA(ctx)
  1891. case agentbase.FieldChunkIndex:
  1892. return m.OldChunkIndex(ctx)
  1893. case agentbase.FieldIndexes:
  1894. return m.OldIndexes(ctx)
  1895. case agentbase.FieldDatasetID:
  1896. return m.OldDatasetID(ctx)
  1897. case agentbase.FieldCollectionID:
  1898. return m.OldCollectionID(ctx)
  1899. case agentbase.FieldSourceName:
  1900. return m.OldSourceName(ctx)
  1901. case agentbase.FieldCanWrite:
  1902. return m.OldCanWrite(ctx)
  1903. case agentbase.FieldIsOwner:
  1904. return m.OldIsOwner(ctx)
  1905. }
  1906. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1907. }
  1908. // SetField sets the value of a field with the given name. It returns an error if
  1909. // the field is not defined in the schema, or if the type mismatched the field
  1910. // type.
  1911. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1912. switch name {
  1913. case agentbase.FieldQ:
  1914. v, ok := value.(string)
  1915. if !ok {
  1916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1917. }
  1918. m.SetQ(v)
  1919. return nil
  1920. case agentbase.FieldA:
  1921. v, ok := value.(string)
  1922. if !ok {
  1923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1924. }
  1925. m.SetA(v)
  1926. return nil
  1927. case agentbase.FieldChunkIndex:
  1928. v, ok := value.(uint64)
  1929. if !ok {
  1930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1931. }
  1932. m.SetChunkIndex(v)
  1933. return nil
  1934. case agentbase.FieldIndexes:
  1935. v, ok := value.([]string)
  1936. if !ok {
  1937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1938. }
  1939. m.SetIndexes(v)
  1940. return nil
  1941. case agentbase.FieldDatasetID:
  1942. v, ok := value.(string)
  1943. if !ok {
  1944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1945. }
  1946. m.SetDatasetID(v)
  1947. return nil
  1948. case agentbase.FieldCollectionID:
  1949. v, ok := value.(string)
  1950. if !ok {
  1951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1952. }
  1953. m.SetCollectionID(v)
  1954. return nil
  1955. case agentbase.FieldSourceName:
  1956. v, ok := value.(string)
  1957. if !ok {
  1958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1959. }
  1960. m.SetSourceName(v)
  1961. return nil
  1962. case agentbase.FieldCanWrite:
  1963. v, ok := value.([]bool)
  1964. if !ok {
  1965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1966. }
  1967. m.SetCanWrite(v)
  1968. return nil
  1969. case agentbase.FieldIsOwner:
  1970. v, ok := value.([]bool)
  1971. if !ok {
  1972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1973. }
  1974. m.SetIsOwner(v)
  1975. return nil
  1976. }
  1977. return fmt.Errorf("unknown AgentBase field %s", name)
  1978. }
  1979. // AddedFields returns all numeric fields that were incremented/decremented during
  1980. // this mutation.
  1981. func (m *AgentBaseMutation) AddedFields() []string {
  1982. var fields []string
  1983. if m.addchunk_index != nil {
  1984. fields = append(fields, agentbase.FieldChunkIndex)
  1985. }
  1986. return fields
  1987. }
  1988. // AddedField returns the numeric value that was incremented/decremented on a field
  1989. // with the given name. The second boolean return value indicates that this field
  1990. // was not set, or was not defined in the schema.
  1991. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  1992. switch name {
  1993. case agentbase.FieldChunkIndex:
  1994. return m.AddedChunkIndex()
  1995. }
  1996. return nil, false
  1997. }
  1998. // AddField adds the value to the field with the given name. It returns an error if
  1999. // the field is not defined in the schema, or if the type mismatched the field
  2000. // type.
  2001. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2002. switch name {
  2003. case agentbase.FieldChunkIndex:
  2004. v, ok := value.(int64)
  2005. if !ok {
  2006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2007. }
  2008. m.AddChunkIndex(v)
  2009. return nil
  2010. }
  2011. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2012. }
  2013. // ClearedFields returns all nullable fields that were cleared during this
  2014. // mutation.
  2015. func (m *AgentBaseMutation) ClearedFields() []string {
  2016. var fields []string
  2017. if m.FieldCleared(agentbase.FieldQ) {
  2018. fields = append(fields, agentbase.FieldQ)
  2019. }
  2020. if m.FieldCleared(agentbase.FieldA) {
  2021. fields = append(fields, agentbase.FieldA)
  2022. }
  2023. if m.FieldCleared(agentbase.FieldIndexes) {
  2024. fields = append(fields, agentbase.FieldIndexes)
  2025. }
  2026. if m.FieldCleared(agentbase.FieldDatasetID) {
  2027. fields = append(fields, agentbase.FieldDatasetID)
  2028. }
  2029. if m.FieldCleared(agentbase.FieldCollectionID) {
  2030. fields = append(fields, agentbase.FieldCollectionID)
  2031. }
  2032. if m.FieldCleared(agentbase.FieldSourceName) {
  2033. fields = append(fields, agentbase.FieldSourceName)
  2034. }
  2035. if m.FieldCleared(agentbase.FieldCanWrite) {
  2036. fields = append(fields, agentbase.FieldCanWrite)
  2037. }
  2038. if m.FieldCleared(agentbase.FieldIsOwner) {
  2039. fields = append(fields, agentbase.FieldIsOwner)
  2040. }
  2041. return fields
  2042. }
  2043. // FieldCleared returns a boolean indicating if a field with the given name was
  2044. // cleared in this mutation.
  2045. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2046. _, ok := m.clearedFields[name]
  2047. return ok
  2048. }
  2049. // ClearField clears the value of the field with the given name. It returns an
  2050. // error if the field is not defined in the schema.
  2051. func (m *AgentBaseMutation) ClearField(name string) error {
  2052. switch name {
  2053. case agentbase.FieldQ:
  2054. m.ClearQ()
  2055. return nil
  2056. case agentbase.FieldA:
  2057. m.ClearA()
  2058. return nil
  2059. case agentbase.FieldIndexes:
  2060. m.ClearIndexes()
  2061. return nil
  2062. case agentbase.FieldDatasetID:
  2063. m.ClearDatasetID()
  2064. return nil
  2065. case agentbase.FieldCollectionID:
  2066. m.ClearCollectionID()
  2067. return nil
  2068. case agentbase.FieldSourceName:
  2069. m.ClearSourceName()
  2070. return nil
  2071. case agentbase.FieldCanWrite:
  2072. m.ClearCanWrite()
  2073. return nil
  2074. case agentbase.FieldIsOwner:
  2075. m.ClearIsOwner()
  2076. return nil
  2077. }
  2078. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2079. }
  2080. // ResetField resets all changes in the mutation for the field with the given name.
  2081. // It returns an error if the field is not defined in the schema.
  2082. func (m *AgentBaseMutation) ResetField(name string) error {
  2083. switch name {
  2084. case agentbase.FieldQ:
  2085. m.ResetQ()
  2086. return nil
  2087. case agentbase.FieldA:
  2088. m.ResetA()
  2089. return nil
  2090. case agentbase.FieldChunkIndex:
  2091. m.ResetChunkIndex()
  2092. return nil
  2093. case agentbase.FieldIndexes:
  2094. m.ResetIndexes()
  2095. return nil
  2096. case agentbase.FieldDatasetID:
  2097. m.ResetDatasetID()
  2098. return nil
  2099. case agentbase.FieldCollectionID:
  2100. m.ResetCollectionID()
  2101. return nil
  2102. case agentbase.FieldSourceName:
  2103. m.ResetSourceName()
  2104. return nil
  2105. case agentbase.FieldCanWrite:
  2106. m.ResetCanWrite()
  2107. return nil
  2108. case agentbase.FieldIsOwner:
  2109. m.ResetIsOwner()
  2110. return nil
  2111. }
  2112. return fmt.Errorf("unknown AgentBase field %s", name)
  2113. }
  2114. // AddedEdges returns all edge names that were set/added in this mutation.
  2115. func (m *AgentBaseMutation) AddedEdges() []string {
  2116. edges := make([]string, 0, 1)
  2117. if m.wx_agent != nil {
  2118. edges = append(edges, agentbase.EdgeWxAgent)
  2119. }
  2120. return edges
  2121. }
  2122. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2123. // name in this mutation.
  2124. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2125. switch name {
  2126. case agentbase.EdgeWxAgent:
  2127. ids := make([]ent.Value, 0, len(m.wx_agent))
  2128. for id := range m.wx_agent {
  2129. ids = append(ids, id)
  2130. }
  2131. return ids
  2132. }
  2133. return nil
  2134. }
  2135. // RemovedEdges returns all edge names that were removed in this mutation.
  2136. func (m *AgentBaseMutation) RemovedEdges() []string {
  2137. edges := make([]string, 0, 1)
  2138. if m.removedwx_agent != nil {
  2139. edges = append(edges, agentbase.EdgeWxAgent)
  2140. }
  2141. return edges
  2142. }
  2143. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2144. // the given name in this mutation.
  2145. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2146. switch name {
  2147. case agentbase.EdgeWxAgent:
  2148. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2149. for id := range m.removedwx_agent {
  2150. ids = append(ids, id)
  2151. }
  2152. return ids
  2153. }
  2154. return nil
  2155. }
  2156. // ClearedEdges returns all edge names that were cleared in this mutation.
  2157. func (m *AgentBaseMutation) ClearedEdges() []string {
  2158. edges := make([]string, 0, 1)
  2159. if m.clearedwx_agent {
  2160. edges = append(edges, agentbase.EdgeWxAgent)
  2161. }
  2162. return edges
  2163. }
  2164. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2165. // was cleared in this mutation.
  2166. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2167. switch name {
  2168. case agentbase.EdgeWxAgent:
  2169. return m.clearedwx_agent
  2170. }
  2171. return false
  2172. }
  2173. // ClearEdge clears the value of the edge with the given name. It returns an error
  2174. // if that edge is not defined in the schema.
  2175. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2176. switch name {
  2177. }
  2178. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2179. }
  2180. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2181. // It returns an error if the edge is not defined in the schema.
  2182. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2183. switch name {
  2184. case agentbase.EdgeWxAgent:
  2185. m.ResetWxAgent()
  2186. return nil
  2187. }
  2188. return fmt.Errorf("unknown AgentBase edge %s", name)
  2189. }
  2190. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2191. type AliyunAvatarMutation struct {
  2192. config
  2193. op Op
  2194. typ string
  2195. id *uint64
  2196. created_at *time.Time
  2197. updated_at *time.Time
  2198. deleted_at *time.Time
  2199. user_id *uint64
  2200. adduser_id *int64
  2201. biz_id *string
  2202. access_key_id *string
  2203. access_key_secret *string
  2204. app_id *string
  2205. tenant_id *uint64
  2206. addtenant_id *int64
  2207. response *string
  2208. token *string
  2209. session_id *string
  2210. clearedFields map[string]struct{}
  2211. done bool
  2212. oldValue func(context.Context) (*AliyunAvatar, error)
  2213. predicates []predicate.AliyunAvatar
  2214. }
  2215. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2216. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2217. type aliyunavatarOption func(*AliyunAvatarMutation)
  2218. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2219. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2220. m := &AliyunAvatarMutation{
  2221. config: c,
  2222. op: op,
  2223. typ: TypeAliyunAvatar,
  2224. clearedFields: make(map[string]struct{}),
  2225. }
  2226. for _, opt := range opts {
  2227. opt(m)
  2228. }
  2229. return m
  2230. }
  2231. // withAliyunAvatarID sets the ID field of the mutation.
  2232. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2233. return func(m *AliyunAvatarMutation) {
  2234. var (
  2235. err error
  2236. once sync.Once
  2237. value *AliyunAvatar
  2238. )
  2239. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2240. once.Do(func() {
  2241. if m.done {
  2242. err = errors.New("querying old values post mutation is not allowed")
  2243. } else {
  2244. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2245. }
  2246. })
  2247. return value, err
  2248. }
  2249. m.id = &id
  2250. }
  2251. }
  2252. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2253. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2254. return func(m *AliyunAvatarMutation) {
  2255. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2256. return node, nil
  2257. }
  2258. m.id = &node.ID
  2259. }
  2260. }
  2261. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2262. // executed in a transaction (ent.Tx), a transactional client is returned.
  2263. func (m AliyunAvatarMutation) Client() *Client {
  2264. client := &Client{config: m.config}
  2265. client.init()
  2266. return client
  2267. }
  2268. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2269. // it returns an error otherwise.
  2270. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2271. if _, ok := m.driver.(*txDriver); !ok {
  2272. return nil, errors.New("ent: mutation is not running in a transaction")
  2273. }
  2274. tx := &Tx{config: m.config}
  2275. tx.init()
  2276. return tx, nil
  2277. }
  2278. // SetID sets the value of the id field. Note that this
  2279. // operation is only accepted on creation of AliyunAvatar entities.
  2280. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2281. m.id = &id
  2282. }
  2283. // ID returns the ID value in the mutation. Note that the ID is only available
  2284. // if it was provided to the builder or after it was returned from the database.
  2285. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2286. if m.id == nil {
  2287. return
  2288. }
  2289. return *m.id, true
  2290. }
  2291. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2292. // That means, if the mutation is applied within a transaction with an isolation level such
  2293. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2294. // or updated by the mutation.
  2295. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2296. switch {
  2297. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2298. id, exists := m.ID()
  2299. if exists {
  2300. return []uint64{id}, nil
  2301. }
  2302. fallthrough
  2303. case m.op.Is(OpUpdate | OpDelete):
  2304. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2305. default:
  2306. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2307. }
  2308. }
  2309. // SetCreatedAt sets the "created_at" field.
  2310. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2311. m.created_at = &t
  2312. }
  2313. // CreatedAt returns the value of the "created_at" field in the mutation.
  2314. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2315. v := m.created_at
  2316. if v == nil {
  2317. return
  2318. }
  2319. return *v, true
  2320. }
  2321. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2322. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2324. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2325. if !m.op.Is(OpUpdateOne) {
  2326. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2327. }
  2328. if m.id == nil || m.oldValue == nil {
  2329. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2330. }
  2331. oldValue, err := m.oldValue(ctx)
  2332. if err != nil {
  2333. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2334. }
  2335. return oldValue.CreatedAt, nil
  2336. }
  2337. // ResetCreatedAt resets all changes to the "created_at" field.
  2338. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2339. m.created_at = nil
  2340. }
  2341. // SetUpdatedAt sets the "updated_at" field.
  2342. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2343. m.updated_at = &t
  2344. }
  2345. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2346. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2347. v := m.updated_at
  2348. if v == nil {
  2349. return
  2350. }
  2351. return *v, true
  2352. }
  2353. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2354. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2356. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2357. if !m.op.Is(OpUpdateOne) {
  2358. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2359. }
  2360. if m.id == nil || m.oldValue == nil {
  2361. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2362. }
  2363. oldValue, err := m.oldValue(ctx)
  2364. if err != nil {
  2365. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2366. }
  2367. return oldValue.UpdatedAt, nil
  2368. }
  2369. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2370. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2371. m.updated_at = nil
  2372. }
  2373. // SetDeletedAt sets the "deleted_at" field.
  2374. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2375. m.deleted_at = &t
  2376. }
  2377. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2378. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2379. v := m.deleted_at
  2380. if v == nil {
  2381. return
  2382. }
  2383. return *v, true
  2384. }
  2385. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2386. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2388. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2389. if !m.op.Is(OpUpdateOne) {
  2390. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2391. }
  2392. if m.id == nil || m.oldValue == nil {
  2393. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2394. }
  2395. oldValue, err := m.oldValue(ctx)
  2396. if err != nil {
  2397. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2398. }
  2399. return oldValue.DeletedAt, nil
  2400. }
  2401. // ClearDeletedAt clears the value of the "deleted_at" field.
  2402. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2403. m.deleted_at = nil
  2404. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2405. }
  2406. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2407. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2408. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2409. return ok
  2410. }
  2411. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2412. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2413. m.deleted_at = nil
  2414. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2415. }
  2416. // SetUserID sets the "user_id" field.
  2417. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2418. m.user_id = &u
  2419. m.adduser_id = nil
  2420. }
  2421. // UserID returns the value of the "user_id" field in the mutation.
  2422. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2423. v := m.user_id
  2424. if v == nil {
  2425. return
  2426. }
  2427. return *v, true
  2428. }
  2429. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2430. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2432. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2433. if !m.op.Is(OpUpdateOne) {
  2434. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2435. }
  2436. if m.id == nil || m.oldValue == nil {
  2437. return v, errors.New("OldUserID requires an ID field in the mutation")
  2438. }
  2439. oldValue, err := m.oldValue(ctx)
  2440. if err != nil {
  2441. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2442. }
  2443. return oldValue.UserID, nil
  2444. }
  2445. // AddUserID adds u to the "user_id" field.
  2446. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2447. if m.adduser_id != nil {
  2448. *m.adduser_id += u
  2449. } else {
  2450. m.adduser_id = &u
  2451. }
  2452. }
  2453. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2454. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2455. v := m.adduser_id
  2456. if v == nil {
  2457. return
  2458. }
  2459. return *v, true
  2460. }
  2461. // ResetUserID resets all changes to the "user_id" field.
  2462. func (m *AliyunAvatarMutation) ResetUserID() {
  2463. m.user_id = nil
  2464. m.adduser_id = nil
  2465. }
  2466. // SetBizID sets the "biz_id" field.
  2467. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2468. m.biz_id = &s
  2469. }
  2470. // BizID returns the value of the "biz_id" field in the mutation.
  2471. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2472. v := m.biz_id
  2473. if v == nil {
  2474. return
  2475. }
  2476. return *v, true
  2477. }
  2478. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2479. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2481. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2482. if !m.op.Is(OpUpdateOne) {
  2483. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2484. }
  2485. if m.id == nil || m.oldValue == nil {
  2486. return v, errors.New("OldBizID requires an ID field in the mutation")
  2487. }
  2488. oldValue, err := m.oldValue(ctx)
  2489. if err != nil {
  2490. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2491. }
  2492. return oldValue.BizID, nil
  2493. }
  2494. // ResetBizID resets all changes to the "biz_id" field.
  2495. func (m *AliyunAvatarMutation) ResetBizID() {
  2496. m.biz_id = nil
  2497. }
  2498. // SetAccessKeyID sets the "access_key_id" field.
  2499. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2500. m.access_key_id = &s
  2501. }
  2502. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2503. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2504. v := m.access_key_id
  2505. if v == nil {
  2506. return
  2507. }
  2508. return *v, true
  2509. }
  2510. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2511. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2512. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2513. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2514. if !m.op.Is(OpUpdateOne) {
  2515. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2516. }
  2517. if m.id == nil || m.oldValue == nil {
  2518. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2519. }
  2520. oldValue, err := m.oldValue(ctx)
  2521. if err != nil {
  2522. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2523. }
  2524. return oldValue.AccessKeyID, nil
  2525. }
  2526. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2527. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2528. m.access_key_id = nil
  2529. }
  2530. // SetAccessKeySecret sets the "access_key_secret" field.
  2531. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2532. m.access_key_secret = &s
  2533. }
  2534. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2535. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2536. v := m.access_key_secret
  2537. if v == nil {
  2538. return
  2539. }
  2540. return *v, true
  2541. }
  2542. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2543. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2544. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2545. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2546. if !m.op.Is(OpUpdateOne) {
  2547. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2548. }
  2549. if m.id == nil || m.oldValue == nil {
  2550. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2551. }
  2552. oldValue, err := m.oldValue(ctx)
  2553. if err != nil {
  2554. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2555. }
  2556. return oldValue.AccessKeySecret, nil
  2557. }
  2558. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2559. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2560. m.access_key_secret = nil
  2561. }
  2562. // SetAppID sets the "app_id" field.
  2563. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2564. m.app_id = &s
  2565. }
  2566. // AppID returns the value of the "app_id" field in the mutation.
  2567. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2568. v := m.app_id
  2569. if v == nil {
  2570. return
  2571. }
  2572. return *v, true
  2573. }
  2574. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2575. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2577. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2578. if !m.op.Is(OpUpdateOne) {
  2579. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2580. }
  2581. if m.id == nil || m.oldValue == nil {
  2582. return v, errors.New("OldAppID requires an ID field in the mutation")
  2583. }
  2584. oldValue, err := m.oldValue(ctx)
  2585. if err != nil {
  2586. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2587. }
  2588. return oldValue.AppID, nil
  2589. }
  2590. // ClearAppID clears the value of the "app_id" field.
  2591. func (m *AliyunAvatarMutation) ClearAppID() {
  2592. m.app_id = nil
  2593. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2594. }
  2595. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2596. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2597. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2598. return ok
  2599. }
  2600. // ResetAppID resets all changes to the "app_id" field.
  2601. func (m *AliyunAvatarMutation) ResetAppID() {
  2602. m.app_id = nil
  2603. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2604. }
  2605. // SetTenantID sets the "tenant_id" field.
  2606. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2607. m.tenant_id = &u
  2608. m.addtenant_id = nil
  2609. }
  2610. // TenantID returns the value of the "tenant_id" field in the mutation.
  2611. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2612. v := m.tenant_id
  2613. if v == nil {
  2614. return
  2615. }
  2616. return *v, true
  2617. }
  2618. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2619. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2621. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2622. if !m.op.Is(OpUpdateOne) {
  2623. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2624. }
  2625. if m.id == nil || m.oldValue == nil {
  2626. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2627. }
  2628. oldValue, err := m.oldValue(ctx)
  2629. if err != nil {
  2630. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2631. }
  2632. return oldValue.TenantID, nil
  2633. }
  2634. // AddTenantID adds u to the "tenant_id" field.
  2635. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2636. if m.addtenant_id != nil {
  2637. *m.addtenant_id += u
  2638. } else {
  2639. m.addtenant_id = &u
  2640. }
  2641. }
  2642. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2643. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2644. v := m.addtenant_id
  2645. if v == nil {
  2646. return
  2647. }
  2648. return *v, true
  2649. }
  2650. // ResetTenantID resets all changes to the "tenant_id" field.
  2651. func (m *AliyunAvatarMutation) ResetTenantID() {
  2652. m.tenant_id = nil
  2653. m.addtenant_id = nil
  2654. }
  2655. // SetResponse sets the "response" field.
  2656. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2657. m.response = &s
  2658. }
  2659. // Response returns the value of the "response" field in the mutation.
  2660. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2661. v := m.response
  2662. if v == nil {
  2663. return
  2664. }
  2665. return *v, true
  2666. }
  2667. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2668. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2670. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2671. if !m.op.Is(OpUpdateOne) {
  2672. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2673. }
  2674. if m.id == nil || m.oldValue == nil {
  2675. return v, errors.New("OldResponse requires an ID field in the mutation")
  2676. }
  2677. oldValue, err := m.oldValue(ctx)
  2678. if err != nil {
  2679. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2680. }
  2681. return oldValue.Response, nil
  2682. }
  2683. // ResetResponse resets all changes to the "response" field.
  2684. func (m *AliyunAvatarMutation) ResetResponse() {
  2685. m.response = nil
  2686. }
  2687. // SetToken sets the "token" field.
  2688. func (m *AliyunAvatarMutation) SetToken(s string) {
  2689. m.token = &s
  2690. }
  2691. // Token returns the value of the "token" field in the mutation.
  2692. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2693. v := m.token
  2694. if v == nil {
  2695. return
  2696. }
  2697. return *v, true
  2698. }
  2699. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2700. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2702. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2703. if !m.op.Is(OpUpdateOne) {
  2704. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2705. }
  2706. if m.id == nil || m.oldValue == nil {
  2707. return v, errors.New("OldToken requires an ID field in the mutation")
  2708. }
  2709. oldValue, err := m.oldValue(ctx)
  2710. if err != nil {
  2711. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2712. }
  2713. return oldValue.Token, nil
  2714. }
  2715. // ResetToken resets all changes to the "token" field.
  2716. func (m *AliyunAvatarMutation) ResetToken() {
  2717. m.token = nil
  2718. }
  2719. // SetSessionID sets the "session_id" field.
  2720. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2721. m.session_id = &s
  2722. }
  2723. // SessionID returns the value of the "session_id" field in the mutation.
  2724. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2725. v := m.session_id
  2726. if v == nil {
  2727. return
  2728. }
  2729. return *v, true
  2730. }
  2731. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2732. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2734. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2735. if !m.op.Is(OpUpdateOne) {
  2736. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2737. }
  2738. if m.id == nil || m.oldValue == nil {
  2739. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2740. }
  2741. oldValue, err := m.oldValue(ctx)
  2742. if err != nil {
  2743. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2744. }
  2745. return oldValue.SessionID, nil
  2746. }
  2747. // ResetSessionID resets all changes to the "session_id" field.
  2748. func (m *AliyunAvatarMutation) ResetSessionID() {
  2749. m.session_id = nil
  2750. }
  2751. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2752. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2753. m.predicates = append(m.predicates, ps...)
  2754. }
  2755. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2756. // users can use type-assertion to append predicates that do not depend on any generated package.
  2757. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2758. p := make([]predicate.AliyunAvatar, len(ps))
  2759. for i := range ps {
  2760. p[i] = ps[i]
  2761. }
  2762. m.Where(p...)
  2763. }
  2764. // Op returns the operation name.
  2765. func (m *AliyunAvatarMutation) Op() Op {
  2766. return m.op
  2767. }
  2768. // SetOp allows setting the mutation operation.
  2769. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2770. m.op = op
  2771. }
  2772. // Type returns the node type of this mutation (AliyunAvatar).
  2773. func (m *AliyunAvatarMutation) Type() string {
  2774. return m.typ
  2775. }
  2776. // Fields returns all fields that were changed during this mutation. Note that in
  2777. // order to get all numeric fields that were incremented/decremented, call
  2778. // AddedFields().
  2779. func (m *AliyunAvatarMutation) Fields() []string {
  2780. fields := make([]string, 0, 12)
  2781. if m.created_at != nil {
  2782. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2783. }
  2784. if m.updated_at != nil {
  2785. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2786. }
  2787. if m.deleted_at != nil {
  2788. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2789. }
  2790. if m.user_id != nil {
  2791. fields = append(fields, aliyunavatar.FieldUserID)
  2792. }
  2793. if m.biz_id != nil {
  2794. fields = append(fields, aliyunavatar.FieldBizID)
  2795. }
  2796. if m.access_key_id != nil {
  2797. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2798. }
  2799. if m.access_key_secret != nil {
  2800. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2801. }
  2802. if m.app_id != nil {
  2803. fields = append(fields, aliyunavatar.FieldAppID)
  2804. }
  2805. if m.tenant_id != nil {
  2806. fields = append(fields, aliyunavatar.FieldTenantID)
  2807. }
  2808. if m.response != nil {
  2809. fields = append(fields, aliyunavatar.FieldResponse)
  2810. }
  2811. if m.token != nil {
  2812. fields = append(fields, aliyunavatar.FieldToken)
  2813. }
  2814. if m.session_id != nil {
  2815. fields = append(fields, aliyunavatar.FieldSessionID)
  2816. }
  2817. return fields
  2818. }
  2819. // Field returns the value of a field with the given name. The second boolean
  2820. // return value indicates that this field was not set, or was not defined in the
  2821. // schema.
  2822. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2823. switch name {
  2824. case aliyunavatar.FieldCreatedAt:
  2825. return m.CreatedAt()
  2826. case aliyunavatar.FieldUpdatedAt:
  2827. return m.UpdatedAt()
  2828. case aliyunavatar.FieldDeletedAt:
  2829. return m.DeletedAt()
  2830. case aliyunavatar.FieldUserID:
  2831. return m.UserID()
  2832. case aliyunavatar.FieldBizID:
  2833. return m.BizID()
  2834. case aliyunavatar.FieldAccessKeyID:
  2835. return m.AccessKeyID()
  2836. case aliyunavatar.FieldAccessKeySecret:
  2837. return m.AccessKeySecret()
  2838. case aliyunavatar.FieldAppID:
  2839. return m.AppID()
  2840. case aliyunavatar.FieldTenantID:
  2841. return m.TenantID()
  2842. case aliyunavatar.FieldResponse:
  2843. return m.Response()
  2844. case aliyunavatar.FieldToken:
  2845. return m.Token()
  2846. case aliyunavatar.FieldSessionID:
  2847. return m.SessionID()
  2848. }
  2849. return nil, false
  2850. }
  2851. // OldField returns the old value of the field from the database. An error is
  2852. // returned if the mutation operation is not UpdateOne, or the query to the
  2853. // database failed.
  2854. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2855. switch name {
  2856. case aliyunavatar.FieldCreatedAt:
  2857. return m.OldCreatedAt(ctx)
  2858. case aliyunavatar.FieldUpdatedAt:
  2859. return m.OldUpdatedAt(ctx)
  2860. case aliyunavatar.FieldDeletedAt:
  2861. return m.OldDeletedAt(ctx)
  2862. case aliyunavatar.FieldUserID:
  2863. return m.OldUserID(ctx)
  2864. case aliyunavatar.FieldBizID:
  2865. return m.OldBizID(ctx)
  2866. case aliyunavatar.FieldAccessKeyID:
  2867. return m.OldAccessKeyID(ctx)
  2868. case aliyunavatar.FieldAccessKeySecret:
  2869. return m.OldAccessKeySecret(ctx)
  2870. case aliyunavatar.FieldAppID:
  2871. return m.OldAppID(ctx)
  2872. case aliyunavatar.FieldTenantID:
  2873. return m.OldTenantID(ctx)
  2874. case aliyunavatar.FieldResponse:
  2875. return m.OldResponse(ctx)
  2876. case aliyunavatar.FieldToken:
  2877. return m.OldToken(ctx)
  2878. case aliyunavatar.FieldSessionID:
  2879. return m.OldSessionID(ctx)
  2880. }
  2881. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2882. }
  2883. // SetField sets the value of a field with the given name. It returns an error if
  2884. // the field is not defined in the schema, or if the type mismatched the field
  2885. // type.
  2886. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2887. switch name {
  2888. case aliyunavatar.FieldCreatedAt:
  2889. v, ok := value.(time.Time)
  2890. if !ok {
  2891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2892. }
  2893. m.SetCreatedAt(v)
  2894. return nil
  2895. case aliyunavatar.FieldUpdatedAt:
  2896. v, ok := value.(time.Time)
  2897. if !ok {
  2898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2899. }
  2900. m.SetUpdatedAt(v)
  2901. return nil
  2902. case aliyunavatar.FieldDeletedAt:
  2903. v, ok := value.(time.Time)
  2904. if !ok {
  2905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2906. }
  2907. m.SetDeletedAt(v)
  2908. return nil
  2909. case aliyunavatar.FieldUserID:
  2910. v, ok := value.(uint64)
  2911. if !ok {
  2912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2913. }
  2914. m.SetUserID(v)
  2915. return nil
  2916. case aliyunavatar.FieldBizID:
  2917. v, ok := value.(string)
  2918. if !ok {
  2919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2920. }
  2921. m.SetBizID(v)
  2922. return nil
  2923. case aliyunavatar.FieldAccessKeyID:
  2924. v, ok := value.(string)
  2925. if !ok {
  2926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2927. }
  2928. m.SetAccessKeyID(v)
  2929. return nil
  2930. case aliyunavatar.FieldAccessKeySecret:
  2931. v, ok := value.(string)
  2932. if !ok {
  2933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2934. }
  2935. m.SetAccessKeySecret(v)
  2936. return nil
  2937. case aliyunavatar.FieldAppID:
  2938. v, ok := value.(string)
  2939. if !ok {
  2940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2941. }
  2942. m.SetAppID(v)
  2943. return nil
  2944. case aliyunavatar.FieldTenantID:
  2945. v, ok := value.(uint64)
  2946. if !ok {
  2947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2948. }
  2949. m.SetTenantID(v)
  2950. return nil
  2951. case aliyunavatar.FieldResponse:
  2952. v, ok := value.(string)
  2953. if !ok {
  2954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2955. }
  2956. m.SetResponse(v)
  2957. return nil
  2958. case aliyunavatar.FieldToken:
  2959. v, ok := value.(string)
  2960. if !ok {
  2961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2962. }
  2963. m.SetToken(v)
  2964. return nil
  2965. case aliyunavatar.FieldSessionID:
  2966. v, ok := value.(string)
  2967. if !ok {
  2968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2969. }
  2970. m.SetSessionID(v)
  2971. return nil
  2972. }
  2973. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  2974. }
  2975. // AddedFields returns all numeric fields that were incremented/decremented during
  2976. // this mutation.
  2977. func (m *AliyunAvatarMutation) AddedFields() []string {
  2978. var fields []string
  2979. if m.adduser_id != nil {
  2980. fields = append(fields, aliyunavatar.FieldUserID)
  2981. }
  2982. if m.addtenant_id != nil {
  2983. fields = append(fields, aliyunavatar.FieldTenantID)
  2984. }
  2985. return fields
  2986. }
  2987. // AddedField returns the numeric value that was incremented/decremented on a field
  2988. // with the given name. The second boolean return value indicates that this field
  2989. // was not set, or was not defined in the schema.
  2990. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  2991. switch name {
  2992. case aliyunavatar.FieldUserID:
  2993. return m.AddedUserID()
  2994. case aliyunavatar.FieldTenantID:
  2995. return m.AddedTenantID()
  2996. }
  2997. return nil, false
  2998. }
  2999. // AddField adds the value to the field with the given name. It returns an error if
  3000. // the field is not defined in the schema, or if the type mismatched the field
  3001. // type.
  3002. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3003. switch name {
  3004. case aliyunavatar.FieldUserID:
  3005. v, ok := value.(int64)
  3006. if !ok {
  3007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3008. }
  3009. m.AddUserID(v)
  3010. return nil
  3011. case aliyunavatar.FieldTenantID:
  3012. v, ok := value.(int64)
  3013. if !ok {
  3014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3015. }
  3016. m.AddTenantID(v)
  3017. return nil
  3018. }
  3019. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3020. }
  3021. // ClearedFields returns all nullable fields that were cleared during this
  3022. // mutation.
  3023. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3024. var fields []string
  3025. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3026. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3027. }
  3028. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3029. fields = append(fields, aliyunavatar.FieldAppID)
  3030. }
  3031. return fields
  3032. }
  3033. // FieldCleared returns a boolean indicating if a field with the given name was
  3034. // cleared in this mutation.
  3035. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3036. _, ok := m.clearedFields[name]
  3037. return ok
  3038. }
  3039. // ClearField clears the value of the field with the given name. It returns an
  3040. // error if the field is not defined in the schema.
  3041. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3042. switch name {
  3043. case aliyunavatar.FieldDeletedAt:
  3044. m.ClearDeletedAt()
  3045. return nil
  3046. case aliyunavatar.FieldAppID:
  3047. m.ClearAppID()
  3048. return nil
  3049. }
  3050. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3051. }
  3052. // ResetField resets all changes in the mutation for the field with the given name.
  3053. // It returns an error if the field is not defined in the schema.
  3054. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3055. switch name {
  3056. case aliyunavatar.FieldCreatedAt:
  3057. m.ResetCreatedAt()
  3058. return nil
  3059. case aliyunavatar.FieldUpdatedAt:
  3060. m.ResetUpdatedAt()
  3061. return nil
  3062. case aliyunavatar.FieldDeletedAt:
  3063. m.ResetDeletedAt()
  3064. return nil
  3065. case aliyunavatar.FieldUserID:
  3066. m.ResetUserID()
  3067. return nil
  3068. case aliyunavatar.FieldBizID:
  3069. m.ResetBizID()
  3070. return nil
  3071. case aliyunavatar.FieldAccessKeyID:
  3072. m.ResetAccessKeyID()
  3073. return nil
  3074. case aliyunavatar.FieldAccessKeySecret:
  3075. m.ResetAccessKeySecret()
  3076. return nil
  3077. case aliyunavatar.FieldAppID:
  3078. m.ResetAppID()
  3079. return nil
  3080. case aliyunavatar.FieldTenantID:
  3081. m.ResetTenantID()
  3082. return nil
  3083. case aliyunavatar.FieldResponse:
  3084. m.ResetResponse()
  3085. return nil
  3086. case aliyunavatar.FieldToken:
  3087. m.ResetToken()
  3088. return nil
  3089. case aliyunavatar.FieldSessionID:
  3090. m.ResetSessionID()
  3091. return nil
  3092. }
  3093. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3094. }
  3095. // AddedEdges returns all edge names that were set/added in this mutation.
  3096. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3097. edges := make([]string, 0, 0)
  3098. return edges
  3099. }
  3100. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3101. // name in this mutation.
  3102. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3103. return nil
  3104. }
  3105. // RemovedEdges returns all edge names that were removed in this mutation.
  3106. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3107. edges := make([]string, 0, 0)
  3108. return edges
  3109. }
  3110. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3111. // the given name in this mutation.
  3112. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3113. return nil
  3114. }
  3115. // ClearedEdges returns all edge names that were cleared in this mutation.
  3116. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3117. edges := make([]string, 0, 0)
  3118. return edges
  3119. }
  3120. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3121. // was cleared in this mutation.
  3122. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3123. return false
  3124. }
  3125. // ClearEdge clears the value of the edge with the given name. It returns an error
  3126. // if that edge is not defined in the schema.
  3127. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3128. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3129. }
  3130. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3131. // It returns an error if the edge is not defined in the schema.
  3132. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3133. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3134. }
  3135. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3136. type AllocAgentMutation struct {
  3137. config
  3138. op Op
  3139. typ string
  3140. id *uint64
  3141. created_at *time.Time
  3142. updated_at *time.Time
  3143. deleted_at *time.Time
  3144. user_id *string
  3145. organization_id *uint64
  3146. addorganization_id *int64
  3147. agents *[]uint64
  3148. appendagents []uint64
  3149. status *int
  3150. addstatus *int
  3151. clearedFields map[string]struct{}
  3152. done bool
  3153. oldValue func(context.Context) (*AllocAgent, error)
  3154. predicates []predicate.AllocAgent
  3155. }
  3156. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3157. // allocagentOption allows management of the mutation configuration using functional options.
  3158. type allocagentOption func(*AllocAgentMutation)
  3159. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3160. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3161. m := &AllocAgentMutation{
  3162. config: c,
  3163. op: op,
  3164. typ: TypeAllocAgent,
  3165. clearedFields: make(map[string]struct{}),
  3166. }
  3167. for _, opt := range opts {
  3168. opt(m)
  3169. }
  3170. return m
  3171. }
  3172. // withAllocAgentID sets the ID field of the mutation.
  3173. func withAllocAgentID(id uint64) allocagentOption {
  3174. return func(m *AllocAgentMutation) {
  3175. var (
  3176. err error
  3177. once sync.Once
  3178. value *AllocAgent
  3179. )
  3180. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3181. once.Do(func() {
  3182. if m.done {
  3183. err = errors.New("querying old values post mutation is not allowed")
  3184. } else {
  3185. value, err = m.Client().AllocAgent.Get(ctx, id)
  3186. }
  3187. })
  3188. return value, err
  3189. }
  3190. m.id = &id
  3191. }
  3192. }
  3193. // withAllocAgent sets the old AllocAgent of the mutation.
  3194. func withAllocAgent(node *AllocAgent) allocagentOption {
  3195. return func(m *AllocAgentMutation) {
  3196. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3197. return node, nil
  3198. }
  3199. m.id = &node.ID
  3200. }
  3201. }
  3202. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3203. // executed in a transaction (ent.Tx), a transactional client is returned.
  3204. func (m AllocAgentMutation) Client() *Client {
  3205. client := &Client{config: m.config}
  3206. client.init()
  3207. return client
  3208. }
  3209. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3210. // it returns an error otherwise.
  3211. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3212. if _, ok := m.driver.(*txDriver); !ok {
  3213. return nil, errors.New("ent: mutation is not running in a transaction")
  3214. }
  3215. tx := &Tx{config: m.config}
  3216. tx.init()
  3217. return tx, nil
  3218. }
  3219. // SetID sets the value of the id field. Note that this
  3220. // operation is only accepted on creation of AllocAgent entities.
  3221. func (m *AllocAgentMutation) SetID(id uint64) {
  3222. m.id = &id
  3223. }
  3224. // ID returns the ID value in the mutation. Note that the ID is only available
  3225. // if it was provided to the builder or after it was returned from the database.
  3226. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3227. if m.id == nil {
  3228. return
  3229. }
  3230. return *m.id, true
  3231. }
  3232. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3233. // That means, if the mutation is applied within a transaction with an isolation level such
  3234. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3235. // or updated by the mutation.
  3236. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3237. switch {
  3238. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3239. id, exists := m.ID()
  3240. if exists {
  3241. return []uint64{id}, nil
  3242. }
  3243. fallthrough
  3244. case m.op.Is(OpUpdate | OpDelete):
  3245. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3246. default:
  3247. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3248. }
  3249. }
  3250. // SetCreatedAt sets the "created_at" field.
  3251. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3252. m.created_at = &t
  3253. }
  3254. // CreatedAt returns the value of the "created_at" field in the mutation.
  3255. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3256. v := m.created_at
  3257. if v == nil {
  3258. return
  3259. }
  3260. return *v, true
  3261. }
  3262. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3263. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3264. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3265. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3266. if !m.op.Is(OpUpdateOne) {
  3267. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3268. }
  3269. if m.id == nil || m.oldValue == nil {
  3270. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3271. }
  3272. oldValue, err := m.oldValue(ctx)
  3273. if err != nil {
  3274. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3275. }
  3276. return oldValue.CreatedAt, nil
  3277. }
  3278. // ResetCreatedAt resets all changes to the "created_at" field.
  3279. func (m *AllocAgentMutation) ResetCreatedAt() {
  3280. m.created_at = nil
  3281. }
  3282. // SetUpdatedAt sets the "updated_at" field.
  3283. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3284. m.updated_at = &t
  3285. }
  3286. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3287. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3288. v := m.updated_at
  3289. if v == nil {
  3290. return
  3291. }
  3292. return *v, true
  3293. }
  3294. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3295. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3296. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3297. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3298. if !m.op.Is(OpUpdateOne) {
  3299. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3300. }
  3301. if m.id == nil || m.oldValue == nil {
  3302. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3303. }
  3304. oldValue, err := m.oldValue(ctx)
  3305. if err != nil {
  3306. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3307. }
  3308. return oldValue.UpdatedAt, nil
  3309. }
  3310. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3311. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3312. m.updated_at = nil
  3313. }
  3314. // SetDeletedAt sets the "deleted_at" field.
  3315. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3316. m.deleted_at = &t
  3317. }
  3318. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3319. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3320. v := m.deleted_at
  3321. if v == nil {
  3322. return
  3323. }
  3324. return *v, true
  3325. }
  3326. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3327. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3329. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3330. if !m.op.Is(OpUpdateOne) {
  3331. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3332. }
  3333. if m.id == nil || m.oldValue == nil {
  3334. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3335. }
  3336. oldValue, err := m.oldValue(ctx)
  3337. if err != nil {
  3338. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3339. }
  3340. return oldValue.DeletedAt, nil
  3341. }
  3342. // ClearDeletedAt clears the value of the "deleted_at" field.
  3343. func (m *AllocAgentMutation) ClearDeletedAt() {
  3344. m.deleted_at = nil
  3345. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3346. }
  3347. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3348. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3349. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3350. return ok
  3351. }
  3352. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3353. func (m *AllocAgentMutation) ResetDeletedAt() {
  3354. m.deleted_at = nil
  3355. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3356. }
  3357. // SetUserID sets the "user_id" field.
  3358. func (m *AllocAgentMutation) SetUserID(s string) {
  3359. m.user_id = &s
  3360. }
  3361. // UserID returns the value of the "user_id" field in the mutation.
  3362. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3363. v := m.user_id
  3364. if v == nil {
  3365. return
  3366. }
  3367. return *v, true
  3368. }
  3369. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3370. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3372. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3373. if !m.op.Is(OpUpdateOne) {
  3374. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3375. }
  3376. if m.id == nil || m.oldValue == nil {
  3377. return v, errors.New("OldUserID requires an ID field in the mutation")
  3378. }
  3379. oldValue, err := m.oldValue(ctx)
  3380. if err != nil {
  3381. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3382. }
  3383. return oldValue.UserID, nil
  3384. }
  3385. // ClearUserID clears the value of the "user_id" field.
  3386. func (m *AllocAgentMutation) ClearUserID() {
  3387. m.user_id = nil
  3388. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3389. }
  3390. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3391. func (m *AllocAgentMutation) UserIDCleared() bool {
  3392. _, ok := m.clearedFields[allocagent.FieldUserID]
  3393. return ok
  3394. }
  3395. // ResetUserID resets all changes to the "user_id" field.
  3396. func (m *AllocAgentMutation) ResetUserID() {
  3397. m.user_id = nil
  3398. delete(m.clearedFields, allocagent.FieldUserID)
  3399. }
  3400. // SetOrganizationID sets the "organization_id" field.
  3401. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3402. m.organization_id = &u
  3403. m.addorganization_id = nil
  3404. }
  3405. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3406. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3407. v := m.organization_id
  3408. if v == nil {
  3409. return
  3410. }
  3411. return *v, true
  3412. }
  3413. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3414. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3416. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3417. if !m.op.Is(OpUpdateOne) {
  3418. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3419. }
  3420. if m.id == nil || m.oldValue == nil {
  3421. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3422. }
  3423. oldValue, err := m.oldValue(ctx)
  3424. if err != nil {
  3425. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3426. }
  3427. return oldValue.OrganizationID, nil
  3428. }
  3429. // AddOrganizationID adds u to the "organization_id" field.
  3430. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3431. if m.addorganization_id != nil {
  3432. *m.addorganization_id += u
  3433. } else {
  3434. m.addorganization_id = &u
  3435. }
  3436. }
  3437. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3438. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3439. v := m.addorganization_id
  3440. if v == nil {
  3441. return
  3442. }
  3443. return *v, true
  3444. }
  3445. // ClearOrganizationID clears the value of the "organization_id" field.
  3446. func (m *AllocAgentMutation) ClearOrganizationID() {
  3447. m.organization_id = nil
  3448. m.addorganization_id = nil
  3449. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3450. }
  3451. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3452. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3453. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3454. return ok
  3455. }
  3456. // ResetOrganizationID resets all changes to the "organization_id" field.
  3457. func (m *AllocAgentMutation) ResetOrganizationID() {
  3458. m.organization_id = nil
  3459. m.addorganization_id = nil
  3460. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3461. }
  3462. // SetAgents sets the "agents" field.
  3463. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3464. m.agents = &u
  3465. m.appendagents = nil
  3466. }
  3467. // Agents returns the value of the "agents" field in the mutation.
  3468. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3469. v := m.agents
  3470. if v == nil {
  3471. return
  3472. }
  3473. return *v, true
  3474. }
  3475. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3476. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3478. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3479. if !m.op.Is(OpUpdateOne) {
  3480. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3481. }
  3482. if m.id == nil || m.oldValue == nil {
  3483. return v, errors.New("OldAgents requires an ID field in the mutation")
  3484. }
  3485. oldValue, err := m.oldValue(ctx)
  3486. if err != nil {
  3487. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3488. }
  3489. return oldValue.Agents, nil
  3490. }
  3491. // AppendAgents adds u to the "agents" field.
  3492. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3493. m.appendagents = append(m.appendagents, u...)
  3494. }
  3495. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3496. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3497. if len(m.appendagents) == 0 {
  3498. return nil, false
  3499. }
  3500. return m.appendagents, true
  3501. }
  3502. // ResetAgents resets all changes to the "agents" field.
  3503. func (m *AllocAgentMutation) ResetAgents() {
  3504. m.agents = nil
  3505. m.appendagents = nil
  3506. }
  3507. // SetStatus sets the "status" field.
  3508. func (m *AllocAgentMutation) SetStatus(i int) {
  3509. m.status = &i
  3510. m.addstatus = nil
  3511. }
  3512. // Status returns the value of the "status" field in the mutation.
  3513. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3514. v := m.status
  3515. if v == nil {
  3516. return
  3517. }
  3518. return *v, true
  3519. }
  3520. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3521. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3523. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3524. if !m.op.Is(OpUpdateOne) {
  3525. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3526. }
  3527. if m.id == nil || m.oldValue == nil {
  3528. return v, errors.New("OldStatus requires an ID field in the mutation")
  3529. }
  3530. oldValue, err := m.oldValue(ctx)
  3531. if err != nil {
  3532. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3533. }
  3534. return oldValue.Status, nil
  3535. }
  3536. // AddStatus adds i to the "status" field.
  3537. func (m *AllocAgentMutation) AddStatus(i int) {
  3538. if m.addstatus != nil {
  3539. *m.addstatus += i
  3540. } else {
  3541. m.addstatus = &i
  3542. }
  3543. }
  3544. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3545. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3546. v := m.addstatus
  3547. if v == nil {
  3548. return
  3549. }
  3550. return *v, true
  3551. }
  3552. // ClearStatus clears the value of the "status" field.
  3553. func (m *AllocAgentMutation) ClearStatus() {
  3554. m.status = nil
  3555. m.addstatus = nil
  3556. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3557. }
  3558. // StatusCleared returns if the "status" field was cleared in this mutation.
  3559. func (m *AllocAgentMutation) StatusCleared() bool {
  3560. _, ok := m.clearedFields[allocagent.FieldStatus]
  3561. return ok
  3562. }
  3563. // ResetStatus resets all changes to the "status" field.
  3564. func (m *AllocAgentMutation) ResetStatus() {
  3565. m.status = nil
  3566. m.addstatus = nil
  3567. delete(m.clearedFields, allocagent.FieldStatus)
  3568. }
  3569. // Where appends a list predicates to the AllocAgentMutation builder.
  3570. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3571. m.predicates = append(m.predicates, ps...)
  3572. }
  3573. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3574. // users can use type-assertion to append predicates that do not depend on any generated package.
  3575. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3576. p := make([]predicate.AllocAgent, len(ps))
  3577. for i := range ps {
  3578. p[i] = ps[i]
  3579. }
  3580. m.Where(p...)
  3581. }
  3582. // Op returns the operation name.
  3583. func (m *AllocAgentMutation) Op() Op {
  3584. return m.op
  3585. }
  3586. // SetOp allows setting the mutation operation.
  3587. func (m *AllocAgentMutation) SetOp(op Op) {
  3588. m.op = op
  3589. }
  3590. // Type returns the node type of this mutation (AllocAgent).
  3591. func (m *AllocAgentMutation) Type() string {
  3592. return m.typ
  3593. }
  3594. // Fields returns all fields that were changed during this mutation. Note that in
  3595. // order to get all numeric fields that were incremented/decremented, call
  3596. // AddedFields().
  3597. func (m *AllocAgentMutation) Fields() []string {
  3598. fields := make([]string, 0, 7)
  3599. if m.created_at != nil {
  3600. fields = append(fields, allocagent.FieldCreatedAt)
  3601. }
  3602. if m.updated_at != nil {
  3603. fields = append(fields, allocagent.FieldUpdatedAt)
  3604. }
  3605. if m.deleted_at != nil {
  3606. fields = append(fields, allocagent.FieldDeletedAt)
  3607. }
  3608. if m.user_id != nil {
  3609. fields = append(fields, allocagent.FieldUserID)
  3610. }
  3611. if m.organization_id != nil {
  3612. fields = append(fields, allocagent.FieldOrganizationID)
  3613. }
  3614. if m.agents != nil {
  3615. fields = append(fields, allocagent.FieldAgents)
  3616. }
  3617. if m.status != nil {
  3618. fields = append(fields, allocagent.FieldStatus)
  3619. }
  3620. return fields
  3621. }
  3622. // Field returns the value of a field with the given name. The second boolean
  3623. // return value indicates that this field was not set, or was not defined in the
  3624. // schema.
  3625. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3626. switch name {
  3627. case allocagent.FieldCreatedAt:
  3628. return m.CreatedAt()
  3629. case allocagent.FieldUpdatedAt:
  3630. return m.UpdatedAt()
  3631. case allocagent.FieldDeletedAt:
  3632. return m.DeletedAt()
  3633. case allocagent.FieldUserID:
  3634. return m.UserID()
  3635. case allocagent.FieldOrganizationID:
  3636. return m.OrganizationID()
  3637. case allocagent.FieldAgents:
  3638. return m.Agents()
  3639. case allocagent.FieldStatus:
  3640. return m.Status()
  3641. }
  3642. return nil, false
  3643. }
  3644. // OldField returns the old value of the field from the database. An error is
  3645. // returned if the mutation operation is not UpdateOne, or the query to the
  3646. // database failed.
  3647. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3648. switch name {
  3649. case allocagent.FieldCreatedAt:
  3650. return m.OldCreatedAt(ctx)
  3651. case allocagent.FieldUpdatedAt:
  3652. return m.OldUpdatedAt(ctx)
  3653. case allocagent.FieldDeletedAt:
  3654. return m.OldDeletedAt(ctx)
  3655. case allocagent.FieldUserID:
  3656. return m.OldUserID(ctx)
  3657. case allocagent.FieldOrganizationID:
  3658. return m.OldOrganizationID(ctx)
  3659. case allocagent.FieldAgents:
  3660. return m.OldAgents(ctx)
  3661. case allocagent.FieldStatus:
  3662. return m.OldStatus(ctx)
  3663. }
  3664. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3665. }
  3666. // SetField sets the value of a field with the given name. It returns an error if
  3667. // the field is not defined in the schema, or if the type mismatched the field
  3668. // type.
  3669. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3670. switch name {
  3671. case allocagent.FieldCreatedAt:
  3672. v, ok := value.(time.Time)
  3673. if !ok {
  3674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3675. }
  3676. m.SetCreatedAt(v)
  3677. return nil
  3678. case allocagent.FieldUpdatedAt:
  3679. v, ok := value.(time.Time)
  3680. if !ok {
  3681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3682. }
  3683. m.SetUpdatedAt(v)
  3684. return nil
  3685. case allocagent.FieldDeletedAt:
  3686. v, ok := value.(time.Time)
  3687. if !ok {
  3688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3689. }
  3690. m.SetDeletedAt(v)
  3691. return nil
  3692. case allocagent.FieldUserID:
  3693. v, ok := value.(string)
  3694. if !ok {
  3695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3696. }
  3697. m.SetUserID(v)
  3698. return nil
  3699. case allocagent.FieldOrganizationID:
  3700. v, ok := value.(uint64)
  3701. if !ok {
  3702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3703. }
  3704. m.SetOrganizationID(v)
  3705. return nil
  3706. case allocagent.FieldAgents:
  3707. v, ok := value.([]uint64)
  3708. if !ok {
  3709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3710. }
  3711. m.SetAgents(v)
  3712. return nil
  3713. case allocagent.FieldStatus:
  3714. v, ok := value.(int)
  3715. if !ok {
  3716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3717. }
  3718. m.SetStatus(v)
  3719. return nil
  3720. }
  3721. return fmt.Errorf("unknown AllocAgent field %s", name)
  3722. }
  3723. // AddedFields returns all numeric fields that were incremented/decremented during
  3724. // this mutation.
  3725. func (m *AllocAgentMutation) AddedFields() []string {
  3726. var fields []string
  3727. if m.addorganization_id != nil {
  3728. fields = append(fields, allocagent.FieldOrganizationID)
  3729. }
  3730. if m.addstatus != nil {
  3731. fields = append(fields, allocagent.FieldStatus)
  3732. }
  3733. return fields
  3734. }
  3735. // AddedField returns the numeric value that was incremented/decremented on a field
  3736. // with the given name. The second boolean return value indicates that this field
  3737. // was not set, or was not defined in the schema.
  3738. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3739. switch name {
  3740. case allocagent.FieldOrganizationID:
  3741. return m.AddedOrganizationID()
  3742. case allocagent.FieldStatus:
  3743. return m.AddedStatus()
  3744. }
  3745. return nil, false
  3746. }
  3747. // AddField adds the value to the field with the given name. It returns an error if
  3748. // the field is not defined in the schema, or if the type mismatched the field
  3749. // type.
  3750. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3751. switch name {
  3752. case allocagent.FieldOrganizationID:
  3753. v, ok := value.(int64)
  3754. if !ok {
  3755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3756. }
  3757. m.AddOrganizationID(v)
  3758. return nil
  3759. case allocagent.FieldStatus:
  3760. v, ok := value.(int)
  3761. if !ok {
  3762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3763. }
  3764. m.AddStatus(v)
  3765. return nil
  3766. }
  3767. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  3768. }
  3769. // ClearedFields returns all nullable fields that were cleared during this
  3770. // mutation.
  3771. func (m *AllocAgentMutation) ClearedFields() []string {
  3772. var fields []string
  3773. if m.FieldCleared(allocagent.FieldDeletedAt) {
  3774. fields = append(fields, allocagent.FieldDeletedAt)
  3775. }
  3776. if m.FieldCleared(allocagent.FieldUserID) {
  3777. fields = append(fields, allocagent.FieldUserID)
  3778. }
  3779. if m.FieldCleared(allocagent.FieldOrganizationID) {
  3780. fields = append(fields, allocagent.FieldOrganizationID)
  3781. }
  3782. if m.FieldCleared(allocagent.FieldStatus) {
  3783. fields = append(fields, allocagent.FieldStatus)
  3784. }
  3785. return fields
  3786. }
  3787. // FieldCleared returns a boolean indicating if a field with the given name was
  3788. // cleared in this mutation.
  3789. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  3790. _, ok := m.clearedFields[name]
  3791. return ok
  3792. }
  3793. // ClearField clears the value of the field with the given name. It returns an
  3794. // error if the field is not defined in the schema.
  3795. func (m *AllocAgentMutation) ClearField(name string) error {
  3796. switch name {
  3797. case allocagent.FieldDeletedAt:
  3798. m.ClearDeletedAt()
  3799. return nil
  3800. case allocagent.FieldUserID:
  3801. m.ClearUserID()
  3802. return nil
  3803. case allocagent.FieldOrganizationID:
  3804. m.ClearOrganizationID()
  3805. return nil
  3806. case allocagent.FieldStatus:
  3807. m.ClearStatus()
  3808. return nil
  3809. }
  3810. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  3811. }
  3812. // ResetField resets all changes in the mutation for the field with the given name.
  3813. // It returns an error if the field is not defined in the schema.
  3814. func (m *AllocAgentMutation) ResetField(name string) error {
  3815. switch name {
  3816. case allocagent.FieldCreatedAt:
  3817. m.ResetCreatedAt()
  3818. return nil
  3819. case allocagent.FieldUpdatedAt:
  3820. m.ResetUpdatedAt()
  3821. return nil
  3822. case allocagent.FieldDeletedAt:
  3823. m.ResetDeletedAt()
  3824. return nil
  3825. case allocagent.FieldUserID:
  3826. m.ResetUserID()
  3827. return nil
  3828. case allocagent.FieldOrganizationID:
  3829. m.ResetOrganizationID()
  3830. return nil
  3831. case allocagent.FieldAgents:
  3832. m.ResetAgents()
  3833. return nil
  3834. case allocagent.FieldStatus:
  3835. m.ResetStatus()
  3836. return nil
  3837. }
  3838. return fmt.Errorf("unknown AllocAgent field %s", name)
  3839. }
  3840. // AddedEdges returns all edge names that were set/added in this mutation.
  3841. func (m *AllocAgentMutation) AddedEdges() []string {
  3842. edges := make([]string, 0, 0)
  3843. return edges
  3844. }
  3845. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3846. // name in this mutation.
  3847. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  3848. return nil
  3849. }
  3850. // RemovedEdges returns all edge names that were removed in this mutation.
  3851. func (m *AllocAgentMutation) RemovedEdges() []string {
  3852. edges := make([]string, 0, 0)
  3853. return edges
  3854. }
  3855. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3856. // the given name in this mutation.
  3857. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  3858. return nil
  3859. }
  3860. // ClearedEdges returns all edge names that were cleared in this mutation.
  3861. func (m *AllocAgentMutation) ClearedEdges() []string {
  3862. edges := make([]string, 0, 0)
  3863. return edges
  3864. }
  3865. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3866. // was cleared in this mutation.
  3867. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  3868. return false
  3869. }
  3870. // ClearEdge clears the value of the edge with the given name. It returns an error
  3871. // if that edge is not defined in the schema.
  3872. func (m *AllocAgentMutation) ClearEdge(name string) error {
  3873. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  3874. }
  3875. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3876. // It returns an error if the edge is not defined in the schema.
  3877. func (m *AllocAgentMutation) ResetEdge(name string) error {
  3878. return fmt.Errorf("unknown AllocAgent edge %s", name)
  3879. }
  3880. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3881. type BatchMsgMutation struct {
  3882. config
  3883. op Op
  3884. typ string
  3885. id *uint64
  3886. created_at *time.Time
  3887. updated_at *time.Time
  3888. deleted_at *time.Time
  3889. status *uint8
  3890. addstatus *int8
  3891. batch_no *string
  3892. task_name *string
  3893. fromwxid *string
  3894. msg *string
  3895. tag *string
  3896. tagids *string
  3897. total *int32
  3898. addtotal *int32
  3899. success *int32
  3900. addsuccess *int32
  3901. fail *int32
  3902. addfail *int32
  3903. start_time *time.Time
  3904. stop_time *time.Time
  3905. send_time *time.Time
  3906. _type *int32
  3907. add_type *int32
  3908. organization_id *uint64
  3909. addorganization_id *int64
  3910. clearedFields map[string]struct{}
  3911. done bool
  3912. oldValue func(context.Context) (*BatchMsg, error)
  3913. predicates []predicate.BatchMsg
  3914. }
  3915. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  3916. // batchmsgOption allows management of the mutation configuration using functional options.
  3917. type batchmsgOption func(*BatchMsgMutation)
  3918. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  3919. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  3920. m := &BatchMsgMutation{
  3921. config: c,
  3922. op: op,
  3923. typ: TypeBatchMsg,
  3924. clearedFields: make(map[string]struct{}),
  3925. }
  3926. for _, opt := range opts {
  3927. opt(m)
  3928. }
  3929. return m
  3930. }
  3931. // withBatchMsgID sets the ID field of the mutation.
  3932. func withBatchMsgID(id uint64) batchmsgOption {
  3933. return func(m *BatchMsgMutation) {
  3934. var (
  3935. err error
  3936. once sync.Once
  3937. value *BatchMsg
  3938. )
  3939. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  3940. once.Do(func() {
  3941. if m.done {
  3942. err = errors.New("querying old values post mutation is not allowed")
  3943. } else {
  3944. value, err = m.Client().BatchMsg.Get(ctx, id)
  3945. }
  3946. })
  3947. return value, err
  3948. }
  3949. m.id = &id
  3950. }
  3951. }
  3952. // withBatchMsg sets the old BatchMsg of the mutation.
  3953. func withBatchMsg(node *BatchMsg) batchmsgOption {
  3954. return func(m *BatchMsgMutation) {
  3955. m.oldValue = func(context.Context) (*BatchMsg, error) {
  3956. return node, nil
  3957. }
  3958. m.id = &node.ID
  3959. }
  3960. }
  3961. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3962. // executed in a transaction (ent.Tx), a transactional client is returned.
  3963. func (m BatchMsgMutation) Client() *Client {
  3964. client := &Client{config: m.config}
  3965. client.init()
  3966. return client
  3967. }
  3968. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3969. // it returns an error otherwise.
  3970. func (m BatchMsgMutation) Tx() (*Tx, error) {
  3971. if _, ok := m.driver.(*txDriver); !ok {
  3972. return nil, errors.New("ent: mutation is not running in a transaction")
  3973. }
  3974. tx := &Tx{config: m.config}
  3975. tx.init()
  3976. return tx, nil
  3977. }
  3978. // SetID sets the value of the id field. Note that this
  3979. // operation is only accepted on creation of BatchMsg entities.
  3980. func (m *BatchMsgMutation) SetID(id uint64) {
  3981. m.id = &id
  3982. }
  3983. // ID returns the ID value in the mutation. Note that the ID is only available
  3984. // if it was provided to the builder or after it was returned from the database.
  3985. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  3986. if m.id == nil {
  3987. return
  3988. }
  3989. return *m.id, true
  3990. }
  3991. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3992. // That means, if the mutation is applied within a transaction with an isolation level such
  3993. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3994. // or updated by the mutation.
  3995. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  3996. switch {
  3997. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3998. id, exists := m.ID()
  3999. if exists {
  4000. return []uint64{id}, nil
  4001. }
  4002. fallthrough
  4003. case m.op.Is(OpUpdate | OpDelete):
  4004. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  4005. default:
  4006. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4007. }
  4008. }
  4009. // SetCreatedAt sets the "created_at" field.
  4010. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  4011. m.created_at = &t
  4012. }
  4013. // CreatedAt returns the value of the "created_at" field in the mutation.
  4014. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  4015. v := m.created_at
  4016. if v == nil {
  4017. return
  4018. }
  4019. return *v, true
  4020. }
  4021. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  4022. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4023. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4024. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4025. if !m.op.Is(OpUpdateOne) {
  4026. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4027. }
  4028. if m.id == nil || m.oldValue == nil {
  4029. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4030. }
  4031. oldValue, err := m.oldValue(ctx)
  4032. if err != nil {
  4033. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4034. }
  4035. return oldValue.CreatedAt, nil
  4036. }
  4037. // ResetCreatedAt resets all changes to the "created_at" field.
  4038. func (m *BatchMsgMutation) ResetCreatedAt() {
  4039. m.created_at = nil
  4040. }
  4041. // SetUpdatedAt sets the "updated_at" field.
  4042. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  4043. m.updated_at = &t
  4044. }
  4045. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4046. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  4047. v := m.updated_at
  4048. if v == nil {
  4049. return
  4050. }
  4051. return *v, true
  4052. }
  4053. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  4054. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4056. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4057. if !m.op.Is(OpUpdateOne) {
  4058. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4059. }
  4060. if m.id == nil || m.oldValue == nil {
  4061. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4062. }
  4063. oldValue, err := m.oldValue(ctx)
  4064. if err != nil {
  4065. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4066. }
  4067. return oldValue.UpdatedAt, nil
  4068. }
  4069. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4070. func (m *BatchMsgMutation) ResetUpdatedAt() {
  4071. m.updated_at = nil
  4072. }
  4073. // SetDeletedAt sets the "deleted_at" field.
  4074. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  4075. m.deleted_at = &t
  4076. }
  4077. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4078. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  4079. v := m.deleted_at
  4080. if v == nil {
  4081. return
  4082. }
  4083. return *v, true
  4084. }
  4085. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  4086. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4088. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4089. if !m.op.Is(OpUpdateOne) {
  4090. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4091. }
  4092. if m.id == nil || m.oldValue == nil {
  4093. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4094. }
  4095. oldValue, err := m.oldValue(ctx)
  4096. if err != nil {
  4097. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4098. }
  4099. return oldValue.DeletedAt, nil
  4100. }
  4101. // ClearDeletedAt clears the value of the "deleted_at" field.
  4102. func (m *BatchMsgMutation) ClearDeletedAt() {
  4103. m.deleted_at = nil
  4104. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  4105. }
  4106. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4107. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  4108. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  4109. return ok
  4110. }
  4111. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4112. func (m *BatchMsgMutation) ResetDeletedAt() {
  4113. m.deleted_at = nil
  4114. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  4115. }
  4116. // SetStatus sets the "status" field.
  4117. func (m *BatchMsgMutation) SetStatus(u uint8) {
  4118. m.status = &u
  4119. m.addstatus = nil
  4120. }
  4121. // Status returns the value of the "status" field in the mutation.
  4122. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  4123. v := m.status
  4124. if v == nil {
  4125. return
  4126. }
  4127. return *v, true
  4128. }
  4129. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  4130. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4132. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4133. if !m.op.Is(OpUpdateOne) {
  4134. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4135. }
  4136. if m.id == nil || m.oldValue == nil {
  4137. return v, errors.New("OldStatus requires an ID field in the mutation")
  4138. }
  4139. oldValue, err := m.oldValue(ctx)
  4140. if err != nil {
  4141. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4142. }
  4143. return oldValue.Status, nil
  4144. }
  4145. // AddStatus adds u to the "status" field.
  4146. func (m *BatchMsgMutation) AddStatus(u int8) {
  4147. if m.addstatus != nil {
  4148. *m.addstatus += u
  4149. } else {
  4150. m.addstatus = &u
  4151. }
  4152. }
  4153. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4154. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  4155. v := m.addstatus
  4156. if v == nil {
  4157. return
  4158. }
  4159. return *v, true
  4160. }
  4161. // ClearStatus clears the value of the "status" field.
  4162. func (m *BatchMsgMutation) ClearStatus() {
  4163. m.status = nil
  4164. m.addstatus = nil
  4165. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  4166. }
  4167. // StatusCleared returns if the "status" field was cleared in this mutation.
  4168. func (m *BatchMsgMutation) StatusCleared() bool {
  4169. _, ok := m.clearedFields[batchmsg.FieldStatus]
  4170. return ok
  4171. }
  4172. // ResetStatus resets all changes to the "status" field.
  4173. func (m *BatchMsgMutation) ResetStatus() {
  4174. m.status = nil
  4175. m.addstatus = nil
  4176. delete(m.clearedFields, batchmsg.FieldStatus)
  4177. }
  4178. // SetBatchNo sets the "batch_no" field.
  4179. func (m *BatchMsgMutation) SetBatchNo(s string) {
  4180. m.batch_no = &s
  4181. }
  4182. // BatchNo returns the value of the "batch_no" field in the mutation.
  4183. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  4184. v := m.batch_no
  4185. if v == nil {
  4186. return
  4187. }
  4188. return *v, true
  4189. }
  4190. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  4191. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4193. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  4194. if !m.op.Is(OpUpdateOne) {
  4195. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  4196. }
  4197. if m.id == nil || m.oldValue == nil {
  4198. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  4199. }
  4200. oldValue, err := m.oldValue(ctx)
  4201. if err != nil {
  4202. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  4203. }
  4204. return oldValue.BatchNo, nil
  4205. }
  4206. // ClearBatchNo clears the value of the "batch_no" field.
  4207. func (m *BatchMsgMutation) ClearBatchNo() {
  4208. m.batch_no = nil
  4209. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  4210. }
  4211. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  4212. func (m *BatchMsgMutation) BatchNoCleared() bool {
  4213. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  4214. return ok
  4215. }
  4216. // ResetBatchNo resets all changes to the "batch_no" field.
  4217. func (m *BatchMsgMutation) ResetBatchNo() {
  4218. m.batch_no = nil
  4219. delete(m.clearedFields, batchmsg.FieldBatchNo)
  4220. }
  4221. // SetTaskName sets the "task_name" field.
  4222. func (m *BatchMsgMutation) SetTaskName(s string) {
  4223. m.task_name = &s
  4224. }
  4225. // TaskName returns the value of the "task_name" field in the mutation.
  4226. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  4227. v := m.task_name
  4228. if v == nil {
  4229. return
  4230. }
  4231. return *v, true
  4232. }
  4233. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  4234. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4236. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  4237. if !m.op.Is(OpUpdateOne) {
  4238. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  4239. }
  4240. if m.id == nil || m.oldValue == nil {
  4241. return v, errors.New("OldTaskName requires an ID field in the mutation")
  4242. }
  4243. oldValue, err := m.oldValue(ctx)
  4244. if err != nil {
  4245. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  4246. }
  4247. return oldValue.TaskName, nil
  4248. }
  4249. // ClearTaskName clears the value of the "task_name" field.
  4250. func (m *BatchMsgMutation) ClearTaskName() {
  4251. m.task_name = nil
  4252. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  4253. }
  4254. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  4255. func (m *BatchMsgMutation) TaskNameCleared() bool {
  4256. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  4257. return ok
  4258. }
  4259. // ResetTaskName resets all changes to the "task_name" field.
  4260. func (m *BatchMsgMutation) ResetTaskName() {
  4261. m.task_name = nil
  4262. delete(m.clearedFields, batchmsg.FieldTaskName)
  4263. }
  4264. // SetFromwxid sets the "fromwxid" field.
  4265. func (m *BatchMsgMutation) SetFromwxid(s string) {
  4266. m.fromwxid = &s
  4267. }
  4268. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  4269. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  4270. v := m.fromwxid
  4271. if v == nil {
  4272. return
  4273. }
  4274. return *v, true
  4275. }
  4276. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  4277. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4278. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4279. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  4280. if !m.op.Is(OpUpdateOne) {
  4281. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  4282. }
  4283. if m.id == nil || m.oldValue == nil {
  4284. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  4285. }
  4286. oldValue, err := m.oldValue(ctx)
  4287. if err != nil {
  4288. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  4289. }
  4290. return oldValue.Fromwxid, nil
  4291. }
  4292. // ClearFromwxid clears the value of the "fromwxid" field.
  4293. func (m *BatchMsgMutation) ClearFromwxid() {
  4294. m.fromwxid = nil
  4295. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  4296. }
  4297. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  4298. func (m *BatchMsgMutation) FromwxidCleared() bool {
  4299. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  4300. return ok
  4301. }
  4302. // ResetFromwxid resets all changes to the "fromwxid" field.
  4303. func (m *BatchMsgMutation) ResetFromwxid() {
  4304. m.fromwxid = nil
  4305. delete(m.clearedFields, batchmsg.FieldFromwxid)
  4306. }
  4307. // SetMsg sets the "msg" field.
  4308. func (m *BatchMsgMutation) SetMsg(s string) {
  4309. m.msg = &s
  4310. }
  4311. // Msg returns the value of the "msg" field in the mutation.
  4312. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  4313. v := m.msg
  4314. if v == nil {
  4315. return
  4316. }
  4317. return *v, true
  4318. }
  4319. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  4320. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4322. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  4323. if !m.op.Is(OpUpdateOne) {
  4324. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  4325. }
  4326. if m.id == nil || m.oldValue == nil {
  4327. return v, errors.New("OldMsg requires an ID field in the mutation")
  4328. }
  4329. oldValue, err := m.oldValue(ctx)
  4330. if err != nil {
  4331. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  4332. }
  4333. return oldValue.Msg, nil
  4334. }
  4335. // ClearMsg clears the value of the "msg" field.
  4336. func (m *BatchMsgMutation) ClearMsg() {
  4337. m.msg = nil
  4338. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  4339. }
  4340. // MsgCleared returns if the "msg" field was cleared in this mutation.
  4341. func (m *BatchMsgMutation) MsgCleared() bool {
  4342. _, ok := m.clearedFields[batchmsg.FieldMsg]
  4343. return ok
  4344. }
  4345. // ResetMsg resets all changes to the "msg" field.
  4346. func (m *BatchMsgMutation) ResetMsg() {
  4347. m.msg = nil
  4348. delete(m.clearedFields, batchmsg.FieldMsg)
  4349. }
  4350. // SetTag sets the "tag" field.
  4351. func (m *BatchMsgMutation) SetTag(s string) {
  4352. m.tag = &s
  4353. }
  4354. // Tag returns the value of the "tag" field in the mutation.
  4355. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  4356. v := m.tag
  4357. if v == nil {
  4358. return
  4359. }
  4360. return *v, true
  4361. }
  4362. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  4363. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4365. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  4366. if !m.op.Is(OpUpdateOne) {
  4367. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  4368. }
  4369. if m.id == nil || m.oldValue == nil {
  4370. return v, errors.New("OldTag requires an ID field in the mutation")
  4371. }
  4372. oldValue, err := m.oldValue(ctx)
  4373. if err != nil {
  4374. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  4375. }
  4376. return oldValue.Tag, nil
  4377. }
  4378. // ClearTag clears the value of the "tag" field.
  4379. func (m *BatchMsgMutation) ClearTag() {
  4380. m.tag = nil
  4381. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  4382. }
  4383. // TagCleared returns if the "tag" field was cleared in this mutation.
  4384. func (m *BatchMsgMutation) TagCleared() bool {
  4385. _, ok := m.clearedFields[batchmsg.FieldTag]
  4386. return ok
  4387. }
  4388. // ResetTag resets all changes to the "tag" field.
  4389. func (m *BatchMsgMutation) ResetTag() {
  4390. m.tag = nil
  4391. delete(m.clearedFields, batchmsg.FieldTag)
  4392. }
  4393. // SetTagids sets the "tagids" field.
  4394. func (m *BatchMsgMutation) SetTagids(s string) {
  4395. m.tagids = &s
  4396. }
  4397. // Tagids returns the value of the "tagids" field in the mutation.
  4398. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  4399. v := m.tagids
  4400. if v == nil {
  4401. return
  4402. }
  4403. return *v, true
  4404. }
  4405. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  4406. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4408. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  4409. if !m.op.Is(OpUpdateOne) {
  4410. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  4411. }
  4412. if m.id == nil || m.oldValue == nil {
  4413. return v, errors.New("OldTagids requires an ID field in the mutation")
  4414. }
  4415. oldValue, err := m.oldValue(ctx)
  4416. if err != nil {
  4417. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  4418. }
  4419. return oldValue.Tagids, nil
  4420. }
  4421. // ClearTagids clears the value of the "tagids" field.
  4422. func (m *BatchMsgMutation) ClearTagids() {
  4423. m.tagids = nil
  4424. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  4425. }
  4426. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  4427. func (m *BatchMsgMutation) TagidsCleared() bool {
  4428. _, ok := m.clearedFields[batchmsg.FieldTagids]
  4429. return ok
  4430. }
  4431. // ResetTagids resets all changes to the "tagids" field.
  4432. func (m *BatchMsgMutation) ResetTagids() {
  4433. m.tagids = nil
  4434. delete(m.clearedFields, batchmsg.FieldTagids)
  4435. }
  4436. // SetTotal sets the "total" field.
  4437. func (m *BatchMsgMutation) SetTotal(i int32) {
  4438. m.total = &i
  4439. m.addtotal = nil
  4440. }
  4441. // Total returns the value of the "total" field in the mutation.
  4442. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  4443. v := m.total
  4444. if v == nil {
  4445. return
  4446. }
  4447. return *v, true
  4448. }
  4449. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  4450. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4452. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  4453. if !m.op.Is(OpUpdateOne) {
  4454. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  4455. }
  4456. if m.id == nil || m.oldValue == nil {
  4457. return v, errors.New("OldTotal requires an ID field in the mutation")
  4458. }
  4459. oldValue, err := m.oldValue(ctx)
  4460. if err != nil {
  4461. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  4462. }
  4463. return oldValue.Total, nil
  4464. }
  4465. // AddTotal adds i to the "total" field.
  4466. func (m *BatchMsgMutation) AddTotal(i int32) {
  4467. if m.addtotal != nil {
  4468. *m.addtotal += i
  4469. } else {
  4470. m.addtotal = &i
  4471. }
  4472. }
  4473. // AddedTotal returns the value that was added to the "total" field in this mutation.
  4474. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  4475. v := m.addtotal
  4476. if v == nil {
  4477. return
  4478. }
  4479. return *v, true
  4480. }
  4481. // ClearTotal clears the value of the "total" field.
  4482. func (m *BatchMsgMutation) ClearTotal() {
  4483. m.total = nil
  4484. m.addtotal = nil
  4485. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  4486. }
  4487. // TotalCleared returns if the "total" field was cleared in this mutation.
  4488. func (m *BatchMsgMutation) TotalCleared() bool {
  4489. _, ok := m.clearedFields[batchmsg.FieldTotal]
  4490. return ok
  4491. }
  4492. // ResetTotal resets all changes to the "total" field.
  4493. func (m *BatchMsgMutation) ResetTotal() {
  4494. m.total = nil
  4495. m.addtotal = nil
  4496. delete(m.clearedFields, batchmsg.FieldTotal)
  4497. }
  4498. // SetSuccess sets the "success" field.
  4499. func (m *BatchMsgMutation) SetSuccess(i int32) {
  4500. m.success = &i
  4501. m.addsuccess = nil
  4502. }
  4503. // Success returns the value of the "success" field in the mutation.
  4504. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  4505. v := m.success
  4506. if v == nil {
  4507. return
  4508. }
  4509. return *v, true
  4510. }
  4511. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  4512. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4514. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  4515. if !m.op.Is(OpUpdateOne) {
  4516. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  4517. }
  4518. if m.id == nil || m.oldValue == nil {
  4519. return v, errors.New("OldSuccess requires an ID field in the mutation")
  4520. }
  4521. oldValue, err := m.oldValue(ctx)
  4522. if err != nil {
  4523. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  4524. }
  4525. return oldValue.Success, nil
  4526. }
  4527. // AddSuccess adds i to the "success" field.
  4528. func (m *BatchMsgMutation) AddSuccess(i int32) {
  4529. if m.addsuccess != nil {
  4530. *m.addsuccess += i
  4531. } else {
  4532. m.addsuccess = &i
  4533. }
  4534. }
  4535. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  4536. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  4537. v := m.addsuccess
  4538. if v == nil {
  4539. return
  4540. }
  4541. return *v, true
  4542. }
  4543. // ClearSuccess clears the value of the "success" field.
  4544. func (m *BatchMsgMutation) ClearSuccess() {
  4545. m.success = nil
  4546. m.addsuccess = nil
  4547. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  4548. }
  4549. // SuccessCleared returns if the "success" field was cleared in this mutation.
  4550. func (m *BatchMsgMutation) SuccessCleared() bool {
  4551. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  4552. return ok
  4553. }
  4554. // ResetSuccess resets all changes to the "success" field.
  4555. func (m *BatchMsgMutation) ResetSuccess() {
  4556. m.success = nil
  4557. m.addsuccess = nil
  4558. delete(m.clearedFields, batchmsg.FieldSuccess)
  4559. }
  4560. // SetFail sets the "fail" field.
  4561. func (m *BatchMsgMutation) SetFail(i int32) {
  4562. m.fail = &i
  4563. m.addfail = nil
  4564. }
  4565. // Fail returns the value of the "fail" field in the mutation.
  4566. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  4567. v := m.fail
  4568. if v == nil {
  4569. return
  4570. }
  4571. return *v, true
  4572. }
  4573. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  4574. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4576. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  4577. if !m.op.Is(OpUpdateOne) {
  4578. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  4579. }
  4580. if m.id == nil || m.oldValue == nil {
  4581. return v, errors.New("OldFail requires an ID field in the mutation")
  4582. }
  4583. oldValue, err := m.oldValue(ctx)
  4584. if err != nil {
  4585. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  4586. }
  4587. return oldValue.Fail, nil
  4588. }
  4589. // AddFail adds i to the "fail" field.
  4590. func (m *BatchMsgMutation) AddFail(i int32) {
  4591. if m.addfail != nil {
  4592. *m.addfail += i
  4593. } else {
  4594. m.addfail = &i
  4595. }
  4596. }
  4597. // AddedFail returns the value that was added to the "fail" field in this mutation.
  4598. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  4599. v := m.addfail
  4600. if v == nil {
  4601. return
  4602. }
  4603. return *v, true
  4604. }
  4605. // ClearFail clears the value of the "fail" field.
  4606. func (m *BatchMsgMutation) ClearFail() {
  4607. m.fail = nil
  4608. m.addfail = nil
  4609. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  4610. }
  4611. // FailCleared returns if the "fail" field was cleared in this mutation.
  4612. func (m *BatchMsgMutation) FailCleared() bool {
  4613. _, ok := m.clearedFields[batchmsg.FieldFail]
  4614. return ok
  4615. }
  4616. // ResetFail resets all changes to the "fail" field.
  4617. func (m *BatchMsgMutation) ResetFail() {
  4618. m.fail = nil
  4619. m.addfail = nil
  4620. delete(m.clearedFields, batchmsg.FieldFail)
  4621. }
  4622. // SetStartTime sets the "start_time" field.
  4623. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  4624. m.start_time = &t
  4625. }
  4626. // StartTime returns the value of the "start_time" field in the mutation.
  4627. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  4628. v := m.start_time
  4629. if v == nil {
  4630. return
  4631. }
  4632. return *v, true
  4633. }
  4634. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  4635. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4637. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  4638. if !m.op.Is(OpUpdateOne) {
  4639. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  4640. }
  4641. if m.id == nil || m.oldValue == nil {
  4642. return v, errors.New("OldStartTime requires an ID field in the mutation")
  4643. }
  4644. oldValue, err := m.oldValue(ctx)
  4645. if err != nil {
  4646. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  4647. }
  4648. return oldValue.StartTime, nil
  4649. }
  4650. // ClearStartTime clears the value of the "start_time" field.
  4651. func (m *BatchMsgMutation) ClearStartTime() {
  4652. m.start_time = nil
  4653. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  4654. }
  4655. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  4656. func (m *BatchMsgMutation) StartTimeCleared() bool {
  4657. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  4658. return ok
  4659. }
  4660. // ResetStartTime resets all changes to the "start_time" field.
  4661. func (m *BatchMsgMutation) ResetStartTime() {
  4662. m.start_time = nil
  4663. delete(m.clearedFields, batchmsg.FieldStartTime)
  4664. }
  4665. // SetStopTime sets the "stop_time" field.
  4666. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  4667. m.stop_time = &t
  4668. }
  4669. // StopTime returns the value of the "stop_time" field in the mutation.
  4670. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  4671. v := m.stop_time
  4672. if v == nil {
  4673. return
  4674. }
  4675. return *v, true
  4676. }
  4677. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  4678. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4680. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  4681. if !m.op.Is(OpUpdateOne) {
  4682. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  4683. }
  4684. if m.id == nil || m.oldValue == nil {
  4685. return v, errors.New("OldStopTime requires an ID field in the mutation")
  4686. }
  4687. oldValue, err := m.oldValue(ctx)
  4688. if err != nil {
  4689. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  4690. }
  4691. return oldValue.StopTime, nil
  4692. }
  4693. // ClearStopTime clears the value of the "stop_time" field.
  4694. func (m *BatchMsgMutation) ClearStopTime() {
  4695. m.stop_time = nil
  4696. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  4697. }
  4698. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  4699. func (m *BatchMsgMutation) StopTimeCleared() bool {
  4700. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  4701. return ok
  4702. }
  4703. // ResetStopTime resets all changes to the "stop_time" field.
  4704. func (m *BatchMsgMutation) ResetStopTime() {
  4705. m.stop_time = nil
  4706. delete(m.clearedFields, batchmsg.FieldStopTime)
  4707. }
  4708. // SetSendTime sets the "send_time" field.
  4709. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  4710. m.send_time = &t
  4711. }
  4712. // SendTime returns the value of the "send_time" field in the mutation.
  4713. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  4714. v := m.send_time
  4715. if v == nil {
  4716. return
  4717. }
  4718. return *v, true
  4719. }
  4720. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  4721. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4723. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  4724. if !m.op.Is(OpUpdateOne) {
  4725. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  4726. }
  4727. if m.id == nil || m.oldValue == nil {
  4728. return v, errors.New("OldSendTime requires an ID field in the mutation")
  4729. }
  4730. oldValue, err := m.oldValue(ctx)
  4731. if err != nil {
  4732. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  4733. }
  4734. return oldValue.SendTime, nil
  4735. }
  4736. // ClearSendTime clears the value of the "send_time" field.
  4737. func (m *BatchMsgMutation) ClearSendTime() {
  4738. m.send_time = nil
  4739. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  4740. }
  4741. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  4742. func (m *BatchMsgMutation) SendTimeCleared() bool {
  4743. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  4744. return ok
  4745. }
  4746. // ResetSendTime resets all changes to the "send_time" field.
  4747. func (m *BatchMsgMutation) ResetSendTime() {
  4748. m.send_time = nil
  4749. delete(m.clearedFields, batchmsg.FieldSendTime)
  4750. }
  4751. // SetType sets the "type" field.
  4752. func (m *BatchMsgMutation) SetType(i int32) {
  4753. m._type = &i
  4754. m.add_type = nil
  4755. }
  4756. // GetType returns the value of the "type" field in the mutation.
  4757. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  4758. v := m._type
  4759. if v == nil {
  4760. return
  4761. }
  4762. return *v, true
  4763. }
  4764. // OldType returns the old "type" field's value of the BatchMsg entity.
  4765. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4767. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  4768. if !m.op.Is(OpUpdateOne) {
  4769. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4770. }
  4771. if m.id == nil || m.oldValue == nil {
  4772. return v, errors.New("OldType requires an ID field in the mutation")
  4773. }
  4774. oldValue, err := m.oldValue(ctx)
  4775. if err != nil {
  4776. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4777. }
  4778. return oldValue.Type, nil
  4779. }
  4780. // AddType adds i to the "type" field.
  4781. func (m *BatchMsgMutation) AddType(i int32) {
  4782. if m.add_type != nil {
  4783. *m.add_type += i
  4784. } else {
  4785. m.add_type = &i
  4786. }
  4787. }
  4788. // AddedType returns the value that was added to the "type" field in this mutation.
  4789. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4790. v := m.add_type
  4791. if v == nil {
  4792. return
  4793. }
  4794. return *v, true
  4795. }
  4796. // ClearType clears the value of the "type" field.
  4797. func (m *BatchMsgMutation) ClearType() {
  4798. m._type = nil
  4799. m.add_type = nil
  4800. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4801. }
  4802. // TypeCleared returns if the "type" field was cleared in this mutation.
  4803. func (m *BatchMsgMutation) TypeCleared() bool {
  4804. _, ok := m.clearedFields[batchmsg.FieldType]
  4805. return ok
  4806. }
  4807. // ResetType resets all changes to the "type" field.
  4808. func (m *BatchMsgMutation) ResetType() {
  4809. m._type = nil
  4810. m.add_type = nil
  4811. delete(m.clearedFields, batchmsg.FieldType)
  4812. }
  4813. // SetOrganizationID sets the "organization_id" field.
  4814. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4815. m.organization_id = &u
  4816. m.addorganization_id = nil
  4817. }
  4818. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4819. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4820. v := m.organization_id
  4821. if v == nil {
  4822. return
  4823. }
  4824. return *v, true
  4825. }
  4826. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4827. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4829. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4830. if !m.op.Is(OpUpdateOne) {
  4831. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4832. }
  4833. if m.id == nil || m.oldValue == nil {
  4834. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4835. }
  4836. oldValue, err := m.oldValue(ctx)
  4837. if err != nil {
  4838. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4839. }
  4840. return oldValue.OrganizationID, nil
  4841. }
  4842. // AddOrganizationID adds u to the "organization_id" field.
  4843. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4844. if m.addorganization_id != nil {
  4845. *m.addorganization_id += u
  4846. } else {
  4847. m.addorganization_id = &u
  4848. }
  4849. }
  4850. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4851. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4852. v := m.addorganization_id
  4853. if v == nil {
  4854. return
  4855. }
  4856. return *v, true
  4857. }
  4858. // ResetOrganizationID resets all changes to the "organization_id" field.
  4859. func (m *BatchMsgMutation) ResetOrganizationID() {
  4860. m.organization_id = nil
  4861. m.addorganization_id = nil
  4862. }
  4863. // Where appends a list predicates to the BatchMsgMutation builder.
  4864. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  4865. m.predicates = append(m.predicates, ps...)
  4866. }
  4867. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  4868. // users can use type-assertion to append predicates that do not depend on any generated package.
  4869. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  4870. p := make([]predicate.BatchMsg, len(ps))
  4871. for i := range ps {
  4872. p[i] = ps[i]
  4873. }
  4874. m.Where(p...)
  4875. }
  4876. // Op returns the operation name.
  4877. func (m *BatchMsgMutation) Op() Op {
  4878. return m.op
  4879. }
  4880. // SetOp allows setting the mutation operation.
  4881. func (m *BatchMsgMutation) SetOp(op Op) {
  4882. m.op = op
  4883. }
  4884. // Type returns the node type of this mutation (BatchMsg).
  4885. func (m *BatchMsgMutation) Type() string {
  4886. return m.typ
  4887. }
  4888. // Fields returns all fields that were changed during this mutation. Note that in
  4889. // order to get all numeric fields that were incremented/decremented, call
  4890. // AddedFields().
  4891. func (m *BatchMsgMutation) Fields() []string {
  4892. fields := make([]string, 0, 18)
  4893. if m.created_at != nil {
  4894. fields = append(fields, batchmsg.FieldCreatedAt)
  4895. }
  4896. if m.updated_at != nil {
  4897. fields = append(fields, batchmsg.FieldUpdatedAt)
  4898. }
  4899. if m.deleted_at != nil {
  4900. fields = append(fields, batchmsg.FieldDeletedAt)
  4901. }
  4902. if m.status != nil {
  4903. fields = append(fields, batchmsg.FieldStatus)
  4904. }
  4905. if m.batch_no != nil {
  4906. fields = append(fields, batchmsg.FieldBatchNo)
  4907. }
  4908. if m.task_name != nil {
  4909. fields = append(fields, batchmsg.FieldTaskName)
  4910. }
  4911. if m.fromwxid != nil {
  4912. fields = append(fields, batchmsg.FieldFromwxid)
  4913. }
  4914. if m.msg != nil {
  4915. fields = append(fields, batchmsg.FieldMsg)
  4916. }
  4917. if m.tag != nil {
  4918. fields = append(fields, batchmsg.FieldTag)
  4919. }
  4920. if m.tagids != nil {
  4921. fields = append(fields, batchmsg.FieldTagids)
  4922. }
  4923. if m.total != nil {
  4924. fields = append(fields, batchmsg.FieldTotal)
  4925. }
  4926. if m.success != nil {
  4927. fields = append(fields, batchmsg.FieldSuccess)
  4928. }
  4929. if m.fail != nil {
  4930. fields = append(fields, batchmsg.FieldFail)
  4931. }
  4932. if m.start_time != nil {
  4933. fields = append(fields, batchmsg.FieldStartTime)
  4934. }
  4935. if m.stop_time != nil {
  4936. fields = append(fields, batchmsg.FieldStopTime)
  4937. }
  4938. if m.send_time != nil {
  4939. fields = append(fields, batchmsg.FieldSendTime)
  4940. }
  4941. if m._type != nil {
  4942. fields = append(fields, batchmsg.FieldType)
  4943. }
  4944. if m.organization_id != nil {
  4945. fields = append(fields, batchmsg.FieldOrganizationID)
  4946. }
  4947. return fields
  4948. }
  4949. // Field returns the value of a field with the given name. The second boolean
  4950. // return value indicates that this field was not set, or was not defined in the
  4951. // schema.
  4952. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  4953. switch name {
  4954. case batchmsg.FieldCreatedAt:
  4955. return m.CreatedAt()
  4956. case batchmsg.FieldUpdatedAt:
  4957. return m.UpdatedAt()
  4958. case batchmsg.FieldDeletedAt:
  4959. return m.DeletedAt()
  4960. case batchmsg.FieldStatus:
  4961. return m.Status()
  4962. case batchmsg.FieldBatchNo:
  4963. return m.BatchNo()
  4964. case batchmsg.FieldTaskName:
  4965. return m.TaskName()
  4966. case batchmsg.FieldFromwxid:
  4967. return m.Fromwxid()
  4968. case batchmsg.FieldMsg:
  4969. return m.Msg()
  4970. case batchmsg.FieldTag:
  4971. return m.Tag()
  4972. case batchmsg.FieldTagids:
  4973. return m.Tagids()
  4974. case batchmsg.FieldTotal:
  4975. return m.Total()
  4976. case batchmsg.FieldSuccess:
  4977. return m.Success()
  4978. case batchmsg.FieldFail:
  4979. return m.Fail()
  4980. case batchmsg.FieldStartTime:
  4981. return m.StartTime()
  4982. case batchmsg.FieldStopTime:
  4983. return m.StopTime()
  4984. case batchmsg.FieldSendTime:
  4985. return m.SendTime()
  4986. case batchmsg.FieldType:
  4987. return m.GetType()
  4988. case batchmsg.FieldOrganizationID:
  4989. return m.OrganizationID()
  4990. }
  4991. return nil, false
  4992. }
  4993. // OldField returns the old value of the field from the database. An error is
  4994. // returned if the mutation operation is not UpdateOne, or the query to the
  4995. // database failed.
  4996. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4997. switch name {
  4998. case batchmsg.FieldCreatedAt:
  4999. return m.OldCreatedAt(ctx)
  5000. case batchmsg.FieldUpdatedAt:
  5001. return m.OldUpdatedAt(ctx)
  5002. case batchmsg.FieldDeletedAt:
  5003. return m.OldDeletedAt(ctx)
  5004. case batchmsg.FieldStatus:
  5005. return m.OldStatus(ctx)
  5006. case batchmsg.FieldBatchNo:
  5007. return m.OldBatchNo(ctx)
  5008. case batchmsg.FieldTaskName:
  5009. return m.OldTaskName(ctx)
  5010. case batchmsg.FieldFromwxid:
  5011. return m.OldFromwxid(ctx)
  5012. case batchmsg.FieldMsg:
  5013. return m.OldMsg(ctx)
  5014. case batchmsg.FieldTag:
  5015. return m.OldTag(ctx)
  5016. case batchmsg.FieldTagids:
  5017. return m.OldTagids(ctx)
  5018. case batchmsg.FieldTotal:
  5019. return m.OldTotal(ctx)
  5020. case batchmsg.FieldSuccess:
  5021. return m.OldSuccess(ctx)
  5022. case batchmsg.FieldFail:
  5023. return m.OldFail(ctx)
  5024. case batchmsg.FieldStartTime:
  5025. return m.OldStartTime(ctx)
  5026. case batchmsg.FieldStopTime:
  5027. return m.OldStopTime(ctx)
  5028. case batchmsg.FieldSendTime:
  5029. return m.OldSendTime(ctx)
  5030. case batchmsg.FieldType:
  5031. return m.OldType(ctx)
  5032. case batchmsg.FieldOrganizationID:
  5033. return m.OldOrganizationID(ctx)
  5034. }
  5035. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  5036. }
  5037. // SetField sets the value of a field with the given name. It returns an error if
  5038. // the field is not defined in the schema, or if the type mismatched the field
  5039. // type.
  5040. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  5041. switch name {
  5042. case batchmsg.FieldCreatedAt:
  5043. v, ok := value.(time.Time)
  5044. if !ok {
  5045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5046. }
  5047. m.SetCreatedAt(v)
  5048. return nil
  5049. case batchmsg.FieldUpdatedAt:
  5050. v, ok := value.(time.Time)
  5051. if !ok {
  5052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5053. }
  5054. m.SetUpdatedAt(v)
  5055. return nil
  5056. case batchmsg.FieldDeletedAt:
  5057. v, ok := value.(time.Time)
  5058. if !ok {
  5059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5060. }
  5061. m.SetDeletedAt(v)
  5062. return nil
  5063. case batchmsg.FieldStatus:
  5064. v, ok := value.(uint8)
  5065. if !ok {
  5066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5067. }
  5068. m.SetStatus(v)
  5069. return nil
  5070. case batchmsg.FieldBatchNo:
  5071. v, ok := value.(string)
  5072. if !ok {
  5073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5074. }
  5075. m.SetBatchNo(v)
  5076. return nil
  5077. case batchmsg.FieldTaskName:
  5078. v, ok := value.(string)
  5079. if !ok {
  5080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5081. }
  5082. m.SetTaskName(v)
  5083. return nil
  5084. case batchmsg.FieldFromwxid:
  5085. v, ok := value.(string)
  5086. if !ok {
  5087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5088. }
  5089. m.SetFromwxid(v)
  5090. return nil
  5091. case batchmsg.FieldMsg:
  5092. v, ok := value.(string)
  5093. if !ok {
  5094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5095. }
  5096. m.SetMsg(v)
  5097. return nil
  5098. case batchmsg.FieldTag:
  5099. v, ok := value.(string)
  5100. if !ok {
  5101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5102. }
  5103. m.SetTag(v)
  5104. return nil
  5105. case batchmsg.FieldTagids:
  5106. v, ok := value.(string)
  5107. if !ok {
  5108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5109. }
  5110. m.SetTagids(v)
  5111. return nil
  5112. case batchmsg.FieldTotal:
  5113. v, ok := value.(int32)
  5114. if !ok {
  5115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5116. }
  5117. m.SetTotal(v)
  5118. return nil
  5119. case batchmsg.FieldSuccess:
  5120. v, ok := value.(int32)
  5121. if !ok {
  5122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5123. }
  5124. m.SetSuccess(v)
  5125. return nil
  5126. case batchmsg.FieldFail:
  5127. v, ok := value.(int32)
  5128. if !ok {
  5129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5130. }
  5131. m.SetFail(v)
  5132. return nil
  5133. case batchmsg.FieldStartTime:
  5134. v, ok := value.(time.Time)
  5135. if !ok {
  5136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5137. }
  5138. m.SetStartTime(v)
  5139. return nil
  5140. case batchmsg.FieldStopTime:
  5141. v, ok := value.(time.Time)
  5142. if !ok {
  5143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5144. }
  5145. m.SetStopTime(v)
  5146. return nil
  5147. case batchmsg.FieldSendTime:
  5148. v, ok := value.(time.Time)
  5149. if !ok {
  5150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5151. }
  5152. m.SetSendTime(v)
  5153. return nil
  5154. case batchmsg.FieldType:
  5155. v, ok := value.(int32)
  5156. if !ok {
  5157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5158. }
  5159. m.SetType(v)
  5160. return nil
  5161. case batchmsg.FieldOrganizationID:
  5162. v, ok := value.(uint64)
  5163. if !ok {
  5164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5165. }
  5166. m.SetOrganizationID(v)
  5167. return nil
  5168. }
  5169. return fmt.Errorf("unknown BatchMsg field %s", name)
  5170. }
  5171. // AddedFields returns all numeric fields that were incremented/decremented during
  5172. // this mutation.
  5173. func (m *BatchMsgMutation) AddedFields() []string {
  5174. var fields []string
  5175. if m.addstatus != nil {
  5176. fields = append(fields, batchmsg.FieldStatus)
  5177. }
  5178. if m.addtotal != nil {
  5179. fields = append(fields, batchmsg.FieldTotal)
  5180. }
  5181. if m.addsuccess != nil {
  5182. fields = append(fields, batchmsg.FieldSuccess)
  5183. }
  5184. if m.addfail != nil {
  5185. fields = append(fields, batchmsg.FieldFail)
  5186. }
  5187. if m.add_type != nil {
  5188. fields = append(fields, batchmsg.FieldType)
  5189. }
  5190. if m.addorganization_id != nil {
  5191. fields = append(fields, batchmsg.FieldOrganizationID)
  5192. }
  5193. return fields
  5194. }
  5195. // AddedField returns the numeric value that was incremented/decremented on a field
  5196. // with the given name. The second boolean return value indicates that this field
  5197. // was not set, or was not defined in the schema.
  5198. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  5199. switch name {
  5200. case batchmsg.FieldStatus:
  5201. return m.AddedStatus()
  5202. case batchmsg.FieldTotal:
  5203. return m.AddedTotal()
  5204. case batchmsg.FieldSuccess:
  5205. return m.AddedSuccess()
  5206. case batchmsg.FieldFail:
  5207. return m.AddedFail()
  5208. case batchmsg.FieldType:
  5209. return m.AddedType()
  5210. case batchmsg.FieldOrganizationID:
  5211. return m.AddedOrganizationID()
  5212. }
  5213. return nil, false
  5214. }
  5215. // AddField adds the value to the field with the given name. It returns an error if
  5216. // the field is not defined in the schema, or if the type mismatched the field
  5217. // type.
  5218. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  5219. switch name {
  5220. case batchmsg.FieldStatus:
  5221. v, ok := value.(int8)
  5222. if !ok {
  5223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5224. }
  5225. m.AddStatus(v)
  5226. return nil
  5227. case batchmsg.FieldTotal:
  5228. v, ok := value.(int32)
  5229. if !ok {
  5230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5231. }
  5232. m.AddTotal(v)
  5233. return nil
  5234. case batchmsg.FieldSuccess:
  5235. v, ok := value.(int32)
  5236. if !ok {
  5237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5238. }
  5239. m.AddSuccess(v)
  5240. return nil
  5241. case batchmsg.FieldFail:
  5242. v, ok := value.(int32)
  5243. if !ok {
  5244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5245. }
  5246. m.AddFail(v)
  5247. return nil
  5248. case batchmsg.FieldType:
  5249. v, ok := value.(int32)
  5250. if !ok {
  5251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5252. }
  5253. m.AddType(v)
  5254. return nil
  5255. case batchmsg.FieldOrganizationID:
  5256. v, ok := value.(int64)
  5257. if !ok {
  5258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5259. }
  5260. m.AddOrganizationID(v)
  5261. return nil
  5262. }
  5263. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  5264. }
  5265. // ClearedFields returns all nullable fields that were cleared during this
  5266. // mutation.
  5267. func (m *BatchMsgMutation) ClearedFields() []string {
  5268. var fields []string
  5269. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  5270. fields = append(fields, batchmsg.FieldDeletedAt)
  5271. }
  5272. if m.FieldCleared(batchmsg.FieldStatus) {
  5273. fields = append(fields, batchmsg.FieldStatus)
  5274. }
  5275. if m.FieldCleared(batchmsg.FieldBatchNo) {
  5276. fields = append(fields, batchmsg.FieldBatchNo)
  5277. }
  5278. if m.FieldCleared(batchmsg.FieldTaskName) {
  5279. fields = append(fields, batchmsg.FieldTaskName)
  5280. }
  5281. if m.FieldCleared(batchmsg.FieldFromwxid) {
  5282. fields = append(fields, batchmsg.FieldFromwxid)
  5283. }
  5284. if m.FieldCleared(batchmsg.FieldMsg) {
  5285. fields = append(fields, batchmsg.FieldMsg)
  5286. }
  5287. if m.FieldCleared(batchmsg.FieldTag) {
  5288. fields = append(fields, batchmsg.FieldTag)
  5289. }
  5290. if m.FieldCleared(batchmsg.FieldTagids) {
  5291. fields = append(fields, batchmsg.FieldTagids)
  5292. }
  5293. if m.FieldCleared(batchmsg.FieldTotal) {
  5294. fields = append(fields, batchmsg.FieldTotal)
  5295. }
  5296. if m.FieldCleared(batchmsg.FieldSuccess) {
  5297. fields = append(fields, batchmsg.FieldSuccess)
  5298. }
  5299. if m.FieldCleared(batchmsg.FieldFail) {
  5300. fields = append(fields, batchmsg.FieldFail)
  5301. }
  5302. if m.FieldCleared(batchmsg.FieldStartTime) {
  5303. fields = append(fields, batchmsg.FieldStartTime)
  5304. }
  5305. if m.FieldCleared(batchmsg.FieldStopTime) {
  5306. fields = append(fields, batchmsg.FieldStopTime)
  5307. }
  5308. if m.FieldCleared(batchmsg.FieldSendTime) {
  5309. fields = append(fields, batchmsg.FieldSendTime)
  5310. }
  5311. if m.FieldCleared(batchmsg.FieldType) {
  5312. fields = append(fields, batchmsg.FieldType)
  5313. }
  5314. return fields
  5315. }
  5316. // FieldCleared returns a boolean indicating if a field with the given name was
  5317. // cleared in this mutation.
  5318. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  5319. _, ok := m.clearedFields[name]
  5320. return ok
  5321. }
  5322. // ClearField clears the value of the field with the given name. It returns an
  5323. // error if the field is not defined in the schema.
  5324. func (m *BatchMsgMutation) ClearField(name string) error {
  5325. switch name {
  5326. case batchmsg.FieldDeletedAt:
  5327. m.ClearDeletedAt()
  5328. return nil
  5329. case batchmsg.FieldStatus:
  5330. m.ClearStatus()
  5331. return nil
  5332. case batchmsg.FieldBatchNo:
  5333. m.ClearBatchNo()
  5334. return nil
  5335. case batchmsg.FieldTaskName:
  5336. m.ClearTaskName()
  5337. return nil
  5338. case batchmsg.FieldFromwxid:
  5339. m.ClearFromwxid()
  5340. return nil
  5341. case batchmsg.FieldMsg:
  5342. m.ClearMsg()
  5343. return nil
  5344. case batchmsg.FieldTag:
  5345. m.ClearTag()
  5346. return nil
  5347. case batchmsg.FieldTagids:
  5348. m.ClearTagids()
  5349. return nil
  5350. case batchmsg.FieldTotal:
  5351. m.ClearTotal()
  5352. return nil
  5353. case batchmsg.FieldSuccess:
  5354. m.ClearSuccess()
  5355. return nil
  5356. case batchmsg.FieldFail:
  5357. m.ClearFail()
  5358. return nil
  5359. case batchmsg.FieldStartTime:
  5360. m.ClearStartTime()
  5361. return nil
  5362. case batchmsg.FieldStopTime:
  5363. m.ClearStopTime()
  5364. return nil
  5365. case batchmsg.FieldSendTime:
  5366. m.ClearSendTime()
  5367. return nil
  5368. case batchmsg.FieldType:
  5369. m.ClearType()
  5370. return nil
  5371. }
  5372. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  5373. }
  5374. // ResetField resets all changes in the mutation for the field with the given name.
  5375. // It returns an error if the field is not defined in the schema.
  5376. func (m *BatchMsgMutation) ResetField(name string) error {
  5377. switch name {
  5378. case batchmsg.FieldCreatedAt:
  5379. m.ResetCreatedAt()
  5380. return nil
  5381. case batchmsg.FieldUpdatedAt:
  5382. m.ResetUpdatedAt()
  5383. return nil
  5384. case batchmsg.FieldDeletedAt:
  5385. m.ResetDeletedAt()
  5386. return nil
  5387. case batchmsg.FieldStatus:
  5388. m.ResetStatus()
  5389. return nil
  5390. case batchmsg.FieldBatchNo:
  5391. m.ResetBatchNo()
  5392. return nil
  5393. case batchmsg.FieldTaskName:
  5394. m.ResetTaskName()
  5395. return nil
  5396. case batchmsg.FieldFromwxid:
  5397. m.ResetFromwxid()
  5398. return nil
  5399. case batchmsg.FieldMsg:
  5400. m.ResetMsg()
  5401. return nil
  5402. case batchmsg.FieldTag:
  5403. m.ResetTag()
  5404. return nil
  5405. case batchmsg.FieldTagids:
  5406. m.ResetTagids()
  5407. return nil
  5408. case batchmsg.FieldTotal:
  5409. m.ResetTotal()
  5410. return nil
  5411. case batchmsg.FieldSuccess:
  5412. m.ResetSuccess()
  5413. return nil
  5414. case batchmsg.FieldFail:
  5415. m.ResetFail()
  5416. return nil
  5417. case batchmsg.FieldStartTime:
  5418. m.ResetStartTime()
  5419. return nil
  5420. case batchmsg.FieldStopTime:
  5421. m.ResetStopTime()
  5422. return nil
  5423. case batchmsg.FieldSendTime:
  5424. m.ResetSendTime()
  5425. return nil
  5426. case batchmsg.FieldType:
  5427. m.ResetType()
  5428. return nil
  5429. case batchmsg.FieldOrganizationID:
  5430. m.ResetOrganizationID()
  5431. return nil
  5432. }
  5433. return fmt.Errorf("unknown BatchMsg field %s", name)
  5434. }
  5435. // AddedEdges returns all edge names that were set/added in this mutation.
  5436. func (m *BatchMsgMutation) AddedEdges() []string {
  5437. edges := make([]string, 0, 0)
  5438. return edges
  5439. }
  5440. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5441. // name in this mutation.
  5442. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  5443. return nil
  5444. }
  5445. // RemovedEdges returns all edge names that were removed in this mutation.
  5446. func (m *BatchMsgMutation) RemovedEdges() []string {
  5447. edges := make([]string, 0, 0)
  5448. return edges
  5449. }
  5450. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5451. // the given name in this mutation.
  5452. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  5453. return nil
  5454. }
  5455. // ClearedEdges returns all edge names that were cleared in this mutation.
  5456. func (m *BatchMsgMutation) ClearedEdges() []string {
  5457. edges := make([]string, 0, 0)
  5458. return edges
  5459. }
  5460. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5461. // was cleared in this mutation.
  5462. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  5463. return false
  5464. }
  5465. // ClearEdge clears the value of the edge with the given name. It returns an error
  5466. // if that edge is not defined in the schema.
  5467. func (m *BatchMsgMutation) ClearEdge(name string) error {
  5468. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  5469. }
  5470. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5471. // It returns an error if the edge is not defined in the schema.
  5472. func (m *BatchMsgMutation) ResetEdge(name string) error {
  5473. return fmt.Errorf("unknown BatchMsg edge %s", name)
  5474. }
  5475. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  5476. type CategoryMutation struct {
  5477. config
  5478. op Op
  5479. typ string
  5480. id *uint64
  5481. created_at *time.Time
  5482. updated_at *time.Time
  5483. deleted_at *time.Time
  5484. name *string
  5485. organization_id *uint64
  5486. addorganization_id *int64
  5487. clearedFields map[string]struct{}
  5488. done bool
  5489. oldValue func(context.Context) (*Category, error)
  5490. predicates []predicate.Category
  5491. }
  5492. var _ ent.Mutation = (*CategoryMutation)(nil)
  5493. // categoryOption allows management of the mutation configuration using functional options.
  5494. type categoryOption func(*CategoryMutation)
  5495. // newCategoryMutation creates new mutation for the Category entity.
  5496. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  5497. m := &CategoryMutation{
  5498. config: c,
  5499. op: op,
  5500. typ: TypeCategory,
  5501. clearedFields: make(map[string]struct{}),
  5502. }
  5503. for _, opt := range opts {
  5504. opt(m)
  5505. }
  5506. return m
  5507. }
  5508. // withCategoryID sets the ID field of the mutation.
  5509. func withCategoryID(id uint64) categoryOption {
  5510. return func(m *CategoryMutation) {
  5511. var (
  5512. err error
  5513. once sync.Once
  5514. value *Category
  5515. )
  5516. m.oldValue = func(ctx context.Context) (*Category, error) {
  5517. once.Do(func() {
  5518. if m.done {
  5519. err = errors.New("querying old values post mutation is not allowed")
  5520. } else {
  5521. value, err = m.Client().Category.Get(ctx, id)
  5522. }
  5523. })
  5524. return value, err
  5525. }
  5526. m.id = &id
  5527. }
  5528. }
  5529. // withCategory sets the old Category of the mutation.
  5530. func withCategory(node *Category) categoryOption {
  5531. return func(m *CategoryMutation) {
  5532. m.oldValue = func(context.Context) (*Category, error) {
  5533. return node, nil
  5534. }
  5535. m.id = &node.ID
  5536. }
  5537. }
  5538. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5539. // executed in a transaction (ent.Tx), a transactional client is returned.
  5540. func (m CategoryMutation) Client() *Client {
  5541. client := &Client{config: m.config}
  5542. client.init()
  5543. return client
  5544. }
  5545. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5546. // it returns an error otherwise.
  5547. func (m CategoryMutation) Tx() (*Tx, error) {
  5548. if _, ok := m.driver.(*txDriver); !ok {
  5549. return nil, errors.New("ent: mutation is not running in a transaction")
  5550. }
  5551. tx := &Tx{config: m.config}
  5552. tx.init()
  5553. return tx, nil
  5554. }
  5555. // SetID sets the value of the id field. Note that this
  5556. // operation is only accepted on creation of Category entities.
  5557. func (m *CategoryMutation) SetID(id uint64) {
  5558. m.id = &id
  5559. }
  5560. // ID returns the ID value in the mutation. Note that the ID is only available
  5561. // if it was provided to the builder or after it was returned from the database.
  5562. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  5563. if m.id == nil {
  5564. return
  5565. }
  5566. return *m.id, true
  5567. }
  5568. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5569. // That means, if the mutation is applied within a transaction with an isolation level such
  5570. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5571. // or updated by the mutation.
  5572. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  5573. switch {
  5574. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5575. id, exists := m.ID()
  5576. if exists {
  5577. return []uint64{id}, nil
  5578. }
  5579. fallthrough
  5580. case m.op.Is(OpUpdate | OpDelete):
  5581. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  5582. default:
  5583. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5584. }
  5585. }
  5586. // SetCreatedAt sets the "created_at" field.
  5587. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  5588. m.created_at = &t
  5589. }
  5590. // CreatedAt returns the value of the "created_at" field in the mutation.
  5591. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  5592. v := m.created_at
  5593. if v == nil {
  5594. return
  5595. }
  5596. return *v, true
  5597. }
  5598. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  5599. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5601. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5602. if !m.op.Is(OpUpdateOne) {
  5603. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5604. }
  5605. if m.id == nil || m.oldValue == nil {
  5606. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5607. }
  5608. oldValue, err := m.oldValue(ctx)
  5609. if err != nil {
  5610. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5611. }
  5612. return oldValue.CreatedAt, nil
  5613. }
  5614. // ResetCreatedAt resets all changes to the "created_at" field.
  5615. func (m *CategoryMutation) ResetCreatedAt() {
  5616. m.created_at = nil
  5617. }
  5618. // SetUpdatedAt sets the "updated_at" field.
  5619. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  5620. m.updated_at = &t
  5621. }
  5622. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5623. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  5624. v := m.updated_at
  5625. if v == nil {
  5626. return
  5627. }
  5628. return *v, true
  5629. }
  5630. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  5631. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5633. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5634. if !m.op.Is(OpUpdateOne) {
  5635. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5636. }
  5637. if m.id == nil || m.oldValue == nil {
  5638. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5639. }
  5640. oldValue, err := m.oldValue(ctx)
  5641. if err != nil {
  5642. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5643. }
  5644. return oldValue.UpdatedAt, nil
  5645. }
  5646. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5647. func (m *CategoryMutation) ResetUpdatedAt() {
  5648. m.updated_at = nil
  5649. }
  5650. // SetDeletedAt sets the "deleted_at" field.
  5651. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  5652. m.deleted_at = &t
  5653. }
  5654. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5655. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  5656. v := m.deleted_at
  5657. if v == nil {
  5658. return
  5659. }
  5660. return *v, true
  5661. }
  5662. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  5663. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5665. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5666. if !m.op.Is(OpUpdateOne) {
  5667. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5668. }
  5669. if m.id == nil || m.oldValue == nil {
  5670. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5671. }
  5672. oldValue, err := m.oldValue(ctx)
  5673. if err != nil {
  5674. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5675. }
  5676. return oldValue.DeletedAt, nil
  5677. }
  5678. // ClearDeletedAt clears the value of the "deleted_at" field.
  5679. func (m *CategoryMutation) ClearDeletedAt() {
  5680. m.deleted_at = nil
  5681. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  5682. }
  5683. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5684. func (m *CategoryMutation) DeletedAtCleared() bool {
  5685. _, ok := m.clearedFields[category.FieldDeletedAt]
  5686. return ok
  5687. }
  5688. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5689. func (m *CategoryMutation) ResetDeletedAt() {
  5690. m.deleted_at = nil
  5691. delete(m.clearedFields, category.FieldDeletedAt)
  5692. }
  5693. // SetName sets the "name" field.
  5694. func (m *CategoryMutation) SetName(s string) {
  5695. m.name = &s
  5696. }
  5697. // Name returns the value of the "name" field in the mutation.
  5698. func (m *CategoryMutation) Name() (r string, exists bool) {
  5699. v := m.name
  5700. if v == nil {
  5701. return
  5702. }
  5703. return *v, true
  5704. }
  5705. // OldName returns the old "name" field's value of the Category entity.
  5706. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5708. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  5709. if !m.op.Is(OpUpdateOne) {
  5710. return v, errors.New("OldName is only allowed on UpdateOne operations")
  5711. }
  5712. if m.id == nil || m.oldValue == nil {
  5713. return v, errors.New("OldName requires an ID field in the mutation")
  5714. }
  5715. oldValue, err := m.oldValue(ctx)
  5716. if err != nil {
  5717. return v, fmt.Errorf("querying old value for OldName: %w", err)
  5718. }
  5719. return oldValue.Name, nil
  5720. }
  5721. // ResetName resets all changes to the "name" field.
  5722. func (m *CategoryMutation) ResetName() {
  5723. m.name = nil
  5724. }
  5725. // SetOrganizationID sets the "organization_id" field.
  5726. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  5727. m.organization_id = &u
  5728. m.addorganization_id = nil
  5729. }
  5730. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5731. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  5732. v := m.organization_id
  5733. if v == nil {
  5734. return
  5735. }
  5736. return *v, true
  5737. }
  5738. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  5739. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5741. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5742. if !m.op.Is(OpUpdateOne) {
  5743. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5744. }
  5745. if m.id == nil || m.oldValue == nil {
  5746. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5747. }
  5748. oldValue, err := m.oldValue(ctx)
  5749. if err != nil {
  5750. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5751. }
  5752. return oldValue.OrganizationID, nil
  5753. }
  5754. // AddOrganizationID adds u to the "organization_id" field.
  5755. func (m *CategoryMutation) AddOrganizationID(u int64) {
  5756. if m.addorganization_id != nil {
  5757. *m.addorganization_id += u
  5758. } else {
  5759. m.addorganization_id = &u
  5760. }
  5761. }
  5762. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5763. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  5764. v := m.addorganization_id
  5765. if v == nil {
  5766. return
  5767. }
  5768. return *v, true
  5769. }
  5770. // ResetOrganizationID resets all changes to the "organization_id" field.
  5771. func (m *CategoryMutation) ResetOrganizationID() {
  5772. m.organization_id = nil
  5773. m.addorganization_id = nil
  5774. }
  5775. // Where appends a list predicates to the CategoryMutation builder.
  5776. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  5777. m.predicates = append(m.predicates, ps...)
  5778. }
  5779. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  5780. // users can use type-assertion to append predicates that do not depend on any generated package.
  5781. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  5782. p := make([]predicate.Category, len(ps))
  5783. for i := range ps {
  5784. p[i] = ps[i]
  5785. }
  5786. m.Where(p...)
  5787. }
  5788. // Op returns the operation name.
  5789. func (m *CategoryMutation) Op() Op {
  5790. return m.op
  5791. }
  5792. // SetOp allows setting the mutation operation.
  5793. func (m *CategoryMutation) SetOp(op Op) {
  5794. m.op = op
  5795. }
  5796. // Type returns the node type of this mutation (Category).
  5797. func (m *CategoryMutation) Type() string {
  5798. return m.typ
  5799. }
  5800. // Fields returns all fields that were changed during this mutation. Note that in
  5801. // order to get all numeric fields that were incremented/decremented, call
  5802. // AddedFields().
  5803. func (m *CategoryMutation) Fields() []string {
  5804. fields := make([]string, 0, 5)
  5805. if m.created_at != nil {
  5806. fields = append(fields, category.FieldCreatedAt)
  5807. }
  5808. if m.updated_at != nil {
  5809. fields = append(fields, category.FieldUpdatedAt)
  5810. }
  5811. if m.deleted_at != nil {
  5812. fields = append(fields, category.FieldDeletedAt)
  5813. }
  5814. if m.name != nil {
  5815. fields = append(fields, category.FieldName)
  5816. }
  5817. if m.organization_id != nil {
  5818. fields = append(fields, category.FieldOrganizationID)
  5819. }
  5820. return fields
  5821. }
  5822. // Field returns the value of a field with the given name. The second boolean
  5823. // return value indicates that this field was not set, or was not defined in the
  5824. // schema.
  5825. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  5826. switch name {
  5827. case category.FieldCreatedAt:
  5828. return m.CreatedAt()
  5829. case category.FieldUpdatedAt:
  5830. return m.UpdatedAt()
  5831. case category.FieldDeletedAt:
  5832. return m.DeletedAt()
  5833. case category.FieldName:
  5834. return m.Name()
  5835. case category.FieldOrganizationID:
  5836. return m.OrganizationID()
  5837. }
  5838. return nil, false
  5839. }
  5840. // OldField returns the old value of the field from the database. An error is
  5841. // returned if the mutation operation is not UpdateOne, or the query to the
  5842. // database failed.
  5843. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5844. switch name {
  5845. case category.FieldCreatedAt:
  5846. return m.OldCreatedAt(ctx)
  5847. case category.FieldUpdatedAt:
  5848. return m.OldUpdatedAt(ctx)
  5849. case category.FieldDeletedAt:
  5850. return m.OldDeletedAt(ctx)
  5851. case category.FieldName:
  5852. return m.OldName(ctx)
  5853. case category.FieldOrganizationID:
  5854. return m.OldOrganizationID(ctx)
  5855. }
  5856. return nil, fmt.Errorf("unknown Category field %s", name)
  5857. }
  5858. // SetField sets the value of a field with the given name. It returns an error if
  5859. // the field is not defined in the schema, or if the type mismatched the field
  5860. // type.
  5861. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  5862. switch name {
  5863. case category.FieldCreatedAt:
  5864. v, ok := value.(time.Time)
  5865. if !ok {
  5866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5867. }
  5868. m.SetCreatedAt(v)
  5869. return nil
  5870. case category.FieldUpdatedAt:
  5871. v, ok := value.(time.Time)
  5872. if !ok {
  5873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5874. }
  5875. m.SetUpdatedAt(v)
  5876. return nil
  5877. case category.FieldDeletedAt:
  5878. v, ok := value.(time.Time)
  5879. if !ok {
  5880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5881. }
  5882. m.SetDeletedAt(v)
  5883. return nil
  5884. case category.FieldName:
  5885. v, ok := value.(string)
  5886. if !ok {
  5887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5888. }
  5889. m.SetName(v)
  5890. return nil
  5891. case category.FieldOrganizationID:
  5892. v, ok := value.(uint64)
  5893. if !ok {
  5894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5895. }
  5896. m.SetOrganizationID(v)
  5897. return nil
  5898. }
  5899. return fmt.Errorf("unknown Category field %s", name)
  5900. }
  5901. // AddedFields returns all numeric fields that were incremented/decremented during
  5902. // this mutation.
  5903. func (m *CategoryMutation) AddedFields() []string {
  5904. var fields []string
  5905. if m.addorganization_id != nil {
  5906. fields = append(fields, category.FieldOrganizationID)
  5907. }
  5908. return fields
  5909. }
  5910. // AddedField returns the numeric value that was incremented/decremented on a field
  5911. // with the given name. The second boolean return value indicates that this field
  5912. // was not set, or was not defined in the schema.
  5913. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  5914. switch name {
  5915. case category.FieldOrganizationID:
  5916. return m.AddedOrganizationID()
  5917. }
  5918. return nil, false
  5919. }
  5920. // AddField adds the value to the field with the given name. It returns an error if
  5921. // the field is not defined in the schema, or if the type mismatched the field
  5922. // type.
  5923. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  5924. switch name {
  5925. case category.FieldOrganizationID:
  5926. v, ok := value.(int64)
  5927. if !ok {
  5928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5929. }
  5930. m.AddOrganizationID(v)
  5931. return nil
  5932. }
  5933. return fmt.Errorf("unknown Category numeric field %s", name)
  5934. }
  5935. // ClearedFields returns all nullable fields that were cleared during this
  5936. // mutation.
  5937. func (m *CategoryMutation) ClearedFields() []string {
  5938. var fields []string
  5939. if m.FieldCleared(category.FieldDeletedAt) {
  5940. fields = append(fields, category.FieldDeletedAt)
  5941. }
  5942. return fields
  5943. }
  5944. // FieldCleared returns a boolean indicating if a field with the given name was
  5945. // cleared in this mutation.
  5946. func (m *CategoryMutation) FieldCleared(name string) bool {
  5947. _, ok := m.clearedFields[name]
  5948. return ok
  5949. }
  5950. // ClearField clears the value of the field with the given name. It returns an
  5951. // error if the field is not defined in the schema.
  5952. func (m *CategoryMutation) ClearField(name string) error {
  5953. switch name {
  5954. case category.FieldDeletedAt:
  5955. m.ClearDeletedAt()
  5956. return nil
  5957. }
  5958. return fmt.Errorf("unknown Category nullable field %s", name)
  5959. }
  5960. // ResetField resets all changes in the mutation for the field with the given name.
  5961. // It returns an error if the field is not defined in the schema.
  5962. func (m *CategoryMutation) ResetField(name string) error {
  5963. switch name {
  5964. case category.FieldCreatedAt:
  5965. m.ResetCreatedAt()
  5966. return nil
  5967. case category.FieldUpdatedAt:
  5968. m.ResetUpdatedAt()
  5969. return nil
  5970. case category.FieldDeletedAt:
  5971. m.ResetDeletedAt()
  5972. return nil
  5973. case category.FieldName:
  5974. m.ResetName()
  5975. return nil
  5976. case category.FieldOrganizationID:
  5977. m.ResetOrganizationID()
  5978. return nil
  5979. }
  5980. return fmt.Errorf("unknown Category field %s", name)
  5981. }
  5982. // AddedEdges returns all edge names that were set/added in this mutation.
  5983. func (m *CategoryMutation) AddedEdges() []string {
  5984. edges := make([]string, 0, 0)
  5985. return edges
  5986. }
  5987. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5988. // name in this mutation.
  5989. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  5990. return nil
  5991. }
  5992. // RemovedEdges returns all edge names that were removed in this mutation.
  5993. func (m *CategoryMutation) RemovedEdges() []string {
  5994. edges := make([]string, 0, 0)
  5995. return edges
  5996. }
  5997. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5998. // the given name in this mutation.
  5999. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  6000. return nil
  6001. }
  6002. // ClearedEdges returns all edge names that were cleared in this mutation.
  6003. func (m *CategoryMutation) ClearedEdges() []string {
  6004. edges := make([]string, 0, 0)
  6005. return edges
  6006. }
  6007. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6008. // was cleared in this mutation.
  6009. func (m *CategoryMutation) EdgeCleared(name string) bool {
  6010. return false
  6011. }
  6012. // ClearEdge clears the value of the edge with the given name. It returns an error
  6013. // if that edge is not defined in the schema.
  6014. func (m *CategoryMutation) ClearEdge(name string) error {
  6015. return fmt.Errorf("unknown Category unique edge %s", name)
  6016. }
  6017. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6018. // It returns an error if the edge is not defined in the schema.
  6019. func (m *CategoryMutation) ResetEdge(name string) error {
  6020. return fmt.Errorf("unknown Category edge %s", name)
  6021. }
  6022. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  6023. type ChatRecordsMutation struct {
  6024. config
  6025. op Op
  6026. typ string
  6027. id *uint64
  6028. created_at *time.Time
  6029. updated_at *time.Time
  6030. deleted_at *time.Time
  6031. content *string
  6032. content_type *uint8
  6033. addcontent_type *int8
  6034. session_id *uint64
  6035. addsession_id *int64
  6036. user_id *uint64
  6037. adduser_id *int64
  6038. bot_id *uint64
  6039. addbot_id *int64
  6040. bot_type *uint8
  6041. addbot_type *int8
  6042. clearedFields map[string]struct{}
  6043. done bool
  6044. oldValue func(context.Context) (*ChatRecords, error)
  6045. predicates []predicate.ChatRecords
  6046. }
  6047. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  6048. // chatrecordsOption allows management of the mutation configuration using functional options.
  6049. type chatrecordsOption func(*ChatRecordsMutation)
  6050. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  6051. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  6052. m := &ChatRecordsMutation{
  6053. config: c,
  6054. op: op,
  6055. typ: TypeChatRecords,
  6056. clearedFields: make(map[string]struct{}),
  6057. }
  6058. for _, opt := range opts {
  6059. opt(m)
  6060. }
  6061. return m
  6062. }
  6063. // withChatRecordsID sets the ID field of the mutation.
  6064. func withChatRecordsID(id uint64) chatrecordsOption {
  6065. return func(m *ChatRecordsMutation) {
  6066. var (
  6067. err error
  6068. once sync.Once
  6069. value *ChatRecords
  6070. )
  6071. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  6072. once.Do(func() {
  6073. if m.done {
  6074. err = errors.New("querying old values post mutation is not allowed")
  6075. } else {
  6076. value, err = m.Client().ChatRecords.Get(ctx, id)
  6077. }
  6078. })
  6079. return value, err
  6080. }
  6081. m.id = &id
  6082. }
  6083. }
  6084. // withChatRecords sets the old ChatRecords of the mutation.
  6085. func withChatRecords(node *ChatRecords) chatrecordsOption {
  6086. return func(m *ChatRecordsMutation) {
  6087. m.oldValue = func(context.Context) (*ChatRecords, error) {
  6088. return node, nil
  6089. }
  6090. m.id = &node.ID
  6091. }
  6092. }
  6093. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6094. // executed in a transaction (ent.Tx), a transactional client is returned.
  6095. func (m ChatRecordsMutation) Client() *Client {
  6096. client := &Client{config: m.config}
  6097. client.init()
  6098. return client
  6099. }
  6100. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6101. // it returns an error otherwise.
  6102. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  6103. if _, ok := m.driver.(*txDriver); !ok {
  6104. return nil, errors.New("ent: mutation is not running in a transaction")
  6105. }
  6106. tx := &Tx{config: m.config}
  6107. tx.init()
  6108. return tx, nil
  6109. }
  6110. // SetID sets the value of the id field. Note that this
  6111. // operation is only accepted on creation of ChatRecords entities.
  6112. func (m *ChatRecordsMutation) SetID(id uint64) {
  6113. m.id = &id
  6114. }
  6115. // ID returns the ID value in the mutation. Note that the ID is only available
  6116. // if it was provided to the builder or after it was returned from the database.
  6117. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  6118. if m.id == nil {
  6119. return
  6120. }
  6121. return *m.id, true
  6122. }
  6123. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6124. // That means, if the mutation is applied within a transaction with an isolation level such
  6125. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6126. // or updated by the mutation.
  6127. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  6128. switch {
  6129. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6130. id, exists := m.ID()
  6131. if exists {
  6132. return []uint64{id}, nil
  6133. }
  6134. fallthrough
  6135. case m.op.Is(OpUpdate | OpDelete):
  6136. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  6137. default:
  6138. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6139. }
  6140. }
  6141. // SetCreatedAt sets the "created_at" field.
  6142. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  6143. m.created_at = &t
  6144. }
  6145. // CreatedAt returns the value of the "created_at" field in the mutation.
  6146. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  6147. v := m.created_at
  6148. if v == nil {
  6149. return
  6150. }
  6151. return *v, true
  6152. }
  6153. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  6154. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6155. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6156. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6157. if !m.op.Is(OpUpdateOne) {
  6158. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6159. }
  6160. if m.id == nil || m.oldValue == nil {
  6161. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6162. }
  6163. oldValue, err := m.oldValue(ctx)
  6164. if err != nil {
  6165. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6166. }
  6167. return oldValue.CreatedAt, nil
  6168. }
  6169. // ResetCreatedAt resets all changes to the "created_at" field.
  6170. func (m *ChatRecordsMutation) ResetCreatedAt() {
  6171. m.created_at = nil
  6172. }
  6173. // SetUpdatedAt sets the "updated_at" field.
  6174. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  6175. m.updated_at = &t
  6176. }
  6177. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6178. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  6179. v := m.updated_at
  6180. if v == nil {
  6181. return
  6182. }
  6183. return *v, true
  6184. }
  6185. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  6186. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6188. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6189. if !m.op.Is(OpUpdateOne) {
  6190. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6191. }
  6192. if m.id == nil || m.oldValue == nil {
  6193. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6194. }
  6195. oldValue, err := m.oldValue(ctx)
  6196. if err != nil {
  6197. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6198. }
  6199. return oldValue.UpdatedAt, nil
  6200. }
  6201. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6202. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  6203. m.updated_at = nil
  6204. }
  6205. // SetDeletedAt sets the "deleted_at" field.
  6206. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  6207. m.deleted_at = &t
  6208. }
  6209. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6210. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  6211. v := m.deleted_at
  6212. if v == nil {
  6213. return
  6214. }
  6215. return *v, true
  6216. }
  6217. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  6218. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6220. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6221. if !m.op.Is(OpUpdateOne) {
  6222. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6223. }
  6224. if m.id == nil || m.oldValue == nil {
  6225. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6226. }
  6227. oldValue, err := m.oldValue(ctx)
  6228. if err != nil {
  6229. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6230. }
  6231. return oldValue.DeletedAt, nil
  6232. }
  6233. // ClearDeletedAt clears the value of the "deleted_at" field.
  6234. func (m *ChatRecordsMutation) ClearDeletedAt() {
  6235. m.deleted_at = nil
  6236. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  6237. }
  6238. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6239. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  6240. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  6241. return ok
  6242. }
  6243. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6244. func (m *ChatRecordsMutation) ResetDeletedAt() {
  6245. m.deleted_at = nil
  6246. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  6247. }
  6248. // SetContent sets the "content" field.
  6249. func (m *ChatRecordsMutation) SetContent(s string) {
  6250. m.content = &s
  6251. }
  6252. // Content returns the value of the "content" field in the mutation.
  6253. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  6254. v := m.content
  6255. if v == nil {
  6256. return
  6257. }
  6258. return *v, true
  6259. }
  6260. // OldContent returns the old "content" field's value of the ChatRecords entity.
  6261. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6263. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  6264. if !m.op.Is(OpUpdateOne) {
  6265. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6266. }
  6267. if m.id == nil || m.oldValue == nil {
  6268. return v, errors.New("OldContent requires an ID field in the mutation")
  6269. }
  6270. oldValue, err := m.oldValue(ctx)
  6271. if err != nil {
  6272. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  6273. }
  6274. return oldValue.Content, nil
  6275. }
  6276. // ResetContent resets all changes to the "content" field.
  6277. func (m *ChatRecordsMutation) ResetContent() {
  6278. m.content = nil
  6279. }
  6280. // SetContentType sets the "content_type" field.
  6281. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  6282. m.content_type = &u
  6283. m.addcontent_type = nil
  6284. }
  6285. // ContentType returns the value of the "content_type" field in the mutation.
  6286. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  6287. v := m.content_type
  6288. if v == nil {
  6289. return
  6290. }
  6291. return *v, true
  6292. }
  6293. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  6294. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6296. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  6297. if !m.op.Is(OpUpdateOne) {
  6298. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  6299. }
  6300. if m.id == nil || m.oldValue == nil {
  6301. return v, errors.New("OldContentType requires an ID field in the mutation")
  6302. }
  6303. oldValue, err := m.oldValue(ctx)
  6304. if err != nil {
  6305. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  6306. }
  6307. return oldValue.ContentType, nil
  6308. }
  6309. // AddContentType adds u to the "content_type" field.
  6310. func (m *ChatRecordsMutation) AddContentType(u int8) {
  6311. if m.addcontent_type != nil {
  6312. *m.addcontent_type += u
  6313. } else {
  6314. m.addcontent_type = &u
  6315. }
  6316. }
  6317. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  6318. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  6319. v := m.addcontent_type
  6320. if v == nil {
  6321. return
  6322. }
  6323. return *v, true
  6324. }
  6325. // ResetContentType resets all changes to the "content_type" field.
  6326. func (m *ChatRecordsMutation) ResetContentType() {
  6327. m.content_type = nil
  6328. m.addcontent_type = nil
  6329. }
  6330. // SetSessionID sets the "session_id" field.
  6331. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  6332. m.session_id = &u
  6333. m.addsession_id = nil
  6334. }
  6335. // SessionID returns the value of the "session_id" field in the mutation.
  6336. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  6337. v := m.session_id
  6338. if v == nil {
  6339. return
  6340. }
  6341. return *v, true
  6342. }
  6343. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  6344. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6346. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  6347. if !m.op.Is(OpUpdateOne) {
  6348. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  6349. }
  6350. if m.id == nil || m.oldValue == nil {
  6351. return v, errors.New("OldSessionID requires an ID field in the mutation")
  6352. }
  6353. oldValue, err := m.oldValue(ctx)
  6354. if err != nil {
  6355. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  6356. }
  6357. return oldValue.SessionID, nil
  6358. }
  6359. // AddSessionID adds u to the "session_id" field.
  6360. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  6361. if m.addsession_id != nil {
  6362. *m.addsession_id += u
  6363. } else {
  6364. m.addsession_id = &u
  6365. }
  6366. }
  6367. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  6368. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  6369. v := m.addsession_id
  6370. if v == nil {
  6371. return
  6372. }
  6373. return *v, true
  6374. }
  6375. // ResetSessionID resets all changes to the "session_id" field.
  6376. func (m *ChatRecordsMutation) ResetSessionID() {
  6377. m.session_id = nil
  6378. m.addsession_id = nil
  6379. }
  6380. // SetUserID sets the "user_id" field.
  6381. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  6382. m.user_id = &u
  6383. m.adduser_id = nil
  6384. }
  6385. // UserID returns the value of the "user_id" field in the mutation.
  6386. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  6387. v := m.user_id
  6388. if v == nil {
  6389. return
  6390. }
  6391. return *v, true
  6392. }
  6393. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  6394. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6396. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6397. if !m.op.Is(OpUpdateOne) {
  6398. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6399. }
  6400. if m.id == nil || m.oldValue == nil {
  6401. return v, errors.New("OldUserID requires an ID field in the mutation")
  6402. }
  6403. oldValue, err := m.oldValue(ctx)
  6404. if err != nil {
  6405. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6406. }
  6407. return oldValue.UserID, nil
  6408. }
  6409. // AddUserID adds u to the "user_id" field.
  6410. func (m *ChatRecordsMutation) AddUserID(u int64) {
  6411. if m.adduser_id != nil {
  6412. *m.adduser_id += u
  6413. } else {
  6414. m.adduser_id = &u
  6415. }
  6416. }
  6417. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6418. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  6419. v := m.adduser_id
  6420. if v == nil {
  6421. return
  6422. }
  6423. return *v, true
  6424. }
  6425. // ResetUserID resets all changes to the "user_id" field.
  6426. func (m *ChatRecordsMutation) ResetUserID() {
  6427. m.user_id = nil
  6428. m.adduser_id = nil
  6429. }
  6430. // SetBotID sets the "bot_id" field.
  6431. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  6432. m.bot_id = &u
  6433. m.addbot_id = nil
  6434. }
  6435. // BotID returns the value of the "bot_id" field in the mutation.
  6436. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  6437. v := m.bot_id
  6438. if v == nil {
  6439. return
  6440. }
  6441. return *v, true
  6442. }
  6443. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  6444. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6446. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6447. if !m.op.Is(OpUpdateOne) {
  6448. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6449. }
  6450. if m.id == nil || m.oldValue == nil {
  6451. return v, errors.New("OldBotID requires an ID field in the mutation")
  6452. }
  6453. oldValue, err := m.oldValue(ctx)
  6454. if err != nil {
  6455. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6456. }
  6457. return oldValue.BotID, nil
  6458. }
  6459. // AddBotID adds u to the "bot_id" field.
  6460. func (m *ChatRecordsMutation) AddBotID(u int64) {
  6461. if m.addbot_id != nil {
  6462. *m.addbot_id += u
  6463. } else {
  6464. m.addbot_id = &u
  6465. }
  6466. }
  6467. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6468. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  6469. v := m.addbot_id
  6470. if v == nil {
  6471. return
  6472. }
  6473. return *v, true
  6474. }
  6475. // ResetBotID resets all changes to the "bot_id" field.
  6476. func (m *ChatRecordsMutation) ResetBotID() {
  6477. m.bot_id = nil
  6478. m.addbot_id = nil
  6479. }
  6480. // SetBotType sets the "bot_type" field.
  6481. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  6482. m.bot_type = &u
  6483. m.addbot_type = nil
  6484. }
  6485. // BotType returns the value of the "bot_type" field in the mutation.
  6486. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  6487. v := m.bot_type
  6488. if v == nil {
  6489. return
  6490. }
  6491. return *v, true
  6492. }
  6493. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  6494. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6496. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6497. if !m.op.Is(OpUpdateOne) {
  6498. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6499. }
  6500. if m.id == nil || m.oldValue == nil {
  6501. return v, errors.New("OldBotType requires an ID field in the mutation")
  6502. }
  6503. oldValue, err := m.oldValue(ctx)
  6504. if err != nil {
  6505. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  6506. }
  6507. return oldValue.BotType, nil
  6508. }
  6509. // AddBotType adds u to the "bot_type" field.
  6510. func (m *ChatRecordsMutation) AddBotType(u int8) {
  6511. if m.addbot_type != nil {
  6512. *m.addbot_type += u
  6513. } else {
  6514. m.addbot_type = &u
  6515. }
  6516. }
  6517. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  6518. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  6519. v := m.addbot_type
  6520. if v == nil {
  6521. return
  6522. }
  6523. return *v, true
  6524. }
  6525. // ResetBotType resets all changes to the "bot_type" field.
  6526. func (m *ChatRecordsMutation) ResetBotType() {
  6527. m.bot_type = nil
  6528. m.addbot_type = nil
  6529. }
  6530. // Where appends a list predicates to the ChatRecordsMutation builder.
  6531. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  6532. m.predicates = append(m.predicates, ps...)
  6533. }
  6534. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  6535. // users can use type-assertion to append predicates that do not depend on any generated package.
  6536. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  6537. p := make([]predicate.ChatRecords, len(ps))
  6538. for i := range ps {
  6539. p[i] = ps[i]
  6540. }
  6541. m.Where(p...)
  6542. }
  6543. // Op returns the operation name.
  6544. func (m *ChatRecordsMutation) Op() Op {
  6545. return m.op
  6546. }
  6547. // SetOp allows setting the mutation operation.
  6548. func (m *ChatRecordsMutation) SetOp(op Op) {
  6549. m.op = op
  6550. }
  6551. // Type returns the node type of this mutation (ChatRecords).
  6552. func (m *ChatRecordsMutation) Type() string {
  6553. return m.typ
  6554. }
  6555. // Fields returns all fields that were changed during this mutation. Note that in
  6556. // order to get all numeric fields that were incremented/decremented, call
  6557. // AddedFields().
  6558. func (m *ChatRecordsMutation) Fields() []string {
  6559. fields := make([]string, 0, 9)
  6560. if m.created_at != nil {
  6561. fields = append(fields, chatrecords.FieldCreatedAt)
  6562. }
  6563. if m.updated_at != nil {
  6564. fields = append(fields, chatrecords.FieldUpdatedAt)
  6565. }
  6566. if m.deleted_at != nil {
  6567. fields = append(fields, chatrecords.FieldDeletedAt)
  6568. }
  6569. if m.content != nil {
  6570. fields = append(fields, chatrecords.FieldContent)
  6571. }
  6572. if m.content_type != nil {
  6573. fields = append(fields, chatrecords.FieldContentType)
  6574. }
  6575. if m.session_id != nil {
  6576. fields = append(fields, chatrecords.FieldSessionID)
  6577. }
  6578. if m.user_id != nil {
  6579. fields = append(fields, chatrecords.FieldUserID)
  6580. }
  6581. if m.bot_id != nil {
  6582. fields = append(fields, chatrecords.FieldBotID)
  6583. }
  6584. if m.bot_type != nil {
  6585. fields = append(fields, chatrecords.FieldBotType)
  6586. }
  6587. return fields
  6588. }
  6589. // Field returns the value of a field with the given name. The second boolean
  6590. // return value indicates that this field was not set, or was not defined in the
  6591. // schema.
  6592. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  6593. switch name {
  6594. case chatrecords.FieldCreatedAt:
  6595. return m.CreatedAt()
  6596. case chatrecords.FieldUpdatedAt:
  6597. return m.UpdatedAt()
  6598. case chatrecords.FieldDeletedAt:
  6599. return m.DeletedAt()
  6600. case chatrecords.FieldContent:
  6601. return m.Content()
  6602. case chatrecords.FieldContentType:
  6603. return m.ContentType()
  6604. case chatrecords.FieldSessionID:
  6605. return m.SessionID()
  6606. case chatrecords.FieldUserID:
  6607. return m.UserID()
  6608. case chatrecords.FieldBotID:
  6609. return m.BotID()
  6610. case chatrecords.FieldBotType:
  6611. return m.BotType()
  6612. }
  6613. return nil, false
  6614. }
  6615. // OldField returns the old value of the field from the database. An error is
  6616. // returned if the mutation operation is not UpdateOne, or the query to the
  6617. // database failed.
  6618. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6619. switch name {
  6620. case chatrecords.FieldCreatedAt:
  6621. return m.OldCreatedAt(ctx)
  6622. case chatrecords.FieldUpdatedAt:
  6623. return m.OldUpdatedAt(ctx)
  6624. case chatrecords.FieldDeletedAt:
  6625. return m.OldDeletedAt(ctx)
  6626. case chatrecords.FieldContent:
  6627. return m.OldContent(ctx)
  6628. case chatrecords.FieldContentType:
  6629. return m.OldContentType(ctx)
  6630. case chatrecords.FieldSessionID:
  6631. return m.OldSessionID(ctx)
  6632. case chatrecords.FieldUserID:
  6633. return m.OldUserID(ctx)
  6634. case chatrecords.FieldBotID:
  6635. return m.OldBotID(ctx)
  6636. case chatrecords.FieldBotType:
  6637. return m.OldBotType(ctx)
  6638. }
  6639. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  6640. }
  6641. // SetField sets the value of a field with the given name. It returns an error if
  6642. // the field is not defined in the schema, or if the type mismatched the field
  6643. // type.
  6644. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  6645. switch name {
  6646. case chatrecords.FieldCreatedAt:
  6647. v, ok := value.(time.Time)
  6648. if !ok {
  6649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6650. }
  6651. m.SetCreatedAt(v)
  6652. return nil
  6653. case chatrecords.FieldUpdatedAt:
  6654. v, ok := value.(time.Time)
  6655. if !ok {
  6656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6657. }
  6658. m.SetUpdatedAt(v)
  6659. return nil
  6660. case chatrecords.FieldDeletedAt:
  6661. v, ok := value.(time.Time)
  6662. if !ok {
  6663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6664. }
  6665. m.SetDeletedAt(v)
  6666. return nil
  6667. case chatrecords.FieldContent:
  6668. v, ok := value.(string)
  6669. if !ok {
  6670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6671. }
  6672. m.SetContent(v)
  6673. return nil
  6674. case chatrecords.FieldContentType:
  6675. v, ok := value.(uint8)
  6676. if !ok {
  6677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6678. }
  6679. m.SetContentType(v)
  6680. return nil
  6681. case chatrecords.FieldSessionID:
  6682. v, ok := value.(uint64)
  6683. if !ok {
  6684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6685. }
  6686. m.SetSessionID(v)
  6687. return nil
  6688. case chatrecords.FieldUserID:
  6689. v, ok := value.(uint64)
  6690. if !ok {
  6691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6692. }
  6693. m.SetUserID(v)
  6694. return nil
  6695. case chatrecords.FieldBotID:
  6696. v, ok := value.(uint64)
  6697. if !ok {
  6698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6699. }
  6700. m.SetBotID(v)
  6701. return nil
  6702. case chatrecords.FieldBotType:
  6703. v, ok := value.(uint8)
  6704. if !ok {
  6705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6706. }
  6707. m.SetBotType(v)
  6708. return nil
  6709. }
  6710. return fmt.Errorf("unknown ChatRecords field %s", name)
  6711. }
  6712. // AddedFields returns all numeric fields that were incremented/decremented during
  6713. // this mutation.
  6714. func (m *ChatRecordsMutation) AddedFields() []string {
  6715. var fields []string
  6716. if m.addcontent_type != nil {
  6717. fields = append(fields, chatrecords.FieldContentType)
  6718. }
  6719. if m.addsession_id != nil {
  6720. fields = append(fields, chatrecords.FieldSessionID)
  6721. }
  6722. if m.adduser_id != nil {
  6723. fields = append(fields, chatrecords.FieldUserID)
  6724. }
  6725. if m.addbot_id != nil {
  6726. fields = append(fields, chatrecords.FieldBotID)
  6727. }
  6728. if m.addbot_type != nil {
  6729. fields = append(fields, chatrecords.FieldBotType)
  6730. }
  6731. return fields
  6732. }
  6733. // AddedField returns the numeric value that was incremented/decremented on a field
  6734. // with the given name. The second boolean return value indicates that this field
  6735. // was not set, or was not defined in the schema.
  6736. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  6737. switch name {
  6738. case chatrecords.FieldContentType:
  6739. return m.AddedContentType()
  6740. case chatrecords.FieldSessionID:
  6741. return m.AddedSessionID()
  6742. case chatrecords.FieldUserID:
  6743. return m.AddedUserID()
  6744. case chatrecords.FieldBotID:
  6745. return m.AddedBotID()
  6746. case chatrecords.FieldBotType:
  6747. return m.AddedBotType()
  6748. }
  6749. return nil, false
  6750. }
  6751. // AddField adds the value to the field with the given name. It returns an error if
  6752. // the field is not defined in the schema, or if the type mismatched the field
  6753. // type.
  6754. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  6755. switch name {
  6756. case chatrecords.FieldContentType:
  6757. v, ok := value.(int8)
  6758. if !ok {
  6759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6760. }
  6761. m.AddContentType(v)
  6762. return nil
  6763. case chatrecords.FieldSessionID:
  6764. v, ok := value.(int64)
  6765. if !ok {
  6766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6767. }
  6768. m.AddSessionID(v)
  6769. return nil
  6770. case chatrecords.FieldUserID:
  6771. v, ok := value.(int64)
  6772. if !ok {
  6773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6774. }
  6775. m.AddUserID(v)
  6776. return nil
  6777. case chatrecords.FieldBotID:
  6778. v, ok := value.(int64)
  6779. if !ok {
  6780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6781. }
  6782. m.AddBotID(v)
  6783. return nil
  6784. case chatrecords.FieldBotType:
  6785. v, ok := value.(int8)
  6786. if !ok {
  6787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6788. }
  6789. m.AddBotType(v)
  6790. return nil
  6791. }
  6792. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  6793. }
  6794. // ClearedFields returns all nullable fields that were cleared during this
  6795. // mutation.
  6796. func (m *ChatRecordsMutation) ClearedFields() []string {
  6797. var fields []string
  6798. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  6799. fields = append(fields, chatrecords.FieldDeletedAt)
  6800. }
  6801. return fields
  6802. }
  6803. // FieldCleared returns a boolean indicating if a field with the given name was
  6804. // cleared in this mutation.
  6805. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  6806. _, ok := m.clearedFields[name]
  6807. return ok
  6808. }
  6809. // ClearField clears the value of the field with the given name. It returns an
  6810. // error if the field is not defined in the schema.
  6811. func (m *ChatRecordsMutation) ClearField(name string) error {
  6812. switch name {
  6813. case chatrecords.FieldDeletedAt:
  6814. m.ClearDeletedAt()
  6815. return nil
  6816. }
  6817. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  6818. }
  6819. // ResetField resets all changes in the mutation for the field with the given name.
  6820. // It returns an error if the field is not defined in the schema.
  6821. func (m *ChatRecordsMutation) ResetField(name string) error {
  6822. switch name {
  6823. case chatrecords.FieldCreatedAt:
  6824. m.ResetCreatedAt()
  6825. return nil
  6826. case chatrecords.FieldUpdatedAt:
  6827. m.ResetUpdatedAt()
  6828. return nil
  6829. case chatrecords.FieldDeletedAt:
  6830. m.ResetDeletedAt()
  6831. return nil
  6832. case chatrecords.FieldContent:
  6833. m.ResetContent()
  6834. return nil
  6835. case chatrecords.FieldContentType:
  6836. m.ResetContentType()
  6837. return nil
  6838. case chatrecords.FieldSessionID:
  6839. m.ResetSessionID()
  6840. return nil
  6841. case chatrecords.FieldUserID:
  6842. m.ResetUserID()
  6843. return nil
  6844. case chatrecords.FieldBotID:
  6845. m.ResetBotID()
  6846. return nil
  6847. case chatrecords.FieldBotType:
  6848. m.ResetBotType()
  6849. return nil
  6850. }
  6851. return fmt.Errorf("unknown ChatRecords field %s", name)
  6852. }
  6853. // AddedEdges returns all edge names that were set/added in this mutation.
  6854. func (m *ChatRecordsMutation) AddedEdges() []string {
  6855. edges := make([]string, 0, 0)
  6856. return edges
  6857. }
  6858. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6859. // name in this mutation.
  6860. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  6861. return nil
  6862. }
  6863. // RemovedEdges returns all edge names that were removed in this mutation.
  6864. func (m *ChatRecordsMutation) RemovedEdges() []string {
  6865. edges := make([]string, 0, 0)
  6866. return edges
  6867. }
  6868. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6869. // the given name in this mutation.
  6870. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  6871. return nil
  6872. }
  6873. // ClearedEdges returns all edge names that were cleared in this mutation.
  6874. func (m *ChatRecordsMutation) ClearedEdges() []string {
  6875. edges := make([]string, 0, 0)
  6876. return edges
  6877. }
  6878. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6879. // was cleared in this mutation.
  6880. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  6881. return false
  6882. }
  6883. // ClearEdge clears the value of the edge with the given name. It returns an error
  6884. // if that edge is not defined in the schema.
  6885. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  6886. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  6887. }
  6888. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6889. // It returns an error if the edge is not defined in the schema.
  6890. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  6891. return fmt.Errorf("unknown ChatRecords edge %s", name)
  6892. }
  6893. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  6894. type ChatSessionMutation struct {
  6895. config
  6896. op Op
  6897. typ string
  6898. id *uint64
  6899. created_at *time.Time
  6900. updated_at *time.Time
  6901. deleted_at *time.Time
  6902. name *string
  6903. user_id *uint64
  6904. adduser_id *int64
  6905. bot_id *uint64
  6906. addbot_id *int64
  6907. bot_type *uint8
  6908. addbot_type *int8
  6909. clearedFields map[string]struct{}
  6910. done bool
  6911. oldValue func(context.Context) (*ChatSession, error)
  6912. predicates []predicate.ChatSession
  6913. }
  6914. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  6915. // chatsessionOption allows management of the mutation configuration using functional options.
  6916. type chatsessionOption func(*ChatSessionMutation)
  6917. // newChatSessionMutation creates new mutation for the ChatSession entity.
  6918. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  6919. m := &ChatSessionMutation{
  6920. config: c,
  6921. op: op,
  6922. typ: TypeChatSession,
  6923. clearedFields: make(map[string]struct{}),
  6924. }
  6925. for _, opt := range opts {
  6926. opt(m)
  6927. }
  6928. return m
  6929. }
  6930. // withChatSessionID sets the ID field of the mutation.
  6931. func withChatSessionID(id uint64) chatsessionOption {
  6932. return func(m *ChatSessionMutation) {
  6933. var (
  6934. err error
  6935. once sync.Once
  6936. value *ChatSession
  6937. )
  6938. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  6939. once.Do(func() {
  6940. if m.done {
  6941. err = errors.New("querying old values post mutation is not allowed")
  6942. } else {
  6943. value, err = m.Client().ChatSession.Get(ctx, id)
  6944. }
  6945. })
  6946. return value, err
  6947. }
  6948. m.id = &id
  6949. }
  6950. }
  6951. // withChatSession sets the old ChatSession of the mutation.
  6952. func withChatSession(node *ChatSession) chatsessionOption {
  6953. return func(m *ChatSessionMutation) {
  6954. m.oldValue = func(context.Context) (*ChatSession, error) {
  6955. return node, nil
  6956. }
  6957. m.id = &node.ID
  6958. }
  6959. }
  6960. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6961. // executed in a transaction (ent.Tx), a transactional client is returned.
  6962. func (m ChatSessionMutation) Client() *Client {
  6963. client := &Client{config: m.config}
  6964. client.init()
  6965. return client
  6966. }
  6967. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6968. // it returns an error otherwise.
  6969. func (m ChatSessionMutation) Tx() (*Tx, error) {
  6970. if _, ok := m.driver.(*txDriver); !ok {
  6971. return nil, errors.New("ent: mutation is not running in a transaction")
  6972. }
  6973. tx := &Tx{config: m.config}
  6974. tx.init()
  6975. return tx, nil
  6976. }
  6977. // SetID sets the value of the id field. Note that this
  6978. // operation is only accepted on creation of ChatSession entities.
  6979. func (m *ChatSessionMutation) SetID(id uint64) {
  6980. m.id = &id
  6981. }
  6982. // ID returns the ID value in the mutation. Note that the ID is only available
  6983. // if it was provided to the builder or after it was returned from the database.
  6984. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  6985. if m.id == nil {
  6986. return
  6987. }
  6988. return *m.id, true
  6989. }
  6990. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6991. // That means, if the mutation is applied within a transaction with an isolation level such
  6992. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6993. // or updated by the mutation.
  6994. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  6995. switch {
  6996. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6997. id, exists := m.ID()
  6998. if exists {
  6999. return []uint64{id}, nil
  7000. }
  7001. fallthrough
  7002. case m.op.Is(OpUpdate | OpDelete):
  7003. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  7004. default:
  7005. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7006. }
  7007. }
  7008. // SetCreatedAt sets the "created_at" field.
  7009. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  7010. m.created_at = &t
  7011. }
  7012. // CreatedAt returns the value of the "created_at" field in the mutation.
  7013. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  7014. v := m.created_at
  7015. if v == nil {
  7016. return
  7017. }
  7018. return *v, true
  7019. }
  7020. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  7021. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7023. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7024. if !m.op.Is(OpUpdateOne) {
  7025. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7026. }
  7027. if m.id == nil || m.oldValue == nil {
  7028. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7029. }
  7030. oldValue, err := m.oldValue(ctx)
  7031. if err != nil {
  7032. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7033. }
  7034. return oldValue.CreatedAt, nil
  7035. }
  7036. // ResetCreatedAt resets all changes to the "created_at" field.
  7037. func (m *ChatSessionMutation) ResetCreatedAt() {
  7038. m.created_at = nil
  7039. }
  7040. // SetUpdatedAt sets the "updated_at" field.
  7041. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  7042. m.updated_at = &t
  7043. }
  7044. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7045. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  7046. v := m.updated_at
  7047. if v == nil {
  7048. return
  7049. }
  7050. return *v, true
  7051. }
  7052. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  7053. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7055. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7056. if !m.op.Is(OpUpdateOne) {
  7057. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7058. }
  7059. if m.id == nil || m.oldValue == nil {
  7060. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7061. }
  7062. oldValue, err := m.oldValue(ctx)
  7063. if err != nil {
  7064. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7065. }
  7066. return oldValue.UpdatedAt, nil
  7067. }
  7068. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7069. func (m *ChatSessionMutation) ResetUpdatedAt() {
  7070. m.updated_at = nil
  7071. }
  7072. // SetDeletedAt sets the "deleted_at" field.
  7073. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  7074. m.deleted_at = &t
  7075. }
  7076. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7077. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  7078. v := m.deleted_at
  7079. if v == nil {
  7080. return
  7081. }
  7082. return *v, true
  7083. }
  7084. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  7085. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7087. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7088. if !m.op.Is(OpUpdateOne) {
  7089. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7090. }
  7091. if m.id == nil || m.oldValue == nil {
  7092. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7093. }
  7094. oldValue, err := m.oldValue(ctx)
  7095. if err != nil {
  7096. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7097. }
  7098. return oldValue.DeletedAt, nil
  7099. }
  7100. // ClearDeletedAt clears the value of the "deleted_at" field.
  7101. func (m *ChatSessionMutation) ClearDeletedAt() {
  7102. m.deleted_at = nil
  7103. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  7104. }
  7105. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7106. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  7107. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  7108. return ok
  7109. }
  7110. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7111. func (m *ChatSessionMutation) ResetDeletedAt() {
  7112. m.deleted_at = nil
  7113. delete(m.clearedFields, chatsession.FieldDeletedAt)
  7114. }
  7115. // SetName sets the "name" field.
  7116. func (m *ChatSessionMutation) SetName(s string) {
  7117. m.name = &s
  7118. }
  7119. // Name returns the value of the "name" field in the mutation.
  7120. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  7121. v := m.name
  7122. if v == nil {
  7123. return
  7124. }
  7125. return *v, true
  7126. }
  7127. // OldName returns the old "name" field's value of the ChatSession entity.
  7128. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7130. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  7131. if !m.op.Is(OpUpdateOne) {
  7132. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7133. }
  7134. if m.id == nil || m.oldValue == nil {
  7135. return v, errors.New("OldName requires an ID field in the mutation")
  7136. }
  7137. oldValue, err := m.oldValue(ctx)
  7138. if err != nil {
  7139. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7140. }
  7141. return oldValue.Name, nil
  7142. }
  7143. // ResetName resets all changes to the "name" field.
  7144. func (m *ChatSessionMutation) ResetName() {
  7145. m.name = nil
  7146. }
  7147. // SetUserID sets the "user_id" field.
  7148. func (m *ChatSessionMutation) SetUserID(u uint64) {
  7149. m.user_id = &u
  7150. m.adduser_id = nil
  7151. }
  7152. // UserID returns the value of the "user_id" field in the mutation.
  7153. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  7154. v := m.user_id
  7155. if v == nil {
  7156. return
  7157. }
  7158. return *v, true
  7159. }
  7160. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  7161. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7162. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7163. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  7164. if !m.op.Is(OpUpdateOne) {
  7165. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  7166. }
  7167. if m.id == nil || m.oldValue == nil {
  7168. return v, errors.New("OldUserID requires an ID field in the mutation")
  7169. }
  7170. oldValue, err := m.oldValue(ctx)
  7171. if err != nil {
  7172. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  7173. }
  7174. return oldValue.UserID, nil
  7175. }
  7176. // AddUserID adds u to the "user_id" field.
  7177. func (m *ChatSessionMutation) AddUserID(u int64) {
  7178. if m.adduser_id != nil {
  7179. *m.adduser_id += u
  7180. } else {
  7181. m.adduser_id = &u
  7182. }
  7183. }
  7184. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  7185. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  7186. v := m.adduser_id
  7187. if v == nil {
  7188. return
  7189. }
  7190. return *v, true
  7191. }
  7192. // ResetUserID resets all changes to the "user_id" field.
  7193. func (m *ChatSessionMutation) ResetUserID() {
  7194. m.user_id = nil
  7195. m.adduser_id = nil
  7196. }
  7197. // SetBotID sets the "bot_id" field.
  7198. func (m *ChatSessionMutation) SetBotID(u uint64) {
  7199. m.bot_id = &u
  7200. m.addbot_id = nil
  7201. }
  7202. // BotID returns the value of the "bot_id" field in the mutation.
  7203. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  7204. v := m.bot_id
  7205. if v == nil {
  7206. return
  7207. }
  7208. return *v, true
  7209. }
  7210. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  7211. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7213. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  7214. if !m.op.Is(OpUpdateOne) {
  7215. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  7216. }
  7217. if m.id == nil || m.oldValue == nil {
  7218. return v, errors.New("OldBotID requires an ID field in the mutation")
  7219. }
  7220. oldValue, err := m.oldValue(ctx)
  7221. if err != nil {
  7222. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  7223. }
  7224. return oldValue.BotID, nil
  7225. }
  7226. // AddBotID adds u to the "bot_id" field.
  7227. func (m *ChatSessionMutation) AddBotID(u int64) {
  7228. if m.addbot_id != nil {
  7229. *m.addbot_id += u
  7230. } else {
  7231. m.addbot_id = &u
  7232. }
  7233. }
  7234. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  7235. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  7236. v := m.addbot_id
  7237. if v == nil {
  7238. return
  7239. }
  7240. return *v, true
  7241. }
  7242. // ResetBotID resets all changes to the "bot_id" field.
  7243. func (m *ChatSessionMutation) ResetBotID() {
  7244. m.bot_id = nil
  7245. m.addbot_id = nil
  7246. }
  7247. // SetBotType sets the "bot_type" field.
  7248. func (m *ChatSessionMutation) SetBotType(u uint8) {
  7249. m.bot_type = &u
  7250. m.addbot_type = nil
  7251. }
  7252. // BotType returns the value of the "bot_type" field in the mutation.
  7253. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  7254. v := m.bot_type
  7255. if v == nil {
  7256. return
  7257. }
  7258. return *v, true
  7259. }
  7260. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  7261. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7263. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  7264. if !m.op.Is(OpUpdateOne) {
  7265. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  7266. }
  7267. if m.id == nil || m.oldValue == nil {
  7268. return v, errors.New("OldBotType requires an ID field in the mutation")
  7269. }
  7270. oldValue, err := m.oldValue(ctx)
  7271. if err != nil {
  7272. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  7273. }
  7274. return oldValue.BotType, nil
  7275. }
  7276. // AddBotType adds u to the "bot_type" field.
  7277. func (m *ChatSessionMutation) AddBotType(u int8) {
  7278. if m.addbot_type != nil {
  7279. *m.addbot_type += u
  7280. } else {
  7281. m.addbot_type = &u
  7282. }
  7283. }
  7284. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  7285. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  7286. v := m.addbot_type
  7287. if v == nil {
  7288. return
  7289. }
  7290. return *v, true
  7291. }
  7292. // ResetBotType resets all changes to the "bot_type" field.
  7293. func (m *ChatSessionMutation) ResetBotType() {
  7294. m.bot_type = nil
  7295. m.addbot_type = nil
  7296. }
  7297. // Where appends a list predicates to the ChatSessionMutation builder.
  7298. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  7299. m.predicates = append(m.predicates, ps...)
  7300. }
  7301. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  7302. // users can use type-assertion to append predicates that do not depend on any generated package.
  7303. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  7304. p := make([]predicate.ChatSession, len(ps))
  7305. for i := range ps {
  7306. p[i] = ps[i]
  7307. }
  7308. m.Where(p...)
  7309. }
  7310. // Op returns the operation name.
  7311. func (m *ChatSessionMutation) Op() Op {
  7312. return m.op
  7313. }
  7314. // SetOp allows setting the mutation operation.
  7315. func (m *ChatSessionMutation) SetOp(op Op) {
  7316. m.op = op
  7317. }
  7318. // Type returns the node type of this mutation (ChatSession).
  7319. func (m *ChatSessionMutation) Type() string {
  7320. return m.typ
  7321. }
  7322. // Fields returns all fields that were changed during this mutation. Note that in
  7323. // order to get all numeric fields that were incremented/decremented, call
  7324. // AddedFields().
  7325. func (m *ChatSessionMutation) Fields() []string {
  7326. fields := make([]string, 0, 7)
  7327. if m.created_at != nil {
  7328. fields = append(fields, chatsession.FieldCreatedAt)
  7329. }
  7330. if m.updated_at != nil {
  7331. fields = append(fields, chatsession.FieldUpdatedAt)
  7332. }
  7333. if m.deleted_at != nil {
  7334. fields = append(fields, chatsession.FieldDeletedAt)
  7335. }
  7336. if m.name != nil {
  7337. fields = append(fields, chatsession.FieldName)
  7338. }
  7339. if m.user_id != nil {
  7340. fields = append(fields, chatsession.FieldUserID)
  7341. }
  7342. if m.bot_id != nil {
  7343. fields = append(fields, chatsession.FieldBotID)
  7344. }
  7345. if m.bot_type != nil {
  7346. fields = append(fields, chatsession.FieldBotType)
  7347. }
  7348. return fields
  7349. }
  7350. // Field returns the value of a field with the given name. The second boolean
  7351. // return value indicates that this field was not set, or was not defined in the
  7352. // schema.
  7353. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  7354. switch name {
  7355. case chatsession.FieldCreatedAt:
  7356. return m.CreatedAt()
  7357. case chatsession.FieldUpdatedAt:
  7358. return m.UpdatedAt()
  7359. case chatsession.FieldDeletedAt:
  7360. return m.DeletedAt()
  7361. case chatsession.FieldName:
  7362. return m.Name()
  7363. case chatsession.FieldUserID:
  7364. return m.UserID()
  7365. case chatsession.FieldBotID:
  7366. return m.BotID()
  7367. case chatsession.FieldBotType:
  7368. return m.BotType()
  7369. }
  7370. return nil, false
  7371. }
  7372. // OldField returns the old value of the field from the database. An error is
  7373. // returned if the mutation operation is not UpdateOne, or the query to the
  7374. // database failed.
  7375. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7376. switch name {
  7377. case chatsession.FieldCreatedAt:
  7378. return m.OldCreatedAt(ctx)
  7379. case chatsession.FieldUpdatedAt:
  7380. return m.OldUpdatedAt(ctx)
  7381. case chatsession.FieldDeletedAt:
  7382. return m.OldDeletedAt(ctx)
  7383. case chatsession.FieldName:
  7384. return m.OldName(ctx)
  7385. case chatsession.FieldUserID:
  7386. return m.OldUserID(ctx)
  7387. case chatsession.FieldBotID:
  7388. return m.OldBotID(ctx)
  7389. case chatsession.FieldBotType:
  7390. return m.OldBotType(ctx)
  7391. }
  7392. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  7393. }
  7394. // SetField sets the value of a field with the given name. It returns an error if
  7395. // the field is not defined in the schema, or if the type mismatched the field
  7396. // type.
  7397. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  7398. switch name {
  7399. case chatsession.FieldCreatedAt:
  7400. v, ok := value.(time.Time)
  7401. if !ok {
  7402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7403. }
  7404. m.SetCreatedAt(v)
  7405. return nil
  7406. case chatsession.FieldUpdatedAt:
  7407. v, ok := value.(time.Time)
  7408. if !ok {
  7409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7410. }
  7411. m.SetUpdatedAt(v)
  7412. return nil
  7413. case chatsession.FieldDeletedAt:
  7414. v, ok := value.(time.Time)
  7415. if !ok {
  7416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7417. }
  7418. m.SetDeletedAt(v)
  7419. return nil
  7420. case chatsession.FieldName:
  7421. v, ok := value.(string)
  7422. if !ok {
  7423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7424. }
  7425. m.SetName(v)
  7426. return nil
  7427. case chatsession.FieldUserID:
  7428. v, ok := value.(uint64)
  7429. if !ok {
  7430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7431. }
  7432. m.SetUserID(v)
  7433. return nil
  7434. case chatsession.FieldBotID:
  7435. v, ok := value.(uint64)
  7436. if !ok {
  7437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7438. }
  7439. m.SetBotID(v)
  7440. return nil
  7441. case chatsession.FieldBotType:
  7442. v, ok := value.(uint8)
  7443. if !ok {
  7444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7445. }
  7446. m.SetBotType(v)
  7447. return nil
  7448. }
  7449. return fmt.Errorf("unknown ChatSession field %s", name)
  7450. }
  7451. // AddedFields returns all numeric fields that were incremented/decremented during
  7452. // this mutation.
  7453. func (m *ChatSessionMutation) AddedFields() []string {
  7454. var fields []string
  7455. if m.adduser_id != nil {
  7456. fields = append(fields, chatsession.FieldUserID)
  7457. }
  7458. if m.addbot_id != nil {
  7459. fields = append(fields, chatsession.FieldBotID)
  7460. }
  7461. if m.addbot_type != nil {
  7462. fields = append(fields, chatsession.FieldBotType)
  7463. }
  7464. return fields
  7465. }
  7466. // AddedField returns the numeric value that was incremented/decremented on a field
  7467. // with the given name. The second boolean return value indicates that this field
  7468. // was not set, or was not defined in the schema.
  7469. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  7470. switch name {
  7471. case chatsession.FieldUserID:
  7472. return m.AddedUserID()
  7473. case chatsession.FieldBotID:
  7474. return m.AddedBotID()
  7475. case chatsession.FieldBotType:
  7476. return m.AddedBotType()
  7477. }
  7478. return nil, false
  7479. }
  7480. // AddField adds the value to the field with the given name. It returns an error if
  7481. // the field is not defined in the schema, or if the type mismatched the field
  7482. // type.
  7483. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  7484. switch name {
  7485. case chatsession.FieldUserID:
  7486. v, ok := value.(int64)
  7487. if !ok {
  7488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7489. }
  7490. m.AddUserID(v)
  7491. return nil
  7492. case chatsession.FieldBotID:
  7493. v, ok := value.(int64)
  7494. if !ok {
  7495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7496. }
  7497. m.AddBotID(v)
  7498. return nil
  7499. case chatsession.FieldBotType:
  7500. v, ok := value.(int8)
  7501. if !ok {
  7502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7503. }
  7504. m.AddBotType(v)
  7505. return nil
  7506. }
  7507. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  7508. }
  7509. // ClearedFields returns all nullable fields that were cleared during this
  7510. // mutation.
  7511. func (m *ChatSessionMutation) ClearedFields() []string {
  7512. var fields []string
  7513. if m.FieldCleared(chatsession.FieldDeletedAt) {
  7514. fields = append(fields, chatsession.FieldDeletedAt)
  7515. }
  7516. return fields
  7517. }
  7518. // FieldCleared returns a boolean indicating if a field with the given name was
  7519. // cleared in this mutation.
  7520. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  7521. _, ok := m.clearedFields[name]
  7522. return ok
  7523. }
  7524. // ClearField clears the value of the field with the given name. It returns an
  7525. // error if the field is not defined in the schema.
  7526. func (m *ChatSessionMutation) ClearField(name string) error {
  7527. switch name {
  7528. case chatsession.FieldDeletedAt:
  7529. m.ClearDeletedAt()
  7530. return nil
  7531. }
  7532. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  7533. }
  7534. // ResetField resets all changes in the mutation for the field with the given name.
  7535. // It returns an error if the field is not defined in the schema.
  7536. func (m *ChatSessionMutation) ResetField(name string) error {
  7537. switch name {
  7538. case chatsession.FieldCreatedAt:
  7539. m.ResetCreatedAt()
  7540. return nil
  7541. case chatsession.FieldUpdatedAt:
  7542. m.ResetUpdatedAt()
  7543. return nil
  7544. case chatsession.FieldDeletedAt:
  7545. m.ResetDeletedAt()
  7546. return nil
  7547. case chatsession.FieldName:
  7548. m.ResetName()
  7549. return nil
  7550. case chatsession.FieldUserID:
  7551. m.ResetUserID()
  7552. return nil
  7553. case chatsession.FieldBotID:
  7554. m.ResetBotID()
  7555. return nil
  7556. case chatsession.FieldBotType:
  7557. m.ResetBotType()
  7558. return nil
  7559. }
  7560. return fmt.Errorf("unknown ChatSession field %s", name)
  7561. }
  7562. // AddedEdges returns all edge names that were set/added in this mutation.
  7563. func (m *ChatSessionMutation) AddedEdges() []string {
  7564. edges := make([]string, 0, 0)
  7565. return edges
  7566. }
  7567. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7568. // name in this mutation.
  7569. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  7570. return nil
  7571. }
  7572. // RemovedEdges returns all edge names that were removed in this mutation.
  7573. func (m *ChatSessionMutation) RemovedEdges() []string {
  7574. edges := make([]string, 0, 0)
  7575. return edges
  7576. }
  7577. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7578. // the given name in this mutation.
  7579. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  7580. return nil
  7581. }
  7582. // ClearedEdges returns all edge names that were cleared in this mutation.
  7583. func (m *ChatSessionMutation) ClearedEdges() []string {
  7584. edges := make([]string, 0, 0)
  7585. return edges
  7586. }
  7587. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7588. // was cleared in this mutation.
  7589. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  7590. return false
  7591. }
  7592. // ClearEdge clears the value of the edge with the given name. It returns an error
  7593. // if that edge is not defined in the schema.
  7594. func (m *ChatSessionMutation) ClearEdge(name string) error {
  7595. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  7596. }
  7597. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7598. // It returns an error if the edge is not defined in the schema.
  7599. func (m *ChatSessionMutation) ResetEdge(name string) error {
  7600. return fmt.Errorf("unknown ChatSession edge %s", name)
  7601. }
  7602. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  7603. type ContactMutation struct {
  7604. config
  7605. op Op
  7606. typ string
  7607. id *uint64
  7608. created_at *time.Time
  7609. updated_at *time.Time
  7610. status *uint8
  7611. addstatus *int8
  7612. deleted_at *time.Time
  7613. wx_wxid *string
  7614. _type *int
  7615. add_type *int
  7616. wxid *string
  7617. account *string
  7618. nickname *string
  7619. markname *string
  7620. headimg *string
  7621. sex *int
  7622. addsex *int
  7623. starrole *string
  7624. dontseeit *int
  7625. adddontseeit *int
  7626. dontseeme *int
  7627. adddontseeme *int
  7628. lag *string
  7629. gid *string
  7630. gname *string
  7631. v3 *string
  7632. organization_id *uint64
  7633. addorganization_id *int64
  7634. clearedFields map[string]struct{}
  7635. contact_relationships map[uint64]struct{}
  7636. removedcontact_relationships map[uint64]struct{}
  7637. clearedcontact_relationships bool
  7638. contact_messages map[uint64]struct{}
  7639. removedcontact_messages map[uint64]struct{}
  7640. clearedcontact_messages bool
  7641. done bool
  7642. oldValue func(context.Context) (*Contact, error)
  7643. predicates []predicate.Contact
  7644. }
  7645. var _ ent.Mutation = (*ContactMutation)(nil)
  7646. // contactOption allows management of the mutation configuration using functional options.
  7647. type contactOption func(*ContactMutation)
  7648. // newContactMutation creates new mutation for the Contact entity.
  7649. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  7650. m := &ContactMutation{
  7651. config: c,
  7652. op: op,
  7653. typ: TypeContact,
  7654. clearedFields: make(map[string]struct{}),
  7655. }
  7656. for _, opt := range opts {
  7657. opt(m)
  7658. }
  7659. return m
  7660. }
  7661. // withContactID sets the ID field of the mutation.
  7662. func withContactID(id uint64) contactOption {
  7663. return func(m *ContactMutation) {
  7664. var (
  7665. err error
  7666. once sync.Once
  7667. value *Contact
  7668. )
  7669. m.oldValue = func(ctx context.Context) (*Contact, error) {
  7670. once.Do(func() {
  7671. if m.done {
  7672. err = errors.New("querying old values post mutation is not allowed")
  7673. } else {
  7674. value, err = m.Client().Contact.Get(ctx, id)
  7675. }
  7676. })
  7677. return value, err
  7678. }
  7679. m.id = &id
  7680. }
  7681. }
  7682. // withContact sets the old Contact of the mutation.
  7683. func withContact(node *Contact) contactOption {
  7684. return func(m *ContactMutation) {
  7685. m.oldValue = func(context.Context) (*Contact, error) {
  7686. return node, nil
  7687. }
  7688. m.id = &node.ID
  7689. }
  7690. }
  7691. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7692. // executed in a transaction (ent.Tx), a transactional client is returned.
  7693. func (m ContactMutation) Client() *Client {
  7694. client := &Client{config: m.config}
  7695. client.init()
  7696. return client
  7697. }
  7698. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7699. // it returns an error otherwise.
  7700. func (m ContactMutation) Tx() (*Tx, error) {
  7701. if _, ok := m.driver.(*txDriver); !ok {
  7702. return nil, errors.New("ent: mutation is not running in a transaction")
  7703. }
  7704. tx := &Tx{config: m.config}
  7705. tx.init()
  7706. return tx, nil
  7707. }
  7708. // SetID sets the value of the id field. Note that this
  7709. // operation is only accepted on creation of Contact entities.
  7710. func (m *ContactMutation) SetID(id uint64) {
  7711. m.id = &id
  7712. }
  7713. // ID returns the ID value in the mutation. Note that the ID is only available
  7714. // if it was provided to the builder or after it was returned from the database.
  7715. func (m *ContactMutation) ID() (id uint64, exists bool) {
  7716. if m.id == nil {
  7717. return
  7718. }
  7719. return *m.id, true
  7720. }
  7721. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7722. // That means, if the mutation is applied within a transaction with an isolation level such
  7723. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7724. // or updated by the mutation.
  7725. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  7726. switch {
  7727. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7728. id, exists := m.ID()
  7729. if exists {
  7730. return []uint64{id}, nil
  7731. }
  7732. fallthrough
  7733. case m.op.Is(OpUpdate | OpDelete):
  7734. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  7735. default:
  7736. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7737. }
  7738. }
  7739. // SetCreatedAt sets the "created_at" field.
  7740. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  7741. m.created_at = &t
  7742. }
  7743. // CreatedAt returns the value of the "created_at" field in the mutation.
  7744. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  7745. v := m.created_at
  7746. if v == nil {
  7747. return
  7748. }
  7749. return *v, true
  7750. }
  7751. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  7752. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7754. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7755. if !m.op.Is(OpUpdateOne) {
  7756. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7757. }
  7758. if m.id == nil || m.oldValue == nil {
  7759. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7760. }
  7761. oldValue, err := m.oldValue(ctx)
  7762. if err != nil {
  7763. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7764. }
  7765. return oldValue.CreatedAt, nil
  7766. }
  7767. // ResetCreatedAt resets all changes to the "created_at" field.
  7768. func (m *ContactMutation) ResetCreatedAt() {
  7769. m.created_at = nil
  7770. }
  7771. // SetUpdatedAt sets the "updated_at" field.
  7772. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  7773. m.updated_at = &t
  7774. }
  7775. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7776. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  7777. v := m.updated_at
  7778. if v == nil {
  7779. return
  7780. }
  7781. return *v, true
  7782. }
  7783. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  7784. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7786. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7787. if !m.op.Is(OpUpdateOne) {
  7788. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7789. }
  7790. if m.id == nil || m.oldValue == nil {
  7791. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7792. }
  7793. oldValue, err := m.oldValue(ctx)
  7794. if err != nil {
  7795. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7796. }
  7797. return oldValue.UpdatedAt, nil
  7798. }
  7799. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7800. func (m *ContactMutation) ResetUpdatedAt() {
  7801. m.updated_at = nil
  7802. }
  7803. // SetStatus sets the "status" field.
  7804. func (m *ContactMutation) SetStatus(u uint8) {
  7805. m.status = &u
  7806. m.addstatus = nil
  7807. }
  7808. // Status returns the value of the "status" field in the mutation.
  7809. func (m *ContactMutation) Status() (r uint8, exists bool) {
  7810. v := m.status
  7811. if v == nil {
  7812. return
  7813. }
  7814. return *v, true
  7815. }
  7816. // OldStatus returns the old "status" field's value of the Contact entity.
  7817. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7819. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7820. if !m.op.Is(OpUpdateOne) {
  7821. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7822. }
  7823. if m.id == nil || m.oldValue == nil {
  7824. return v, errors.New("OldStatus requires an ID field in the mutation")
  7825. }
  7826. oldValue, err := m.oldValue(ctx)
  7827. if err != nil {
  7828. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7829. }
  7830. return oldValue.Status, nil
  7831. }
  7832. // AddStatus adds u to the "status" field.
  7833. func (m *ContactMutation) AddStatus(u int8) {
  7834. if m.addstatus != nil {
  7835. *m.addstatus += u
  7836. } else {
  7837. m.addstatus = &u
  7838. }
  7839. }
  7840. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7841. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  7842. v := m.addstatus
  7843. if v == nil {
  7844. return
  7845. }
  7846. return *v, true
  7847. }
  7848. // ClearStatus clears the value of the "status" field.
  7849. func (m *ContactMutation) ClearStatus() {
  7850. m.status = nil
  7851. m.addstatus = nil
  7852. m.clearedFields[contact.FieldStatus] = struct{}{}
  7853. }
  7854. // StatusCleared returns if the "status" field was cleared in this mutation.
  7855. func (m *ContactMutation) StatusCleared() bool {
  7856. _, ok := m.clearedFields[contact.FieldStatus]
  7857. return ok
  7858. }
  7859. // ResetStatus resets all changes to the "status" field.
  7860. func (m *ContactMutation) ResetStatus() {
  7861. m.status = nil
  7862. m.addstatus = nil
  7863. delete(m.clearedFields, contact.FieldStatus)
  7864. }
  7865. // SetDeletedAt sets the "deleted_at" field.
  7866. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  7867. m.deleted_at = &t
  7868. }
  7869. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7870. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  7871. v := m.deleted_at
  7872. if v == nil {
  7873. return
  7874. }
  7875. return *v, true
  7876. }
  7877. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  7878. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7879. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7880. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7881. if !m.op.Is(OpUpdateOne) {
  7882. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7883. }
  7884. if m.id == nil || m.oldValue == nil {
  7885. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7886. }
  7887. oldValue, err := m.oldValue(ctx)
  7888. if err != nil {
  7889. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7890. }
  7891. return oldValue.DeletedAt, nil
  7892. }
  7893. // ClearDeletedAt clears the value of the "deleted_at" field.
  7894. func (m *ContactMutation) ClearDeletedAt() {
  7895. m.deleted_at = nil
  7896. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  7897. }
  7898. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7899. func (m *ContactMutation) DeletedAtCleared() bool {
  7900. _, ok := m.clearedFields[contact.FieldDeletedAt]
  7901. return ok
  7902. }
  7903. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7904. func (m *ContactMutation) ResetDeletedAt() {
  7905. m.deleted_at = nil
  7906. delete(m.clearedFields, contact.FieldDeletedAt)
  7907. }
  7908. // SetWxWxid sets the "wx_wxid" field.
  7909. func (m *ContactMutation) SetWxWxid(s string) {
  7910. m.wx_wxid = &s
  7911. }
  7912. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7913. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  7914. v := m.wx_wxid
  7915. if v == nil {
  7916. return
  7917. }
  7918. return *v, true
  7919. }
  7920. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  7921. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7923. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  7924. if !m.op.Is(OpUpdateOne) {
  7925. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  7926. }
  7927. if m.id == nil || m.oldValue == nil {
  7928. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  7929. }
  7930. oldValue, err := m.oldValue(ctx)
  7931. if err != nil {
  7932. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  7933. }
  7934. return oldValue.WxWxid, nil
  7935. }
  7936. // ResetWxWxid resets all changes to the "wx_wxid" field.
  7937. func (m *ContactMutation) ResetWxWxid() {
  7938. m.wx_wxid = nil
  7939. }
  7940. // SetType sets the "type" field.
  7941. func (m *ContactMutation) SetType(i int) {
  7942. m._type = &i
  7943. m.add_type = nil
  7944. }
  7945. // GetType returns the value of the "type" field in the mutation.
  7946. func (m *ContactMutation) GetType() (r int, exists bool) {
  7947. v := m._type
  7948. if v == nil {
  7949. return
  7950. }
  7951. return *v, true
  7952. }
  7953. // OldType returns the old "type" field's value of the Contact entity.
  7954. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7956. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  7957. if !m.op.Is(OpUpdateOne) {
  7958. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7959. }
  7960. if m.id == nil || m.oldValue == nil {
  7961. return v, errors.New("OldType requires an ID field in the mutation")
  7962. }
  7963. oldValue, err := m.oldValue(ctx)
  7964. if err != nil {
  7965. return v, fmt.Errorf("querying old value for OldType: %w", err)
  7966. }
  7967. return oldValue.Type, nil
  7968. }
  7969. // AddType adds i to the "type" field.
  7970. func (m *ContactMutation) AddType(i int) {
  7971. if m.add_type != nil {
  7972. *m.add_type += i
  7973. } else {
  7974. m.add_type = &i
  7975. }
  7976. }
  7977. // AddedType returns the value that was added to the "type" field in this mutation.
  7978. func (m *ContactMutation) AddedType() (r int, exists bool) {
  7979. v := m.add_type
  7980. if v == nil {
  7981. return
  7982. }
  7983. return *v, true
  7984. }
  7985. // ClearType clears the value of the "type" field.
  7986. func (m *ContactMutation) ClearType() {
  7987. m._type = nil
  7988. m.add_type = nil
  7989. m.clearedFields[contact.FieldType] = struct{}{}
  7990. }
  7991. // TypeCleared returns if the "type" field was cleared in this mutation.
  7992. func (m *ContactMutation) TypeCleared() bool {
  7993. _, ok := m.clearedFields[contact.FieldType]
  7994. return ok
  7995. }
  7996. // ResetType resets all changes to the "type" field.
  7997. func (m *ContactMutation) ResetType() {
  7998. m._type = nil
  7999. m.add_type = nil
  8000. delete(m.clearedFields, contact.FieldType)
  8001. }
  8002. // SetWxid sets the "wxid" field.
  8003. func (m *ContactMutation) SetWxid(s string) {
  8004. m.wxid = &s
  8005. }
  8006. // Wxid returns the value of the "wxid" field in the mutation.
  8007. func (m *ContactMutation) Wxid() (r string, exists bool) {
  8008. v := m.wxid
  8009. if v == nil {
  8010. return
  8011. }
  8012. return *v, true
  8013. }
  8014. // OldWxid returns the old "wxid" field's value of the Contact entity.
  8015. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8017. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  8018. if !m.op.Is(OpUpdateOne) {
  8019. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  8020. }
  8021. if m.id == nil || m.oldValue == nil {
  8022. return v, errors.New("OldWxid requires an ID field in the mutation")
  8023. }
  8024. oldValue, err := m.oldValue(ctx)
  8025. if err != nil {
  8026. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  8027. }
  8028. return oldValue.Wxid, nil
  8029. }
  8030. // ResetWxid resets all changes to the "wxid" field.
  8031. func (m *ContactMutation) ResetWxid() {
  8032. m.wxid = nil
  8033. }
  8034. // SetAccount sets the "account" field.
  8035. func (m *ContactMutation) SetAccount(s string) {
  8036. m.account = &s
  8037. }
  8038. // Account returns the value of the "account" field in the mutation.
  8039. func (m *ContactMutation) Account() (r string, exists bool) {
  8040. v := m.account
  8041. if v == nil {
  8042. return
  8043. }
  8044. return *v, true
  8045. }
  8046. // OldAccount returns the old "account" field's value of the Contact entity.
  8047. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8049. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  8050. if !m.op.Is(OpUpdateOne) {
  8051. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  8052. }
  8053. if m.id == nil || m.oldValue == nil {
  8054. return v, errors.New("OldAccount requires an ID field in the mutation")
  8055. }
  8056. oldValue, err := m.oldValue(ctx)
  8057. if err != nil {
  8058. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  8059. }
  8060. return oldValue.Account, nil
  8061. }
  8062. // ResetAccount resets all changes to the "account" field.
  8063. func (m *ContactMutation) ResetAccount() {
  8064. m.account = nil
  8065. }
  8066. // SetNickname sets the "nickname" field.
  8067. func (m *ContactMutation) SetNickname(s string) {
  8068. m.nickname = &s
  8069. }
  8070. // Nickname returns the value of the "nickname" field in the mutation.
  8071. func (m *ContactMutation) Nickname() (r string, exists bool) {
  8072. v := m.nickname
  8073. if v == nil {
  8074. return
  8075. }
  8076. return *v, true
  8077. }
  8078. // OldNickname returns the old "nickname" field's value of the Contact entity.
  8079. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8081. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  8082. if !m.op.Is(OpUpdateOne) {
  8083. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  8084. }
  8085. if m.id == nil || m.oldValue == nil {
  8086. return v, errors.New("OldNickname requires an ID field in the mutation")
  8087. }
  8088. oldValue, err := m.oldValue(ctx)
  8089. if err != nil {
  8090. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  8091. }
  8092. return oldValue.Nickname, nil
  8093. }
  8094. // ResetNickname resets all changes to the "nickname" field.
  8095. func (m *ContactMutation) ResetNickname() {
  8096. m.nickname = nil
  8097. }
  8098. // SetMarkname sets the "markname" field.
  8099. func (m *ContactMutation) SetMarkname(s string) {
  8100. m.markname = &s
  8101. }
  8102. // Markname returns the value of the "markname" field in the mutation.
  8103. func (m *ContactMutation) Markname() (r string, exists bool) {
  8104. v := m.markname
  8105. if v == nil {
  8106. return
  8107. }
  8108. return *v, true
  8109. }
  8110. // OldMarkname returns the old "markname" field's value of the Contact entity.
  8111. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8113. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  8114. if !m.op.Is(OpUpdateOne) {
  8115. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  8116. }
  8117. if m.id == nil || m.oldValue == nil {
  8118. return v, errors.New("OldMarkname requires an ID field in the mutation")
  8119. }
  8120. oldValue, err := m.oldValue(ctx)
  8121. if err != nil {
  8122. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  8123. }
  8124. return oldValue.Markname, nil
  8125. }
  8126. // ResetMarkname resets all changes to the "markname" field.
  8127. func (m *ContactMutation) ResetMarkname() {
  8128. m.markname = nil
  8129. }
  8130. // SetHeadimg sets the "headimg" field.
  8131. func (m *ContactMutation) SetHeadimg(s string) {
  8132. m.headimg = &s
  8133. }
  8134. // Headimg returns the value of the "headimg" field in the mutation.
  8135. func (m *ContactMutation) Headimg() (r string, exists bool) {
  8136. v := m.headimg
  8137. if v == nil {
  8138. return
  8139. }
  8140. return *v, true
  8141. }
  8142. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  8143. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8145. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  8146. if !m.op.Is(OpUpdateOne) {
  8147. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  8148. }
  8149. if m.id == nil || m.oldValue == nil {
  8150. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  8151. }
  8152. oldValue, err := m.oldValue(ctx)
  8153. if err != nil {
  8154. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  8155. }
  8156. return oldValue.Headimg, nil
  8157. }
  8158. // ResetHeadimg resets all changes to the "headimg" field.
  8159. func (m *ContactMutation) ResetHeadimg() {
  8160. m.headimg = nil
  8161. }
  8162. // SetSex sets the "sex" field.
  8163. func (m *ContactMutation) SetSex(i int) {
  8164. m.sex = &i
  8165. m.addsex = nil
  8166. }
  8167. // Sex returns the value of the "sex" field in the mutation.
  8168. func (m *ContactMutation) Sex() (r int, exists bool) {
  8169. v := m.sex
  8170. if v == nil {
  8171. return
  8172. }
  8173. return *v, true
  8174. }
  8175. // OldSex returns the old "sex" field's value of the Contact entity.
  8176. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8178. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  8179. if !m.op.Is(OpUpdateOne) {
  8180. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  8181. }
  8182. if m.id == nil || m.oldValue == nil {
  8183. return v, errors.New("OldSex requires an ID field in the mutation")
  8184. }
  8185. oldValue, err := m.oldValue(ctx)
  8186. if err != nil {
  8187. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  8188. }
  8189. return oldValue.Sex, nil
  8190. }
  8191. // AddSex adds i to the "sex" field.
  8192. func (m *ContactMutation) AddSex(i int) {
  8193. if m.addsex != nil {
  8194. *m.addsex += i
  8195. } else {
  8196. m.addsex = &i
  8197. }
  8198. }
  8199. // AddedSex returns the value that was added to the "sex" field in this mutation.
  8200. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  8201. v := m.addsex
  8202. if v == nil {
  8203. return
  8204. }
  8205. return *v, true
  8206. }
  8207. // ResetSex resets all changes to the "sex" field.
  8208. func (m *ContactMutation) ResetSex() {
  8209. m.sex = nil
  8210. m.addsex = nil
  8211. }
  8212. // SetStarrole sets the "starrole" field.
  8213. func (m *ContactMutation) SetStarrole(s string) {
  8214. m.starrole = &s
  8215. }
  8216. // Starrole returns the value of the "starrole" field in the mutation.
  8217. func (m *ContactMutation) Starrole() (r string, exists bool) {
  8218. v := m.starrole
  8219. if v == nil {
  8220. return
  8221. }
  8222. return *v, true
  8223. }
  8224. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  8225. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8227. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  8228. if !m.op.Is(OpUpdateOne) {
  8229. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  8230. }
  8231. if m.id == nil || m.oldValue == nil {
  8232. return v, errors.New("OldStarrole requires an ID field in the mutation")
  8233. }
  8234. oldValue, err := m.oldValue(ctx)
  8235. if err != nil {
  8236. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  8237. }
  8238. return oldValue.Starrole, nil
  8239. }
  8240. // ResetStarrole resets all changes to the "starrole" field.
  8241. func (m *ContactMutation) ResetStarrole() {
  8242. m.starrole = nil
  8243. }
  8244. // SetDontseeit sets the "dontseeit" field.
  8245. func (m *ContactMutation) SetDontseeit(i int) {
  8246. m.dontseeit = &i
  8247. m.adddontseeit = nil
  8248. }
  8249. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  8250. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  8251. v := m.dontseeit
  8252. if v == nil {
  8253. return
  8254. }
  8255. return *v, true
  8256. }
  8257. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  8258. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8260. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  8261. if !m.op.Is(OpUpdateOne) {
  8262. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  8263. }
  8264. if m.id == nil || m.oldValue == nil {
  8265. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  8266. }
  8267. oldValue, err := m.oldValue(ctx)
  8268. if err != nil {
  8269. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  8270. }
  8271. return oldValue.Dontseeit, nil
  8272. }
  8273. // AddDontseeit adds i to the "dontseeit" field.
  8274. func (m *ContactMutation) AddDontseeit(i int) {
  8275. if m.adddontseeit != nil {
  8276. *m.adddontseeit += i
  8277. } else {
  8278. m.adddontseeit = &i
  8279. }
  8280. }
  8281. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  8282. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  8283. v := m.adddontseeit
  8284. if v == nil {
  8285. return
  8286. }
  8287. return *v, true
  8288. }
  8289. // ResetDontseeit resets all changes to the "dontseeit" field.
  8290. func (m *ContactMutation) ResetDontseeit() {
  8291. m.dontseeit = nil
  8292. m.adddontseeit = nil
  8293. }
  8294. // SetDontseeme sets the "dontseeme" field.
  8295. func (m *ContactMutation) SetDontseeme(i int) {
  8296. m.dontseeme = &i
  8297. m.adddontseeme = nil
  8298. }
  8299. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  8300. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  8301. v := m.dontseeme
  8302. if v == nil {
  8303. return
  8304. }
  8305. return *v, true
  8306. }
  8307. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  8308. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8310. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  8311. if !m.op.Is(OpUpdateOne) {
  8312. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  8313. }
  8314. if m.id == nil || m.oldValue == nil {
  8315. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  8316. }
  8317. oldValue, err := m.oldValue(ctx)
  8318. if err != nil {
  8319. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  8320. }
  8321. return oldValue.Dontseeme, nil
  8322. }
  8323. // AddDontseeme adds i to the "dontseeme" field.
  8324. func (m *ContactMutation) AddDontseeme(i int) {
  8325. if m.adddontseeme != nil {
  8326. *m.adddontseeme += i
  8327. } else {
  8328. m.adddontseeme = &i
  8329. }
  8330. }
  8331. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  8332. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  8333. v := m.adddontseeme
  8334. if v == nil {
  8335. return
  8336. }
  8337. return *v, true
  8338. }
  8339. // ResetDontseeme resets all changes to the "dontseeme" field.
  8340. func (m *ContactMutation) ResetDontseeme() {
  8341. m.dontseeme = nil
  8342. m.adddontseeme = nil
  8343. }
  8344. // SetLag sets the "lag" field.
  8345. func (m *ContactMutation) SetLag(s string) {
  8346. m.lag = &s
  8347. }
  8348. // Lag returns the value of the "lag" field in the mutation.
  8349. func (m *ContactMutation) Lag() (r string, exists bool) {
  8350. v := m.lag
  8351. if v == nil {
  8352. return
  8353. }
  8354. return *v, true
  8355. }
  8356. // OldLag returns the old "lag" field's value of the Contact entity.
  8357. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8359. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  8360. if !m.op.Is(OpUpdateOne) {
  8361. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  8362. }
  8363. if m.id == nil || m.oldValue == nil {
  8364. return v, errors.New("OldLag requires an ID field in the mutation")
  8365. }
  8366. oldValue, err := m.oldValue(ctx)
  8367. if err != nil {
  8368. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  8369. }
  8370. return oldValue.Lag, nil
  8371. }
  8372. // ResetLag resets all changes to the "lag" field.
  8373. func (m *ContactMutation) ResetLag() {
  8374. m.lag = nil
  8375. }
  8376. // SetGid sets the "gid" field.
  8377. func (m *ContactMutation) SetGid(s string) {
  8378. m.gid = &s
  8379. }
  8380. // Gid returns the value of the "gid" field in the mutation.
  8381. func (m *ContactMutation) Gid() (r string, exists bool) {
  8382. v := m.gid
  8383. if v == nil {
  8384. return
  8385. }
  8386. return *v, true
  8387. }
  8388. // OldGid returns the old "gid" field's value of the Contact entity.
  8389. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8391. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  8392. if !m.op.Is(OpUpdateOne) {
  8393. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  8394. }
  8395. if m.id == nil || m.oldValue == nil {
  8396. return v, errors.New("OldGid requires an ID field in the mutation")
  8397. }
  8398. oldValue, err := m.oldValue(ctx)
  8399. if err != nil {
  8400. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  8401. }
  8402. return oldValue.Gid, nil
  8403. }
  8404. // ResetGid resets all changes to the "gid" field.
  8405. func (m *ContactMutation) ResetGid() {
  8406. m.gid = nil
  8407. }
  8408. // SetGname sets the "gname" field.
  8409. func (m *ContactMutation) SetGname(s string) {
  8410. m.gname = &s
  8411. }
  8412. // Gname returns the value of the "gname" field in the mutation.
  8413. func (m *ContactMutation) Gname() (r string, exists bool) {
  8414. v := m.gname
  8415. if v == nil {
  8416. return
  8417. }
  8418. return *v, true
  8419. }
  8420. // OldGname returns the old "gname" field's value of the Contact entity.
  8421. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8423. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  8424. if !m.op.Is(OpUpdateOne) {
  8425. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  8426. }
  8427. if m.id == nil || m.oldValue == nil {
  8428. return v, errors.New("OldGname requires an ID field in the mutation")
  8429. }
  8430. oldValue, err := m.oldValue(ctx)
  8431. if err != nil {
  8432. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  8433. }
  8434. return oldValue.Gname, nil
  8435. }
  8436. // ResetGname resets all changes to the "gname" field.
  8437. func (m *ContactMutation) ResetGname() {
  8438. m.gname = nil
  8439. }
  8440. // SetV3 sets the "v3" field.
  8441. func (m *ContactMutation) SetV3(s string) {
  8442. m.v3 = &s
  8443. }
  8444. // V3 returns the value of the "v3" field in the mutation.
  8445. func (m *ContactMutation) V3() (r string, exists bool) {
  8446. v := m.v3
  8447. if v == nil {
  8448. return
  8449. }
  8450. return *v, true
  8451. }
  8452. // OldV3 returns the old "v3" field's value of the Contact entity.
  8453. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8455. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  8456. if !m.op.Is(OpUpdateOne) {
  8457. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  8458. }
  8459. if m.id == nil || m.oldValue == nil {
  8460. return v, errors.New("OldV3 requires an ID field in the mutation")
  8461. }
  8462. oldValue, err := m.oldValue(ctx)
  8463. if err != nil {
  8464. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  8465. }
  8466. return oldValue.V3, nil
  8467. }
  8468. // ResetV3 resets all changes to the "v3" field.
  8469. func (m *ContactMutation) ResetV3() {
  8470. m.v3 = nil
  8471. }
  8472. // SetOrganizationID sets the "organization_id" field.
  8473. func (m *ContactMutation) SetOrganizationID(u uint64) {
  8474. m.organization_id = &u
  8475. m.addorganization_id = nil
  8476. }
  8477. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8478. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  8479. v := m.organization_id
  8480. if v == nil {
  8481. return
  8482. }
  8483. return *v, true
  8484. }
  8485. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  8486. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8488. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8489. if !m.op.Is(OpUpdateOne) {
  8490. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8491. }
  8492. if m.id == nil || m.oldValue == nil {
  8493. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8494. }
  8495. oldValue, err := m.oldValue(ctx)
  8496. if err != nil {
  8497. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8498. }
  8499. return oldValue.OrganizationID, nil
  8500. }
  8501. // AddOrganizationID adds u to the "organization_id" field.
  8502. func (m *ContactMutation) AddOrganizationID(u int64) {
  8503. if m.addorganization_id != nil {
  8504. *m.addorganization_id += u
  8505. } else {
  8506. m.addorganization_id = &u
  8507. }
  8508. }
  8509. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8510. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  8511. v := m.addorganization_id
  8512. if v == nil {
  8513. return
  8514. }
  8515. return *v, true
  8516. }
  8517. // ClearOrganizationID clears the value of the "organization_id" field.
  8518. func (m *ContactMutation) ClearOrganizationID() {
  8519. m.organization_id = nil
  8520. m.addorganization_id = nil
  8521. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  8522. }
  8523. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  8524. func (m *ContactMutation) OrganizationIDCleared() bool {
  8525. _, ok := m.clearedFields[contact.FieldOrganizationID]
  8526. return ok
  8527. }
  8528. // ResetOrganizationID resets all changes to the "organization_id" field.
  8529. func (m *ContactMutation) ResetOrganizationID() {
  8530. m.organization_id = nil
  8531. m.addorganization_id = nil
  8532. delete(m.clearedFields, contact.FieldOrganizationID)
  8533. }
  8534. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  8535. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  8536. if m.contact_relationships == nil {
  8537. m.contact_relationships = make(map[uint64]struct{})
  8538. }
  8539. for i := range ids {
  8540. m.contact_relationships[ids[i]] = struct{}{}
  8541. }
  8542. }
  8543. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  8544. func (m *ContactMutation) ClearContactRelationships() {
  8545. m.clearedcontact_relationships = true
  8546. }
  8547. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  8548. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  8549. return m.clearedcontact_relationships
  8550. }
  8551. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  8552. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  8553. if m.removedcontact_relationships == nil {
  8554. m.removedcontact_relationships = make(map[uint64]struct{})
  8555. }
  8556. for i := range ids {
  8557. delete(m.contact_relationships, ids[i])
  8558. m.removedcontact_relationships[ids[i]] = struct{}{}
  8559. }
  8560. }
  8561. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  8562. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  8563. for id := range m.removedcontact_relationships {
  8564. ids = append(ids, id)
  8565. }
  8566. return
  8567. }
  8568. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  8569. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  8570. for id := range m.contact_relationships {
  8571. ids = append(ids, id)
  8572. }
  8573. return
  8574. }
  8575. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  8576. func (m *ContactMutation) ResetContactRelationships() {
  8577. m.contact_relationships = nil
  8578. m.clearedcontact_relationships = false
  8579. m.removedcontact_relationships = nil
  8580. }
  8581. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  8582. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  8583. if m.contact_messages == nil {
  8584. m.contact_messages = make(map[uint64]struct{})
  8585. }
  8586. for i := range ids {
  8587. m.contact_messages[ids[i]] = struct{}{}
  8588. }
  8589. }
  8590. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  8591. func (m *ContactMutation) ClearContactMessages() {
  8592. m.clearedcontact_messages = true
  8593. }
  8594. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  8595. func (m *ContactMutation) ContactMessagesCleared() bool {
  8596. return m.clearedcontact_messages
  8597. }
  8598. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  8599. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  8600. if m.removedcontact_messages == nil {
  8601. m.removedcontact_messages = make(map[uint64]struct{})
  8602. }
  8603. for i := range ids {
  8604. delete(m.contact_messages, ids[i])
  8605. m.removedcontact_messages[ids[i]] = struct{}{}
  8606. }
  8607. }
  8608. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  8609. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  8610. for id := range m.removedcontact_messages {
  8611. ids = append(ids, id)
  8612. }
  8613. return
  8614. }
  8615. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  8616. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  8617. for id := range m.contact_messages {
  8618. ids = append(ids, id)
  8619. }
  8620. return
  8621. }
  8622. // ResetContactMessages resets all changes to the "contact_messages" edge.
  8623. func (m *ContactMutation) ResetContactMessages() {
  8624. m.contact_messages = nil
  8625. m.clearedcontact_messages = false
  8626. m.removedcontact_messages = nil
  8627. }
  8628. // Where appends a list predicates to the ContactMutation builder.
  8629. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  8630. m.predicates = append(m.predicates, ps...)
  8631. }
  8632. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  8633. // users can use type-assertion to append predicates that do not depend on any generated package.
  8634. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  8635. p := make([]predicate.Contact, len(ps))
  8636. for i := range ps {
  8637. p[i] = ps[i]
  8638. }
  8639. m.Where(p...)
  8640. }
  8641. // Op returns the operation name.
  8642. func (m *ContactMutation) Op() Op {
  8643. return m.op
  8644. }
  8645. // SetOp allows setting the mutation operation.
  8646. func (m *ContactMutation) SetOp(op Op) {
  8647. m.op = op
  8648. }
  8649. // Type returns the node type of this mutation (Contact).
  8650. func (m *ContactMutation) Type() string {
  8651. return m.typ
  8652. }
  8653. // Fields returns all fields that were changed during this mutation. Note that in
  8654. // order to get all numeric fields that were incremented/decremented, call
  8655. // AddedFields().
  8656. func (m *ContactMutation) Fields() []string {
  8657. fields := make([]string, 0, 20)
  8658. if m.created_at != nil {
  8659. fields = append(fields, contact.FieldCreatedAt)
  8660. }
  8661. if m.updated_at != nil {
  8662. fields = append(fields, contact.FieldUpdatedAt)
  8663. }
  8664. if m.status != nil {
  8665. fields = append(fields, contact.FieldStatus)
  8666. }
  8667. if m.deleted_at != nil {
  8668. fields = append(fields, contact.FieldDeletedAt)
  8669. }
  8670. if m.wx_wxid != nil {
  8671. fields = append(fields, contact.FieldWxWxid)
  8672. }
  8673. if m._type != nil {
  8674. fields = append(fields, contact.FieldType)
  8675. }
  8676. if m.wxid != nil {
  8677. fields = append(fields, contact.FieldWxid)
  8678. }
  8679. if m.account != nil {
  8680. fields = append(fields, contact.FieldAccount)
  8681. }
  8682. if m.nickname != nil {
  8683. fields = append(fields, contact.FieldNickname)
  8684. }
  8685. if m.markname != nil {
  8686. fields = append(fields, contact.FieldMarkname)
  8687. }
  8688. if m.headimg != nil {
  8689. fields = append(fields, contact.FieldHeadimg)
  8690. }
  8691. if m.sex != nil {
  8692. fields = append(fields, contact.FieldSex)
  8693. }
  8694. if m.starrole != nil {
  8695. fields = append(fields, contact.FieldStarrole)
  8696. }
  8697. if m.dontseeit != nil {
  8698. fields = append(fields, contact.FieldDontseeit)
  8699. }
  8700. if m.dontseeme != nil {
  8701. fields = append(fields, contact.FieldDontseeme)
  8702. }
  8703. if m.lag != nil {
  8704. fields = append(fields, contact.FieldLag)
  8705. }
  8706. if m.gid != nil {
  8707. fields = append(fields, contact.FieldGid)
  8708. }
  8709. if m.gname != nil {
  8710. fields = append(fields, contact.FieldGname)
  8711. }
  8712. if m.v3 != nil {
  8713. fields = append(fields, contact.FieldV3)
  8714. }
  8715. if m.organization_id != nil {
  8716. fields = append(fields, contact.FieldOrganizationID)
  8717. }
  8718. return fields
  8719. }
  8720. // Field returns the value of a field with the given name. The second boolean
  8721. // return value indicates that this field was not set, or was not defined in the
  8722. // schema.
  8723. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  8724. switch name {
  8725. case contact.FieldCreatedAt:
  8726. return m.CreatedAt()
  8727. case contact.FieldUpdatedAt:
  8728. return m.UpdatedAt()
  8729. case contact.FieldStatus:
  8730. return m.Status()
  8731. case contact.FieldDeletedAt:
  8732. return m.DeletedAt()
  8733. case contact.FieldWxWxid:
  8734. return m.WxWxid()
  8735. case contact.FieldType:
  8736. return m.GetType()
  8737. case contact.FieldWxid:
  8738. return m.Wxid()
  8739. case contact.FieldAccount:
  8740. return m.Account()
  8741. case contact.FieldNickname:
  8742. return m.Nickname()
  8743. case contact.FieldMarkname:
  8744. return m.Markname()
  8745. case contact.FieldHeadimg:
  8746. return m.Headimg()
  8747. case contact.FieldSex:
  8748. return m.Sex()
  8749. case contact.FieldStarrole:
  8750. return m.Starrole()
  8751. case contact.FieldDontseeit:
  8752. return m.Dontseeit()
  8753. case contact.FieldDontseeme:
  8754. return m.Dontseeme()
  8755. case contact.FieldLag:
  8756. return m.Lag()
  8757. case contact.FieldGid:
  8758. return m.Gid()
  8759. case contact.FieldGname:
  8760. return m.Gname()
  8761. case contact.FieldV3:
  8762. return m.V3()
  8763. case contact.FieldOrganizationID:
  8764. return m.OrganizationID()
  8765. }
  8766. return nil, false
  8767. }
  8768. // OldField returns the old value of the field from the database. An error is
  8769. // returned if the mutation operation is not UpdateOne, or the query to the
  8770. // database failed.
  8771. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8772. switch name {
  8773. case contact.FieldCreatedAt:
  8774. return m.OldCreatedAt(ctx)
  8775. case contact.FieldUpdatedAt:
  8776. return m.OldUpdatedAt(ctx)
  8777. case contact.FieldStatus:
  8778. return m.OldStatus(ctx)
  8779. case contact.FieldDeletedAt:
  8780. return m.OldDeletedAt(ctx)
  8781. case contact.FieldWxWxid:
  8782. return m.OldWxWxid(ctx)
  8783. case contact.FieldType:
  8784. return m.OldType(ctx)
  8785. case contact.FieldWxid:
  8786. return m.OldWxid(ctx)
  8787. case contact.FieldAccount:
  8788. return m.OldAccount(ctx)
  8789. case contact.FieldNickname:
  8790. return m.OldNickname(ctx)
  8791. case contact.FieldMarkname:
  8792. return m.OldMarkname(ctx)
  8793. case contact.FieldHeadimg:
  8794. return m.OldHeadimg(ctx)
  8795. case contact.FieldSex:
  8796. return m.OldSex(ctx)
  8797. case contact.FieldStarrole:
  8798. return m.OldStarrole(ctx)
  8799. case contact.FieldDontseeit:
  8800. return m.OldDontseeit(ctx)
  8801. case contact.FieldDontseeme:
  8802. return m.OldDontseeme(ctx)
  8803. case contact.FieldLag:
  8804. return m.OldLag(ctx)
  8805. case contact.FieldGid:
  8806. return m.OldGid(ctx)
  8807. case contact.FieldGname:
  8808. return m.OldGname(ctx)
  8809. case contact.FieldV3:
  8810. return m.OldV3(ctx)
  8811. case contact.FieldOrganizationID:
  8812. return m.OldOrganizationID(ctx)
  8813. }
  8814. return nil, fmt.Errorf("unknown Contact field %s", name)
  8815. }
  8816. // SetField sets the value of a field with the given name. It returns an error if
  8817. // the field is not defined in the schema, or if the type mismatched the field
  8818. // type.
  8819. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  8820. switch name {
  8821. case contact.FieldCreatedAt:
  8822. v, ok := value.(time.Time)
  8823. if !ok {
  8824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8825. }
  8826. m.SetCreatedAt(v)
  8827. return nil
  8828. case contact.FieldUpdatedAt:
  8829. v, ok := value.(time.Time)
  8830. if !ok {
  8831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8832. }
  8833. m.SetUpdatedAt(v)
  8834. return nil
  8835. case contact.FieldStatus:
  8836. v, ok := value.(uint8)
  8837. if !ok {
  8838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8839. }
  8840. m.SetStatus(v)
  8841. return nil
  8842. case contact.FieldDeletedAt:
  8843. v, ok := value.(time.Time)
  8844. if !ok {
  8845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8846. }
  8847. m.SetDeletedAt(v)
  8848. return nil
  8849. case contact.FieldWxWxid:
  8850. v, ok := value.(string)
  8851. if !ok {
  8852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8853. }
  8854. m.SetWxWxid(v)
  8855. return nil
  8856. case contact.FieldType:
  8857. v, ok := value.(int)
  8858. if !ok {
  8859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8860. }
  8861. m.SetType(v)
  8862. return nil
  8863. case contact.FieldWxid:
  8864. v, ok := value.(string)
  8865. if !ok {
  8866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8867. }
  8868. m.SetWxid(v)
  8869. return nil
  8870. case contact.FieldAccount:
  8871. v, ok := value.(string)
  8872. if !ok {
  8873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8874. }
  8875. m.SetAccount(v)
  8876. return nil
  8877. case contact.FieldNickname:
  8878. v, ok := value.(string)
  8879. if !ok {
  8880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8881. }
  8882. m.SetNickname(v)
  8883. return nil
  8884. case contact.FieldMarkname:
  8885. v, ok := value.(string)
  8886. if !ok {
  8887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8888. }
  8889. m.SetMarkname(v)
  8890. return nil
  8891. case contact.FieldHeadimg:
  8892. v, ok := value.(string)
  8893. if !ok {
  8894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8895. }
  8896. m.SetHeadimg(v)
  8897. return nil
  8898. case contact.FieldSex:
  8899. v, ok := value.(int)
  8900. if !ok {
  8901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8902. }
  8903. m.SetSex(v)
  8904. return nil
  8905. case contact.FieldStarrole:
  8906. v, ok := value.(string)
  8907. if !ok {
  8908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8909. }
  8910. m.SetStarrole(v)
  8911. return nil
  8912. case contact.FieldDontseeit:
  8913. v, ok := value.(int)
  8914. if !ok {
  8915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8916. }
  8917. m.SetDontseeit(v)
  8918. return nil
  8919. case contact.FieldDontseeme:
  8920. v, ok := value.(int)
  8921. if !ok {
  8922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8923. }
  8924. m.SetDontseeme(v)
  8925. return nil
  8926. case contact.FieldLag:
  8927. v, ok := value.(string)
  8928. if !ok {
  8929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8930. }
  8931. m.SetLag(v)
  8932. return nil
  8933. case contact.FieldGid:
  8934. v, ok := value.(string)
  8935. if !ok {
  8936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8937. }
  8938. m.SetGid(v)
  8939. return nil
  8940. case contact.FieldGname:
  8941. v, ok := value.(string)
  8942. if !ok {
  8943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8944. }
  8945. m.SetGname(v)
  8946. return nil
  8947. case contact.FieldV3:
  8948. v, ok := value.(string)
  8949. if !ok {
  8950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8951. }
  8952. m.SetV3(v)
  8953. return nil
  8954. case contact.FieldOrganizationID:
  8955. v, ok := value.(uint64)
  8956. if !ok {
  8957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8958. }
  8959. m.SetOrganizationID(v)
  8960. return nil
  8961. }
  8962. return fmt.Errorf("unknown Contact field %s", name)
  8963. }
  8964. // AddedFields returns all numeric fields that were incremented/decremented during
  8965. // this mutation.
  8966. func (m *ContactMutation) AddedFields() []string {
  8967. var fields []string
  8968. if m.addstatus != nil {
  8969. fields = append(fields, contact.FieldStatus)
  8970. }
  8971. if m.add_type != nil {
  8972. fields = append(fields, contact.FieldType)
  8973. }
  8974. if m.addsex != nil {
  8975. fields = append(fields, contact.FieldSex)
  8976. }
  8977. if m.adddontseeit != nil {
  8978. fields = append(fields, contact.FieldDontseeit)
  8979. }
  8980. if m.adddontseeme != nil {
  8981. fields = append(fields, contact.FieldDontseeme)
  8982. }
  8983. if m.addorganization_id != nil {
  8984. fields = append(fields, contact.FieldOrganizationID)
  8985. }
  8986. return fields
  8987. }
  8988. // AddedField returns the numeric value that was incremented/decremented on a field
  8989. // with the given name. The second boolean return value indicates that this field
  8990. // was not set, or was not defined in the schema.
  8991. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  8992. switch name {
  8993. case contact.FieldStatus:
  8994. return m.AddedStatus()
  8995. case contact.FieldType:
  8996. return m.AddedType()
  8997. case contact.FieldSex:
  8998. return m.AddedSex()
  8999. case contact.FieldDontseeit:
  9000. return m.AddedDontseeit()
  9001. case contact.FieldDontseeme:
  9002. return m.AddedDontseeme()
  9003. case contact.FieldOrganizationID:
  9004. return m.AddedOrganizationID()
  9005. }
  9006. return nil, false
  9007. }
  9008. // AddField adds the value to the field with the given name. It returns an error if
  9009. // the field is not defined in the schema, or if the type mismatched the field
  9010. // type.
  9011. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  9012. switch name {
  9013. case contact.FieldStatus:
  9014. v, ok := value.(int8)
  9015. if !ok {
  9016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9017. }
  9018. m.AddStatus(v)
  9019. return nil
  9020. case contact.FieldType:
  9021. v, ok := value.(int)
  9022. if !ok {
  9023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9024. }
  9025. m.AddType(v)
  9026. return nil
  9027. case contact.FieldSex:
  9028. v, ok := value.(int)
  9029. if !ok {
  9030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9031. }
  9032. m.AddSex(v)
  9033. return nil
  9034. case contact.FieldDontseeit:
  9035. v, ok := value.(int)
  9036. if !ok {
  9037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9038. }
  9039. m.AddDontseeit(v)
  9040. return nil
  9041. case contact.FieldDontseeme:
  9042. v, ok := value.(int)
  9043. if !ok {
  9044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9045. }
  9046. m.AddDontseeme(v)
  9047. return nil
  9048. case contact.FieldOrganizationID:
  9049. v, ok := value.(int64)
  9050. if !ok {
  9051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9052. }
  9053. m.AddOrganizationID(v)
  9054. return nil
  9055. }
  9056. return fmt.Errorf("unknown Contact numeric field %s", name)
  9057. }
  9058. // ClearedFields returns all nullable fields that were cleared during this
  9059. // mutation.
  9060. func (m *ContactMutation) ClearedFields() []string {
  9061. var fields []string
  9062. if m.FieldCleared(contact.FieldStatus) {
  9063. fields = append(fields, contact.FieldStatus)
  9064. }
  9065. if m.FieldCleared(contact.FieldDeletedAt) {
  9066. fields = append(fields, contact.FieldDeletedAt)
  9067. }
  9068. if m.FieldCleared(contact.FieldType) {
  9069. fields = append(fields, contact.FieldType)
  9070. }
  9071. if m.FieldCleared(contact.FieldOrganizationID) {
  9072. fields = append(fields, contact.FieldOrganizationID)
  9073. }
  9074. return fields
  9075. }
  9076. // FieldCleared returns a boolean indicating if a field with the given name was
  9077. // cleared in this mutation.
  9078. func (m *ContactMutation) FieldCleared(name string) bool {
  9079. _, ok := m.clearedFields[name]
  9080. return ok
  9081. }
  9082. // ClearField clears the value of the field with the given name. It returns an
  9083. // error if the field is not defined in the schema.
  9084. func (m *ContactMutation) ClearField(name string) error {
  9085. switch name {
  9086. case contact.FieldStatus:
  9087. m.ClearStatus()
  9088. return nil
  9089. case contact.FieldDeletedAt:
  9090. m.ClearDeletedAt()
  9091. return nil
  9092. case contact.FieldType:
  9093. m.ClearType()
  9094. return nil
  9095. case contact.FieldOrganizationID:
  9096. m.ClearOrganizationID()
  9097. return nil
  9098. }
  9099. return fmt.Errorf("unknown Contact nullable field %s", name)
  9100. }
  9101. // ResetField resets all changes in the mutation for the field with the given name.
  9102. // It returns an error if the field is not defined in the schema.
  9103. func (m *ContactMutation) ResetField(name string) error {
  9104. switch name {
  9105. case contact.FieldCreatedAt:
  9106. m.ResetCreatedAt()
  9107. return nil
  9108. case contact.FieldUpdatedAt:
  9109. m.ResetUpdatedAt()
  9110. return nil
  9111. case contact.FieldStatus:
  9112. m.ResetStatus()
  9113. return nil
  9114. case contact.FieldDeletedAt:
  9115. m.ResetDeletedAt()
  9116. return nil
  9117. case contact.FieldWxWxid:
  9118. m.ResetWxWxid()
  9119. return nil
  9120. case contact.FieldType:
  9121. m.ResetType()
  9122. return nil
  9123. case contact.FieldWxid:
  9124. m.ResetWxid()
  9125. return nil
  9126. case contact.FieldAccount:
  9127. m.ResetAccount()
  9128. return nil
  9129. case contact.FieldNickname:
  9130. m.ResetNickname()
  9131. return nil
  9132. case contact.FieldMarkname:
  9133. m.ResetMarkname()
  9134. return nil
  9135. case contact.FieldHeadimg:
  9136. m.ResetHeadimg()
  9137. return nil
  9138. case contact.FieldSex:
  9139. m.ResetSex()
  9140. return nil
  9141. case contact.FieldStarrole:
  9142. m.ResetStarrole()
  9143. return nil
  9144. case contact.FieldDontseeit:
  9145. m.ResetDontseeit()
  9146. return nil
  9147. case contact.FieldDontseeme:
  9148. m.ResetDontseeme()
  9149. return nil
  9150. case contact.FieldLag:
  9151. m.ResetLag()
  9152. return nil
  9153. case contact.FieldGid:
  9154. m.ResetGid()
  9155. return nil
  9156. case contact.FieldGname:
  9157. m.ResetGname()
  9158. return nil
  9159. case contact.FieldV3:
  9160. m.ResetV3()
  9161. return nil
  9162. case contact.FieldOrganizationID:
  9163. m.ResetOrganizationID()
  9164. return nil
  9165. }
  9166. return fmt.Errorf("unknown Contact field %s", name)
  9167. }
  9168. // AddedEdges returns all edge names that were set/added in this mutation.
  9169. func (m *ContactMutation) AddedEdges() []string {
  9170. edges := make([]string, 0, 2)
  9171. if m.contact_relationships != nil {
  9172. edges = append(edges, contact.EdgeContactRelationships)
  9173. }
  9174. if m.contact_messages != nil {
  9175. edges = append(edges, contact.EdgeContactMessages)
  9176. }
  9177. return edges
  9178. }
  9179. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9180. // name in this mutation.
  9181. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  9182. switch name {
  9183. case contact.EdgeContactRelationships:
  9184. ids := make([]ent.Value, 0, len(m.contact_relationships))
  9185. for id := range m.contact_relationships {
  9186. ids = append(ids, id)
  9187. }
  9188. return ids
  9189. case contact.EdgeContactMessages:
  9190. ids := make([]ent.Value, 0, len(m.contact_messages))
  9191. for id := range m.contact_messages {
  9192. ids = append(ids, id)
  9193. }
  9194. return ids
  9195. }
  9196. return nil
  9197. }
  9198. // RemovedEdges returns all edge names that were removed in this mutation.
  9199. func (m *ContactMutation) RemovedEdges() []string {
  9200. edges := make([]string, 0, 2)
  9201. if m.removedcontact_relationships != nil {
  9202. edges = append(edges, contact.EdgeContactRelationships)
  9203. }
  9204. if m.removedcontact_messages != nil {
  9205. edges = append(edges, contact.EdgeContactMessages)
  9206. }
  9207. return edges
  9208. }
  9209. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9210. // the given name in this mutation.
  9211. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  9212. switch name {
  9213. case contact.EdgeContactRelationships:
  9214. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  9215. for id := range m.removedcontact_relationships {
  9216. ids = append(ids, id)
  9217. }
  9218. return ids
  9219. case contact.EdgeContactMessages:
  9220. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  9221. for id := range m.removedcontact_messages {
  9222. ids = append(ids, id)
  9223. }
  9224. return ids
  9225. }
  9226. return nil
  9227. }
  9228. // ClearedEdges returns all edge names that were cleared in this mutation.
  9229. func (m *ContactMutation) ClearedEdges() []string {
  9230. edges := make([]string, 0, 2)
  9231. if m.clearedcontact_relationships {
  9232. edges = append(edges, contact.EdgeContactRelationships)
  9233. }
  9234. if m.clearedcontact_messages {
  9235. edges = append(edges, contact.EdgeContactMessages)
  9236. }
  9237. return edges
  9238. }
  9239. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9240. // was cleared in this mutation.
  9241. func (m *ContactMutation) EdgeCleared(name string) bool {
  9242. switch name {
  9243. case contact.EdgeContactRelationships:
  9244. return m.clearedcontact_relationships
  9245. case contact.EdgeContactMessages:
  9246. return m.clearedcontact_messages
  9247. }
  9248. return false
  9249. }
  9250. // ClearEdge clears the value of the edge with the given name. It returns an error
  9251. // if that edge is not defined in the schema.
  9252. func (m *ContactMutation) ClearEdge(name string) error {
  9253. switch name {
  9254. }
  9255. return fmt.Errorf("unknown Contact unique edge %s", name)
  9256. }
  9257. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9258. // It returns an error if the edge is not defined in the schema.
  9259. func (m *ContactMutation) ResetEdge(name string) error {
  9260. switch name {
  9261. case contact.EdgeContactRelationships:
  9262. m.ResetContactRelationships()
  9263. return nil
  9264. case contact.EdgeContactMessages:
  9265. m.ResetContactMessages()
  9266. return nil
  9267. }
  9268. return fmt.Errorf("unknown Contact edge %s", name)
  9269. }
  9270. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  9271. type CreditBalanceMutation struct {
  9272. config
  9273. op Op
  9274. typ string
  9275. id *uint64
  9276. created_at *time.Time
  9277. updated_at *time.Time
  9278. deleted_at *time.Time
  9279. user_id *string
  9280. balance *float32
  9281. addbalance *float32
  9282. status *int
  9283. addstatus *int
  9284. organization_id *uint64
  9285. addorganization_id *int64
  9286. clearedFields map[string]struct{}
  9287. done bool
  9288. oldValue func(context.Context) (*CreditBalance, error)
  9289. predicates []predicate.CreditBalance
  9290. }
  9291. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  9292. // creditbalanceOption allows management of the mutation configuration using functional options.
  9293. type creditbalanceOption func(*CreditBalanceMutation)
  9294. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  9295. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  9296. m := &CreditBalanceMutation{
  9297. config: c,
  9298. op: op,
  9299. typ: TypeCreditBalance,
  9300. clearedFields: make(map[string]struct{}),
  9301. }
  9302. for _, opt := range opts {
  9303. opt(m)
  9304. }
  9305. return m
  9306. }
  9307. // withCreditBalanceID sets the ID field of the mutation.
  9308. func withCreditBalanceID(id uint64) creditbalanceOption {
  9309. return func(m *CreditBalanceMutation) {
  9310. var (
  9311. err error
  9312. once sync.Once
  9313. value *CreditBalance
  9314. )
  9315. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  9316. once.Do(func() {
  9317. if m.done {
  9318. err = errors.New("querying old values post mutation is not allowed")
  9319. } else {
  9320. value, err = m.Client().CreditBalance.Get(ctx, id)
  9321. }
  9322. })
  9323. return value, err
  9324. }
  9325. m.id = &id
  9326. }
  9327. }
  9328. // withCreditBalance sets the old CreditBalance of the mutation.
  9329. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  9330. return func(m *CreditBalanceMutation) {
  9331. m.oldValue = func(context.Context) (*CreditBalance, error) {
  9332. return node, nil
  9333. }
  9334. m.id = &node.ID
  9335. }
  9336. }
  9337. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9338. // executed in a transaction (ent.Tx), a transactional client is returned.
  9339. func (m CreditBalanceMutation) Client() *Client {
  9340. client := &Client{config: m.config}
  9341. client.init()
  9342. return client
  9343. }
  9344. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9345. // it returns an error otherwise.
  9346. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  9347. if _, ok := m.driver.(*txDriver); !ok {
  9348. return nil, errors.New("ent: mutation is not running in a transaction")
  9349. }
  9350. tx := &Tx{config: m.config}
  9351. tx.init()
  9352. return tx, nil
  9353. }
  9354. // SetID sets the value of the id field. Note that this
  9355. // operation is only accepted on creation of CreditBalance entities.
  9356. func (m *CreditBalanceMutation) SetID(id uint64) {
  9357. m.id = &id
  9358. }
  9359. // ID returns the ID value in the mutation. Note that the ID is only available
  9360. // if it was provided to the builder or after it was returned from the database.
  9361. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  9362. if m.id == nil {
  9363. return
  9364. }
  9365. return *m.id, true
  9366. }
  9367. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9368. // That means, if the mutation is applied within a transaction with an isolation level such
  9369. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9370. // or updated by the mutation.
  9371. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  9372. switch {
  9373. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9374. id, exists := m.ID()
  9375. if exists {
  9376. return []uint64{id}, nil
  9377. }
  9378. fallthrough
  9379. case m.op.Is(OpUpdate | OpDelete):
  9380. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  9381. default:
  9382. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9383. }
  9384. }
  9385. // SetCreatedAt sets the "created_at" field.
  9386. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  9387. m.created_at = &t
  9388. }
  9389. // CreatedAt returns the value of the "created_at" field in the mutation.
  9390. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  9391. v := m.created_at
  9392. if v == nil {
  9393. return
  9394. }
  9395. return *v, true
  9396. }
  9397. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  9398. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9400. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9401. if !m.op.Is(OpUpdateOne) {
  9402. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9403. }
  9404. if m.id == nil || m.oldValue == nil {
  9405. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9406. }
  9407. oldValue, err := m.oldValue(ctx)
  9408. if err != nil {
  9409. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9410. }
  9411. return oldValue.CreatedAt, nil
  9412. }
  9413. // ResetCreatedAt resets all changes to the "created_at" field.
  9414. func (m *CreditBalanceMutation) ResetCreatedAt() {
  9415. m.created_at = nil
  9416. }
  9417. // SetUpdatedAt sets the "updated_at" field.
  9418. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  9419. m.updated_at = &t
  9420. }
  9421. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9422. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  9423. v := m.updated_at
  9424. if v == nil {
  9425. return
  9426. }
  9427. return *v, true
  9428. }
  9429. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  9430. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9432. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9433. if !m.op.Is(OpUpdateOne) {
  9434. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9435. }
  9436. if m.id == nil || m.oldValue == nil {
  9437. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9438. }
  9439. oldValue, err := m.oldValue(ctx)
  9440. if err != nil {
  9441. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9442. }
  9443. return oldValue.UpdatedAt, nil
  9444. }
  9445. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9446. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  9447. m.updated_at = nil
  9448. }
  9449. // SetDeletedAt sets the "deleted_at" field.
  9450. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  9451. m.deleted_at = &t
  9452. }
  9453. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9454. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  9455. v := m.deleted_at
  9456. if v == nil {
  9457. return
  9458. }
  9459. return *v, true
  9460. }
  9461. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  9462. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9464. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9465. if !m.op.Is(OpUpdateOne) {
  9466. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9467. }
  9468. if m.id == nil || m.oldValue == nil {
  9469. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9470. }
  9471. oldValue, err := m.oldValue(ctx)
  9472. if err != nil {
  9473. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9474. }
  9475. return oldValue.DeletedAt, nil
  9476. }
  9477. // ClearDeletedAt clears the value of the "deleted_at" field.
  9478. func (m *CreditBalanceMutation) ClearDeletedAt() {
  9479. m.deleted_at = nil
  9480. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  9481. }
  9482. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9483. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  9484. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  9485. return ok
  9486. }
  9487. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9488. func (m *CreditBalanceMutation) ResetDeletedAt() {
  9489. m.deleted_at = nil
  9490. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  9491. }
  9492. // SetUserID sets the "user_id" field.
  9493. func (m *CreditBalanceMutation) SetUserID(s string) {
  9494. m.user_id = &s
  9495. }
  9496. // UserID returns the value of the "user_id" field in the mutation.
  9497. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  9498. v := m.user_id
  9499. if v == nil {
  9500. return
  9501. }
  9502. return *v, true
  9503. }
  9504. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  9505. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9507. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  9508. if !m.op.Is(OpUpdateOne) {
  9509. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  9510. }
  9511. if m.id == nil || m.oldValue == nil {
  9512. return v, errors.New("OldUserID requires an ID field in the mutation")
  9513. }
  9514. oldValue, err := m.oldValue(ctx)
  9515. if err != nil {
  9516. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  9517. }
  9518. return oldValue.UserID, nil
  9519. }
  9520. // ResetUserID resets all changes to the "user_id" field.
  9521. func (m *CreditBalanceMutation) ResetUserID() {
  9522. m.user_id = nil
  9523. }
  9524. // SetBalance sets the "balance" field.
  9525. func (m *CreditBalanceMutation) SetBalance(f float32) {
  9526. m.balance = &f
  9527. m.addbalance = nil
  9528. }
  9529. // Balance returns the value of the "balance" field in the mutation.
  9530. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  9531. v := m.balance
  9532. if v == nil {
  9533. return
  9534. }
  9535. return *v, true
  9536. }
  9537. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  9538. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9540. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  9541. if !m.op.Is(OpUpdateOne) {
  9542. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  9543. }
  9544. if m.id == nil || m.oldValue == nil {
  9545. return v, errors.New("OldBalance requires an ID field in the mutation")
  9546. }
  9547. oldValue, err := m.oldValue(ctx)
  9548. if err != nil {
  9549. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  9550. }
  9551. return oldValue.Balance, nil
  9552. }
  9553. // AddBalance adds f to the "balance" field.
  9554. func (m *CreditBalanceMutation) AddBalance(f float32) {
  9555. if m.addbalance != nil {
  9556. *m.addbalance += f
  9557. } else {
  9558. m.addbalance = &f
  9559. }
  9560. }
  9561. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  9562. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  9563. v := m.addbalance
  9564. if v == nil {
  9565. return
  9566. }
  9567. return *v, true
  9568. }
  9569. // ResetBalance resets all changes to the "balance" field.
  9570. func (m *CreditBalanceMutation) ResetBalance() {
  9571. m.balance = nil
  9572. m.addbalance = nil
  9573. }
  9574. // SetStatus sets the "status" field.
  9575. func (m *CreditBalanceMutation) SetStatus(i int) {
  9576. m.status = &i
  9577. m.addstatus = nil
  9578. }
  9579. // Status returns the value of the "status" field in the mutation.
  9580. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  9581. v := m.status
  9582. if v == nil {
  9583. return
  9584. }
  9585. return *v, true
  9586. }
  9587. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  9588. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9590. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  9591. if !m.op.Is(OpUpdateOne) {
  9592. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9593. }
  9594. if m.id == nil || m.oldValue == nil {
  9595. return v, errors.New("OldStatus requires an ID field in the mutation")
  9596. }
  9597. oldValue, err := m.oldValue(ctx)
  9598. if err != nil {
  9599. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9600. }
  9601. return oldValue.Status, nil
  9602. }
  9603. // AddStatus adds i to the "status" field.
  9604. func (m *CreditBalanceMutation) AddStatus(i int) {
  9605. if m.addstatus != nil {
  9606. *m.addstatus += i
  9607. } else {
  9608. m.addstatus = &i
  9609. }
  9610. }
  9611. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9612. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  9613. v := m.addstatus
  9614. if v == nil {
  9615. return
  9616. }
  9617. return *v, true
  9618. }
  9619. // ClearStatus clears the value of the "status" field.
  9620. func (m *CreditBalanceMutation) ClearStatus() {
  9621. m.status = nil
  9622. m.addstatus = nil
  9623. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  9624. }
  9625. // StatusCleared returns if the "status" field was cleared in this mutation.
  9626. func (m *CreditBalanceMutation) StatusCleared() bool {
  9627. _, ok := m.clearedFields[creditbalance.FieldStatus]
  9628. return ok
  9629. }
  9630. // ResetStatus resets all changes to the "status" field.
  9631. func (m *CreditBalanceMutation) ResetStatus() {
  9632. m.status = nil
  9633. m.addstatus = nil
  9634. delete(m.clearedFields, creditbalance.FieldStatus)
  9635. }
  9636. // SetOrganizationID sets the "organization_id" field.
  9637. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  9638. m.organization_id = &u
  9639. m.addorganization_id = nil
  9640. }
  9641. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9642. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  9643. v := m.organization_id
  9644. if v == nil {
  9645. return
  9646. }
  9647. return *v, true
  9648. }
  9649. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  9650. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9652. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9653. if !m.op.Is(OpUpdateOne) {
  9654. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9655. }
  9656. if m.id == nil || m.oldValue == nil {
  9657. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9658. }
  9659. oldValue, err := m.oldValue(ctx)
  9660. if err != nil {
  9661. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9662. }
  9663. return oldValue.OrganizationID, nil
  9664. }
  9665. // AddOrganizationID adds u to the "organization_id" field.
  9666. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  9667. if m.addorganization_id != nil {
  9668. *m.addorganization_id += u
  9669. } else {
  9670. m.addorganization_id = &u
  9671. }
  9672. }
  9673. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9674. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  9675. v := m.addorganization_id
  9676. if v == nil {
  9677. return
  9678. }
  9679. return *v, true
  9680. }
  9681. // ResetOrganizationID resets all changes to the "organization_id" field.
  9682. func (m *CreditBalanceMutation) ResetOrganizationID() {
  9683. m.organization_id = nil
  9684. m.addorganization_id = nil
  9685. }
  9686. // Where appends a list predicates to the CreditBalanceMutation builder.
  9687. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  9688. m.predicates = append(m.predicates, ps...)
  9689. }
  9690. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  9691. // users can use type-assertion to append predicates that do not depend on any generated package.
  9692. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  9693. p := make([]predicate.CreditBalance, len(ps))
  9694. for i := range ps {
  9695. p[i] = ps[i]
  9696. }
  9697. m.Where(p...)
  9698. }
  9699. // Op returns the operation name.
  9700. func (m *CreditBalanceMutation) Op() Op {
  9701. return m.op
  9702. }
  9703. // SetOp allows setting the mutation operation.
  9704. func (m *CreditBalanceMutation) SetOp(op Op) {
  9705. m.op = op
  9706. }
  9707. // Type returns the node type of this mutation (CreditBalance).
  9708. func (m *CreditBalanceMutation) Type() string {
  9709. return m.typ
  9710. }
  9711. // Fields returns all fields that were changed during this mutation. Note that in
  9712. // order to get all numeric fields that were incremented/decremented, call
  9713. // AddedFields().
  9714. func (m *CreditBalanceMutation) Fields() []string {
  9715. fields := make([]string, 0, 7)
  9716. if m.created_at != nil {
  9717. fields = append(fields, creditbalance.FieldCreatedAt)
  9718. }
  9719. if m.updated_at != nil {
  9720. fields = append(fields, creditbalance.FieldUpdatedAt)
  9721. }
  9722. if m.deleted_at != nil {
  9723. fields = append(fields, creditbalance.FieldDeletedAt)
  9724. }
  9725. if m.user_id != nil {
  9726. fields = append(fields, creditbalance.FieldUserID)
  9727. }
  9728. if m.balance != nil {
  9729. fields = append(fields, creditbalance.FieldBalance)
  9730. }
  9731. if m.status != nil {
  9732. fields = append(fields, creditbalance.FieldStatus)
  9733. }
  9734. if m.organization_id != nil {
  9735. fields = append(fields, creditbalance.FieldOrganizationID)
  9736. }
  9737. return fields
  9738. }
  9739. // Field returns the value of a field with the given name. The second boolean
  9740. // return value indicates that this field was not set, or was not defined in the
  9741. // schema.
  9742. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  9743. switch name {
  9744. case creditbalance.FieldCreatedAt:
  9745. return m.CreatedAt()
  9746. case creditbalance.FieldUpdatedAt:
  9747. return m.UpdatedAt()
  9748. case creditbalance.FieldDeletedAt:
  9749. return m.DeletedAt()
  9750. case creditbalance.FieldUserID:
  9751. return m.UserID()
  9752. case creditbalance.FieldBalance:
  9753. return m.Balance()
  9754. case creditbalance.FieldStatus:
  9755. return m.Status()
  9756. case creditbalance.FieldOrganizationID:
  9757. return m.OrganizationID()
  9758. }
  9759. return nil, false
  9760. }
  9761. // OldField returns the old value of the field from the database. An error is
  9762. // returned if the mutation operation is not UpdateOne, or the query to the
  9763. // database failed.
  9764. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9765. switch name {
  9766. case creditbalance.FieldCreatedAt:
  9767. return m.OldCreatedAt(ctx)
  9768. case creditbalance.FieldUpdatedAt:
  9769. return m.OldUpdatedAt(ctx)
  9770. case creditbalance.FieldDeletedAt:
  9771. return m.OldDeletedAt(ctx)
  9772. case creditbalance.FieldUserID:
  9773. return m.OldUserID(ctx)
  9774. case creditbalance.FieldBalance:
  9775. return m.OldBalance(ctx)
  9776. case creditbalance.FieldStatus:
  9777. return m.OldStatus(ctx)
  9778. case creditbalance.FieldOrganizationID:
  9779. return m.OldOrganizationID(ctx)
  9780. }
  9781. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  9782. }
  9783. // SetField sets the value of a field with the given name. It returns an error if
  9784. // the field is not defined in the schema, or if the type mismatched the field
  9785. // type.
  9786. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  9787. switch name {
  9788. case creditbalance.FieldCreatedAt:
  9789. v, ok := value.(time.Time)
  9790. if !ok {
  9791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9792. }
  9793. m.SetCreatedAt(v)
  9794. return nil
  9795. case creditbalance.FieldUpdatedAt:
  9796. v, ok := value.(time.Time)
  9797. if !ok {
  9798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9799. }
  9800. m.SetUpdatedAt(v)
  9801. return nil
  9802. case creditbalance.FieldDeletedAt:
  9803. v, ok := value.(time.Time)
  9804. if !ok {
  9805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9806. }
  9807. m.SetDeletedAt(v)
  9808. return nil
  9809. case creditbalance.FieldUserID:
  9810. v, ok := value.(string)
  9811. if !ok {
  9812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9813. }
  9814. m.SetUserID(v)
  9815. return nil
  9816. case creditbalance.FieldBalance:
  9817. v, ok := value.(float32)
  9818. if !ok {
  9819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9820. }
  9821. m.SetBalance(v)
  9822. return nil
  9823. case creditbalance.FieldStatus:
  9824. v, ok := value.(int)
  9825. if !ok {
  9826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9827. }
  9828. m.SetStatus(v)
  9829. return nil
  9830. case creditbalance.FieldOrganizationID:
  9831. v, ok := value.(uint64)
  9832. if !ok {
  9833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9834. }
  9835. m.SetOrganizationID(v)
  9836. return nil
  9837. }
  9838. return fmt.Errorf("unknown CreditBalance field %s", name)
  9839. }
  9840. // AddedFields returns all numeric fields that were incremented/decremented during
  9841. // this mutation.
  9842. func (m *CreditBalanceMutation) AddedFields() []string {
  9843. var fields []string
  9844. if m.addbalance != nil {
  9845. fields = append(fields, creditbalance.FieldBalance)
  9846. }
  9847. if m.addstatus != nil {
  9848. fields = append(fields, creditbalance.FieldStatus)
  9849. }
  9850. if m.addorganization_id != nil {
  9851. fields = append(fields, creditbalance.FieldOrganizationID)
  9852. }
  9853. return fields
  9854. }
  9855. // AddedField returns the numeric value that was incremented/decremented on a field
  9856. // with the given name. The second boolean return value indicates that this field
  9857. // was not set, or was not defined in the schema.
  9858. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  9859. switch name {
  9860. case creditbalance.FieldBalance:
  9861. return m.AddedBalance()
  9862. case creditbalance.FieldStatus:
  9863. return m.AddedStatus()
  9864. case creditbalance.FieldOrganizationID:
  9865. return m.AddedOrganizationID()
  9866. }
  9867. return nil, false
  9868. }
  9869. // AddField adds the value to the field with the given name. It returns an error if
  9870. // the field is not defined in the schema, or if the type mismatched the field
  9871. // type.
  9872. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  9873. switch name {
  9874. case creditbalance.FieldBalance:
  9875. v, ok := value.(float32)
  9876. if !ok {
  9877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9878. }
  9879. m.AddBalance(v)
  9880. return nil
  9881. case creditbalance.FieldStatus:
  9882. v, ok := value.(int)
  9883. if !ok {
  9884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9885. }
  9886. m.AddStatus(v)
  9887. return nil
  9888. case creditbalance.FieldOrganizationID:
  9889. v, ok := value.(int64)
  9890. if !ok {
  9891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9892. }
  9893. m.AddOrganizationID(v)
  9894. return nil
  9895. }
  9896. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  9897. }
  9898. // ClearedFields returns all nullable fields that were cleared during this
  9899. // mutation.
  9900. func (m *CreditBalanceMutation) ClearedFields() []string {
  9901. var fields []string
  9902. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  9903. fields = append(fields, creditbalance.FieldDeletedAt)
  9904. }
  9905. if m.FieldCleared(creditbalance.FieldStatus) {
  9906. fields = append(fields, creditbalance.FieldStatus)
  9907. }
  9908. return fields
  9909. }
  9910. // FieldCleared returns a boolean indicating if a field with the given name was
  9911. // cleared in this mutation.
  9912. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  9913. _, ok := m.clearedFields[name]
  9914. return ok
  9915. }
  9916. // ClearField clears the value of the field with the given name. It returns an
  9917. // error if the field is not defined in the schema.
  9918. func (m *CreditBalanceMutation) ClearField(name string) error {
  9919. switch name {
  9920. case creditbalance.FieldDeletedAt:
  9921. m.ClearDeletedAt()
  9922. return nil
  9923. case creditbalance.FieldStatus:
  9924. m.ClearStatus()
  9925. return nil
  9926. }
  9927. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  9928. }
  9929. // ResetField resets all changes in the mutation for the field with the given name.
  9930. // It returns an error if the field is not defined in the schema.
  9931. func (m *CreditBalanceMutation) ResetField(name string) error {
  9932. switch name {
  9933. case creditbalance.FieldCreatedAt:
  9934. m.ResetCreatedAt()
  9935. return nil
  9936. case creditbalance.FieldUpdatedAt:
  9937. m.ResetUpdatedAt()
  9938. return nil
  9939. case creditbalance.FieldDeletedAt:
  9940. m.ResetDeletedAt()
  9941. return nil
  9942. case creditbalance.FieldUserID:
  9943. m.ResetUserID()
  9944. return nil
  9945. case creditbalance.FieldBalance:
  9946. m.ResetBalance()
  9947. return nil
  9948. case creditbalance.FieldStatus:
  9949. m.ResetStatus()
  9950. return nil
  9951. case creditbalance.FieldOrganizationID:
  9952. m.ResetOrganizationID()
  9953. return nil
  9954. }
  9955. return fmt.Errorf("unknown CreditBalance field %s", name)
  9956. }
  9957. // AddedEdges returns all edge names that were set/added in this mutation.
  9958. func (m *CreditBalanceMutation) AddedEdges() []string {
  9959. edges := make([]string, 0, 0)
  9960. return edges
  9961. }
  9962. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9963. // name in this mutation.
  9964. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  9965. return nil
  9966. }
  9967. // RemovedEdges returns all edge names that were removed in this mutation.
  9968. func (m *CreditBalanceMutation) RemovedEdges() []string {
  9969. edges := make([]string, 0, 0)
  9970. return edges
  9971. }
  9972. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9973. // the given name in this mutation.
  9974. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  9975. return nil
  9976. }
  9977. // ClearedEdges returns all edge names that were cleared in this mutation.
  9978. func (m *CreditBalanceMutation) ClearedEdges() []string {
  9979. edges := make([]string, 0, 0)
  9980. return edges
  9981. }
  9982. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9983. // was cleared in this mutation.
  9984. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  9985. return false
  9986. }
  9987. // ClearEdge clears the value of the edge with the given name. It returns an error
  9988. // if that edge is not defined in the schema.
  9989. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  9990. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  9991. }
  9992. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9993. // It returns an error if the edge is not defined in the schema.
  9994. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  9995. return fmt.Errorf("unknown CreditBalance edge %s", name)
  9996. }
  9997. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  9998. type CreditUsageMutation struct {
  9999. config
  10000. op Op
  10001. typ string
  10002. id *uint64
  10003. created_at *time.Time
  10004. updated_at *time.Time
  10005. deleted_at *time.Time
  10006. user_id *string
  10007. number *float32
  10008. addnumber *float32
  10009. status *int
  10010. addstatus *int
  10011. ntype *int
  10012. addntype *int
  10013. table *string
  10014. organization_id *uint64
  10015. addorganization_id *int64
  10016. nid *uint64
  10017. addnid *int64
  10018. reason *string
  10019. operator *string
  10020. clearedFields map[string]struct{}
  10021. done bool
  10022. oldValue func(context.Context) (*CreditUsage, error)
  10023. predicates []predicate.CreditUsage
  10024. }
  10025. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  10026. // creditusageOption allows management of the mutation configuration using functional options.
  10027. type creditusageOption func(*CreditUsageMutation)
  10028. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  10029. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  10030. m := &CreditUsageMutation{
  10031. config: c,
  10032. op: op,
  10033. typ: TypeCreditUsage,
  10034. clearedFields: make(map[string]struct{}),
  10035. }
  10036. for _, opt := range opts {
  10037. opt(m)
  10038. }
  10039. return m
  10040. }
  10041. // withCreditUsageID sets the ID field of the mutation.
  10042. func withCreditUsageID(id uint64) creditusageOption {
  10043. return func(m *CreditUsageMutation) {
  10044. var (
  10045. err error
  10046. once sync.Once
  10047. value *CreditUsage
  10048. )
  10049. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  10050. once.Do(func() {
  10051. if m.done {
  10052. err = errors.New("querying old values post mutation is not allowed")
  10053. } else {
  10054. value, err = m.Client().CreditUsage.Get(ctx, id)
  10055. }
  10056. })
  10057. return value, err
  10058. }
  10059. m.id = &id
  10060. }
  10061. }
  10062. // withCreditUsage sets the old CreditUsage of the mutation.
  10063. func withCreditUsage(node *CreditUsage) creditusageOption {
  10064. return func(m *CreditUsageMutation) {
  10065. m.oldValue = func(context.Context) (*CreditUsage, error) {
  10066. return node, nil
  10067. }
  10068. m.id = &node.ID
  10069. }
  10070. }
  10071. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10072. // executed in a transaction (ent.Tx), a transactional client is returned.
  10073. func (m CreditUsageMutation) Client() *Client {
  10074. client := &Client{config: m.config}
  10075. client.init()
  10076. return client
  10077. }
  10078. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10079. // it returns an error otherwise.
  10080. func (m CreditUsageMutation) Tx() (*Tx, error) {
  10081. if _, ok := m.driver.(*txDriver); !ok {
  10082. return nil, errors.New("ent: mutation is not running in a transaction")
  10083. }
  10084. tx := &Tx{config: m.config}
  10085. tx.init()
  10086. return tx, nil
  10087. }
  10088. // SetID sets the value of the id field. Note that this
  10089. // operation is only accepted on creation of CreditUsage entities.
  10090. func (m *CreditUsageMutation) SetID(id uint64) {
  10091. m.id = &id
  10092. }
  10093. // ID returns the ID value in the mutation. Note that the ID is only available
  10094. // if it was provided to the builder or after it was returned from the database.
  10095. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  10096. if m.id == nil {
  10097. return
  10098. }
  10099. return *m.id, true
  10100. }
  10101. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10102. // That means, if the mutation is applied within a transaction with an isolation level such
  10103. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10104. // or updated by the mutation.
  10105. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  10106. switch {
  10107. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10108. id, exists := m.ID()
  10109. if exists {
  10110. return []uint64{id}, nil
  10111. }
  10112. fallthrough
  10113. case m.op.Is(OpUpdate | OpDelete):
  10114. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  10115. default:
  10116. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10117. }
  10118. }
  10119. // SetCreatedAt sets the "created_at" field.
  10120. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  10121. m.created_at = &t
  10122. }
  10123. // CreatedAt returns the value of the "created_at" field in the mutation.
  10124. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  10125. v := m.created_at
  10126. if v == nil {
  10127. return
  10128. }
  10129. return *v, true
  10130. }
  10131. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  10132. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10134. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10135. if !m.op.Is(OpUpdateOne) {
  10136. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10137. }
  10138. if m.id == nil || m.oldValue == nil {
  10139. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10140. }
  10141. oldValue, err := m.oldValue(ctx)
  10142. if err != nil {
  10143. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10144. }
  10145. return oldValue.CreatedAt, nil
  10146. }
  10147. // ResetCreatedAt resets all changes to the "created_at" field.
  10148. func (m *CreditUsageMutation) ResetCreatedAt() {
  10149. m.created_at = nil
  10150. }
  10151. // SetUpdatedAt sets the "updated_at" field.
  10152. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  10153. m.updated_at = &t
  10154. }
  10155. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10156. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  10157. v := m.updated_at
  10158. if v == nil {
  10159. return
  10160. }
  10161. return *v, true
  10162. }
  10163. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  10164. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10166. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10167. if !m.op.Is(OpUpdateOne) {
  10168. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10169. }
  10170. if m.id == nil || m.oldValue == nil {
  10171. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10172. }
  10173. oldValue, err := m.oldValue(ctx)
  10174. if err != nil {
  10175. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10176. }
  10177. return oldValue.UpdatedAt, nil
  10178. }
  10179. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10180. func (m *CreditUsageMutation) ResetUpdatedAt() {
  10181. m.updated_at = nil
  10182. }
  10183. // SetDeletedAt sets the "deleted_at" field.
  10184. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  10185. m.deleted_at = &t
  10186. }
  10187. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10188. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  10189. v := m.deleted_at
  10190. if v == nil {
  10191. return
  10192. }
  10193. return *v, true
  10194. }
  10195. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  10196. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10197. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10198. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10199. if !m.op.Is(OpUpdateOne) {
  10200. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10201. }
  10202. if m.id == nil || m.oldValue == nil {
  10203. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10204. }
  10205. oldValue, err := m.oldValue(ctx)
  10206. if err != nil {
  10207. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10208. }
  10209. return oldValue.DeletedAt, nil
  10210. }
  10211. // ClearDeletedAt clears the value of the "deleted_at" field.
  10212. func (m *CreditUsageMutation) ClearDeletedAt() {
  10213. m.deleted_at = nil
  10214. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  10215. }
  10216. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10217. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  10218. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  10219. return ok
  10220. }
  10221. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10222. func (m *CreditUsageMutation) ResetDeletedAt() {
  10223. m.deleted_at = nil
  10224. delete(m.clearedFields, creditusage.FieldDeletedAt)
  10225. }
  10226. // SetUserID sets the "user_id" field.
  10227. func (m *CreditUsageMutation) SetUserID(s string) {
  10228. m.user_id = &s
  10229. }
  10230. // UserID returns the value of the "user_id" field in the mutation.
  10231. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  10232. v := m.user_id
  10233. if v == nil {
  10234. return
  10235. }
  10236. return *v, true
  10237. }
  10238. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  10239. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10241. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  10242. if !m.op.Is(OpUpdateOne) {
  10243. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  10244. }
  10245. if m.id == nil || m.oldValue == nil {
  10246. return v, errors.New("OldUserID requires an ID field in the mutation")
  10247. }
  10248. oldValue, err := m.oldValue(ctx)
  10249. if err != nil {
  10250. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  10251. }
  10252. return oldValue.UserID, nil
  10253. }
  10254. // ResetUserID resets all changes to the "user_id" field.
  10255. func (m *CreditUsageMutation) ResetUserID() {
  10256. m.user_id = nil
  10257. }
  10258. // SetNumber sets the "number" field.
  10259. func (m *CreditUsageMutation) SetNumber(f float32) {
  10260. m.number = &f
  10261. m.addnumber = nil
  10262. }
  10263. // Number returns the value of the "number" field in the mutation.
  10264. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  10265. v := m.number
  10266. if v == nil {
  10267. return
  10268. }
  10269. return *v, true
  10270. }
  10271. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  10272. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10274. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  10275. if !m.op.Is(OpUpdateOne) {
  10276. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  10277. }
  10278. if m.id == nil || m.oldValue == nil {
  10279. return v, errors.New("OldNumber requires an ID field in the mutation")
  10280. }
  10281. oldValue, err := m.oldValue(ctx)
  10282. if err != nil {
  10283. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  10284. }
  10285. return oldValue.Number, nil
  10286. }
  10287. // AddNumber adds f to the "number" field.
  10288. func (m *CreditUsageMutation) AddNumber(f float32) {
  10289. if m.addnumber != nil {
  10290. *m.addnumber += f
  10291. } else {
  10292. m.addnumber = &f
  10293. }
  10294. }
  10295. // AddedNumber returns the value that was added to the "number" field in this mutation.
  10296. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  10297. v := m.addnumber
  10298. if v == nil {
  10299. return
  10300. }
  10301. return *v, true
  10302. }
  10303. // ResetNumber resets all changes to the "number" field.
  10304. func (m *CreditUsageMutation) ResetNumber() {
  10305. m.number = nil
  10306. m.addnumber = nil
  10307. }
  10308. // SetStatus sets the "status" field.
  10309. func (m *CreditUsageMutation) SetStatus(i int) {
  10310. m.status = &i
  10311. m.addstatus = nil
  10312. }
  10313. // Status returns the value of the "status" field in the mutation.
  10314. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  10315. v := m.status
  10316. if v == nil {
  10317. return
  10318. }
  10319. return *v, true
  10320. }
  10321. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  10322. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10324. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  10325. if !m.op.Is(OpUpdateOne) {
  10326. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10327. }
  10328. if m.id == nil || m.oldValue == nil {
  10329. return v, errors.New("OldStatus requires an ID field in the mutation")
  10330. }
  10331. oldValue, err := m.oldValue(ctx)
  10332. if err != nil {
  10333. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10334. }
  10335. return oldValue.Status, nil
  10336. }
  10337. // AddStatus adds i to the "status" field.
  10338. func (m *CreditUsageMutation) AddStatus(i int) {
  10339. if m.addstatus != nil {
  10340. *m.addstatus += i
  10341. } else {
  10342. m.addstatus = &i
  10343. }
  10344. }
  10345. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10346. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  10347. v := m.addstatus
  10348. if v == nil {
  10349. return
  10350. }
  10351. return *v, true
  10352. }
  10353. // ClearStatus clears the value of the "status" field.
  10354. func (m *CreditUsageMutation) ClearStatus() {
  10355. m.status = nil
  10356. m.addstatus = nil
  10357. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  10358. }
  10359. // StatusCleared returns if the "status" field was cleared in this mutation.
  10360. func (m *CreditUsageMutation) StatusCleared() bool {
  10361. _, ok := m.clearedFields[creditusage.FieldStatus]
  10362. return ok
  10363. }
  10364. // ResetStatus resets all changes to the "status" field.
  10365. func (m *CreditUsageMutation) ResetStatus() {
  10366. m.status = nil
  10367. m.addstatus = nil
  10368. delete(m.clearedFields, creditusage.FieldStatus)
  10369. }
  10370. // SetNtype sets the "ntype" field.
  10371. func (m *CreditUsageMutation) SetNtype(i int) {
  10372. m.ntype = &i
  10373. m.addntype = nil
  10374. }
  10375. // Ntype returns the value of the "ntype" field in the mutation.
  10376. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  10377. v := m.ntype
  10378. if v == nil {
  10379. return
  10380. }
  10381. return *v, true
  10382. }
  10383. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  10384. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10386. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  10387. if !m.op.Is(OpUpdateOne) {
  10388. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  10389. }
  10390. if m.id == nil || m.oldValue == nil {
  10391. return v, errors.New("OldNtype requires an ID field in the mutation")
  10392. }
  10393. oldValue, err := m.oldValue(ctx)
  10394. if err != nil {
  10395. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  10396. }
  10397. return oldValue.Ntype, nil
  10398. }
  10399. // AddNtype adds i to the "ntype" field.
  10400. func (m *CreditUsageMutation) AddNtype(i int) {
  10401. if m.addntype != nil {
  10402. *m.addntype += i
  10403. } else {
  10404. m.addntype = &i
  10405. }
  10406. }
  10407. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  10408. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  10409. v := m.addntype
  10410. if v == nil {
  10411. return
  10412. }
  10413. return *v, true
  10414. }
  10415. // ResetNtype resets all changes to the "ntype" field.
  10416. func (m *CreditUsageMutation) ResetNtype() {
  10417. m.ntype = nil
  10418. m.addntype = nil
  10419. }
  10420. // SetTable sets the "table" field.
  10421. func (m *CreditUsageMutation) SetTable(s string) {
  10422. m.table = &s
  10423. }
  10424. // Table returns the value of the "table" field in the mutation.
  10425. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  10426. v := m.table
  10427. if v == nil {
  10428. return
  10429. }
  10430. return *v, true
  10431. }
  10432. // OldTable returns the old "table" field's value of the CreditUsage entity.
  10433. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10435. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  10436. if !m.op.Is(OpUpdateOne) {
  10437. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  10438. }
  10439. if m.id == nil || m.oldValue == nil {
  10440. return v, errors.New("OldTable requires an ID field in the mutation")
  10441. }
  10442. oldValue, err := m.oldValue(ctx)
  10443. if err != nil {
  10444. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  10445. }
  10446. return oldValue.Table, nil
  10447. }
  10448. // ResetTable resets all changes to the "table" field.
  10449. func (m *CreditUsageMutation) ResetTable() {
  10450. m.table = nil
  10451. }
  10452. // SetOrganizationID sets the "organization_id" field.
  10453. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  10454. m.organization_id = &u
  10455. m.addorganization_id = nil
  10456. }
  10457. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10458. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  10459. v := m.organization_id
  10460. if v == nil {
  10461. return
  10462. }
  10463. return *v, true
  10464. }
  10465. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  10466. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10468. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10469. if !m.op.Is(OpUpdateOne) {
  10470. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10471. }
  10472. if m.id == nil || m.oldValue == nil {
  10473. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10474. }
  10475. oldValue, err := m.oldValue(ctx)
  10476. if err != nil {
  10477. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10478. }
  10479. return oldValue.OrganizationID, nil
  10480. }
  10481. // AddOrganizationID adds u to the "organization_id" field.
  10482. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  10483. if m.addorganization_id != nil {
  10484. *m.addorganization_id += u
  10485. } else {
  10486. m.addorganization_id = &u
  10487. }
  10488. }
  10489. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10490. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  10491. v := m.addorganization_id
  10492. if v == nil {
  10493. return
  10494. }
  10495. return *v, true
  10496. }
  10497. // ResetOrganizationID resets all changes to the "organization_id" field.
  10498. func (m *CreditUsageMutation) ResetOrganizationID() {
  10499. m.organization_id = nil
  10500. m.addorganization_id = nil
  10501. }
  10502. // SetNid sets the "nid" field.
  10503. func (m *CreditUsageMutation) SetNid(u uint64) {
  10504. m.nid = &u
  10505. m.addnid = nil
  10506. }
  10507. // Nid returns the value of the "nid" field in the mutation.
  10508. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  10509. v := m.nid
  10510. if v == nil {
  10511. return
  10512. }
  10513. return *v, true
  10514. }
  10515. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  10516. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10518. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  10519. if !m.op.Is(OpUpdateOne) {
  10520. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  10521. }
  10522. if m.id == nil || m.oldValue == nil {
  10523. return v, errors.New("OldNid requires an ID field in the mutation")
  10524. }
  10525. oldValue, err := m.oldValue(ctx)
  10526. if err != nil {
  10527. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  10528. }
  10529. return oldValue.Nid, nil
  10530. }
  10531. // AddNid adds u to the "nid" field.
  10532. func (m *CreditUsageMutation) AddNid(u int64) {
  10533. if m.addnid != nil {
  10534. *m.addnid += u
  10535. } else {
  10536. m.addnid = &u
  10537. }
  10538. }
  10539. // AddedNid returns the value that was added to the "nid" field in this mutation.
  10540. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  10541. v := m.addnid
  10542. if v == nil {
  10543. return
  10544. }
  10545. return *v, true
  10546. }
  10547. // ResetNid resets all changes to the "nid" field.
  10548. func (m *CreditUsageMutation) ResetNid() {
  10549. m.nid = nil
  10550. m.addnid = nil
  10551. }
  10552. // SetReason sets the "reason" field.
  10553. func (m *CreditUsageMutation) SetReason(s string) {
  10554. m.reason = &s
  10555. }
  10556. // Reason returns the value of the "reason" field in the mutation.
  10557. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  10558. v := m.reason
  10559. if v == nil {
  10560. return
  10561. }
  10562. return *v, true
  10563. }
  10564. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  10565. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10567. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  10568. if !m.op.Is(OpUpdateOne) {
  10569. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  10570. }
  10571. if m.id == nil || m.oldValue == nil {
  10572. return v, errors.New("OldReason requires an ID field in the mutation")
  10573. }
  10574. oldValue, err := m.oldValue(ctx)
  10575. if err != nil {
  10576. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  10577. }
  10578. return oldValue.Reason, nil
  10579. }
  10580. // ResetReason resets all changes to the "reason" field.
  10581. func (m *CreditUsageMutation) ResetReason() {
  10582. m.reason = nil
  10583. }
  10584. // SetOperator sets the "operator" field.
  10585. func (m *CreditUsageMutation) SetOperator(s string) {
  10586. m.operator = &s
  10587. }
  10588. // Operator returns the value of the "operator" field in the mutation.
  10589. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  10590. v := m.operator
  10591. if v == nil {
  10592. return
  10593. }
  10594. return *v, true
  10595. }
  10596. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  10597. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10599. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  10600. if !m.op.Is(OpUpdateOne) {
  10601. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  10602. }
  10603. if m.id == nil || m.oldValue == nil {
  10604. return v, errors.New("OldOperator requires an ID field in the mutation")
  10605. }
  10606. oldValue, err := m.oldValue(ctx)
  10607. if err != nil {
  10608. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  10609. }
  10610. return oldValue.Operator, nil
  10611. }
  10612. // ResetOperator resets all changes to the "operator" field.
  10613. func (m *CreditUsageMutation) ResetOperator() {
  10614. m.operator = nil
  10615. }
  10616. // Where appends a list predicates to the CreditUsageMutation builder.
  10617. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  10618. m.predicates = append(m.predicates, ps...)
  10619. }
  10620. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  10621. // users can use type-assertion to append predicates that do not depend on any generated package.
  10622. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  10623. p := make([]predicate.CreditUsage, len(ps))
  10624. for i := range ps {
  10625. p[i] = ps[i]
  10626. }
  10627. m.Where(p...)
  10628. }
  10629. // Op returns the operation name.
  10630. func (m *CreditUsageMutation) Op() Op {
  10631. return m.op
  10632. }
  10633. // SetOp allows setting the mutation operation.
  10634. func (m *CreditUsageMutation) SetOp(op Op) {
  10635. m.op = op
  10636. }
  10637. // Type returns the node type of this mutation (CreditUsage).
  10638. func (m *CreditUsageMutation) Type() string {
  10639. return m.typ
  10640. }
  10641. // Fields returns all fields that were changed during this mutation. Note that in
  10642. // order to get all numeric fields that were incremented/decremented, call
  10643. // AddedFields().
  10644. func (m *CreditUsageMutation) Fields() []string {
  10645. fields := make([]string, 0, 12)
  10646. if m.created_at != nil {
  10647. fields = append(fields, creditusage.FieldCreatedAt)
  10648. }
  10649. if m.updated_at != nil {
  10650. fields = append(fields, creditusage.FieldUpdatedAt)
  10651. }
  10652. if m.deleted_at != nil {
  10653. fields = append(fields, creditusage.FieldDeletedAt)
  10654. }
  10655. if m.user_id != nil {
  10656. fields = append(fields, creditusage.FieldUserID)
  10657. }
  10658. if m.number != nil {
  10659. fields = append(fields, creditusage.FieldNumber)
  10660. }
  10661. if m.status != nil {
  10662. fields = append(fields, creditusage.FieldStatus)
  10663. }
  10664. if m.ntype != nil {
  10665. fields = append(fields, creditusage.FieldNtype)
  10666. }
  10667. if m.table != nil {
  10668. fields = append(fields, creditusage.FieldTable)
  10669. }
  10670. if m.organization_id != nil {
  10671. fields = append(fields, creditusage.FieldOrganizationID)
  10672. }
  10673. if m.nid != nil {
  10674. fields = append(fields, creditusage.FieldNid)
  10675. }
  10676. if m.reason != nil {
  10677. fields = append(fields, creditusage.FieldReason)
  10678. }
  10679. if m.operator != nil {
  10680. fields = append(fields, creditusage.FieldOperator)
  10681. }
  10682. return fields
  10683. }
  10684. // Field returns the value of a field with the given name. The second boolean
  10685. // return value indicates that this field was not set, or was not defined in the
  10686. // schema.
  10687. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  10688. switch name {
  10689. case creditusage.FieldCreatedAt:
  10690. return m.CreatedAt()
  10691. case creditusage.FieldUpdatedAt:
  10692. return m.UpdatedAt()
  10693. case creditusage.FieldDeletedAt:
  10694. return m.DeletedAt()
  10695. case creditusage.FieldUserID:
  10696. return m.UserID()
  10697. case creditusage.FieldNumber:
  10698. return m.Number()
  10699. case creditusage.FieldStatus:
  10700. return m.Status()
  10701. case creditusage.FieldNtype:
  10702. return m.Ntype()
  10703. case creditusage.FieldTable:
  10704. return m.Table()
  10705. case creditusage.FieldOrganizationID:
  10706. return m.OrganizationID()
  10707. case creditusage.FieldNid:
  10708. return m.Nid()
  10709. case creditusage.FieldReason:
  10710. return m.Reason()
  10711. case creditusage.FieldOperator:
  10712. return m.Operator()
  10713. }
  10714. return nil, false
  10715. }
  10716. // OldField returns the old value of the field from the database. An error is
  10717. // returned if the mutation operation is not UpdateOne, or the query to the
  10718. // database failed.
  10719. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10720. switch name {
  10721. case creditusage.FieldCreatedAt:
  10722. return m.OldCreatedAt(ctx)
  10723. case creditusage.FieldUpdatedAt:
  10724. return m.OldUpdatedAt(ctx)
  10725. case creditusage.FieldDeletedAt:
  10726. return m.OldDeletedAt(ctx)
  10727. case creditusage.FieldUserID:
  10728. return m.OldUserID(ctx)
  10729. case creditusage.FieldNumber:
  10730. return m.OldNumber(ctx)
  10731. case creditusage.FieldStatus:
  10732. return m.OldStatus(ctx)
  10733. case creditusage.FieldNtype:
  10734. return m.OldNtype(ctx)
  10735. case creditusage.FieldTable:
  10736. return m.OldTable(ctx)
  10737. case creditusage.FieldOrganizationID:
  10738. return m.OldOrganizationID(ctx)
  10739. case creditusage.FieldNid:
  10740. return m.OldNid(ctx)
  10741. case creditusage.FieldReason:
  10742. return m.OldReason(ctx)
  10743. case creditusage.FieldOperator:
  10744. return m.OldOperator(ctx)
  10745. }
  10746. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  10747. }
  10748. // SetField sets the value of a field with the given name. It returns an error if
  10749. // the field is not defined in the schema, or if the type mismatched the field
  10750. // type.
  10751. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  10752. switch name {
  10753. case creditusage.FieldCreatedAt:
  10754. v, ok := value.(time.Time)
  10755. if !ok {
  10756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10757. }
  10758. m.SetCreatedAt(v)
  10759. return nil
  10760. case creditusage.FieldUpdatedAt:
  10761. v, ok := value.(time.Time)
  10762. if !ok {
  10763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10764. }
  10765. m.SetUpdatedAt(v)
  10766. return nil
  10767. case creditusage.FieldDeletedAt:
  10768. v, ok := value.(time.Time)
  10769. if !ok {
  10770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10771. }
  10772. m.SetDeletedAt(v)
  10773. return nil
  10774. case creditusage.FieldUserID:
  10775. v, ok := value.(string)
  10776. if !ok {
  10777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10778. }
  10779. m.SetUserID(v)
  10780. return nil
  10781. case creditusage.FieldNumber:
  10782. v, ok := value.(float32)
  10783. if !ok {
  10784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10785. }
  10786. m.SetNumber(v)
  10787. return nil
  10788. case creditusage.FieldStatus:
  10789. v, ok := value.(int)
  10790. if !ok {
  10791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10792. }
  10793. m.SetStatus(v)
  10794. return nil
  10795. case creditusage.FieldNtype:
  10796. v, ok := value.(int)
  10797. if !ok {
  10798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10799. }
  10800. m.SetNtype(v)
  10801. return nil
  10802. case creditusage.FieldTable:
  10803. v, ok := value.(string)
  10804. if !ok {
  10805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10806. }
  10807. m.SetTable(v)
  10808. return nil
  10809. case creditusage.FieldOrganizationID:
  10810. v, ok := value.(uint64)
  10811. if !ok {
  10812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10813. }
  10814. m.SetOrganizationID(v)
  10815. return nil
  10816. case creditusage.FieldNid:
  10817. v, ok := value.(uint64)
  10818. if !ok {
  10819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10820. }
  10821. m.SetNid(v)
  10822. return nil
  10823. case creditusage.FieldReason:
  10824. v, ok := value.(string)
  10825. if !ok {
  10826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10827. }
  10828. m.SetReason(v)
  10829. return nil
  10830. case creditusage.FieldOperator:
  10831. v, ok := value.(string)
  10832. if !ok {
  10833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10834. }
  10835. m.SetOperator(v)
  10836. return nil
  10837. }
  10838. return fmt.Errorf("unknown CreditUsage field %s", name)
  10839. }
  10840. // AddedFields returns all numeric fields that were incremented/decremented during
  10841. // this mutation.
  10842. func (m *CreditUsageMutation) AddedFields() []string {
  10843. var fields []string
  10844. if m.addnumber != nil {
  10845. fields = append(fields, creditusage.FieldNumber)
  10846. }
  10847. if m.addstatus != nil {
  10848. fields = append(fields, creditusage.FieldStatus)
  10849. }
  10850. if m.addntype != nil {
  10851. fields = append(fields, creditusage.FieldNtype)
  10852. }
  10853. if m.addorganization_id != nil {
  10854. fields = append(fields, creditusage.FieldOrganizationID)
  10855. }
  10856. if m.addnid != nil {
  10857. fields = append(fields, creditusage.FieldNid)
  10858. }
  10859. return fields
  10860. }
  10861. // AddedField returns the numeric value that was incremented/decremented on a field
  10862. // with the given name. The second boolean return value indicates that this field
  10863. // was not set, or was not defined in the schema.
  10864. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  10865. switch name {
  10866. case creditusage.FieldNumber:
  10867. return m.AddedNumber()
  10868. case creditusage.FieldStatus:
  10869. return m.AddedStatus()
  10870. case creditusage.FieldNtype:
  10871. return m.AddedNtype()
  10872. case creditusage.FieldOrganizationID:
  10873. return m.AddedOrganizationID()
  10874. case creditusage.FieldNid:
  10875. return m.AddedNid()
  10876. }
  10877. return nil, false
  10878. }
  10879. // AddField adds the value to the field with the given name. It returns an error if
  10880. // the field is not defined in the schema, or if the type mismatched the field
  10881. // type.
  10882. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  10883. switch name {
  10884. case creditusage.FieldNumber:
  10885. v, ok := value.(float32)
  10886. if !ok {
  10887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10888. }
  10889. m.AddNumber(v)
  10890. return nil
  10891. case creditusage.FieldStatus:
  10892. v, ok := value.(int)
  10893. if !ok {
  10894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10895. }
  10896. m.AddStatus(v)
  10897. return nil
  10898. case creditusage.FieldNtype:
  10899. v, ok := value.(int)
  10900. if !ok {
  10901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10902. }
  10903. m.AddNtype(v)
  10904. return nil
  10905. case creditusage.FieldOrganizationID:
  10906. v, ok := value.(int64)
  10907. if !ok {
  10908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10909. }
  10910. m.AddOrganizationID(v)
  10911. return nil
  10912. case creditusage.FieldNid:
  10913. v, ok := value.(int64)
  10914. if !ok {
  10915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10916. }
  10917. m.AddNid(v)
  10918. return nil
  10919. }
  10920. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  10921. }
  10922. // ClearedFields returns all nullable fields that were cleared during this
  10923. // mutation.
  10924. func (m *CreditUsageMutation) ClearedFields() []string {
  10925. var fields []string
  10926. if m.FieldCleared(creditusage.FieldDeletedAt) {
  10927. fields = append(fields, creditusage.FieldDeletedAt)
  10928. }
  10929. if m.FieldCleared(creditusage.FieldStatus) {
  10930. fields = append(fields, creditusage.FieldStatus)
  10931. }
  10932. return fields
  10933. }
  10934. // FieldCleared returns a boolean indicating if a field with the given name was
  10935. // cleared in this mutation.
  10936. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  10937. _, ok := m.clearedFields[name]
  10938. return ok
  10939. }
  10940. // ClearField clears the value of the field with the given name. It returns an
  10941. // error if the field is not defined in the schema.
  10942. func (m *CreditUsageMutation) ClearField(name string) error {
  10943. switch name {
  10944. case creditusage.FieldDeletedAt:
  10945. m.ClearDeletedAt()
  10946. return nil
  10947. case creditusage.FieldStatus:
  10948. m.ClearStatus()
  10949. return nil
  10950. }
  10951. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  10952. }
  10953. // ResetField resets all changes in the mutation for the field with the given name.
  10954. // It returns an error if the field is not defined in the schema.
  10955. func (m *CreditUsageMutation) ResetField(name string) error {
  10956. switch name {
  10957. case creditusage.FieldCreatedAt:
  10958. m.ResetCreatedAt()
  10959. return nil
  10960. case creditusage.FieldUpdatedAt:
  10961. m.ResetUpdatedAt()
  10962. return nil
  10963. case creditusage.FieldDeletedAt:
  10964. m.ResetDeletedAt()
  10965. return nil
  10966. case creditusage.FieldUserID:
  10967. m.ResetUserID()
  10968. return nil
  10969. case creditusage.FieldNumber:
  10970. m.ResetNumber()
  10971. return nil
  10972. case creditusage.FieldStatus:
  10973. m.ResetStatus()
  10974. return nil
  10975. case creditusage.FieldNtype:
  10976. m.ResetNtype()
  10977. return nil
  10978. case creditusage.FieldTable:
  10979. m.ResetTable()
  10980. return nil
  10981. case creditusage.FieldOrganizationID:
  10982. m.ResetOrganizationID()
  10983. return nil
  10984. case creditusage.FieldNid:
  10985. m.ResetNid()
  10986. return nil
  10987. case creditusage.FieldReason:
  10988. m.ResetReason()
  10989. return nil
  10990. case creditusage.FieldOperator:
  10991. m.ResetOperator()
  10992. return nil
  10993. }
  10994. return fmt.Errorf("unknown CreditUsage field %s", name)
  10995. }
  10996. // AddedEdges returns all edge names that were set/added in this mutation.
  10997. func (m *CreditUsageMutation) AddedEdges() []string {
  10998. edges := make([]string, 0, 0)
  10999. return edges
  11000. }
  11001. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11002. // name in this mutation.
  11003. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  11004. return nil
  11005. }
  11006. // RemovedEdges returns all edge names that were removed in this mutation.
  11007. func (m *CreditUsageMutation) RemovedEdges() []string {
  11008. edges := make([]string, 0, 0)
  11009. return edges
  11010. }
  11011. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11012. // the given name in this mutation.
  11013. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  11014. return nil
  11015. }
  11016. // ClearedEdges returns all edge names that were cleared in this mutation.
  11017. func (m *CreditUsageMutation) ClearedEdges() []string {
  11018. edges := make([]string, 0, 0)
  11019. return edges
  11020. }
  11021. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11022. // was cleared in this mutation.
  11023. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  11024. return false
  11025. }
  11026. // ClearEdge clears the value of the edge with the given name. It returns an error
  11027. // if that edge is not defined in the schema.
  11028. func (m *CreditUsageMutation) ClearEdge(name string) error {
  11029. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  11030. }
  11031. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11032. // It returns an error if the edge is not defined in the schema.
  11033. func (m *CreditUsageMutation) ResetEdge(name string) error {
  11034. return fmt.Errorf("unknown CreditUsage edge %s", name)
  11035. }
  11036. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  11037. type EmployeeMutation struct {
  11038. config
  11039. op Op
  11040. typ string
  11041. id *uint64
  11042. created_at *time.Time
  11043. updated_at *time.Time
  11044. deleted_at *time.Time
  11045. title *string
  11046. avatar *string
  11047. tags *string
  11048. hire_count *int
  11049. addhire_count *int
  11050. service_count *int
  11051. addservice_count *int
  11052. achievement_count *int
  11053. addachievement_count *int
  11054. intro *string
  11055. estimate *string
  11056. skill *string
  11057. ability_type *string
  11058. scene *string
  11059. switch_in *string
  11060. video_url *string
  11061. organization_id *uint64
  11062. addorganization_id *int64
  11063. category_id *uint64
  11064. addcategory_id *int64
  11065. api_base *string
  11066. api_key *string
  11067. ai_info *string
  11068. is_vip *int
  11069. addis_vip *int
  11070. chat_url *string
  11071. clearedFields map[string]struct{}
  11072. em_work_experiences map[uint64]struct{}
  11073. removedem_work_experiences map[uint64]struct{}
  11074. clearedem_work_experiences bool
  11075. em_tutorial map[uint64]struct{}
  11076. removedem_tutorial map[uint64]struct{}
  11077. clearedem_tutorial bool
  11078. done bool
  11079. oldValue func(context.Context) (*Employee, error)
  11080. predicates []predicate.Employee
  11081. }
  11082. var _ ent.Mutation = (*EmployeeMutation)(nil)
  11083. // employeeOption allows management of the mutation configuration using functional options.
  11084. type employeeOption func(*EmployeeMutation)
  11085. // newEmployeeMutation creates new mutation for the Employee entity.
  11086. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  11087. m := &EmployeeMutation{
  11088. config: c,
  11089. op: op,
  11090. typ: TypeEmployee,
  11091. clearedFields: make(map[string]struct{}),
  11092. }
  11093. for _, opt := range opts {
  11094. opt(m)
  11095. }
  11096. return m
  11097. }
  11098. // withEmployeeID sets the ID field of the mutation.
  11099. func withEmployeeID(id uint64) employeeOption {
  11100. return func(m *EmployeeMutation) {
  11101. var (
  11102. err error
  11103. once sync.Once
  11104. value *Employee
  11105. )
  11106. m.oldValue = func(ctx context.Context) (*Employee, error) {
  11107. once.Do(func() {
  11108. if m.done {
  11109. err = errors.New("querying old values post mutation is not allowed")
  11110. } else {
  11111. value, err = m.Client().Employee.Get(ctx, id)
  11112. }
  11113. })
  11114. return value, err
  11115. }
  11116. m.id = &id
  11117. }
  11118. }
  11119. // withEmployee sets the old Employee of the mutation.
  11120. func withEmployee(node *Employee) employeeOption {
  11121. return func(m *EmployeeMutation) {
  11122. m.oldValue = func(context.Context) (*Employee, error) {
  11123. return node, nil
  11124. }
  11125. m.id = &node.ID
  11126. }
  11127. }
  11128. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11129. // executed in a transaction (ent.Tx), a transactional client is returned.
  11130. func (m EmployeeMutation) Client() *Client {
  11131. client := &Client{config: m.config}
  11132. client.init()
  11133. return client
  11134. }
  11135. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11136. // it returns an error otherwise.
  11137. func (m EmployeeMutation) Tx() (*Tx, error) {
  11138. if _, ok := m.driver.(*txDriver); !ok {
  11139. return nil, errors.New("ent: mutation is not running in a transaction")
  11140. }
  11141. tx := &Tx{config: m.config}
  11142. tx.init()
  11143. return tx, nil
  11144. }
  11145. // SetID sets the value of the id field. Note that this
  11146. // operation is only accepted on creation of Employee entities.
  11147. func (m *EmployeeMutation) SetID(id uint64) {
  11148. m.id = &id
  11149. }
  11150. // ID returns the ID value in the mutation. Note that the ID is only available
  11151. // if it was provided to the builder or after it was returned from the database.
  11152. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  11153. if m.id == nil {
  11154. return
  11155. }
  11156. return *m.id, true
  11157. }
  11158. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11159. // That means, if the mutation is applied within a transaction with an isolation level such
  11160. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11161. // or updated by the mutation.
  11162. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  11163. switch {
  11164. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11165. id, exists := m.ID()
  11166. if exists {
  11167. return []uint64{id}, nil
  11168. }
  11169. fallthrough
  11170. case m.op.Is(OpUpdate | OpDelete):
  11171. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  11172. default:
  11173. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11174. }
  11175. }
  11176. // SetCreatedAt sets the "created_at" field.
  11177. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  11178. m.created_at = &t
  11179. }
  11180. // CreatedAt returns the value of the "created_at" field in the mutation.
  11181. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  11182. v := m.created_at
  11183. if v == nil {
  11184. return
  11185. }
  11186. return *v, true
  11187. }
  11188. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  11189. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11191. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11192. if !m.op.Is(OpUpdateOne) {
  11193. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11194. }
  11195. if m.id == nil || m.oldValue == nil {
  11196. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11197. }
  11198. oldValue, err := m.oldValue(ctx)
  11199. if err != nil {
  11200. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11201. }
  11202. return oldValue.CreatedAt, nil
  11203. }
  11204. // ResetCreatedAt resets all changes to the "created_at" field.
  11205. func (m *EmployeeMutation) ResetCreatedAt() {
  11206. m.created_at = nil
  11207. }
  11208. // SetUpdatedAt sets the "updated_at" field.
  11209. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  11210. m.updated_at = &t
  11211. }
  11212. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11213. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  11214. v := m.updated_at
  11215. if v == nil {
  11216. return
  11217. }
  11218. return *v, true
  11219. }
  11220. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  11221. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11223. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11224. if !m.op.Is(OpUpdateOne) {
  11225. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11226. }
  11227. if m.id == nil || m.oldValue == nil {
  11228. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11229. }
  11230. oldValue, err := m.oldValue(ctx)
  11231. if err != nil {
  11232. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11233. }
  11234. return oldValue.UpdatedAt, nil
  11235. }
  11236. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11237. func (m *EmployeeMutation) ResetUpdatedAt() {
  11238. m.updated_at = nil
  11239. }
  11240. // SetDeletedAt sets the "deleted_at" field.
  11241. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  11242. m.deleted_at = &t
  11243. }
  11244. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11245. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  11246. v := m.deleted_at
  11247. if v == nil {
  11248. return
  11249. }
  11250. return *v, true
  11251. }
  11252. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  11253. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11255. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11256. if !m.op.Is(OpUpdateOne) {
  11257. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11258. }
  11259. if m.id == nil || m.oldValue == nil {
  11260. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11261. }
  11262. oldValue, err := m.oldValue(ctx)
  11263. if err != nil {
  11264. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11265. }
  11266. return oldValue.DeletedAt, nil
  11267. }
  11268. // ClearDeletedAt clears the value of the "deleted_at" field.
  11269. func (m *EmployeeMutation) ClearDeletedAt() {
  11270. m.deleted_at = nil
  11271. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  11272. }
  11273. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11274. func (m *EmployeeMutation) DeletedAtCleared() bool {
  11275. _, ok := m.clearedFields[employee.FieldDeletedAt]
  11276. return ok
  11277. }
  11278. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11279. func (m *EmployeeMutation) ResetDeletedAt() {
  11280. m.deleted_at = nil
  11281. delete(m.clearedFields, employee.FieldDeletedAt)
  11282. }
  11283. // SetTitle sets the "title" field.
  11284. func (m *EmployeeMutation) SetTitle(s string) {
  11285. m.title = &s
  11286. }
  11287. // Title returns the value of the "title" field in the mutation.
  11288. func (m *EmployeeMutation) Title() (r string, exists bool) {
  11289. v := m.title
  11290. if v == nil {
  11291. return
  11292. }
  11293. return *v, true
  11294. }
  11295. // OldTitle returns the old "title" field's value of the Employee entity.
  11296. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11298. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  11299. if !m.op.Is(OpUpdateOne) {
  11300. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  11301. }
  11302. if m.id == nil || m.oldValue == nil {
  11303. return v, errors.New("OldTitle requires an ID field in the mutation")
  11304. }
  11305. oldValue, err := m.oldValue(ctx)
  11306. if err != nil {
  11307. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  11308. }
  11309. return oldValue.Title, nil
  11310. }
  11311. // ResetTitle resets all changes to the "title" field.
  11312. func (m *EmployeeMutation) ResetTitle() {
  11313. m.title = nil
  11314. }
  11315. // SetAvatar sets the "avatar" field.
  11316. func (m *EmployeeMutation) SetAvatar(s string) {
  11317. m.avatar = &s
  11318. }
  11319. // Avatar returns the value of the "avatar" field in the mutation.
  11320. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  11321. v := m.avatar
  11322. if v == nil {
  11323. return
  11324. }
  11325. return *v, true
  11326. }
  11327. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  11328. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11330. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  11331. if !m.op.Is(OpUpdateOne) {
  11332. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  11333. }
  11334. if m.id == nil || m.oldValue == nil {
  11335. return v, errors.New("OldAvatar requires an ID field in the mutation")
  11336. }
  11337. oldValue, err := m.oldValue(ctx)
  11338. if err != nil {
  11339. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  11340. }
  11341. return oldValue.Avatar, nil
  11342. }
  11343. // ResetAvatar resets all changes to the "avatar" field.
  11344. func (m *EmployeeMutation) ResetAvatar() {
  11345. m.avatar = nil
  11346. }
  11347. // SetTags sets the "tags" field.
  11348. func (m *EmployeeMutation) SetTags(s string) {
  11349. m.tags = &s
  11350. }
  11351. // Tags returns the value of the "tags" field in the mutation.
  11352. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  11353. v := m.tags
  11354. if v == nil {
  11355. return
  11356. }
  11357. return *v, true
  11358. }
  11359. // OldTags returns the old "tags" field's value of the Employee entity.
  11360. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11362. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  11363. if !m.op.Is(OpUpdateOne) {
  11364. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  11365. }
  11366. if m.id == nil || m.oldValue == nil {
  11367. return v, errors.New("OldTags requires an ID field in the mutation")
  11368. }
  11369. oldValue, err := m.oldValue(ctx)
  11370. if err != nil {
  11371. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  11372. }
  11373. return oldValue.Tags, nil
  11374. }
  11375. // ResetTags resets all changes to the "tags" field.
  11376. func (m *EmployeeMutation) ResetTags() {
  11377. m.tags = nil
  11378. }
  11379. // SetHireCount sets the "hire_count" field.
  11380. func (m *EmployeeMutation) SetHireCount(i int) {
  11381. m.hire_count = &i
  11382. m.addhire_count = nil
  11383. }
  11384. // HireCount returns the value of the "hire_count" field in the mutation.
  11385. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  11386. v := m.hire_count
  11387. if v == nil {
  11388. return
  11389. }
  11390. return *v, true
  11391. }
  11392. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  11393. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11395. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  11396. if !m.op.Is(OpUpdateOne) {
  11397. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  11398. }
  11399. if m.id == nil || m.oldValue == nil {
  11400. return v, errors.New("OldHireCount requires an ID field in the mutation")
  11401. }
  11402. oldValue, err := m.oldValue(ctx)
  11403. if err != nil {
  11404. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  11405. }
  11406. return oldValue.HireCount, nil
  11407. }
  11408. // AddHireCount adds i to the "hire_count" field.
  11409. func (m *EmployeeMutation) AddHireCount(i int) {
  11410. if m.addhire_count != nil {
  11411. *m.addhire_count += i
  11412. } else {
  11413. m.addhire_count = &i
  11414. }
  11415. }
  11416. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  11417. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  11418. v := m.addhire_count
  11419. if v == nil {
  11420. return
  11421. }
  11422. return *v, true
  11423. }
  11424. // ResetHireCount resets all changes to the "hire_count" field.
  11425. func (m *EmployeeMutation) ResetHireCount() {
  11426. m.hire_count = nil
  11427. m.addhire_count = nil
  11428. }
  11429. // SetServiceCount sets the "service_count" field.
  11430. func (m *EmployeeMutation) SetServiceCount(i int) {
  11431. m.service_count = &i
  11432. m.addservice_count = nil
  11433. }
  11434. // ServiceCount returns the value of the "service_count" field in the mutation.
  11435. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  11436. v := m.service_count
  11437. if v == nil {
  11438. return
  11439. }
  11440. return *v, true
  11441. }
  11442. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  11443. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11445. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  11446. if !m.op.Is(OpUpdateOne) {
  11447. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  11448. }
  11449. if m.id == nil || m.oldValue == nil {
  11450. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  11451. }
  11452. oldValue, err := m.oldValue(ctx)
  11453. if err != nil {
  11454. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  11455. }
  11456. return oldValue.ServiceCount, nil
  11457. }
  11458. // AddServiceCount adds i to the "service_count" field.
  11459. func (m *EmployeeMutation) AddServiceCount(i int) {
  11460. if m.addservice_count != nil {
  11461. *m.addservice_count += i
  11462. } else {
  11463. m.addservice_count = &i
  11464. }
  11465. }
  11466. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  11467. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  11468. v := m.addservice_count
  11469. if v == nil {
  11470. return
  11471. }
  11472. return *v, true
  11473. }
  11474. // ResetServiceCount resets all changes to the "service_count" field.
  11475. func (m *EmployeeMutation) ResetServiceCount() {
  11476. m.service_count = nil
  11477. m.addservice_count = nil
  11478. }
  11479. // SetAchievementCount sets the "achievement_count" field.
  11480. func (m *EmployeeMutation) SetAchievementCount(i int) {
  11481. m.achievement_count = &i
  11482. m.addachievement_count = nil
  11483. }
  11484. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  11485. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  11486. v := m.achievement_count
  11487. if v == nil {
  11488. return
  11489. }
  11490. return *v, true
  11491. }
  11492. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  11493. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11495. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  11496. if !m.op.Is(OpUpdateOne) {
  11497. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  11498. }
  11499. if m.id == nil || m.oldValue == nil {
  11500. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  11501. }
  11502. oldValue, err := m.oldValue(ctx)
  11503. if err != nil {
  11504. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  11505. }
  11506. return oldValue.AchievementCount, nil
  11507. }
  11508. // AddAchievementCount adds i to the "achievement_count" field.
  11509. func (m *EmployeeMutation) AddAchievementCount(i int) {
  11510. if m.addachievement_count != nil {
  11511. *m.addachievement_count += i
  11512. } else {
  11513. m.addachievement_count = &i
  11514. }
  11515. }
  11516. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  11517. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  11518. v := m.addachievement_count
  11519. if v == nil {
  11520. return
  11521. }
  11522. return *v, true
  11523. }
  11524. // ResetAchievementCount resets all changes to the "achievement_count" field.
  11525. func (m *EmployeeMutation) ResetAchievementCount() {
  11526. m.achievement_count = nil
  11527. m.addachievement_count = nil
  11528. }
  11529. // SetIntro sets the "intro" field.
  11530. func (m *EmployeeMutation) SetIntro(s string) {
  11531. m.intro = &s
  11532. }
  11533. // Intro returns the value of the "intro" field in the mutation.
  11534. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  11535. v := m.intro
  11536. if v == nil {
  11537. return
  11538. }
  11539. return *v, true
  11540. }
  11541. // OldIntro returns the old "intro" field's value of the Employee entity.
  11542. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11544. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  11545. if !m.op.Is(OpUpdateOne) {
  11546. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  11547. }
  11548. if m.id == nil || m.oldValue == nil {
  11549. return v, errors.New("OldIntro requires an ID field in the mutation")
  11550. }
  11551. oldValue, err := m.oldValue(ctx)
  11552. if err != nil {
  11553. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  11554. }
  11555. return oldValue.Intro, nil
  11556. }
  11557. // ResetIntro resets all changes to the "intro" field.
  11558. func (m *EmployeeMutation) ResetIntro() {
  11559. m.intro = nil
  11560. }
  11561. // SetEstimate sets the "estimate" field.
  11562. func (m *EmployeeMutation) SetEstimate(s string) {
  11563. m.estimate = &s
  11564. }
  11565. // Estimate returns the value of the "estimate" field in the mutation.
  11566. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  11567. v := m.estimate
  11568. if v == nil {
  11569. return
  11570. }
  11571. return *v, true
  11572. }
  11573. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  11574. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11576. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  11577. if !m.op.Is(OpUpdateOne) {
  11578. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  11579. }
  11580. if m.id == nil || m.oldValue == nil {
  11581. return v, errors.New("OldEstimate requires an ID field in the mutation")
  11582. }
  11583. oldValue, err := m.oldValue(ctx)
  11584. if err != nil {
  11585. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  11586. }
  11587. return oldValue.Estimate, nil
  11588. }
  11589. // ResetEstimate resets all changes to the "estimate" field.
  11590. func (m *EmployeeMutation) ResetEstimate() {
  11591. m.estimate = nil
  11592. }
  11593. // SetSkill sets the "skill" field.
  11594. func (m *EmployeeMutation) SetSkill(s string) {
  11595. m.skill = &s
  11596. }
  11597. // Skill returns the value of the "skill" field in the mutation.
  11598. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  11599. v := m.skill
  11600. if v == nil {
  11601. return
  11602. }
  11603. return *v, true
  11604. }
  11605. // OldSkill returns the old "skill" field's value of the Employee entity.
  11606. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11608. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  11609. if !m.op.Is(OpUpdateOne) {
  11610. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  11611. }
  11612. if m.id == nil || m.oldValue == nil {
  11613. return v, errors.New("OldSkill requires an ID field in the mutation")
  11614. }
  11615. oldValue, err := m.oldValue(ctx)
  11616. if err != nil {
  11617. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  11618. }
  11619. return oldValue.Skill, nil
  11620. }
  11621. // ResetSkill resets all changes to the "skill" field.
  11622. func (m *EmployeeMutation) ResetSkill() {
  11623. m.skill = nil
  11624. }
  11625. // SetAbilityType sets the "ability_type" field.
  11626. func (m *EmployeeMutation) SetAbilityType(s string) {
  11627. m.ability_type = &s
  11628. }
  11629. // AbilityType returns the value of the "ability_type" field in the mutation.
  11630. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  11631. v := m.ability_type
  11632. if v == nil {
  11633. return
  11634. }
  11635. return *v, true
  11636. }
  11637. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  11638. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11639. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11640. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  11641. if !m.op.Is(OpUpdateOne) {
  11642. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  11643. }
  11644. if m.id == nil || m.oldValue == nil {
  11645. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  11646. }
  11647. oldValue, err := m.oldValue(ctx)
  11648. if err != nil {
  11649. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  11650. }
  11651. return oldValue.AbilityType, nil
  11652. }
  11653. // ResetAbilityType resets all changes to the "ability_type" field.
  11654. func (m *EmployeeMutation) ResetAbilityType() {
  11655. m.ability_type = nil
  11656. }
  11657. // SetScene sets the "scene" field.
  11658. func (m *EmployeeMutation) SetScene(s string) {
  11659. m.scene = &s
  11660. }
  11661. // Scene returns the value of the "scene" field in the mutation.
  11662. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  11663. v := m.scene
  11664. if v == nil {
  11665. return
  11666. }
  11667. return *v, true
  11668. }
  11669. // OldScene returns the old "scene" field's value of the Employee entity.
  11670. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11672. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  11673. if !m.op.Is(OpUpdateOne) {
  11674. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  11675. }
  11676. if m.id == nil || m.oldValue == nil {
  11677. return v, errors.New("OldScene requires an ID field in the mutation")
  11678. }
  11679. oldValue, err := m.oldValue(ctx)
  11680. if err != nil {
  11681. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  11682. }
  11683. return oldValue.Scene, nil
  11684. }
  11685. // ResetScene resets all changes to the "scene" field.
  11686. func (m *EmployeeMutation) ResetScene() {
  11687. m.scene = nil
  11688. }
  11689. // SetSwitchIn sets the "switch_in" field.
  11690. func (m *EmployeeMutation) SetSwitchIn(s string) {
  11691. m.switch_in = &s
  11692. }
  11693. // SwitchIn returns the value of the "switch_in" field in the mutation.
  11694. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  11695. v := m.switch_in
  11696. if v == nil {
  11697. return
  11698. }
  11699. return *v, true
  11700. }
  11701. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  11702. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11704. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  11705. if !m.op.Is(OpUpdateOne) {
  11706. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  11707. }
  11708. if m.id == nil || m.oldValue == nil {
  11709. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  11710. }
  11711. oldValue, err := m.oldValue(ctx)
  11712. if err != nil {
  11713. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  11714. }
  11715. return oldValue.SwitchIn, nil
  11716. }
  11717. // ResetSwitchIn resets all changes to the "switch_in" field.
  11718. func (m *EmployeeMutation) ResetSwitchIn() {
  11719. m.switch_in = nil
  11720. }
  11721. // SetVideoURL sets the "video_url" field.
  11722. func (m *EmployeeMutation) SetVideoURL(s string) {
  11723. m.video_url = &s
  11724. }
  11725. // VideoURL returns the value of the "video_url" field in the mutation.
  11726. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  11727. v := m.video_url
  11728. if v == nil {
  11729. return
  11730. }
  11731. return *v, true
  11732. }
  11733. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  11734. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11736. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  11737. if !m.op.Is(OpUpdateOne) {
  11738. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  11739. }
  11740. if m.id == nil || m.oldValue == nil {
  11741. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  11742. }
  11743. oldValue, err := m.oldValue(ctx)
  11744. if err != nil {
  11745. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  11746. }
  11747. return oldValue.VideoURL, nil
  11748. }
  11749. // ResetVideoURL resets all changes to the "video_url" field.
  11750. func (m *EmployeeMutation) ResetVideoURL() {
  11751. m.video_url = nil
  11752. }
  11753. // SetOrganizationID sets the "organization_id" field.
  11754. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  11755. m.organization_id = &u
  11756. m.addorganization_id = nil
  11757. }
  11758. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11759. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  11760. v := m.organization_id
  11761. if v == nil {
  11762. return
  11763. }
  11764. return *v, true
  11765. }
  11766. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  11767. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11768. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11769. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11770. if !m.op.Is(OpUpdateOne) {
  11771. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11772. }
  11773. if m.id == nil || m.oldValue == nil {
  11774. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11775. }
  11776. oldValue, err := m.oldValue(ctx)
  11777. if err != nil {
  11778. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11779. }
  11780. return oldValue.OrganizationID, nil
  11781. }
  11782. // AddOrganizationID adds u to the "organization_id" field.
  11783. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  11784. if m.addorganization_id != nil {
  11785. *m.addorganization_id += u
  11786. } else {
  11787. m.addorganization_id = &u
  11788. }
  11789. }
  11790. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11791. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  11792. v := m.addorganization_id
  11793. if v == nil {
  11794. return
  11795. }
  11796. return *v, true
  11797. }
  11798. // ResetOrganizationID resets all changes to the "organization_id" field.
  11799. func (m *EmployeeMutation) ResetOrganizationID() {
  11800. m.organization_id = nil
  11801. m.addorganization_id = nil
  11802. }
  11803. // SetCategoryID sets the "category_id" field.
  11804. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  11805. m.category_id = &u
  11806. m.addcategory_id = nil
  11807. }
  11808. // CategoryID returns the value of the "category_id" field in the mutation.
  11809. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  11810. v := m.category_id
  11811. if v == nil {
  11812. return
  11813. }
  11814. return *v, true
  11815. }
  11816. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  11817. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11819. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  11820. if !m.op.Is(OpUpdateOne) {
  11821. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  11822. }
  11823. if m.id == nil || m.oldValue == nil {
  11824. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  11825. }
  11826. oldValue, err := m.oldValue(ctx)
  11827. if err != nil {
  11828. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  11829. }
  11830. return oldValue.CategoryID, nil
  11831. }
  11832. // AddCategoryID adds u to the "category_id" field.
  11833. func (m *EmployeeMutation) AddCategoryID(u int64) {
  11834. if m.addcategory_id != nil {
  11835. *m.addcategory_id += u
  11836. } else {
  11837. m.addcategory_id = &u
  11838. }
  11839. }
  11840. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  11841. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  11842. v := m.addcategory_id
  11843. if v == nil {
  11844. return
  11845. }
  11846. return *v, true
  11847. }
  11848. // ResetCategoryID resets all changes to the "category_id" field.
  11849. func (m *EmployeeMutation) ResetCategoryID() {
  11850. m.category_id = nil
  11851. m.addcategory_id = nil
  11852. }
  11853. // SetAPIBase sets the "api_base" field.
  11854. func (m *EmployeeMutation) SetAPIBase(s string) {
  11855. m.api_base = &s
  11856. }
  11857. // APIBase returns the value of the "api_base" field in the mutation.
  11858. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  11859. v := m.api_base
  11860. if v == nil {
  11861. return
  11862. }
  11863. return *v, true
  11864. }
  11865. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  11866. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11867. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11868. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  11869. if !m.op.Is(OpUpdateOne) {
  11870. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  11871. }
  11872. if m.id == nil || m.oldValue == nil {
  11873. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  11874. }
  11875. oldValue, err := m.oldValue(ctx)
  11876. if err != nil {
  11877. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  11878. }
  11879. return oldValue.APIBase, nil
  11880. }
  11881. // ResetAPIBase resets all changes to the "api_base" field.
  11882. func (m *EmployeeMutation) ResetAPIBase() {
  11883. m.api_base = nil
  11884. }
  11885. // SetAPIKey sets the "api_key" field.
  11886. func (m *EmployeeMutation) SetAPIKey(s string) {
  11887. m.api_key = &s
  11888. }
  11889. // APIKey returns the value of the "api_key" field in the mutation.
  11890. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  11891. v := m.api_key
  11892. if v == nil {
  11893. return
  11894. }
  11895. return *v, true
  11896. }
  11897. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  11898. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11900. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  11901. if !m.op.Is(OpUpdateOne) {
  11902. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  11903. }
  11904. if m.id == nil || m.oldValue == nil {
  11905. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  11906. }
  11907. oldValue, err := m.oldValue(ctx)
  11908. if err != nil {
  11909. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  11910. }
  11911. return oldValue.APIKey, nil
  11912. }
  11913. // ResetAPIKey resets all changes to the "api_key" field.
  11914. func (m *EmployeeMutation) ResetAPIKey() {
  11915. m.api_key = nil
  11916. }
  11917. // SetAiInfo sets the "ai_info" field.
  11918. func (m *EmployeeMutation) SetAiInfo(s string) {
  11919. m.ai_info = &s
  11920. }
  11921. // AiInfo returns the value of the "ai_info" field in the mutation.
  11922. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  11923. v := m.ai_info
  11924. if v == nil {
  11925. return
  11926. }
  11927. return *v, true
  11928. }
  11929. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  11930. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11932. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  11933. if !m.op.Is(OpUpdateOne) {
  11934. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  11935. }
  11936. if m.id == nil || m.oldValue == nil {
  11937. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  11938. }
  11939. oldValue, err := m.oldValue(ctx)
  11940. if err != nil {
  11941. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  11942. }
  11943. return oldValue.AiInfo, nil
  11944. }
  11945. // ClearAiInfo clears the value of the "ai_info" field.
  11946. func (m *EmployeeMutation) ClearAiInfo() {
  11947. m.ai_info = nil
  11948. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  11949. }
  11950. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  11951. func (m *EmployeeMutation) AiInfoCleared() bool {
  11952. _, ok := m.clearedFields[employee.FieldAiInfo]
  11953. return ok
  11954. }
  11955. // ResetAiInfo resets all changes to the "ai_info" field.
  11956. func (m *EmployeeMutation) ResetAiInfo() {
  11957. m.ai_info = nil
  11958. delete(m.clearedFields, employee.FieldAiInfo)
  11959. }
  11960. // SetIsVip sets the "is_vip" field.
  11961. func (m *EmployeeMutation) SetIsVip(i int) {
  11962. m.is_vip = &i
  11963. m.addis_vip = nil
  11964. }
  11965. // IsVip returns the value of the "is_vip" field in the mutation.
  11966. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  11967. v := m.is_vip
  11968. if v == nil {
  11969. return
  11970. }
  11971. return *v, true
  11972. }
  11973. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  11974. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11976. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  11977. if !m.op.Is(OpUpdateOne) {
  11978. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  11979. }
  11980. if m.id == nil || m.oldValue == nil {
  11981. return v, errors.New("OldIsVip requires an ID field in the mutation")
  11982. }
  11983. oldValue, err := m.oldValue(ctx)
  11984. if err != nil {
  11985. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  11986. }
  11987. return oldValue.IsVip, nil
  11988. }
  11989. // AddIsVip adds i to the "is_vip" field.
  11990. func (m *EmployeeMutation) AddIsVip(i int) {
  11991. if m.addis_vip != nil {
  11992. *m.addis_vip += i
  11993. } else {
  11994. m.addis_vip = &i
  11995. }
  11996. }
  11997. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  11998. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  11999. v := m.addis_vip
  12000. if v == nil {
  12001. return
  12002. }
  12003. return *v, true
  12004. }
  12005. // ResetIsVip resets all changes to the "is_vip" field.
  12006. func (m *EmployeeMutation) ResetIsVip() {
  12007. m.is_vip = nil
  12008. m.addis_vip = nil
  12009. }
  12010. // SetChatURL sets the "chat_url" field.
  12011. func (m *EmployeeMutation) SetChatURL(s string) {
  12012. m.chat_url = &s
  12013. }
  12014. // ChatURL returns the value of the "chat_url" field in the mutation.
  12015. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  12016. v := m.chat_url
  12017. if v == nil {
  12018. return
  12019. }
  12020. return *v, true
  12021. }
  12022. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  12023. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12025. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  12026. if !m.op.Is(OpUpdateOne) {
  12027. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  12028. }
  12029. if m.id == nil || m.oldValue == nil {
  12030. return v, errors.New("OldChatURL requires an ID field in the mutation")
  12031. }
  12032. oldValue, err := m.oldValue(ctx)
  12033. if err != nil {
  12034. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  12035. }
  12036. return oldValue.ChatURL, nil
  12037. }
  12038. // ResetChatURL resets all changes to the "chat_url" field.
  12039. func (m *EmployeeMutation) ResetChatURL() {
  12040. m.chat_url = nil
  12041. }
  12042. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  12043. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  12044. if m.em_work_experiences == nil {
  12045. m.em_work_experiences = make(map[uint64]struct{})
  12046. }
  12047. for i := range ids {
  12048. m.em_work_experiences[ids[i]] = struct{}{}
  12049. }
  12050. }
  12051. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  12052. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  12053. m.clearedem_work_experiences = true
  12054. }
  12055. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  12056. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  12057. return m.clearedem_work_experiences
  12058. }
  12059. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  12060. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  12061. if m.removedem_work_experiences == nil {
  12062. m.removedem_work_experiences = make(map[uint64]struct{})
  12063. }
  12064. for i := range ids {
  12065. delete(m.em_work_experiences, ids[i])
  12066. m.removedem_work_experiences[ids[i]] = struct{}{}
  12067. }
  12068. }
  12069. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  12070. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  12071. for id := range m.removedem_work_experiences {
  12072. ids = append(ids, id)
  12073. }
  12074. return
  12075. }
  12076. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  12077. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  12078. for id := range m.em_work_experiences {
  12079. ids = append(ids, id)
  12080. }
  12081. return
  12082. }
  12083. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  12084. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  12085. m.em_work_experiences = nil
  12086. m.clearedem_work_experiences = false
  12087. m.removedem_work_experiences = nil
  12088. }
  12089. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  12090. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  12091. if m.em_tutorial == nil {
  12092. m.em_tutorial = make(map[uint64]struct{})
  12093. }
  12094. for i := range ids {
  12095. m.em_tutorial[ids[i]] = struct{}{}
  12096. }
  12097. }
  12098. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  12099. func (m *EmployeeMutation) ClearEmTutorial() {
  12100. m.clearedem_tutorial = true
  12101. }
  12102. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  12103. func (m *EmployeeMutation) EmTutorialCleared() bool {
  12104. return m.clearedem_tutorial
  12105. }
  12106. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  12107. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  12108. if m.removedem_tutorial == nil {
  12109. m.removedem_tutorial = make(map[uint64]struct{})
  12110. }
  12111. for i := range ids {
  12112. delete(m.em_tutorial, ids[i])
  12113. m.removedem_tutorial[ids[i]] = struct{}{}
  12114. }
  12115. }
  12116. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  12117. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  12118. for id := range m.removedem_tutorial {
  12119. ids = append(ids, id)
  12120. }
  12121. return
  12122. }
  12123. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  12124. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  12125. for id := range m.em_tutorial {
  12126. ids = append(ids, id)
  12127. }
  12128. return
  12129. }
  12130. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  12131. func (m *EmployeeMutation) ResetEmTutorial() {
  12132. m.em_tutorial = nil
  12133. m.clearedem_tutorial = false
  12134. m.removedem_tutorial = nil
  12135. }
  12136. // Where appends a list predicates to the EmployeeMutation builder.
  12137. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  12138. m.predicates = append(m.predicates, ps...)
  12139. }
  12140. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  12141. // users can use type-assertion to append predicates that do not depend on any generated package.
  12142. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  12143. p := make([]predicate.Employee, len(ps))
  12144. for i := range ps {
  12145. p[i] = ps[i]
  12146. }
  12147. m.Where(p...)
  12148. }
  12149. // Op returns the operation name.
  12150. func (m *EmployeeMutation) Op() Op {
  12151. return m.op
  12152. }
  12153. // SetOp allows setting the mutation operation.
  12154. func (m *EmployeeMutation) SetOp(op Op) {
  12155. m.op = op
  12156. }
  12157. // Type returns the node type of this mutation (Employee).
  12158. func (m *EmployeeMutation) Type() string {
  12159. return m.typ
  12160. }
  12161. // Fields returns all fields that were changed during this mutation. Note that in
  12162. // order to get all numeric fields that were incremented/decremented, call
  12163. // AddedFields().
  12164. func (m *EmployeeMutation) Fields() []string {
  12165. fields := make([]string, 0, 23)
  12166. if m.created_at != nil {
  12167. fields = append(fields, employee.FieldCreatedAt)
  12168. }
  12169. if m.updated_at != nil {
  12170. fields = append(fields, employee.FieldUpdatedAt)
  12171. }
  12172. if m.deleted_at != nil {
  12173. fields = append(fields, employee.FieldDeletedAt)
  12174. }
  12175. if m.title != nil {
  12176. fields = append(fields, employee.FieldTitle)
  12177. }
  12178. if m.avatar != nil {
  12179. fields = append(fields, employee.FieldAvatar)
  12180. }
  12181. if m.tags != nil {
  12182. fields = append(fields, employee.FieldTags)
  12183. }
  12184. if m.hire_count != nil {
  12185. fields = append(fields, employee.FieldHireCount)
  12186. }
  12187. if m.service_count != nil {
  12188. fields = append(fields, employee.FieldServiceCount)
  12189. }
  12190. if m.achievement_count != nil {
  12191. fields = append(fields, employee.FieldAchievementCount)
  12192. }
  12193. if m.intro != nil {
  12194. fields = append(fields, employee.FieldIntro)
  12195. }
  12196. if m.estimate != nil {
  12197. fields = append(fields, employee.FieldEstimate)
  12198. }
  12199. if m.skill != nil {
  12200. fields = append(fields, employee.FieldSkill)
  12201. }
  12202. if m.ability_type != nil {
  12203. fields = append(fields, employee.FieldAbilityType)
  12204. }
  12205. if m.scene != nil {
  12206. fields = append(fields, employee.FieldScene)
  12207. }
  12208. if m.switch_in != nil {
  12209. fields = append(fields, employee.FieldSwitchIn)
  12210. }
  12211. if m.video_url != nil {
  12212. fields = append(fields, employee.FieldVideoURL)
  12213. }
  12214. if m.organization_id != nil {
  12215. fields = append(fields, employee.FieldOrganizationID)
  12216. }
  12217. if m.category_id != nil {
  12218. fields = append(fields, employee.FieldCategoryID)
  12219. }
  12220. if m.api_base != nil {
  12221. fields = append(fields, employee.FieldAPIBase)
  12222. }
  12223. if m.api_key != nil {
  12224. fields = append(fields, employee.FieldAPIKey)
  12225. }
  12226. if m.ai_info != nil {
  12227. fields = append(fields, employee.FieldAiInfo)
  12228. }
  12229. if m.is_vip != nil {
  12230. fields = append(fields, employee.FieldIsVip)
  12231. }
  12232. if m.chat_url != nil {
  12233. fields = append(fields, employee.FieldChatURL)
  12234. }
  12235. return fields
  12236. }
  12237. // Field returns the value of a field with the given name. The second boolean
  12238. // return value indicates that this field was not set, or was not defined in the
  12239. // schema.
  12240. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  12241. switch name {
  12242. case employee.FieldCreatedAt:
  12243. return m.CreatedAt()
  12244. case employee.FieldUpdatedAt:
  12245. return m.UpdatedAt()
  12246. case employee.FieldDeletedAt:
  12247. return m.DeletedAt()
  12248. case employee.FieldTitle:
  12249. return m.Title()
  12250. case employee.FieldAvatar:
  12251. return m.Avatar()
  12252. case employee.FieldTags:
  12253. return m.Tags()
  12254. case employee.FieldHireCount:
  12255. return m.HireCount()
  12256. case employee.FieldServiceCount:
  12257. return m.ServiceCount()
  12258. case employee.FieldAchievementCount:
  12259. return m.AchievementCount()
  12260. case employee.FieldIntro:
  12261. return m.Intro()
  12262. case employee.FieldEstimate:
  12263. return m.Estimate()
  12264. case employee.FieldSkill:
  12265. return m.Skill()
  12266. case employee.FieldAbilityType:
  12267. return m.AbilityType()
  12268. case employee.FieldScene:
  12269. return m.Scene()
  12270. case employee.FieldSwitchIn:
  12271. return m.SwitchIn()
  12272. case employee.FieldVideoURL:
  12273. return m.VideoURL()
  12274. case employee.FieldOrganizationID:
  12275. return m.OrganizationID()
  12276. case employee.FieldCategoryID:
  12277. return m.CategoryID()
  12278. case employee.FieldAPIBase:
  12279. return m.APIBase()
  12280. case employee.FieldAPIKey:
  12281. return m.APIKey()
  12282. case employee.FieldAiInfo:
  12283. return m.AiInfo()
  12284. case employee.FieldIsVip:
  12285. return m.IsVip()
  12286. case employee.FieldChatURL:
  12287. return m.ChatURL()
  12288. }
  12289. return nil, false
  12290. }
  12291. // OldField returns the old value of the field from the database. An error is
  12292. // returned if the mutation operation is not UpdateOne, or the query to the
  12293. // database failed.
  12294. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12295. switch name {
  12296. case employee.FieldCreatedAt:
  12297. return m.OldCreatedAt(ctx)
  12298. case employee.FieldUpdatedAt:
  12299. return m.OldUpdatedAt(ctx)
  12300. case employee.FieldDeletedAt:
  12301. return m.OldDeletedAt(ctx)
  12302. case employee.FieldTitle:
  12303. return m.OldTitle(ctx)
  12304. case employee.FieldAvatar:
  12305. return m.OldAvatar(ctx)
  12306. case employee.FieldTags:
  12307. return m.OldTags(ctx)
  12308. case employee.FieldHireCount:
  12309. return m.OldHireCount(ctx)
  12310. case employee.FieldServiceCount:
  12311. return m.OldServiceCount(ctx)
  12312. case employee.FieldAchievementCount:
  12313. return m.OldAchievementCount(ctx)
  12314. case employee.FieldIntro:
  12315. return m.OldIntro(ctx)
  12316. case employee.FieldEstimate:
  12317. return m.OldEstimate(ctx)
  12318. case employee.FieldSkill:
  12319. return m.OldSkill(ctx)
  12320. case employee.FieldAbilityType:
  12321. return m.OldAbilityType(ctx)
  12322. case employee.FieldScene:
  12323. return m.OldScene(ctx)
  12324. case employee.FieldSwitchIn:
  12325. return m.OldSwitchIn(ctx)
  12326. case employee.FieldVideoURL:
  12327. return m.OldVideoURL(ctx)
  12328. case employee.FieldOrganizationID:
  12329. return m.OldOrganizationID(ctx)
  12330. case employee.FieldCategoryID:
  12331. return m.OldCategoryID(ctx)
  12332. case employee.FieldAPIBase:
  12333. return m.OldAPIBase(ctx)
  12334. case employee.FieldAPIKey:
  12335. return m.OldAPIKey(ctx)
  12336. case employee.FieldAiInfo:
  12337. return m.OldAiInfo(ctx)
  12338. case employee.FieldIsVip:
  12339. return m.OldIsVip(ctx)
  12340. case employee.FieldChatURL:
  12341. return m.OldChatURL(ctx)
  12342. }
  12343. return nil, fmt.Errorf("unknown Employee field %s", name)
  12344. }
  12345. // SetField sets the value of a field with the given name. It returns an error if
  12346. // the field is not defined in the schema, or if the type mismatched the field
  12347. // type.
  12348. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  12349. switch name {
  12350. case employee.FieldCreatedAt:
  12351. v, ok := value.(time.Time)
  12352. if !ok {
  12353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12354. }
  12355. m.SetCreatedAt(v)
  12356. return nil
  12357. case employee.FieldUpdatedAt:
  12358. v, ok := value.(time.Time)
  12359. if !ok {
  12360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12361. }
  12362. m.SetUpdatedAt(v)
  12363. return nil
  12364. case employee.FieldDeletedAt:
  12365. v, ok := value.(time.Time)
  12366. if !ok {
  12367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12368. }
  12369. m.SetDeletedAt(v)
  12370. return nil
  12371. case employee.FieldTitle:
  12372. v, ok := value.(string)
  12373. if !ok {
  12374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12375. }
  12376. m.SetTitle(v)
  12377. return nil
  12378. case employee.FieldAvatar:
  12379. v, ok := value.(string)
  12380. if !ok {
  12381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12382. }
  12383. m.SetAvatar(v)
  12384. return nil
  12385. case employee.FieldTags:
  12386. v, ok := value.(string)
  12387. if !ok {
  12388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12389. }
  12390. m.SetTags(v)
  12391. return nil
  12392. case employee.FieldHireCount:
  12393. v, ok := value.(int)
  12394. if !ok {
  12395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12396. }
  12397. m.SetHireCount(v)
  12398. return nil
  12399. case employee.FieldServiceCount:
  12400. v, ok := value.(int)
  12401. if !ok {
  12402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12403. }
  12404. m.SetServiceCount(v)
  12405. return nil
  12406. case employee.FieldAchievementCount:
  12407. v, ok := value.(int)
  12408. if !ok {
  12409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12410. }
  12411. m.SetAchievementCount(v)
  12412. return nil
  12413. case employee.FieldIntro:
  12414. v, ok := value.(string)
  12415. if !ok {
  12416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12417. }
  12418. m.SetIntro(v)
  12419. return nil
  12420. case employee.FieldEstimate:
  12421. v, ok := value.(string)
  12422. if !ok {
  12423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12424. }
  12425. m.SetEstimate(v)
  12426. return nil
  12427. case employee.FieldSkill:
  12428. v, ok := value.(string)
  12429. if !ok {
  12430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12431. }
  12432. m.SetSkill(v)
  12433. return nil
  12434. case employee.FieldAbilityType:
  12435. v, ok := value.(string)
  12436. if !ok {
  12437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12438. }
  12439. m.SetAbilityType(v)
  12440. return nil
  12441. case employee.FieldScene:
  12442. v, ok := value.(string)
  12443. if !ok {
  12444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12445. }
  12446. m.SetScene(v)
  12447. return nil
  12448. case employee.FieldSwitchIn:
  12449. v, ok := value.(string)
  12450. if !ok {
  12451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12452. }
  12453. m.SetSwitchIn(v)
  12454. return nil
  12455. case employee.FieldVideoURL:
  12456. v, ok := value.(string)
  12457. if !ok {
  12458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12459. }
  12460. m.SetVideoURL(v)
  12461. return nil
  12462. case employee.FieldOrganizationID:
  12463. v, ok := value.(uint64)
  12464. if !ok {
  12465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12466. }
  12467. m.SetOrganizationID(v)
  12468. return nil
  12469. case employee.FieldCategoryID:
  12470. v, ok := value.(uint64)
  12471. if !ok {
  12472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12473. }
  12474. m.SetCategoryID(v)
  12475. return nil
  12476. case employee.FieldAPIBase:
  12477. v, ok := value.(string)
  12478. if !ok {
  12479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12480. }
  12481. m.SetAPIBase(v)
  12482. return nil
  12483. case employee.FieldAPIKey:
  12484. v, ok := value.(string)
  12485. if !ok {
  12486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12487. }
  12488. m.SetAPIKey(v)
  12489. return nil
  12490. case employee.FieldAiInfo:
  12491. v, ok := value.(string)
  12492. if !ok {
  12493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12494. }
  12495. m.SetAiInfo(v)
  12496. return nil
  12497. case employee.FieldIsVip:
  12498. v, ok := value.(int)
  12499. if !ok {
  12500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12501. }
  12502. m.SetIsVip(v)
  12503. return nil
  12504. case employee.FieldChatURL:
  12505. v, ok := value.(string)
  12506. if !ok {
  12507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12508. }
  12509. m.SetChatURL(v)
  12510. return nil
  12511. }
  12512. return fmt.Errorf("unknown Employee field %s", name)
  12513. }
  12514. // AddedFields returns all numeric fields that were incremented/decremented during
  12515. // this mutation.
  12516. func (m *EmployeeMutation) AddedFields() []string {
  12517. var fields []string
  12518. if m.addhire_count != nil {
  12519. fields = append(fields, employee.FieldHireCount)
  12520. }
  12521. if m.addservice_count != nil {
  12522. fields = append(fields, employee.FieldServiceCount)
  12523. }
  12524. if m.addachievement_count != nil {
  12525. fields = append(fields, employee.FieldAchievementCount)
  12526. }
  12527. if m.addorganization_id != nil {
  12528. fields = append(fields, employee.FieldOrganizationID)
  12529. }
  12530. if m.addcategory_id != nil {
  12531. fields = append(fields, employee.FieldCategoryID)
  12532. }
  12533. if m.addis_vip != nil {
  12534. fields = append(fields, employee.FieldIsVip)
  12535. }
  12536. return fields
  12537. }
  12538. // AddedField returns the numeric value that was incremented/decremented on a field
  12539. // with the given name. The second boolean return value indicates that this field
  12540. // was not set, or was not defined in the schema.
  12541. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  12542. switch name {
  12543. case employee.FieldHireCount:
  12544. return m.AddedHireCount()
  12545. case employee.FieldServiceCount:
  12546. return m.AddedServiceCount()
  12547. case employee.FieldAchievementCount:
  12548. return m.AddedAchievementCount()
  12549. case employee.FieldOrganizationID:
  12550. return m.AddedOrganizationID()
  12551. case employee.FieldCategoryID:
  12552. return m.AddedCategoryID()
  12553. case employee.FieldIsVip:
  12554. return m.AddedIsVip()
  12555. }
  12556. return nil, false
  12557. }
  12558. // AddField adds the value to the field with the given name. It returns an error if
  12559. // the field is not defined in the schema, or if the type mismatched the field
  12560. // type.
  12561. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  12562. switch name {
  12563. case employee.FieldHireCount:
  12564. v, ok := value.(int)
  12565. if !ok {
  12566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12567. }
  12568. m.AddHireCount(v)
  12569. return nil
  12570. case employee.FieldServiceCount:
  12571. v, ok := value.(int)
  12572. if !ok {
  12573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12574. }
  12575. m.AddServiceCount(v)
  12576. return nil
  12577. case employee.FieldAchievementCount:
  12578. v, ok := value.(int)
  12579. if !ok {
  12580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12581. }
  12582. m.AddAchievementCount(v)
  12583. return nil
  12584. case employee.FieldOrganizationID:
  12585. v, ok := value.(int64)
  12586. if !ok {
  12587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12588. }
  12589. m.AddOrganizationID(v)
  12590. return nil
  12591. case employee.FieldCategoryID:
  12592. v, ok := value.(int64)
  12593. if !ok {
  12594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12595. }
  12596. m.AddCategoryID(v)
  12597. return nil
  12598. case employee.FieldIsVip:
  12599. v, ok := value.(int)
  12600. if !ok {
  12601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12602. }
  12603. m.AddIsVip(v)
  12604. return nil
  12605. }
  12606. return fmt.Errorf("unknown Employee numeric field %s", name)
  12607. }
  12608. // ClearedFields returns all nullable fields that were cleared during this
  12609. // mutation.
  12610. func (m *EmployeeMutation) ClearedFields() []string {
  12611. var fields []string
  12612. if m.FieldCleared(employee.FieldDeletedAt) {
  12613. fields = append(fields, employee.FieldDeletedAt)
  12614. }
  12615. if m.FieldCleared(employee.FieldAiInfo) {
  12616. fields = append(fields, employee.FieldAiInfo)
  12617. }
  12618. return fields
  12619. }
  12620. // FieldCleared returns a boolean indicating if a field with the given name was
  12621. // cleared in this mutation.
  12622. func (m *EmployeeMutation) FieldCleared(name string) bool {
  12623. _, ok := m.clearedFields[name]
  12624. return ok
  12625. }
  12626. // ClearField clears the value of the field with the given name. It returns an
  12627. // error if the field is not defined in the schema.
  12628. func (m *EmployeeMutation) ClearField(name string) error {
  12629. switch name {
  12630. case employee.FieldDeletedAt:
  12631. m.ClearDeletedAt()
  12632. return nil
  12633. case employee.FieldAiInfo:
  12634. m.ClearAiInfo()
  12635. return nil
  12636. }
  12637. return fmt.Errorf("unknown Employee nullable field %s", name)
  12638. }
  12639. // ResetField resets all changes in the mutation for the field with the given name.
  12640. // It returns an error if the field is not defined in the schema.
  12641. func (m *EmployeeMutation) ResetField(name string) error {
  12642. switch name {
  12643. case employee.FieldCreatedAt:
  12644. m.ResetCreatedAt()
  12645. return nil
  12646. case employee.FieldUpdatedAt:
  12647. m.ResetUpdatedAt()
  12648. return nil
  12649. case employee.FieldDeletedAt:
  12650. m.ResetDeletedAt()
  12651. return nil
  12652. case employee.FieldTitle:
  12653. m.ResetTitle()
  12654. return nil
  12655. case employee.FieldAvatar:
  12656. m.ResetAvatar()
  12657. return nil
  12658. case employee.FieldTags:
  12659. m.ResetTags()
  12660. return nil
  12661. case employee.FieldHireCount:
  12662. m.ResetHireCount()
  12663. return nil
  12664. case employee.FieldServiceCount:
  12665. m.ResetServiceCount()
  12666. return nil
  12667. case employee.FieldAchievementCount:
  12668. m.ResetAchievementCount()
  12669. return nil
  12670. case employee.FieldIntro:
  12671. m.ResetIntro()
  12672. return nil
  12673. case employee.FieldEstimate:
  12674. m.ResetEstimate()
  12675. return nil
  12676. case employee.FieldSkill:
  12677. m.ResetSkill()
  12678. return nil
  12679. case employee.FieldAbilityType:
  12680. m.ResetAbilityType()
  12681. return nil
  12682. case employee.FieldScene:
  12683. m.ResetScene()
  12684. return nil
  12685. case employee.FieldSwitchIn:
  12686. m.ResetSwitchIn()
  12687. return nil
  12688. case employee.FieldVideoURL:
  12689. m.ResetVideoURL()
  12690. return nil
  12691. case employee.FieldOrganizationID:
  12692. m.ResetOrganizationID()
  12693. return nil
  12694. case employee.FieldCategoryID:
  12695. m.ResetCategoryID()
  12696. return nil
  12697. case employee.FieldAPIBase:
  12698. m.ResetAPIBase()
  12699. return nil
  12700. case employee.FieldAPIKey:
  12701. m.ResetAPIKey()
  12702. return nil
  12703. case employee.FieldAiInfo:
  12704. m.ResetAiInfo()
  12705. return nil
  12706. case employee.FieldIsVip:
  12707. m.ResetIsVip()
  12708. return nil
  12709. case employee.FieldChatURL:
  12710. m.ResetChatURL()
  12711. return nil
  12712. }
  12713. return fmt.Errorf("unknown Employee field %s", name)
  12714. }
  12715. // AddedEdges returns all edge names that were set/added in this mutation.
  12716. func (m *EmployeeMutation) AddedEdges() []string {
  12717. edges := make([]string, 0, 2)
  12718. if m.em_work_experiences != nil {
  12719. edges = append(edges, employee.EdgeEmWorkExperiences)
  12720. }
  12721. if m.em_tutorial != nil {
  12722. edges = append(edges, employee.EdgeEmTutorial)
  12723. }
  12724. return edges
  12725. }
  12726. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12727. // name in this mutation.
  12728. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  12729. switch name {
  12730. case employee.EdgeEmWorkExperiences:
  12731. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  12732. for id := range m.em_work_experiences {
  12733. ids = append(ids, id)
  12734. }
  12735. return ids
  12736. case employee.EdgeEmTutorial:
  12737. ids := make([]ent.Value, 0, len(m.em_tutorial))
  12738. for id := range m.em_tutorial {
  12739. ids = append(ids, id)
  12740. }
  12741. return ids
  12742. }
  12743. return nil
  12744. }
  12745. // RemovedEdges returns all edge names that were removed in this mutation.
  12746. func (m *EmployeeMutation) RemovedEdges() []string {
  12747. edges := make([]string, 0, 2)
  12748. if m.removedem_work_experiences != nil {
  12749. edges = append(edges, employee.EdgeEmWorkExperiences)
  12750. }
  12751. if m.removedem_tutorial != nil {
  12752. edges = append(edges, employee.EdgeEmTutorial)
  12753. }
  12754. return edges
  12755. }
  12756. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12757. // the given name in this mutation.
  12758. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  12759. switch name {
  12760. case employee.EdgeEmWorkExperiences:
  12761. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  12762. for id := range m.removedem_work_experiences {
  12763. ids = append(ids, id)
  12764. }
  12765. return ids
  12766. case employee.EdgeEmTutorial:
  12767. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  12768. for id := range m.removedem_tutorial {
  12769. ids = append(ids, id)
  12770. }
  12771. return ids
  12772. }
  12773. return nil
  12774. }
  12775. // ClearedEdges returns all edge names that were cleared in this mutation.
  12776. func (m *EmployeeMutation) ClearedEdges() []string {
  12777. edges := make([]string, 0, 2)
  12778. if m.clearedem_work_experiences {
  12779. edges = append(edges, employee.EdgeEmWorkExperiences)
  12780. }
  12781. if m.clearedem_tutorial {
  12782. edges = append(edges, employee.EdgeEmTutorial)
  12783. }
  12784. return edges
  12785. }
  12786. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12787. // was cleared in this mutation.
  12788. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  12789. switch name {
  12790. case employee.EdgeEmWorkExperiences:
  12791. return m.clearedem_work_experiences
  12792. case employee.EdgeEmTutorial:
  12793. return m.clearedem_tutorial
  12794. }
  12795. return false
  12796. }
  12797. // ClearEdge clears the value of the edge with the given name. It returns an error
  12798. // if that edge is not defined in the schema.
  12799. func (m *EmployeeMutation) ClearEdge(name string) error {
  12800. switch name {
  12801. }
  12802. return fmt.Errorf("unknown Employee unique edge %s", name)
  12803. }
  12804. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12805. // It returns an error if the edge is not defined in the schema.
  12806. func (m *EmployeeMutation) ResetEdge(name string) error {
  12807. switch name {
  12808. case employee.EdgeEmWorkExperiences:
  12809. m.ResetEmWorkExperiences()
  12810. return nil
  12811. case employee.EdgeEmTutorial:
  12812. m.ResetEmTutorial()
  12813. return nil
  12814. }
  12815. return fmt.Errorf("unknown Employee edge %s", name)
  12816. }
  12817. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  12818. type EmployeeConfigMutation struct {
  12819. config
  12820. op Op
  12821. typ string
  12822. id *uint64
  12823. created_at *time.Time
  12824. updated_at *time.Time
  12825. deleted_at *time.Time
  12826. stype *string
  12827. title *string
  12828. photo *string
  12829. organization_id *uint64
  12830. addorganization_id *int64
  12831. clearedFields map[string]struct{}
  12832. done bool
  12833. oldValue func(context.Context) (*EmployeeConfig, error)
  12834. predicates []predicate.EmployeeConfig
  12835. }
  12836. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  12837. // employeeconfigOption allows management of the mutation configuration using functional options.
  12838. type employeeconfigOption func(*EmployeeConfigMutation)
  12839. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  12840. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  12841. m := &EmployeeConfigMutation{
  12842. config: c,
  12843. op: op,
  12844. typ: TypeEmployeeConfig,
  12845. clearedFields: make(map[string]struct{}),
  12846. }
  12847. for _, opt := range opts {
  12848. opt(m)
  12849. }
  12850. return m
  12851. }
  12852. // withEmployeeConfigID sets the ID field of the mutation.
  12853. func withEmployeeConfigID(id uint64) employeeconfigOption {
  12854. return func(m *EmployeeConfigMutation) {
  12855. var (
  12856. err error
  12857. once sync.Once
  12858. value *EmployeeConfig
  12859. )
  12860. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  12861. once.Do(func() {
  12862. if m.done {
  12863. err = errors.New("querying old values post mutation is not allowed")
  12864. } else {
  12865. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  12866. }
  12867. })
  12868. return value, err
  12869. }
  12870. m.id = &id
  12871. }
  12872. }
  12873. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  12874. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  12875. return func(m *EmployeeConfigMutation) {
  12876. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  12877. return node, nil
  12878. }
  12879. m.id = &node.ID
  12880. }
  12881. }
  12882. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12883. // executed in a transaction (ent.Tx), a transactional client is returned.
  12884. func (m EmployeeConfigMutation) Client() *Client {
  12885. client := &Client{config: m.config}
  12886. client.init()
  12887. return client
  12888. }
  12889. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12890. // it returns an error otherwise.
  12891. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  12892. if _, ok := m.driver.(*txDriver); !ok {
  12893. return nil, errors.New("ent: mutation is not running in a transaction")
  12894. }
  12895. tx := &Tx{config: m.config}
  12896. tx.init()
  12897. return tx, nil
  12898. }
  12899. // SetID sets the value of the id field. Note that this
  12900. // operation is only accepted on creation of EmployeeConfig entities.
  12901. func (m *EmployeeConfigMutation) SetID(id uint64) {
  12902. m.id = &id
  12903. }
  12904. // ID returns the ID value in the mutation. Note that the ID is only available
  12905. // if it was provided to the builder or after it was returned from the database.
  12906. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  12907. if m.id == nil {
  12908. return
  12909. }
  12910. return *m.id, true
  12911. }
  12912. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12913. // That means, if the mutation is applied within a transaction with an isolation level such
  12914. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12915. // or updated by the mutation.
  12916. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  12917. switch {
  12918. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12919. id, exists := m.ID()
  12920. if exists {
  12921. return []uint64{id}, nil
  12922. }
  12923. fallthrough
  12924. case m.op.Is(OpUpdate | OpDelete):
  12925. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  12926. default:
  12927. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12928. }
  12929. }
  12930. // SetCreatedAt sets the "created_at" field.
  12931. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  12932. m.created_at = &t
  12933. }
  12934. // CreatedAt returns the value of the "created_at" field in the mutation.
  12935. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  12936. v := m.created_at
  12937. if v == nil {
  12938. return
  12939. }
  12940. return *v, true
  12941. }
  12942. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  12943. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  12944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12945. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12946. if !m.op.Is(OpUpdateOne) {
  12947. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12948. }
  12949. if m.id == nil || m.oldValue == nil {
  12950. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12951. }
  12952. oldValue, err := m.oldValue(ctx)
  12953. if err != nil {
  12954. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12955. }
  12956. return oldValue.CreatedAt, nil
  12957. }
  12958. // ResetCreatedAt resets all changes to the "created_at" field.
  12959. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  12960. m.created_at = nil
  12961. }
  12962. // SetUpdatedAt sets the "updated_at" field.
  12963. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  12964. m.updated_at = &t
  12965. }
  12966. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12967. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  12968. v := m.updated_at
  12969. if v == nil {
  12970. return
  12971. }
  12972. return *v, true
  12973. }
  12974. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  12975. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  12976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12977. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12978. if !m.op.Is(OpUpdateOne) {
  12979. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12980. }
  12981. if m.id == nil || m.oldValue == nil {
  12982. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12983. }
  12984. oldValue, err := m.oldValue(ctx)
  12985. if err != nil {
  12986. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12987. }
  12988. return oldValue.UpdatedAt, nil
  12989. }
  12990. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12991. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  12992. m.updated_at = nil
  12993. }
  12994. // SetDeletedAt sets the "deleted_at" field.
  12995. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  12996. m.deleted_at = &t
  12997. }
  12998. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12999. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  13000. v := m.deleted_at
  13001. if v == nil {
  13002. return
  13003. }
  13004. return *v, true
  13005. }
  13006. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  13007. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13009. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13010. if !m.op.Is(OpUpdateOne) {
  13011. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13012. }
  13013. if m.id == nil || m.oldValue == nil {
  13014. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13015. }
  13016. oldValue, err := m.oldValue(ctx)
  13017. if err != nil {
  13018. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13019. }
  13020. return oldValue.DeletedAt, nil
  13021. }
  13022. // ClearDeletedAt clears the value of the "deleted_at" field.
  13023. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  13024. m.deleted_at = nil
  13025. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  13026. }
  13027. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13028. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  13029. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  13030. return ok
  13031. }
  13032. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13033. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  13034. m.deleted_at = nil
  13035. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  13036. }
  13037. // SetStype sets the "stype" field.
  13038. func (m *EmployeeConfigMutation) SetStype(s string) {
  13039. m.stype = &s
  13040. }
  13041. // Stype returns the value of the "stype" field in the mutation.
  13042. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  13043. v := m.stype
  13044. if v == nil {
  13045. return
  13046. }
  13047. return *v, true
  13048. }
  13049. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  13050. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13052. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  13053. if !m.op.Is(OpUpdateOne) {
  13054. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  13055. }
  13056. if m.id == nil || m.oldValue == nil {
  13057. return v, errors.New("OldStype requires an ID field in the mutation")
  13058. }
  13059. oldValue, err := m.oldValue(ctx)
  13060. if err != nil {
  13061. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  13062. }
  13063. return oldValue.Stype, nil
  13064. }
  13065. // ResetStype resets all changes to the "stype" field.
  13066. func (m *EmployeeConfigMutation) ResetStype() {
  13067. m.stype = nil
  13068. }
  13069. // SetTitle sets the "title" field.
  13070. func (m *EmployeeConfigMutation) SetTitle(s string) {
  13071. m.title = &s
  13072. }
  13073. // Title returns the value of the "title" field in the mutation.
  13074. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  13075. v := m.title
  13076. if v == nil {
  13077. return
  13078. }
  13079. return *v, true
  13080. }
  13081. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  13082. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13084. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  13085. if !m.op.Is(OpUpdateOne) {
  13086. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  13087. }
  13088. if m.id == nil || m.oldValue == nil {
  13089. return v, errors.New("OldTitle requires an ID field in the mutation")
  13090. }
  13091. oldValue, err := m.oldValue(ctx)
  13092. if err != nil {
  13093. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  13094. }
  13095. return oldValue.Title, nil
  13096. }
  13097. // ResetTitle resets all changes to the "title" field.
  13098. func (m *EmployeeConfigMutation) ResetTitle() {
  13099. m.title = nil
  13100. }
  13101. // SetPhoto sets the "photo" field.
  13102. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  13103. m.photo = &s
  13104. }
  13105. // Photo returns the value of the "photo" field in the mutation.
  13106. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  13107. v := m.photo
  13108. if v == nil {
  13109. return
  13110. }
  13111. return *v, true
  13112. }
  13113. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  13114. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13116. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  13117. if !m.op.Is(OpUpdateOne) {
  13118. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  13119. }
  13120. if m.id == nil || m.oldValue == nil {
  13121. return v, errors.New("OldPhoto requires an ID field in the mutation")
  13122. }
  13123. oldValue, err := m.oldValue(ctx)
  13124. if err != nil {
  13125. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  13126. }
  13127. return oldValue.Photo, nil
  13128. }
  13129. // ResetPhoto resets all changes to the "photo" field.
  13130. func (m *EmployeeConfigMutation) ResetPhoto() {
  13131. m.photo = nil
  13132. }
  13133. // SetOrganizationID sets the "organization_id" field.
  13134. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  13135. m.organization_id = &u
  13136. m.addorganization_id = nil
  13137. }
  13138. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13139. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  13140. v := m.organization_id
  13141. if v == nil {
  13142. return
  13143. }
  13144. return *v, true
  13145. }
  13146. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  13147. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13149. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13150. if !m.op.Is(OpUpdateOne) {
  13151. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13152. }
  13153. if m.id == nil || m.oldValue == nil {
  13154. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13155. }
  13156. oldValue, err := m.oldValue(ctx)
  13157. if err != nil {
  13158. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13159. }
  13160. return oldValue.OrganizationID, nil
  13161. }
  13162. // AddOrganizationID adds u to the "organization_id" field.
  13163. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  13164. if m.addorganization_id != nil {
  13165. *m.addorganization_id += u
  13166. } else {
  13167. m.addorganization_id = &u
  13168. }
  13169. }
  13170. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13171. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  13172. v := m.addorganization_id
  13173. if v == nil {
  13174. return
  13175. }
  13176. return *v, true
  13177. }
  13178. // ClearOrganizationID clears the value of the "organization_id" field.
  13179. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  13180. m.organization_id = nil
  13181. m.addorganization_id = nil
  13182. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  13183. }
  13184. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13185. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  13186. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  13187. return ok
  13188. }
  13189. // ResetOrganizationID resets all changes to the "organization_id" field.
  13190. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  13191. m.organization_id = nil
  13192. m.addorganization_id = nil
  13193. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  13194. }
  13195. // Where appends a list predicates to the EmployeeConfigMutation builder.
  13196. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  13197. m.predicates = append(m.predicates, ps...)
  13198. }
  13199. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  13200. // users can use type-assertion to append predicates that do not depend on any generated package.
  13201. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  13202. p := make([]predicate.EmployeeConfig, len(ps))
  13203. for i := range ps {
  13204. p[i] = ps[i]
  13205. }
  13206. m.Where(p...)
  13207. }
  13208. // Op returns the operation name.
  13209. func (m *EmployeeConfigMutation) Op() Op {
  13210. return m.op
  13211. }
  13212. // SetOp allows setting the mutation operation.
  13213. func (m *EmployeeConfigMutation) SetOp(op Op) {
  13214. m.op = op
  13215. }
  13216. // Type returns the node type of this mutation (EmployeeConfig).
  13217. func (m *EmployeeConfigMutation) Type() string {
  13218. return m.typ
  13219. }
  13220. // Fields returns all fields that were changed during this mutation. Note that in
  13221. // order to get all numeric fields that were incremented/decremented, call
  13222. // AddedFields().
  13223. func (m *EmployeeConfigMutation) Fields() []string {
  13224. fields := make([]string, 0, 7)
  13225. if m.created_at != nil {
  13226. fields = append(fields, employeeconfig.FieldCreatedAt)
  13227. }
  13228. if m.updated_at != nil {
  13229. fields = append(fields, employeeconfig.FieldUpdatedAt)
  13230. }
  13231. if m.deleted_at != nil {
  13232. fields = append(fields, employeeconfig.FieldDeletedAt)
  13233. }
  13234. if m.stype != nil {
  13235. fields = append(fields, employeeconfig.FieldStype)
  13236. }
  13237. if m.title != nil {
  13238. fields = append(fields, employeeconfig.FieldTitle)
  13239. }
  13240. if m.photo != nil {
  13241. fields = append(fields, employeeconfig.FieldPhoto)
  13242. }
  13243. if m.organization_id != nil {
  13244. fields = append(fields, employeeconfig.FieldOrganizationID)
  13245. }
  13246. return fields
  13247. }
  13248. // Field returns the value of a field with the given name. The second boolean
  13249. // return value indicates that this field was not set, or was not defined in the
  13250. // schema.
  13251. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  13252. switch name {
  13253. case employeeconfig.FieldCreatedAt:
  13254. return m.CreatedAt()
  13255. case employeeconfig.FieldUpdatedAt:
  13256. return m.UpdatedAt()
  13257. case employeeconfig.FieldDeletedAt:
  13258. return m.DeletedAt()
  13259. case employeeconfig.FieldStype:
  13260. return m.Stype()
  13261. case employeeconfig.FieldTitle:
  13262. return m.Title()
  13263. case employeeconfig.FieldPhoto:
  13264. return m.Photo()
  13265. case employeeconfig.FieldOrganizationID:
  13266. return m.OrganizationID()
  13267. }
  13268. return nil, false
  13269. }
  13270. // OldField returns the old value of the field from the database. An error is
  13271. // returned if the mutation operation is not UpdateOne, or the query to the
  13272. // database failed.
  13273. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13274. switch name {
  13275. case employeeconfig.FieldCreatedAt:
  13276. return m.OldCreatedAt(ctx)
  13277. case employeeconfig.FieldUpdatedAt:
  13278. return m.OldUpdatedAt(ctx)
  13279. case employeeconfig.FieldDeletedAt:
  13280. return m.OldDeletedAt(ctx)
  13281. case employeeconfig.FieldStype:
  13282. return m.OldStype(ctx)
  13283. case employeeconfig.FieldTitle:
  13284. return m.OldTitle(ctx)
  13285. case employeeconfig.FieldPhoto:
  13286. return m.OldPhoto(ctx)
  13287. case employeeconfig.FieldOrganizationID:
  13288. return m.OldOrganizationID(ctx)
  13289. }
  13290. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  13291. }
  13292. // SetField sets the value of a field with the given name. It returns an error if
  13293. // the field is not defined in the schema, or if the type mismatched the field
  13294. // type.
  13295. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  13296. switch name {
  13297. case employeeconfig.FieldCreatedAt:
  13298. v, ok := value.(time.Time)
  13299. if !ok {
  13300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13301. }
  13302. m.SetCreatedAt(v)
  13303. return nil
  13304. case employeeconfig.FieldUpdatedAt:
  13305. v, ok := value.(time.Time)
  13306. if !ok {
  13307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13308. }
  13309. m.SetUpdatedAt(v)
  13310. return nil
  13311. case employeeconfig.FieldDeletedAt:
  13312. v, ok := value.(time.Time)
  13313. if !ok {
  13314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13315. }
  13316. m.SetDeletedAt(v)
  13317. return nil
  13318. case employeeconfig.FieldStype:
  13319. v, ok := value.(string)
  13320. if !ok {
  13321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13322. }
  13323. m.SetStype(v)
  13324. return nil
  13325. case employeeconfig.FieldTitle:
  13326. v, ok := value.(string)
  13327. if !ok {
  13328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13329. }
  13330. m.SetTitle(v)
  13331. return nil
  13332. case employeeconfig.FieldPhoto:
  13333. v, ok := value.(string)
  13334. if !ok {
  13335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13336. }
  13337. m.SetPhoto(v)
  13338. return nil
  13339. case employeeconfig.FieldOrganizationID:
  13340. v, ok := value.(uint64)
  13341. if !ok {
  13342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13343. }
  13344. m.SetOrganizationID(v)
  13345. return nil
  13346. }
  13347. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  13348. }
  13349. // AddedFields returns all numeric fields that were incremented/decremented during
  13350. // this mutation.
  13351. func (m *EmployeeConfigMutation) AddedFields() []string {
  13352. var fields []string
  13353. if m.addorganization_id != nil {
  13354. fields = append(fields, employeeconfig.FieldOrganizationID)
  13355. }
  13356. return fields
  13357. }
  13358. // AddedField returns the numeric value that was incremented/decremented on a field
  13359. // with the given name. The second boolean return value indicates that this field
  13360. // was not set, or was not defined in the schema.
  13361. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  13362. switch name {
  13363. case employeeconfig.FieldOrganizationID:
  13364. return m.AddedOrganizationID()
  13365. }
  13366. return nil, false
  13367. }
  13368. // AddField adds the value to the field with the given name. It returns an error if
  13369. // the field is not defined in the schema, or if the type mismatched the field
  13370. // type.
  13371. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  13372. switch name {
  13373. case employeeconfig.FieldOrganizationID:
  13374. v, ok := value.(int64)
  13375. if !ok {
  13376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13377. }
  13378. m.AddOrganizationID(v)
  13379. return nil
  13380. }
  13381. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  13382. }
  13383. // ClearedFields returns all nullable fields that were cleared during this
  13384. // mutation.
  13385. func (m *EmployeeConfigMutation) ClearedFields() []string {
  13386. var fields []string
  13387. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  13388. fields = append(fields, employeeconfig.FieldDeletedAt)
  13389. }
  13390. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  13391. fields = append(fields, employeeconfig.FieldOrganizationID)
  13392. }
  13393. return fields
  13394. }
  13395. // FieldCleared returns a boolean indicating if a field with the given name was
  13396. // cleared in this mutation.
  13397. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  13398. _, ok := m.clearedFields[name]
  13399. return ok
  13400. }
  13401. // ClearField clears the value of the field with the given name. It returns an
  13402. // error if the field is not defined in the schema.
  13403. func (m *EmployeeConfigMutation) ClearField(name string) error {
  13404. switch name {
  13405. case employeeconfig.FieldDeletedAt:
  13406. m.ClearDeletedAt()
  13407. return nil
  13408. case employeeconfig.FieldOrganizationID:
  13409. m.ClearOrganizationID()
  13410. return nil
  13411. }
  13412. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  13413. }
  13414. // ResetField resets all changes in the mutation for the field with the given name.
  13415. // It returns an error if the field is not defined in the schema.
  13416. func (m *EmployeeConfigMutation) ResetField(name string) error {
  13417. switch name {
  13418. case employeeconfig.FieldCreatedAt:
  13419. m.ResetCreatedAt()
  13420. return nil
  13421. case employeeconfig.FieldUpdatedAt:
  13422. m.ResetUpdatedAt()
  13423. return nil
  13424. case employeeconfig.FieldDeletedAt:
  13425. m.ResetDeletedAt()
  13426. return nil
  13427. case employeeconfig.FieldStype:
  13428. m.ResetStype()
  13429. return nil
  13430. case employeeconfig.FieldTitle:
  13431. m.ResetTitle()
  13432. return nil
  13433. case employeeconfig.FieldPhoto:
  13434. m.ResetPhoto()
  13435. return nil
  13436. case employeeconfig.FieldOrganizationID:
  13437. m.ResetOrganizationID()
  13438. return nil
  13439. }
  13440. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  13441. }
  13442. // AddedEdges returns all edge names that were set/added in this mutation.
  13443. func (m *EmployeeConfigMutation) AddedEdges() []string {
  13444. edges := make([]string, 0, 0)
  13445. return edges
  13446. }
  13447. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13448. // name in this mutation.
  13449. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  13450. return nil
  13451. }
  13452. // RemovedEdges returns all edge names that were removed in this mutation.
  13453. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  13454. edges := make([]string, 0, 0)
  13455. return edges
  13456. }
  13457. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13458. // the given name in this mutation.
  13459. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  13460. return nil
  13461. }
  13462. // ClearedEdges returns all edge names that were cleared in this mutation.
  13463. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  13464. edges := make([]string, 0, 0)
  13465. return edges
  13466. }
  13467. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13468. // was cleared in this mutation.
  13469. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  13470. return false
  13471. }
  13472. // ClearEdge clears the value of the edge with the given name. It returns an error
  13473. // if that edge is not defined in the schema.
  13474. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  13475. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  13476. }
  13477. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13478. // It returns an error if the edge is not defined in the schema.
  13479. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  13480. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  13481. }
  13482. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  13483. type LabelMutation struct {
  13484. config
  13485. op Op
  13486. typ string
  13487. id *uint64
  13488. created_at *time.Time
  13489. updated_at *time.Time
  13490. status *uint8
  13491. addstatus *int8
  13492. _type *int
  13493. add_type *int
  13494. name *string
  13495. from *int
  13496. addfrom *int
  13497. mode *int
  13498. addmode *int
  13499. conditions *string
  13500. organization_id *uint64
  13501. addorganization_id *int64
  13502. clearedFields map[string]struct{}
  13503. label_relationships map[uint64]struct{}
  13504. removedlabel_relationships map[uint64]struct{}
  13505. clearedlabel_relationships bool
  13506. done bool
  13507. oldValue func(context.Context) (*Label, error)
  13508. predicates []predicate.Label
  13509. }
  13510. var _ ent.Mutation = (*LabelMutation)(nil)
  13511. // labelOption allows management of the mutation configuration using functional options.
  13512. type labelOption func(*LabelMutation)
  13513. // newLabelMutation creates new mutation for the Label entity.
  13514. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  13515. m := &LabelMutation{
  13516. config: c,
  13517. op: op,
  13518. typ: TypeLabel,
  13519. clearedFields: make(map[string]struct{}),
  13520. }
  13521. for _, opt := range opts {
  13522. opt(m)
  13523. }
  13524. return m
  13525. }
  13526. // withLabelID sets the ID field of the mutation.
  13527. func withLabelID(id uint64) labelOption {
  13528. return func(m *LabelMutation) {
  13529. var (
  13530. err error
  13531. once sync.Once
  13532. value *Label
  13533. )
  13534. m.oldValue = func(ctx context.Context) (*Label, error) {
  13535. once.Do(func() {
  13536. if m.done {
  13537. err = errors.New("querying old values post mutation is not allowed")
  13538. } else {
  13539. value, err = m.Client().Label.Get(ctx, id)
  13540. }
  13541. })
  13542. return value, err
  13543. }
  13544. m.id = &id
  13545. }
  13546. }
  13547. // withLabel sets the old Label of the mutation.
  13548. func withLabel(node *Label) labelOption {
  13549. return func(m *LabelMutation) {
  13550. m.oldValue = func(context.Context) (*Label, error) {
  13551. return node, nil
  13552. }
  13553. m.id = &node.ID
  13554. }
  13555. }
  13556. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13557. // executed in a transaction (ent.Tx), a transactional client is returned.
  13558. func (m LabelMutation) Client() *Client {
  13559. client := &Client{config: m.config}
  13560. client.init()
  13561. return client
  13562. }
  13563. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13564. // it returns an error otherwise.
  13565. func (m LabelMutation) Tx() (*Tx, error) {
  13566. if _, ok := m.driver.(*txDriver); !ok {
  13567. return nil, errors.New("ent: mutation is not running in a transaction")
  13568. }
  13569. tx := &Tx{config: m.config}
  13570. tx.init()
  13571. return tx, nil
  13572. }
  13573. // SetID sets the value of the id field. Note that this
  13574. // operation is only accepted on creation of Label entities.
  13575. func (m *LabelMutation) SetID(id uint64) {
  13576. m.id = &id
  13577. }
  13578. // ID returns the ID value in the mutation. Note that the ID is only available
  13579. // if it was provided to the builder or after it was returned from the database.
  13580. func (m *LabelMutation) ID() (id uint64, exists bool) {
  13581. if m.id == nil {
  13582. return
  13583. }
  13584. return *m.id, true
  13585. }
  13586. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13587. // That means, if the mutation is applied within a transaction with an isolation level such
  13588. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13589. // or updated by the mutation.
  13590. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  13591. switch {
  13592. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13593. id, exists := m.ID()
  13594. if exists {
  13595. return []uint64{id}, nil
  13596. }
  13597. fallthrough
  13598. case m.op.Is(OpUpdate | OpDelete):
  13599. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  13600. default:
  13601. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13602. }
  13603. }
  13604. // SetCreatedAt sets the "created_at" field.
  13605. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  13606. m.created_at = &t
  13607. }
  13608. // CreatedAt returns the value of the "created_at" field in the mutation.
  13609. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  13610. v := m.created_at
  13611. if v == nil {
  13612. return
  13613. }
  13614. return *v, true
  13615. }
  13616. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  13617. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13619. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13620. if !m.op.Is(OpUpdateOne) {
  13621. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13622. }
  13623. if m.id == nil || m.oldValue == nil {
  13624. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13625. }
  13626. oldValue, err := m.oldValue(ctx)
  13627. if err != nil {
  13628. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13629. }
  13630. return oldValue.CreatedAt, nil
  13631. }
  13632. // ResetCreatedAt resets all changes to the "created_at" field.
  13633. func (m *LabelMutation) ResetCreatedAt() {
  13634. m.created_at = nil
  13635. }
  13636. // SetUpdatedAt sets the "updated_at" field.
  13637. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  13638. m.updated_at = &t
  13639. }
  13640. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13641. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  13642. v := m.updated_at
  13643. if v == nil {
  13644. return
  13645. }
  13646. return *v, true
  13647. }
  13648. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  13649. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13651. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13652. if !m.op.Is(OpUpdateOne) {
  13653. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13654. }
  13655. if m.id == nil || m.oldValue == nil {
  13656. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13657. }
  13658. oldValue, err := m.oldValue(ctx)
  13659. if err != nil {
  13660. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13661. }
  13662. return oldValue.UpdatedAt, nil
  13663. }
  13664. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13665. func (m *LabelMutation) ResetUpdatedAt() {
  13666. m.updated_at = nil
  13667. }
  13668. // SetStatus sets the "status" field.
  13669. func (m *LabelMutation) SetStatus(u uint8) {
  13670. m.status = &u
  13671. m.addstatus = nil
  13672. }
  13673. // Status returns the value of the "status" field in the mutation.
  13674. func (m *LabelMutation) Status() (r uint8, exists bool) {
  13675. v := m.status
  13676. if v == nil {
  13677. return
  13678. }
  13679. return *v, true
  13680. }
  13681. // OldStatus returns the old "status" field's value of the Label entity.
  13682. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13684. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13685. if !m.op.Is(OpUpdateOne) {
  13686. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13687. }
  13688. if m.id == nil || m.oldValue == nil {
  13689. return v, errors.New("OldStatus requires an ID field in the mutation")
  13690. }
  13691. oldValue, err := m.oldValue(ctx)
  13692. if err != nil {
  13693. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13694. }
  13695. return oldValue.Status, nil
  13696. }
  13697. // AddStatus adds u to the "status" field.
  13698. func (m *LabelMutation) AddStatus(u int8) {
  13699. if m.addstatus != nil {
  13700. *m.addstatus += u
  13701. } else {
  13702. m.addstatus = &u
  13703. }
  13704. }
  13705. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13706. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  13707. v := m.addstatus
  13708. if v == nil {
  13709. return
  13710. }
  13711. return *v, true
  13712. }
  13713. // ClearStatus clears the value of the "status" field.
  13714. func (m *LabelMutation) ClearStatus() {
  13715. m.status = nil
  13716. m.addstatus = nil
  13717. m.clearedFields[label.FieldStatus] = struct{}{}
  13718. }
  13719. // StatusCleared returns if the "status" field was cleared in this mutation.
  13720. func (m *LabelMutation) StatusCleared() bool {
  13721. _, ok := m.clearedFields[label.FieldStatus]
  13722. return ok
  13723. }
  13724. // ResetStatus resets all changes to the "status" field.
  13725. func (m *LabelMutation) ResetStatus() {
  13726. m.status = nil
  13727. m.addstatus = nil
  13728. delete(m.clearedFields, label.FieldStatus)
  13729. }
  13730. // SetType sets the "type" field.
  13731. func (m *LabelMutation) SetType(i int) {
  13732. m._type = &i
  13733. m.add_type = nil
  13734. }
  13735. // GetType returns the value of the "type" field in the mutation.
  13736. func (m *LabelMutation) GetType() (r int, exists bool) {
  13737. v := m._type
  13738. if v == nil {
  13739. return
  13740. }
  13741. return *v, true
  13742. }
  13743. // OldType returns the old "type" field's value of the Label entity.
  13744. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13746. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  13747. if !m.op.Is(OpUpdateOne) {
  13748. return v, errors.New("OldType is only allowed on UpdateOne operations")
  13749. }
  13750. if m.id == nil || m.oldValue == nil {
  13751. return v, errors.New("OldType requires an ID field in the mutation")
  13752. }
  13753. oldValue, err := m.oldValue(ctx)
  13754. if err != nil {
  13755. return v, fmt.Errorf("querying old value for OldType: %w", err)
  13756. }
  13757. return oldValue.Type, nil
  13758. }
  13759. // AddType adds i to the "type" field.
  13760. func (m *LabelMutation) AddType(i int) {
  13761. if m.add_type != nil {
  13762. *m.add_type += i
  13763. } else {
  13764. m.add_type = &i
  13765. }
  13766. }
  13767. // AddedType returns the value that was added to the "type" field in this mutation.
  13768. func (m *LabelMutation) AddedType() (r int, exists bool) {
  13769. v := m.add_type
  13770. if v == nil {
  13771. return
  13772. }
  13773. return *v, true
  13774. }
  13775. // ResetType resets all changes to the "type" field.
  13776. func (m *LabelMutation) ResetType() {
  13777. m._type = nil
  13778. m.add_type = nil
  13779. }
  13780. // SetName sets the "name" field.
  13781. func (m *LabelMutation) SetName(s string) {
  13782. m.name = &s
  13783. }
  13784. // Name returns the value of the "name" field in the mutation.
  13785. func (m *LabelMutation) Name() (r string, exists bool) {
  13786. v := m.name
  13787. if v == nil {
  13788. return
  13789. }
  13790. return *v, true
  13791. }
  13792. // OldName returns the old "name" field's value of the Label entity.
  13793. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13794. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13795. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  13796. if !m.op.Is(OpUpdateOne) {
  13797. return v, errors.New("OldName is only allowed on UpdateOne operations")
  13798. }
  13799. if m.id == nil || m.oldValue == nil {
  13800. return v, errors.New("OldName requires an ID field in the mutation")
  13801. }
  13802. oldValue, err := m.oldValue(ctx)
  13803. if err != nil {
  13804. return v, fmt.Errorf("querying old value for OldName: %w", err)
  13805. }
  13806. return oldValue.Name, nil
  13807. }
  13808. // ResetName resets all changes to the "name" field.
  13809. func (m *LabelMutation) ResetName() {
  13810. m.name = nil
  13811. }
  13812. // SetFrom sets the "from" field.
  13813. func (m *LabelMutation) SetFrom(i int) {
  13814. m.from = &i
  13815. m.addfrom = nil
  13816. }
  13817. // From returns the value of the "from" field in the mutation.
  13818. func (m *LabelMutation) From() (r int, exists bool) {
  13819. v := m.from
  13820. if v == nil {
  13821. return
  13822. }
  13823. return *v, true
  13824. }
  13825. // OldFrom returns the old "from" field's value of the Label entity.
  13826. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13828. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  13829. if !m.op.Is(OpUpdateOne) {
  13830. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  13831. }
  13832. if m.id == nil || m.oldValue == nil {
  13833. return v, errors.New("OldFrom requires an ID field in the mutation")
  13834. }
  13835. oldValue, err := m.oldValue(ctx)
  13836. if err != nil {
  13837. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  13838. }
  13839. return oldValue.From, nil
  13840. }
  13841. // AddFrom adds i to the "from" field.
  13842. func (m *LabelMutation) AddFrom(i int) {
  13843. if m.addfrom != nil {
  13844. *m.addfrom += i
  13845. } else {
  13846. m.addfrom = &i
  13847. }
  13848. }
  13849. // AddedFrom returns the value that was added to the "from" field in this mutation.
  13850. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  13851. v := m.addfrom
  13852. if v == nil {
  13853. return
  13854. }
  13855. return *v, true
  13856. }
  13857. // ResetFrom resets all changes to the "from" field.
  13858. func (m *LabelMutation) ResetFrom() {
  13859. m.from = nil
  13860. m.addfrom = nil
  13861. }
  13862. // SetMode sets the "mode" field.
  13863. func (m *LabelMutation) SetMode(i int) {
  13864. m.mode = &i
  13865. m.addmode = nil
  13866. }
  13867. // Mode returns the value of the "mode" field in the mutation.
  13868. func (m *LabelMutation) Mode() (r int, exists bool) {
  13869. v := m.mode
  13870. if v == nil {
  13871. return
  13872. }
  13873. return *v, true
  13874. }
  13875. // OldMode returns the old "mode" field's value of the Label entity.
  13876. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13878. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  13879. if !m.op.Is(OpUpdateOne) {
  13880. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  13881. }
  13882. if m.id == nil || m.oldValue == nil {
  13883. return v, errors.New("OldMode requires an ID field in the mutation")
  13884. }
  13885. oldValue, err := m.oldValue(ctx)
  13886. if err != nil {
  13887. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  13888. }
  13889. return oldValue.Mode, nil
  13890. }
  13891. // AddMode adds i to the "mode" field.
  13892. func (m *LabelMutation) AddMode(i int) {
  13893. if m.addmode != nil {
  13894. *m.addmode += i
  13895. } else {
  13896. m.addmode = &i
  13897. }
  13898. }
  13899. // AddedMode returns the value that was added to the "mode" field in this mutation.
  13900. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  13901. v := m.addmode
  13902. if v == nil {
  13903. return
  13904. }
  13905. return *v, true
  13906. }
  13907. // ResetMode resets all changes to the "mode" field.
  13908. func (m *LabelMutation) ResetMode() {
  13909. m.mode = nil
  13910. m.addmode = nil
  13911. }
  13912. // SetConditions sets the "conditions" field.
  13913. func (m *LabelMutation) SetConditions(s string) {
  13914. m.conditions = &s
  13915. }
  13916. // Conditions returns the value of the "conditions" field in the mutation.
  13917. func (m *LabelMutation) Conditions() (r string, exists bool) {
  13918. v := m.conditions
  13919. if v == nil {
  13920. return
  13921. }
  13922. return *v, true
  13923. }
  13924. // OldConditions returns the old "conditions" field's value of the Label entity.
  13925. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13927. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  13928. if !m.op.Is(OpUpdateOne) {
  13929. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  13930. }
  13931. if m.id == nil || m.oldValue == nil {
  13932. return v, errors.New("OldConditions requires an ID field in the mutation")
  13933. }
  13934. oldValue, err := m.oldValue(ctx)
  13935. if err != nil {
  13936. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  13937. }
  13938. return oldValue.Conditions, nil
  13939. }
  13940. // ClearConditions clears the value of the "conditions" field.
  13941. func (m *LabelMutation) ClearConditions() {
  13942. m.conditions = nil
  13943. m.clearedFields[label.FieldConditions] = struct{}{}
  13944. }
  13945. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  13946. func (m *LabelMutation) ConditionsCleared() bool {
  13947. _, ok := m.clearedFields[label.FieldConditions]
  13948. return ok
  13949. }
  13950. // ResetConditions resets all changes to the "conditions" field.
  13951. func (m *LabelMutation) ResetConditions() {
  13952. m.conditions = nil
  13953. delete(m.clearedFields, label.FieldConditions)
  13954. }
  13955. // SetOrganizationID sets the "organization_id" field.
  13956. func (m *LabelMutation) SetOrganizationID(u uint64) {
  13957. m.organization_id = &u
  13958. m.addorganization_id = nil
  13959. }
  13960. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13961. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  13962. v := m.organization_id
  13963. if v == nil {
  13964. return
  13965. }
  13966. return *v, true
  13967. }
  13968. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  13969. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13971. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13972. if !m.op.Is(OpUpdateOne) {
  13973. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13974. }
  13975. if m.id == nil || m.oldValue == nil {
  13976. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13977. }
  13978. oldValue, err := m.oldValue(ctx)
  13979. if err != nil {
  13980. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13981. }
  13982. return oldValue.OrganizationID, nil
  13983. }
  13984. // AddOrganizationID adds u to the "organization_id" field.
  13985. func (m *LabelMutation) AddOrganizationID(u int64) {
  13986. if m.addorganization_id != nil {
  13987. *m.addorganization_id += u
  13988. } else {
  13989. m.addorganization_id = &u
  13990. }
  13991. }
  13992. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13993. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  13994. v := m.addorganization_id
  13995. if v == nil {
  13996. return
  13997. }
  13998. return *v, true
  13999. }
  14000. // ClearOrganizationID clears the value of the "organization_id" field.
  14001. func (m *LabelMutation) ClearOrganizationID() {
  14002. m.organization_id = nil
  14003. m.addorganization_id = nil
  14004. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  14005. }
  14006. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14007. func (m *LabelMutation) OrganizationIDCleared() bool {
  14008. _, ok := m.clearedFields[label.FieldOrganizationID]
  14009. return ok
  14010. }
  14011. // ResetOrganizationID resets all changes to the "organization_id" field.
  14012. func (m *LabelMutation) ResetOrganizationID() {
  14013. m.organization_id = nil
  14014. m.addorganization_id = nil
  14015. delete(m.clearedFields, label.FieldOrganizationID)
  14016. }
  14017. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  14018. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  14019. if m.label_relationships == nil {
  14020. m.label_relationships = make(map[uint64]struct{})
  14021. }
  14022. for i := range ids {
  14023. m.label_relationships[ids[i]] = struct{}{}
  14024. }
  14025. }
  14026. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  14027. func (m *LabelMutation) ClearLabelRelationships() {
  14028. m.clearedlabel_relationships = true
  14029. }
  14030. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  14031. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  14032. return m.clearedlabel_relationships
  14033. }
  14034. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  14035. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  14036. if m.removedlabel_relationships == nil {
  14037. m.removedlabel_relationships = make(map[uint64]struct{})
  14038. }
  14039. for i := range ids {
  14040. delete(m.label_relationships, ids[i])
  14041. m.removedlabel_relationships[ids[i]] = struct{}{}
  14042. }
  14043. }
  14044. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  14045. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  14046. for id := range m.removedlabel_relationships {
  14047. ids = append(ids, id)
  14048. }
  14049. return
  14050. }
  14051. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  14052. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  14053. for id := range m.label_relationships {
  14054. ids = append(ids, id)
  14055. }
  14056. return
  14057. }
  14058. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  14059. func (m *LabelMutation) ResetLabelRelationships() {
  14060. m.label_relationships = nil
  14061. m.clearedlabel_relationships = false
  14062. m.removedlabel_relationships = nil
  14063. }
  14064. // Where appends a list predicates to the LabelMutation builder.
  14065. func (m *LabelMutation) Where(ps ...predicate.Label) {
  14066. m.predicates = append(m.predicates, ps...)
  14067. }
  14068. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  14069. // users can use type-assertion to append predicates that do not depend on any generated package.
  14070. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  14071. p := make([]predicate.Label, len(ps))
  14072. for i := range ps {
  14073. p[i] = ps[i]
  14074. }
  14075. m.Where(p...)
  14076. }
  14077. // Op returns the operation name.
  14078. func (m *LabelMutation) Op() Op {
  14079. return m.op
  14080. }
  14081. // SetOp allows setting the mutation operation.
  14082. func (m *LabelMutation) SetOp(op Op) {
  14083. m.op = op
  14084. }
  14085. // Type returns the node type of this mutation (Label).
  14086. func (m *LabelMutation) Type() string {
  14087. return m.typ
  14088. }
  14089. // Fields returns all fields that were changed during this mutation. Note that in
  14090. // order to get all numeric fields that were incremented/decremented, call
  14091. // AddedFields().
  14092. func (m *LabelMutation) Fields() []string {
  14093. fields := make([]string, 0, 9)
  14094. if m.created_at != nil {
  14095. fields = append(fields, label.FieldCreatedAt)
  14096. }
  14097. if m.updated_at != nil {
  14098. fields = append(fields, label.FieldUpdatedAt)
  14099. }
  14100. if m.status != nil {
  14101. fields = append(fields, label.FieldStatus)
  14102. }
  14103. if m._type != nil {
  14104. fields = append(fields, label.FieldType)
  14105. }
  14106. if m.name != nil {
  14107. fields = append(fields, label.FieldName)
  14108. }
  14109. if m.from != nil {
  14110. fields = append(fields, label.FieldFrom)
  14111. }
  14112. if m.mode != nil {
  14113. fields = append(fields, label.FieldMode)
  14114. }
  14115. if m.conditions != nil {
  14116. fields = append(fields, label.FieldConditions)
  14117. }
  14118. if m.organization_id != nil {
  14119. fields = append(fields, label.FieldOrganizationID)
  14120. }
  14121. return fields
  14122. }
  14123. // Field returns the value of a field with the given name. The second boolean
  14124. // return value indicates that this field was not set, or was not defined in the
  14125. // schema.
  14126. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  14127. switch name {
  14128. case label.FieldCreatedAt:
  14129. return m.CreatedAt()
  14130. case label.FieldUpdatedAt:
  14131. return m.UpdatedAt()
  14132. case label.FieldStatus:
  14133. return m.Status()
  14134. case label.FieldType:
  14135. return m.GetType()
  14136. case label.FieldName:
  14137. return m.Name()
  14138. case label.FieldFrom:
  14139. return m.From()
  14140. case label.FieldMode:
  14141. return m.Mode()
  14142. case label.FieldConditions:
  14143. return m.Conditions()
  14144. case label.FieldOrganizationID:
  14145. return m.OrganizationID()
  14146. }
  14147. return nil, false
  14148. }
  14149. // OldField returns the old value of the field from the database. An error is
  14150. // returned if the mutation operation is not UpdateOne, or the query to the
  14151. // database failed.
  14152. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14153. switch name {
  14154. case label.FieldCreatedAt:
  14155. return m.OldCreatedAt(ctx)
  14156. case label.FieldUpdatedAt:
  14157. return m.OldUpdatedAt(ctx)
  14158. case label.FieldStatus:
  14159. return m.OldStatus(ctx)
  14160. case label.FieldType:
  14161. return m.OldType(ctx)
  14162. case label.FieldName:
  14163. return m.OldName(ctx)
  14164. case label.FieldFrom:
  14165. return m.OldFrom(ctx)
  14166. case label.FieldMode:
  14167. return m.OldMode(ctx)
  14168. case label.FieldConditions:
  14169. return m.OldConditions(ctx)
  14170. case label.FieldOrganizationID:
  14171. return m.OldOrganizationID(ctx)
  14172. }
  14173. return nil, fmt.Errorf("unknown Label field %s", name)
  14174. }
  14175. // SetField sets the value of a field with the given name. It returns an error if
  14176. // the field is not defined in the schema, or if the type mismatched the field
  14177. // type.
  14178. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  14179. switch name {
  14180. case label.FieldCreatedAt:
  14181. v, ok := value.(time.Time)
  14182. if !ok {
  14183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14184. }
  14185. m.SetCreatedAt(v)
  14186. return nil
  14187. case label.FieldUpdatedAt:
  14188. v, ok := value.(time.Time)
  14189. if !ok {
  14190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14191. }
  14192. m.SetUpdatedAt(v)
  14193. return nil
  14194. case label.FieldStatus:
  14195. v, ok := value.(uint8)
  14196. if !ok {
  14197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14198. }
  14199. m.SetStatus(v)
  14200. return nil
  14201. case label.FieldType:
  14202. v, ok := value.(int)
  14203. if !ok {
  14204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14205. }
  14206. m.SetType(v)
  14207. return nil
  14208. case label.FieldName:
  14209. v, ok := value.(string)
  14210. if !ok {
  14211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14212. }
  14213. m.SetName(v)
  14214. return nil
  14215. case label.FieldFrom:
  14216. v, ok := value.(int)
  14217. if !ok {
  14218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14219. }
  14220. m.SetFrom(v)
  14221. return nil
  14222. case label.FieldMode:
  14223. v, ok := value.(int)
  14224. if !ok {
  14225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14226. }
  14227. m.SetMode(v)
  14228. return nil
  14229. case label.FieldConditions:
  14230. v, ok := value.(string)
  14231. if !ok {
  14232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14233. }
  14234. m.SetConditions(v)
  14235. return nil
  14236. case label.FieldOrganizationID:
  14237. v, ok := value.(uint64)
  14238. if !ok {
  14239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14240. }
  14241. m.SetOrganizationID(v)
  14242. return nil
  14243. }
  14244. return fmt.Errorf("unknown Label field %s", name)
  14245. }
  14246. // AddedFields returns all numeric fields that were incremented/decremented during
  14247. // this mutation.
  14248. func (m *LabelMutation) AddedFields() []string {
  14249. var fields []string
  14250. if m.addstatus != nil {
  14251. fields = append(fields, label.FieldStatus)
  14252. }
  14253. if m.add_type != nil {
  14254. fields = append(fields, label.FieldType)
  14255. }
  14256. if m.addfrom != nil {
  14257. fields = append(fields, label.FieldFrom)
  14258. }
  14259. if m.addmode != nil {
  14260. fields = append(fields, label.FieldMode)
  14261. }
  14262. if m.addorganization_id != nil {
  14263. fields = append(fields, label.FieldOrganizationID)
  14264. }
  14265. return fields
  14266. }
  14267. // AddedField returns the numeric value that was incremented/decremented on a field
  14268. // with the given name. The second boolean return value indicates that this field
  14269. // was not set, or was not defined in the schema.
  14270. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  14271. switch name {
  14272. case label.FieldStatus:
  14273. return m.AddedStatus()
  14274. case label.FieldType:
  14275. return m.AddedType()
  14276. case label.FieldFrom:
  14277. return m.AddedFrom()
  14278. case label.FieldMode:
  14279. return m.AddedMode()
  14280. case label.FieldOrganizationID:
  14281. return m.AddedOrganizationID()
  14282. }
  14283. return nil, false
  14284. }
  14285. // AddField adds the value to the field with the given name. It returns an error if
  14286. // the field is not defined in the schema, or if the type mismatched the field
  14287. // type.
  14288. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  14289. switch name {
  14290. case label.FieldStatus:
  14291. v, ok := value.(int8)
  14292. if !ok {
  14293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14294. }
  14295. m.AddStatus(v)
  14296. return nil
  14297. case label.FieldType:
  14298. v, ok := value.(int)
  14299. if !ok {
  14300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14301. }
  14302. m.AddType(v)
  14303. return nil
  14304. case label.FieldFrom:
  14305. v, ok := value.(int)
  14306. if !ok {
  14307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14308. }
  14309. m.AddFrom(v)
  14310. return nil
  14311. case label.FieldMode:
  14312. v, ok := value.(int)
  14313. if !ok {
  14314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14315. }
  14316. m.AddMode(v)
  14317. return nil
  14318. case label.FieldOrganizationID:
  14319. v, ok := value.(int64)
  14320. if !ok {
  14321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14322. }
  14323. m.AddOrganizationID(v)
  14324. return nil
  14325. }
  14326. return fmt.Errorf("unknown Label numeric field %s", name)
  14327. }
  14328. // ClearedFields returns all nullable fields that were cleared during this
  14329. // mutation.
  14330. func (m *LabelMutation) ClearedFields() []string {
  14331. var fields []string
  14332. if m.FieldCleared(label.FieldStatus) {
  14333. fields = append(fields, label.FieldStatus)
  14334. }
  14335. if m.FieldCleared(label.FieldConditions) {
  14336. fields = append(fields, label.FieldConditions)
  14337. }
  14338. if m.FieldCleared(label.FieldOrganizationID) {
  14339. fields = append(fields, label.FieldOrganizationID)
  14340. }
  14341. return fields
  14342. }
  14343. // FieldCleared returns a boolean indicating if a field with the given name was
  14344. // cleared in this mutation.
  14345. func (m *LabelMutation) FieldCleared(name string) bool {
  14346. _, ok := m.clearedFields[name]
  14347. return ok
  14348. }
  14349. // ClearField clears the value of the field with the given name. It returns an
  14350. // error if the field is not defined in the schema.
  14351. func (m *LabelMutation) ClearField(name string) error {
  14352. switch name {
  14353. case label.FieldStatus:
  14354. m.ClearStatus()
  14355. return nil
  14356. case label.FieldConditions:
  14357. m.ClearConditions()
  14358. return nil
  14359. case label.FieldOrganizationID:
  14360. m.ClearOrganizationID()
  14361. return nil
  14362. }
  14363. return fmt.Errorf("unknown Label nullable field %s", name)
  14364. }
  14365. // ResetField resets all changes in the mutation for the field with the given name.
  14366. // It returns an error if the field is not defined in the schema.
  14367. func (m *LabelMutation) ResetField(name string) error {
  14368. switch name {
  14369. case label.FieldCreatedAt:
  14370. m.ResetCreatedAt()
  14371. return nil
  14372. case label.FieldUpdatedAt:
  14373. m.ResetUpdatedAt()
  14374. return nil
  14375. case label.FieldStatus:
  14376. m.ResetStatus()
  14377. return nil
  14378. case label.FieldType:
  14379. m.ResetType()
  14380. return nil
  14381. case label.FieldName:
  14382. m.ResetName()
  14383. return nil
  14384. case label.FieldFrom:
  14385. m.ResetFrom()
  14386. return nil
  14387. case label.FieldMode:
  14388. m.ResetMode()
  14389. return nil
  14390. case label.FieldConditions:
  14391. m.ResetConditions()
  14392. return nil
  14393. case label.FieldOrganizationID:
  14394. m.ResetOrganizationID()
  14395. return nil
  14396. }
  14397. return fmt.Errorf("unknown Label field %s", name)
  14398. }
  14399. // AddedEdges returns all edge names that were set/added in this mutation.
  14400. func (m *LabelMutation) AddedEdges() []string {
  14401. edges := make([]string, 0, 1)
  14402. if m.label_relationships != nil {
  14403. edges = append(edges, label.EdgeLabelRelationships)
  14404. }
  14405. return edges
  14406. }
  14407. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14408. // name in this mutation.
  14409. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  14410. switch name {
  14411. case label.EdgeLabelRelationships:
  14412. ids := make([]ent.Value, 0, len(m.label_relationships))
  14413. for id := range m.label_relationships {
  14414. ids = append(ids, id)
  14415. }
  14416. return ids
  14417. }
  14418. return nil
  14419. }
  14420. // RemovedEdges returns all edge names that were removed in this mutation.
  14421. func (m *LabelMutation) RemovedEdges() []string {
  14422. edges := make([]string, 0, 1)
  14423. if m.removedlabel_relationships != nil {
  14424. edges = append(edges, label.EdgeLabelRelationships)
  14425. }
  14426. return edges
  14427. }
  14428. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14429. // the given name in this mutation.
  14430. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  14431. switch name {
  14432. case label.EdgeLabelRelationships:
  14433. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  14434. for id := range m.removedlabel_relationships {
  14435. ids = append(ids, id)
  14436. }
  14437. return ids
  14438. }
  14439. return nil
  14440. }
  14441. // ClearedEdges returns all edge names that were cleared in this mutation.
  14442. func (m *LabelMutation) ClearedEdges() []string {
  14443. edges := make([]string, 0, 1)
  14444. if m.clearedlabel_relationships {
  14445. edges = append(edges, label.EdgeLabelRelationships)
  14446. }
  14447. return edges
  14448. }
  14449. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14450. // was cleared in this mutation.
  14451. func (m *LabelMutation) EdgeCleared(name string) bool {
  14452. switch name {
  14453. case label.EdgeLabelRelationships:
  14454. return m.clearedlabel_relationships
  14455. }
  14456. return false
  14457. }
  14458. // ClearEdge clears the value of the edge with the given name. It returns an error
  14459. // if that edge is not defined in the schema.
  14460. func (m *LabelMutation) ClearEdge(name string) error {
  14461. switch name {
  14462. }
  14463. return fmt.Errorf("unknown Label unique edge %s", name)
  14464. }
  14465. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14466. // It returns an error if the edge is not defined in the schema.
  14467. func (m *LabelMutation) ResetEdge(name string) error {
  14468. switch name {
  14469. case label.EdgeLabelRelationships:
  14470. m.ResetLabelRelationships()
  14471. return nil
  14472. }
  14473. return fmt.Errorf("unknown Label edge %s", name)
  14474. }
  14475. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  14476. type LabelRelationshipMutation struct {
  14477. config
  14478. op Op
  14479. typ string
  14480. id *uint64
  14481. created_at *time.Time
  14482. updated_at *time.Time
  14483. status *uint8
  14484. addstatus *int8
  14485. organization_id *uint64
  14486. addorganization_id *int64
  14487. clearedFields map[string]struct{}
  14488. contacts *uint64
  14489. clearedcontacts bool
  14490. labels *uint64
  14491. clearedlabels bool
  14492. done bool
  14493. oldValue func(context.Context) (*LabelRelationship, error)
  14494. predicates []predicate.LabelRelationship
  14495. }
  14496. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  14497. // labelrelationshipOption allows management of the mutation configuration using functional options.
  14498. type labelrelationshipOption func(*LabelRelationshipMutation)
  14499. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  14500. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  14501. m := &LabelRelationshipMutation{
  14502. config: c,
  14503. op: op,
  14504. typ: TypeLabelRelationship,
  14505. clearedFields: make(map[string]struct{}),
  14506. }
  14507. for _, opt := range opts {
  14508. opt(m)
  14509. }
  14510. return m
  14511. }
  14512. // withLabelRelationshipID sets the ID field of the mutation.
  14513. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  14514. return func(m *LabelRelationshipMutation) {
  14515. var (
  14516. err error
  14517. once sync.Once
  14518. value *LabelRelationship
  14519. )
  14520. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  14521. once.Do(func() {
  14522. if m.done {
  14523. err = errors.New("querying old values post mutation is not allowed")
  14524. } else {
  14525. value, err = m.Client().LabelRelationship.Get(ctx, id)
  14526. }
  14527. })
  14528. return value, err
  14529. }
  14530. m.id = &id
  14531. }
  14532. }
  14533. // withLabelRelationship sets the old LabelRelationship of the mutation.
  14534. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  14535. return func(m *LabelRelationshipMutation) {
  14536. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  14537. return node, nil
  14538. }
  14539. m.id = &node.ID
  14540. }
  14541. }
  14542. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14543. // executed in a transaction (ent.Tx), a transactional client is returned.
  14544. func (m LabelRelationshipMutation) Client() *Client {
  14545. client := &Client{config: m.config}
  14546. client.init()
  14547. return client
  14548. }
  14549. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14550. // it returns an error otherwise.
  14551. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  14552. if _, ok := m.driver.(*txDriver); !ok {
  14553. return nil, errors.New("ent: mutation is not running in a transaction")
  14554. }
  14555. tx := &Tx{config: m.config}
  14556. tx.init()
  14557. return tx, nil
  14558. }
  14559. // SetID sets the value of the id field. Note that this
  14560. // operation is only accepted on creation of LabelRelationship entities.
  14561. func (m *LabelRelationshipMutation) SetID(id uint64) {
  14562. m.id = &id
  14563. }
  14564. // ID returns the ID value in the mutation. Note that the ID is only available
  14565. // if it was provided to the builder or after it was returned from the database.
  14566. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  14567. if m.id == nil {
  14568. return
  14569. }
  14570. return *m.id, true
  14571. }
  14572. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14573. // That means, if the mutation is applied within a transaction with an isolation level such
  14574. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14575. // or updated by the mutation.
  14576. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  14577. switch {
  14578. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14579. id, exists := m.ID()
  14580. if exists {
  14581. return []uint64{id}, nil
  14582. }
  14583. fallthrough
  14584. case m.op.Is(OpUpdate | OpDelete):
  14585. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  14586. default:
  14587. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14588. }
  14589. }
  14590. // SetCreatedAt sets the "created_at" field.
  14591. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  14592. m.created_at = &t
  14593. }
  14594. // CreatedAt returns the value of the "created_at" field in the mutation.
  14595. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  14596. v := m.created_at
  14597. if v == nil {
  14598. return
  14599. }
  14600. return *v, true
  14601. }
  14602. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  14603. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14605. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14606. if !m.op.Is(OpUpdateOne) {
  14607. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14608. }
  14609. if m.id == nil || m.oldValue == nil {
  14610. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14611. }
  14612. oldValue, err := m.oldValue(ctx)
  14613. if err != nil {
  14614. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14615. }
  14616. return oldValue.CreatedAt, nil
  14617. }
  14618. // ResetCreatedAt resets all changes to the "created_at" field.
  14619. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  14620. m.created_at = nil
  14621. }
  14622. // SetUpdatedAt sets the "updated_at" field.
  14623. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  14624. m.updated_at = &t
  14625. }
  14626. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14627. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  14628. v := m.updated_at
  14629. if v == nil {
  14630. return
  14631. }
  14632. return *v, true
  14633. }
  14634. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  14635. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14637. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14638. if !m.op.Is(OpUpdateOne) {
  14639. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14640. }
  14641. if m.id == nil || m.oldValue == nil {
  14642. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14643. }
  14644. oldValue, err := m.oldValue(ctx)
  14645. if err != nil {
  14646. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14647. }
  14648. return oldValue.UpdatedAt, nil
  14649. }
  14650. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14651. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  14652. m.updated_at = nil
  14653. }
  14654. // SetStatus sets the "status" field.
  14655. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  14656. m.status = &u
  14657. m.addstatus = nil
  14658. }
  14659. // Status returns the value of the "status" field in the mutation.
  14660. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  14661. v := m.status
  14662. if v == nil {
  14663. return
  14664. }
  14665. return *v, true
  14666. }
  14667. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  14668. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14670. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14671. if !m.op.Is(OpUpdateOne) {
  14672. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14673. }
  14674. if m.id == nil || m.oldValue == nil {
  14675. return v, errors.New("OldStatus requires an ID field in the mutation")
  14676. }
  14677. oldValue, err := m.oldValue(ctx)
  14678. if err != nil {
  14679. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14680. }
  14681. return oldValue.Status, nil
  14682. }
  14683. // AddStatus adds u to the "status" field.
  14684. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  14685. if m.addstatus != nil {
  14686. *m.addstatus += u
  14687. } else {
  14688. m.addstatus = &u
  14689. }
  14690. }
  14691. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14692. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  14693. v := m.addstatus
  14694. if v == nil {
  14695. return
  14696. }
  14697. return *v, true
  14698. }
  14699. // ClearStatus clears the value of the "status" field.
  14700. func (m *LabelRelationshipMutation) ClearStatus() {
  14701. m.status = nil
  14702. m.addstatus = nil
  14703. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  14704. }
  14705. // StatusCleared returns if the "status" field was cleared in this mutation.
  14706. func (m *LabelRelationshipMutation) StatusCleared() bool {
  14707. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  14708. return ok
  14709. }
  14710. // ResetStatus resets all changes to the "status" field.
  14711. func (m *LabelRelationshipMutation) ResetStatus() {
  14712. m.status = nil
  14713. m.addstatus = nil
  14714. delete(m.clearedFields, labelrelationship.FieldStatus)
  14715. }
  14716. // SetLabelID sets the "label_id" field.
  14717. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  14718. m.labels = &u
  14719. }
  14720. // LabelID returns the value of the "label_id" field in the mutation.
  14721. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  14722. v := m.labels
  14723. if v == nil {
  14724. return
  14725. }
  14726. return *v, true
  14727. }
  14728. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  14729. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14731. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  14732. if !m.op.Is(OpUpdateOne) {
  14733. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  14734. }
  14735. if m.id == nil || m.oldValue == nil {
  14736. return v, errors.New("OldLabelID requires an ID field in the mutation")
  14737. }
  14738. oldValue, err := m.oldValue(ctx)
  14739. if err != nil {
  14740. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  14741. }
  14742. return oldValue.LabelID, nil
  14743. }
  14744. // ResetLabelID resets all changes to the "label_id" field.
  14745. func (m *LabelRelationshipMutation) ResetLabelID() {
  14746. m.labels = nil
  14747. }
  14748. // SetContactID sets the "contact_id" field.
  14749. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  14750. m.contacts = &u
  14751. }
  14752. // ContactID returns the value of the "contact_id" field in the mutation.
  14753. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  14754. v := m.contacts
  14755. if v == nil {
  14756. return
  14757. }
  14758. return *v, true
  14759. }
  14760. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  14761. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14763. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  14764. if !m.op.Is(OpUpdateOne) {
  14765. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  14766. }
  14767. if m.id == nil || m.oldValue == nil {
  14768. return v, errors.New("OldContactID requires an ID field in the mutation")
  14769. }
  14770. oldValue, err := m.oldValue(ctx)
  14771. if err != nil {
  14772. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  14773. }
  14774. return oldValue.ContactID, nil
  14775. }
  14776. // ResetContactID resets all changes to the "contact_id" field.
  14777. func (m *LabelRelationshipMutation) ResetContactID() {
  14778. m.contacts = nil
  14779. }
  14780. // SetOrganizationID sets the "organization_id" field.
  14781. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  14782. m.organization_id = &u
  14783. m.addorganization_id = nil
  14784. }
  14785. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14786. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  14787. v := m.organization_id
  14788. if v == nil {
  14789. return
  14790. }
  14791. return *v, true
  14792. }
  14793. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  14794. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14796. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14797. if !m.op.Is(OpUpdateOne) {
  14798. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14799. }
  14800. if m.id == nil || m.oldValue == nil {
  14801. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14802. }
  14803. oldValue, err := m.oldValue(ctx)
  14804. if err != nil {
  14805. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14806. }
  14807. return oldValue.OrganizationID, nil
  14808. }
  14809. // AddOrganizationID adds u to the "organization_id" field.
  14810. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  14811. if m.addorganization_id != nil {
  14812. *m.addorganization_id += u
  14813. } else {
  14814. m.addorganization_id = &u
  14815. }
  14816. }
  14817. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14818. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  14819. v := m.addorganization_id
  14820. if v == nil {
  14821. return
  14822. }
  14823. return *v, true
  14824. }
  14825. // ClearOrganizationID clears the value of the "organization_id" field.
  14826. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  14827. m.organization_id = nil
  14828. m.addorganization_id = nil
  14829. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  14830. }
  14831. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14832. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  14833. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  14834. return ok
  14835. }
  14836. // ResetOrganizationID resets all changes to the "organization_id" field.
  14837. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  14838. m.organization_id = nil
  14839. m.addorganization_id = nil
  14840. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  14841. }
  14842. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  14843. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  14844. m.contacts = &id
  14845. }
  14846. // ClearContacts clears the "contacts" edge to the Contact entity.
  14847. func (m *LabelRelationshipMutation) ClearContacts() {
  14848. m.clearedcontacts = true
  14849. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  14850. }
  14851. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  14852. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  14853. return m.clearedcontacts
  14854. }
  14855. // ContactsID returns the "contacts" edge ID in the mutation.
  14856. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  14857. if m.contacts != nil {
  14858. return *m.contacts, true
  14859. }
  14860. return
  14861. }
  14862. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  14863. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14864. // ContactsID instead. It exists only for internal usage by the builders.
  14865. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  14866. if id := m.contacts; id != nil {
  14867. ids = append(ids, *id)
  14868. }
  14869. return
  14870. }
  14871. // ResetContacts resets all changes to the "contacts" edge.
  14872. func (m *LabelRelationshipMutation) ResetContacts() {
  14873. m.contacts = nil
  14874. m.clearedcontacts = false
  14875. }
  14876. // SetLabelsID sets the "labels" edge to the Label entity by id.
  14877. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  14878. m.labels = &id
  14879. }
  14880. // ClearLabels clears the "labels" edge to the Label entity.
  14881. func (m *LabelRelationshipMutation) ClearLabels() {
  14882. m.clearedlabels = true
  14883. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  14884. }
  14885. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  14886. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  14887. return m.clearedlabels
  14888. }
  14889. // LabelsID returns the "labels" edge ID in the mutation.
  14890. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  14891. if m.labels != nil {
  14892. return *m.labels, true
  14893. }
  14894. return
  14895. }
  14896. // LabelsIDs returns the "labels" edge IDs in the mutation.
  14897. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14898. // LabelsID instead. It exists only for internal usage by the builders.
  14899. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  14900. if id := m.labels; id != nil {
  14901. ids = append(ids, *id)
  14902. }
  14903. return
  14904. }
  14905. // ResetLabels resets all changes to the "labels" edge.
  14906. func (m *LabelRelationshipMutation) ResetLabels() {
  14907. m.labels = nil
  14908. m.clearedlabels = false
  14909. }
  14910. // Where appends a list predicates to the LabelRelationshipMutation builder.
  14911. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  14912. m.predicates = append(m.predicates, ps...)
  14913. }
  14914. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  14915. // users can use type-assertion to append predicates that do not depend on any generated package.
  14916. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  14917. p := make([]predicate.LabelRelationship, len(ps))
  14918. for i := range ps {
  14919. p[i] = ps[i]
  14920. }
  14921. m.Where(p...)
  14922. }
  14923. // Op returns the operation name.
  14924. func (m *LabelRelationshipMutation) Op() Op {
  14925. return m.op
  14926. }
  14927. // SetOp allows setting the mutation operation.
  14928. func (m *LabelRelationshipMutation) SetOp(op Op) {
  14929. m.op = op
  14930. }
  14931. // Type returns the node type of this mutation (LabelRelationship).
  14932. func (m *LabelRelationshipMutation) Type() string {
  14933. return m.typ
  14934. }
  14935. // Fields returns all fields that were changed during this mutation. Note that in
  14936. // order to get all numeric fields that were incremented/decremented, call
  14937. // AddedFields().
  14938. func (m *LabelRelationshipMutation) Fields() []string {
  14939. fields := make([]string, 0, 6)
  14940. if m.created_at != nil {
  14941. fields = append(fields, labelrelationship.FieldCreatedAt)
  14942. }
  14943. if m.updated_at != nil {
  14944. fields = append(fields, labelrelationship.FieldUpdatedAt)
  14945. }
  14946. if m.status != nil {
  14947. fields = append(fields, labelrelationship.FieldStatus)
  14948. }
  14949. if m.labels != nil {
  14950. fields = append(fields, labelrelationship.FieldLabelID)
  14951. }
  14952. if m.contacts != nil {
  14953. fields = append(fields, labelrelationship.FieldContactID)
  14954. }
  14955. if m.organization_id != nil {
  14956. fields = append(fields, labelrelationship.FieldOrganizationID)
  14957. }
  14958. return fields
  14959. }
  14960. // Field returns the value of a field with the given name. The second boolean
  14961. // return value indicates that this field was not set, or was not defined in the
  14962. // schema.
  14963. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  14964. switch name {
  14965. case labelrelationship.FieldCreatedAt:
  14966. return m.CreatedAt()
  14967. case labelrelationship.FieldUpdatedAt:
  14968. return m.UpdatedAt()
  14969. case labelrelationship.FieldStatus:
  14970. return m.Status()
  14971. case labelrelationship.FieldLabelID:
  14972. return m.LabelID()
  14973. case labelrelationship.FieldContactID:
  14974. return m.ContactID()
  14975. case labelrelationship.FieldOrganizationID:
  14976. return m.OrganizationID()
  14977. }
  14978. return nil, false
  14979. }
  14980. // OldField returns the old value of the field from the database. An error is
  14981. // returned if the mutation operation is not UpdateOne, or the query to the
  14982. // database failed.
  14983. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14984. switch name {
  14985. case labelrelationship.FieldCreatedAt:
  14986. return m.OldCreatedAt(ctx)
  14987. case labelrelationship.FieldUpdatedAt:
  14988. return m.OldUpdatedAt(ctx)
  14989. case labelrelationship.FieldStatus:
  14990. return m.OldStatus(ctx)
  14991. case labelrelationship.FieldLabelID:
  14992. return m.OldLabelID(ctx)
  14993. case labelrelationship.FieldContactID:
  14994. return m.OldContactID(ctx)
  14995. case labelrelationship.FieldOrganizationID:
  14996. return m.OldOrganizationID(ctx)
  14997. }
  14998. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  14999. }
  15000. // SetField sets the value of a field with the given name. It returns an error if
  15001. // the field is not defined in the schema, or if the type mismatched the field
  15002. // type.
  15003. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  15004. switch name {
  15005. case labelrelationship.FieldCreatedAt:
  15006. v, ok := value.(time.Time)
  15007. if !ok {
  15008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15009. }
  15010. m.SetCreatedAt(v)
  15011. return nil
  15012. case labelrelationship.FieldUpdatedAt:
  15013. v, ok := value.(time.Time)
  15014. if !ok {
  15015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15016. }
  15017. m.SetUpdatedAt(v)
  15018. return nil
  15019. case labelrelationship.FieldStatus:
  15020. v, ok := value.(uint8)
  15021. if !ok {
  15022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15023. }
  15024. m.SetStatus(v)
  15025. return nil
  15026. case labelrelationship.FieldLabelID:
  15027. v, ok := value.(uint64)
  15028. if !ok {
  15029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15030. }
  15031. m.SetLabelID(v)
  15032. return nil
  15033. case labelrelationship.FieldContactID:
  15034. v, ok := value.(uint64)
  15035. if !ok {
  15036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15037. }
  15038. m.SetContactID(v)
  15039. return nil
  15040. case labelrelationship.FieldOrganizationID:
  15041. v, ok := value.(uint64)
  15042. if !ok {
  15043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15044. }
  15045. m.SetOrganizationID(v)
  15046. return nil
  15047. }
  15048. return fmt.Errorf("unknown LabelRelationship field %s", name)
  15049. }
  15050. // AddedFields returns all numeric fields that were incremented/decremented during
  15051. // this mutation.
  15052. func (m *LabelRelationshipMutation) AddedFields() []string {
  15053. var fields []string
  15054. if m.addstatus != nil {
  15055. fields = append(fields, labelrelationship.FieldStatus)
  15056. }
  15057. if m.addorganization_id != nil {
  15058. fields = append(fields, labelrelationship.FieldOrganizationID)
  15059. }
  15060. return fields
  15061. }
  15062. // AddedField returns the numeric value that was incremented/decremented on a field
  15063. // with the given name. The second boolean return value indicates that this field
  15064. // was not set, or was not defined in the schema.
  15065. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  15066. switch name {
  15067. case labelrelationship.FieldStatus:
  15068. return m.AddedStatus()
  15069. case labelrelationship.FieldOrganizationID:
  15070. return m.AddedOrganizationID()
  15071. }
  15072. return nil, false
  15073. }
  15074. // AddField adds the value to the field with the given name. It returns an error if
  15075. // the field is not defined in the schema, or if the type mismatched the field
  15076. // type.
  15077. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  15078. switch name {
  15079. case labelrelationship.FieldStatus:
  15080. v, ok := value.(int8)
  15081. if !ok {
  15082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15083. }
  15084. m.AddStatus(v)
  15085. return nil
  15086. case labelrelationship.FieldOrganizationID:
  15087. v, ok := value.(int64)
  15088. if !ok {
  15089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15090. }
  15091. m.AddOrganizationID(v)
  15092. return nil
  15093. }
  15094. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  15095. }
  15096. // ClearedFields returns all nullable fields that were cleared during this
  15097. // mutation.
  15098. func (m *LabelRelationshipMutation) ClearedFields() []string {
  15099. var fields []string
  15100. if m.FieldCleared(labelrelationship.FieldStatus) {
  15101. fields = append(fields, labelrelationship.FieldStatus)
  15102. }
  15103. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  15104. fields = append(fields, labelrelationship.FieldOrganizationID)
  15105. }
  15106. return fields
  15107. }
  15108. // FieldCleared returns a boolean indicating if a field with the given name was
  15109. // cleared in this mutation.
  15110. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  15111. _, ok := m.clearedFields[name]
  15112. return ok
  15113. }
  15114. // ClearField clears the value of the field with the given name. It returns an
  15115. // error if the field is not defined in the schema.
  15116. func (m *LabelRelationshipMutation) ClearField(name string) error {
  15117. switch name {
  15118. case labelrelationship.FieldStatus:
  15119. m.ClearStatus()
  15120. return nil
  15121. case labelrelationship.FieldOrganizationID:
  15122. m.ClearOrganizationID()
  15123. return nil
  15124. }
  15125. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  15126. }
  15127. // ResetField resets all changes in the mutation for the field with the given name.
  15128. // It returns an error if the field is not defined in the schema.
  15129. func (m *LabelRelationshipMutation) ResetField(name string) error {
  15130. switch name {
  15131. case labelrelationship.FieldCreatedAt:
  15132. m.ResetCreatedAt()
  15133. return nil
  15134. case labelrelationship.FieldUpdatedAt:
  15135. m.ResetUpdatedAt()
  15136. return nil
  15137. case labelrelationship.FieldStatus:
  15138. m.ResetStatus()
  15139. return nil
  15140. case labelrelationship.FieldLabelID:
  15141. m.ResetLabelID()
  15142. return nil
  15143. case labelrelationship.FieldContactID:
  15144. m.ResetContactID()
  15145. return nil
  15146. case labelrelationship.FieldOrganizationID:
  15147. m.ResetOrganizationID()
  15148. return nil
  15149. }
  15150. return fmt.Errorf("unknown LabelRelationship field %s", name)
  15151. }
  15152. // AddedEdges returns all edge names that were set/added in this mutation.
  15153. func (m *LabelRelationshipMutation) AddedEdges() []string {
  15154. edges := make([]string, 0, 2)
  15155. if m.contacts != nil {
  15156. edges = append(edges, labelrelationship.EdgeContacts)
  15157. }
  15158. if m.labels != nil {
  15159. edges = append(edges, labelrelationship.EdgeLabels)
  15160. }
  15161. return edges
  15162. }
  15163. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15164. // name in this mutation.
  15165. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  15166. switch name {
  15167. case labelrelationship.EdgeContacts:
  15168. if id := m.contacts; id != nil {
  15169. return []ent.Value{*id}
  15170. }
  15171. case labelrelationship.EdgeLabels:
  15172. if id := m.labels; id != nil {
  15173. return []ent.Value{*id}
  15174. }
  15175. }
  15176. return nil
  15177. }
  15178. // RemovedEdges returns all edge names that were removed in this mutation.
  15179. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  15180. edges := make([]string, 0, 2)
  15181. return edges
  15182. }
  15183. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15184. // the given name in this mutation.
  15185. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  15186. return nil
  15187. }
  15188. // ClearedEdges returns all edge names that were cleared in this mutation.
  15189. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  15190. edges := make([]string, 0, 2)
  15191. if m.clearedcontacts {
  15192. edges = append(edges, labelrelationship.EdgeContacts)
  15193. }
  15194. if m.clearedlabels {
  15195. edges = append(edges, labelrelationship.EdgeLabels)
  15196. }
  15197. return edges
  15198. }
  15199. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15200. // was cleared in this mutation.
  15201. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  15202. switch name {
  15203. case labelrelationship.EdgeContacts:
  15204. return m.clearedcontacts
  15205. case labelrelationship.EdgeLabels:
  15206. return m.clearedlabels
  15207. }
  15208. return false
  15209. }
  15210. // ClearEdge clears the value of the edge with the given name. It returns an error
  15211. // if that edge is not defined in the schema.
  15212. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  15213. switch name {
  15214. case labelrelationship.EdgeContacts:
  15215. m.ClearContacts()
  15216. return nil
  15217. case labelrelationship.EdgeLabels:
  15218. m.ClearLabels()
  15219. return nil
  15220. }
  15221. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  15222. }
  15223. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15224. // It returns an error if the edge is not defined in the schema.
  15225. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  15226. switch name {
  15227. case labelrelationship.EdgeContacts:
  15228. m.ResetContacts()
  15229. return nil
  15230. case labelrelationship.EdgeLabels:
  15231. m.ResetLabels()
  15232. return nil
  15233. }
  15234. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  15235. }
  15236. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  15237. type LabelTaggingMutation struct {
  15238. config
  15239. op Op
  15240. typ string
  15241. id *uint64
  15242. created_at *time.Time
  15243. updated_at *time.Time
  15244. status *uint8
  15245. addstatus *int8
  15246. deleted_at *time.Time
  15247. organization_id *uint64
  15248. addorganization_id *int64
  15249. _type *int
  15250. add_type *int
  15251. conditions *string
  15252. action_label_add *[]uint64
  15253. appendaction_label_add []uint64
  15254. action_label_del *[]uint64
  15255. appendaction_label_del []uint64
  15256. clearedFields map[string]struct{}
  15257. done bool
  15258. oldValue func(context.Context) (*LabelTagging, error)
  15259. predicates []predicate.LabelTagging
  15260. }
  15261. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  15262. // labeltaggingOption allows management of the mutation configuration using functional options.
  15263. type labeltaggingOption func(*LabelTaggingMutation)
  15264. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  15265. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  15266. m := &LabelTaggingMutation{
  15267. config: c,
  15268. op: op,
  15269. typ: TypeLabelTagging,
  15270. clearedFields: make(map[string]struct{}),
  15271. }
  15272. for _, opt := range opts {
  15273. opt(m)
  15274. }
  15275. return m
  15276. }
  15277. // withLabelTaggingID sets the ID field of the mutation.
  15278. func withLabelTaggingID(id uint64) labeltaggingOption {
  15279. return func(m *LabelTaggingMutation) {
  15280. var (
  15281. err error
  15282. once sync.Once
  15283. value *LabelTagging
  15284. )
  15285. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  15286. once.Do(func() {
  15287. if m.done {
  15288. err = errors.New("querying old values post mutation is not allowed")
  15289. } else {
  15290. value, err = m.Client().LabelTagging.Get(ctx, id)
  15291. }
  15292. })
  15293. return value, err
  15294. }
  15295. m.id = &id
  15296. }
  15297. }
  15298. // withLabelTagging sets the old LabelTagging of the mutation.
  15299. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  15300. return func(m *LabelTaggingMutation) {
  15301. m.oldValue = func(context.Context) (*LabelTagging, error) {
  15302. return node, nil
  15303. }
  15304. m.id = &node.ID
  15305. }
  15306. }
  15307. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15308. // executed in a transaction (ent.Tx), a transactional client is returned.
  15309. func (m LabelTaggingMutation) Client() *Client {
  15310. client := &Client{config: m.config}
  15311. client.init()
  15312. return client
  15313. }
  15314. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15315. // it returns an error otherwise.
  15316. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  15317. if _, ok := m.driver.(*txDriver); !ok {
  15318. return nil, errors.New("ent: mutation is not running in a transaction")
  15319. }
  15320. tx := &Tx{config: m.config}
  15321. tx.init()
  15322. return tx, nil
  15323. }
  15324. // SetID sets the value of the id field. Note that this
  15325. // operation is only accepted on creation of LabelTagging entities.
  15326. func (m *LabelTaggingMutation) SetID(id uint64) {
  15327. m.id = &id
  15328. }
  15329. // ID returns the ID value in the mutation. Note that the ID is only available
  15330. // if it was provided to the builder or after it was returned from the database.
  15331. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  15332. if m.id == nil {
  15333. return
  15334. }
  15335. return *m.id, true
  15336. }
  15337. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15338. // That means, if the mutation is applied within a transaction with an isolation level such
  15339. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15340. // or updated by the mutation.
  15341. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  15342. switch {
  15343. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15344. id, exists := m.ID()
  15345. if exists {
  15346. return []uint64{id}, nil
  15347. }
  15348. fallthrough
  15349. case m.op.Is(OpUpdate | OpDelete):
  15350. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  15351. default:
  15352. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15353. }
  15354. }
  15355. // SetCreatedAt sets the "created_at" field.
  15356. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  15357. m.created_at = &t
  15358. }
  15359. // CreatedAt returns the value of the "created_at" field in the mutation.
  15360. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  15361. v := m.created_at
  15362. if v == nil {
  15363. return
  15364. }
  15365. return *v, true
  15366. }
  15367. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  15368. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15370. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15371. if !m.op.Is(OpUpdateOne) {
  15372. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15373. }
  15374. if m.id == nil || m.oldValue == nil {
  15375. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15376. }
  15377. oldValue, err := m.oldValue(ctx)
  15378. if err != nil {
  15379. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15380. }
  15381. return oldValue.CreatedAt, nil
  15382. }
  15383. // ResetCreatedAt resets all changes to the "created_at" field.
  15384. func (m *LabelTaggingMutation) ResetCreatedAt() {
  15385. m.created_at = nil
  15386. }
  15387. // SetUpdatedAt sets the "updated_at" field.
  15388. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  15389. m.updated_at = &t
  15390. }
  15391. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15392. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  15393. v := m.updated_at
  15394. if v == nil {
  15395. return
  15396. }
  15397. return *v, true
  15398. }
  15399. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  15400. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15402. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15403. if !m.op.Is(OpUpdateOne) {
  15404. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15405. }
  15406. if m.id == nil || m.oldValue == nil {
  15407. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15408. }
  15409. oldValue, err := m.oldValue(ctx)
  15410. if err != nil {
  15411. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15412. }
  15413. return oldValue.UpdatedAt, nil
  15414. }
  15415. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15416. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  15417. m.updated_at = nil
  15418. }
  15419. // SetStatus sets the "status" field.
  15420. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  15421. m.status = &u
  15422. m.addstatus = nil
  15423. }
  15424. // Status returns the value of the "status" field in the mutation.
  15425. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  15426. v := m.status
  15427. if v == nil {
  15428. return
  15429. }
  15430. return *v, true
  15431. }
  15432. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  15433. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15435. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15436. if !m.op.Is(OpUpdateOne) {
  15437. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15438. }
  15439. if m.id == nil || m.oldValue == nil {
  15440. return v, errors.New("OldStatus requires an ID field in the mutation")
  15441. }
  15442. oldValue, err := m.oldValue(ctx)
  15443. if err != nil {
  15444. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15445. }
  15446. return oldValue.Status, nil
  15447. }
  15448. // AddStatus adds u to the "status" field.
  15449. func (m *LabelTaggingMutation) AddStatus(u int8) {
  15450. if m.addstatus != nil {
  15451. *m.addstatus += u
  15452. } else {
  15453. m.addstatus = &u
  15454. }
  15455. }
  15456. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15457. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  15458. v := m.addstatus
  15459. if v == nil {
  15460. return
  15461. }
  15462. return *v, true
  15463. }
  15464. // ClearStatus clears the value of the "status" field.
  15465. func (m *LabelTaggingMutation) ClearStatus() {
  15466. m.status = nil
  15467. m.addstatus = nil
  15468. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  15469. }
  15470. // StatusCleared returns if the "status" field was cleared in this mutation.
  15471. func (m *LabelTaggingMutation) StatusCleared() bool {
  15472. _, ok := m.clearedFields[labeltagging.FieldStatus]
  15473. return ok
  15474. }
  15475. // ResetStatus resets all changes to the "status" field.
  15476. func (m *LabelTaggingMutation) ResetStatus() {
  15477. m.status = nil
  15478. m.addstatus = nil
  15479. delete(m.clearedFields, labeltagging.FieldStatus)
  15480. }
  15481. // SetDeletedAt sets the "deleted_at" field.
  15482. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  15483. m.deleted_at = &t
  15484. }
  15485. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15486. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  15487. v := m.deleted_at
  15488. if v == nil {
  15489. return
  15490. }
  15491. return *v, true
  15492. }
  15493. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  15494. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15496. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15497. if !m.op.Is(OpUpdateOne) {
  15498. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15499. }
  15500. if m.id == nil || m.oldValue == nil {
  15501. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15502. }
  15503. oldValue, err := m.oldValue(ctx)
  15504. if err != nil {
  15505. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15506. }
  15507. return oldValue.DeletedAt, nil
  15508. }
  15509. // ClearDeletedAt clears the value of the "deleted_at" field.
  15510. func (m *LabelTaggingMutation) ClearDeletedAt() {
  15511. m.deleted_at = nil
  15512. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  15513. }
  15514. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15515. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  15516. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  15517. return ok
  15518. }
  15519. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15520. func (m *LabelTaggingMutation) ResetDeletedAt() {
  15521. m.deleted_at = nil
  15522. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  15523. }
  15524. // SetOrganizationID sets the "organization_id" field.
  15525. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  15526. m.organization_id = &u
  15527. m.addorganization_id = nil
  15528. }
  15529. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15530. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  15531. v := m.organization_id
  15532. if v == nil {
  15533. return
  15534. }
  15535. return *v, true
  15536. }
  15537. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  15538. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15540. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15541. if !m.op.Is(OpUpdateOne) {
  15542. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15543. }
  15544. if m.id == nil || m.oldValue == nil {
  15545. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15546. }
  15547. oldValue, err := m.oldValue(ctx)
  15548. if err != nil {
  15549. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15550. }
  15551. return oldValue.OrganizationID, nil
  15552. }
  15553. // AddOrganizationID adds u to the "organization_id" field.
  15554. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  15555. if m.addorganization_id != nil {
  15556. *m.addorganization_id += u
  15557. } else {
  15558. m.addorganization_id = &u
  15559. }
  15560. }
  15561. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15562. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  15563. v := m.addorganization_id
  15564. if v == nil {
  15565. return
  15566. }
  15567. return *v, true
  15568. }
  15569. // ResetOrganizationID resets all changes to the "organization_id" field.
  15570. func (m *LabelTaggingMutation) ResetOrganizationID() {
  15571. m.organization_id = nil
  15572. m.addorganization_id = nil
  15573. }
  15574. // SetType sets the "type" field.
  15575. func (m *LabelTaggingMutation) SetType(i int) {
  15576. m._type = &i
  15577. m.add_type = nil
  15578. }
  15579. // GetType returns the value of the "type" field in the mutation.
  15580. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  15581. v := m._type
  15582. if v == nil {
  15583. return
  15584. }
  15585. return *v, true
  15586. }
  15587. // OldType returns the old "type" field's value of the LabelTagging entity.
  15588. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15590. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  15591. if !m.op.Is(OpUpdateOne) {
  15592. return v, errors.New("OldType is only allowed on UpdateOne operations")
  15593. }
  15594. if m.id == nil || m.oldValue == nil {
  15595. return v, errors.New("OldType requires an ID field in the mutation")
  15596. }
  15597. oldValue, err := m.oldValue(ctx)
  15598. if err != nil {
  15599. return v, fmt.Errorf("querying old value for OldType: %w", err)
  15600. }
  15601. return oldValue.Type, nil
  15602. }
  15603. // AddType adds i to the "type" field.
  15604. func (m *LabelTaggingMutation) AddType(i int) {
  15605. if m.add_type != nil {
  15606. *m.add_type += i
  15607. } else {
  15608. m.add_type = &i
  15609. }
  15610. }
  15611. // AddedType returns the value that was added to the "type" field in this mutation.
  15612. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  15613. v := m.add_type
  15614. if v == nil {
  15615. return
  15616. }
  15617. return *v, true
  15618. }
  15619. // ResetType resets all changes to the "type" field.
  15620. func (m *LabelTaggingMutation) ResetType() {
  15621. m._type = nil
  15622. m.add_type = nil
  15623. }
  15624. // SetConditions sets the "conditions" field.
  15625. func (m *LabelTaggingMutation) SetConditions(s string) {
  15626. m.conditions = &s
  15627. }
  15628. // Conditions returns the value of the "conditions" field in the mutation.
  15629. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  15630. v := m.conditions
  15631. if v == nil {
  15632. return
  15633. }
  15634. return *v, true
  15635. }
  15636. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  15637. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15639. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  15640. if !m.op.Is(OpUpdateOne) {
  15641. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  15642. }
  15643. if m.id == nil || m.oldValue == nil {
  15644. return v, errors.New("OldConditions requires an ID field in the mutation")
  15645. }
  15646. oldValue, err := m.oldValue(ctx)
  15647. if err != nil {
  15648. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  15649. }
  15650. return oldValue.Conditions, nil
  15651. }
  15652. // ResetConditions resets all changes to the "conditions" field.
  15653. func (m *LabelTaggingMutation) ResetConditions() {
  15654. m.conditions = nil
  15655. }
  15656. // SetActionLabelAdd sets the "action_label_add" field.
  15657. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  15658. m.action_label_add = &u
  15659. m.appendaction_label_add = nil
  15660. }
  15661. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  15662. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  15663. v := m.action_label_add
  15664. if v == nil {
  15665. return
  15666. }
  15667. return *v, true
  15668. }
  15669. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  15670. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15672. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  15673. if !m.op.Is(OpUpdateOne) {
  15674. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  15675. }
  15676. if m.id == nil || m.oldValue == nil {
  15677. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  15678. }
  15679. oldValue, err := m.oldValue(ctx)
  15680. if err != nil {
  15681. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  15682. }
  15683. return oldValue.ActionLabelAdd, nil
  15684. }
  15685. // AppendActionLabelAdd adds u to the "action_label_add" field.
  15686. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  15687. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  15688. }
  15689. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  15690. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  15691. if len(m.appendaction_label_add) == 0 {
  15692. return nil, false
  15693. }
  15694. return m.appendaction_label_add, true
  15695. }
  15696. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  15697. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  15698. m.action_label_add = nil
  15699. m.appendaction_label_add = nil
  15700. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  15701. }
  15702. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  15703. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  15704. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  15705. return ok
  15706. }
  15707. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  15708. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  15709. m.action_label_add = nil
  15710. m.appendaction_label_add = nil
  15711. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  15712. }
  15713. // SetActionLabelDel sets the "action_label_del" field.
  15714. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  15715. m.action_label_del = &u
  15716. m.appendaction_label_del = nil
  15717. }
  15718. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  15719. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  15720. v := m.action_label_del
  15721. if v == nil {
  15722. return
  15723. }
  15724. return *v, true
  15725. }
  15726. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  15727. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15729. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  15730. if !m.op.Is(OpUpdateOne) {
  15731. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  15732. }
  15733. if m.id == nil || m.oldValue == nil {
  15734. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  15735. }
  15736. oldValue, err := m.oldValue(ctx)
  15737. if err != nil {
  15738. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  15739. }
  15740. return oldValue.ActionLabelDel, nil
  15741. }
  15742. // AppendActionLabelDel adds u to the "action_label_del" field.
  15743. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  15744. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  15745. }
  15746. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  15747. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  15748. if len(m.appendaction_label_del) == 0 {
  15749. return nil, false
  15750. }
  15751. return m.appendaction_label_del, true
  15752. }
  15753. // ClearActionLabelDel clears the value of the "action_label_del" field.
  15754. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  15755. m.action_label_del = nil
  15756. m.appendaction_label_del = nil
  15757. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  15758. }
  15759. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  15760. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  15761. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  15762. return ok
  15763. }
  15764. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  15765. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  15766. m.action_label_del = nil
  15767. m.appendaction_label_del = nil
  15768. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  15769. }
  15770. // Where appends a list predicates to the LabelTaggingMutation builder.
  15771. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  15772. m.predicates = append(m.predicates, ps...)
  15773. }
  15774. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  15775. // users can use type-assertion to append predicates that do not depend on any generated package.
  15776. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  15777. p := make([]predicate.LabelTagging, len(ps))
  15778. for i := range ps {
  15779. p[i] = ps[i]
  15780. }
  15781. m.Where(p...)
  15782. }
  15783. // Op returns the operation name.
  15784. func (m *LabelTaggingMutation) Op() Op {
  15785. return m.op
  15786. }
  15787. // SetOp allows setting the mutation operation.
  15788. func (m *LabelTaggingMutation) SetOp(op Op) {
  15789. m.op = op
  15790. }
  15791. // Type returns the node type of this mutation (LabelTagging).
  15792. func (m *LabelTaggingMutation) Type() string {
  15793. return m.typ
  15794. }
  15795. // Fields returns all fields that were changed during this mutation. Note that in
  15796. // order to get all numeric fields that were incremented/decremented, call
  15797. // AddedFields().
  15798. func (m *LabelTaggingMutation) Fields() []string {
  15799. fields := make([]string, 0, 9)
  15800. if m.created_at != nil {
  15801. fields = append(fields, labeltagging.FieldCreatedAt)
  15802. }
  15803. if m.updated_at != nil {
  15804. fields = append(fields, labeltagging.FieldUpdatedAt)
  15805. }
  15806. if m.status != nil {
  15807. fields = append(fields, labeltagging.FieldStatus)
  15808. }
  15809. if m.deleted_at != nil {
  15810. fields = append(fields, labeltagging.FieldDeletedAt)
  15811. }
  15812. if m.organization_id != nil {
  15813. fields = append(fields, labeltagging.FieldOrganizationID)
  15814. }
  15815. if m._type != nil {
  15816. fields = append(fields, labeltagging.FieldType)
  15817. }
  15818. if m.conditions != nil {
  15819. fields = append(fields, labeltagging.FieldConditions)
  15820. }
  15821. if m.action_label_add != nil {
  15822. fields = append(fields, labeltagging.FieldActionLabelAdd)
  15823. }
  15824. if m.action_label_del != nil {
  15825. fields = append(fields, labeltagging.FieldActionLabelDel)
  15826. }
  15827. return fields
  15828. }
  15829. // Field returns the value of a field with the given name. The second boolean
  15830. // return value indicates that this field was not set, or was not defined in the
  15831. // schema.
  15832. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  15833. switch name {
  15834. case labeltagging.FieldCreatedAt:
  15835. return m.CreatedAt()
  15836. case labeltagging.FieldUpdatedAt:
  15837. return m.UpdatedAt()
  15838. case labeltagging.FieldStatus:
  15839. return m.Status()
  15840. case labeltagging.FieldDeletedAt:
  15841. return m.DeletedAt()
  15842. case labeltagging.FieldOrganizationID:
  15843. return m.OrganizationID()
  15844. case labeltagging.FieldType:
  15845. return m.GetType()
  15846. case labeltagging.FieldConditions:
  15847. return m.Conditions()
  15848. case labeltagging.FieldActionLabelAdd:
  15849. return m.ActionLabelAdd()
  15850. case labeltagging.FieldActionLabelDel:
  15851. return m.ActionLabelDel()
  15852. }
  15853. return nil, false
  15854. }
  15855. // OldField returns the old value of the field from the database. An error is
  15856. // returned if the mutation operation is not UpdateOne, or the query to the
  15857. // database failed.
  15858. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15859. switch name {
  15860. case labeltagging.FieldCreatedAt:
  15861. return m.OldCreatedAt(ctx)
  15862. case labeltagging.FieldUpdatedAt:
  15863. return m.OldUpdatedAt(ctx)
  15864. case labeltagging.FieldStatus:
  15865. return m.OldStatus(ctx)
  15866. case labeltagging.FieldDeletedAt:
  15867. return m.OldDeletedAt(ctx)
  15868. case labeltagging.FieldOrganizationID:
  15869. return m.OldOrganizationID(ctx)
  15870. case labeltagging.FieldType:
  15871. return m.OldType(ctx)
  15872. case labeltagging.FieldConditions:
  15873. return m.OldConditions(ctx)
  15874. case labeltagging.FieldActionLabelAdd:
  15875. return m.OldActionLabelAdd(ctx)
  15876. case labeltagging.FieldActionLabelDel:
  15877. return m.OldActionLabelDel(ctx)
  15878. }
  15879. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  15880. }
  15881. // SetField sets the value of a field with the given name. It returns an error if
  15882. // the field is not defined in the schema, or if the type mismatched the field
  15883. // type.
  15884. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  15885. switch name {
  15886. case labeltagging.FieldCreatedAt:
  15887. v, ok := value.(time.Time)
  15888. if !ok {
  15889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15890. }
  15891. m.SetCreatedAt(v)
  15892. return nil
  15893. case labeltagging.FieldUpdatedAt:
  15894. v, ok := value.(time.Time)
  15895. if !ok {
  15896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15897. }
  15898. m.SetUpdatedAt(v)
  15899. return nil
  15900. case labeltagging.FieldStatus:
  15901. v, ok := value.(uint8)
  15902. if !ok {
  15903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15904. }
  15905. m.SetStatus(v)
  15906. return nil
  15907. case labeltagging.FieldDeletedAt:
  15908. v, ok := value.(time.Time)
  15909. if !ok {
  15910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15911. }
  15912. m.SetDeletedAt(v)
  15913. return nil
  15914. case labeltagging.FieldOrganizationID:
  15915. v, ok := value.(uint64)
  15916. if !ok {
  15917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15918. }
  15919. m.SetOrganizationID(v)
  15920. return nil
  15921. case labeltagging.FieldType:
  15922. v, ok := value.(int)
  15923. if !ok {
  15924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15925. }
  15926. m.SetType(v)
  15927. return nil
  15928. case labeltagging.FieldConditions:
  15929. v, ok := value.(string)
  15930. if !ok {
  15931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15932. }
  15933. m.SetConditions(v)
  15934. return nil
  15935. case labeltagging.FieldActionLabelAdd:
  15936. v, ok := value.([]uint64)
  15937. if !ok {
  15938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15939. }
  15940. m.SetActionLabelAdd(v)
  15941. return nil
  15942. case labeltagging.FieldActionLabelDel:
  15943. v, ok := value.([]uint64)
  15944. if !ok {
  15945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15946. }
  15947. m.SetActionLabelDel(v)
  15948. return nil
  15949. }
  15950. return fmt.Errorf("unknown LabelTagging field %s", name)
  15951. }
  15952. // AddedFields returns all numeric fields that were incremented/decremented during
  15953. // this mutation.
  15954. func (m *LabelTaggingMutation) AddedFields() []string {
  15955. var fields []string
  15956. if m.addstatus != nil {
  15957. fields = append(fields, labeltagging.FieldStatus)
  15958. }
  15959. if m.addorganization_id != nil {
  15960. fields = append(fields, labeltagging.FieldOrganizationID)
  15961. }
  15962. if m.add_type != nil {
  15963. fields = append(fields, labeltagging.FieldType)
  15964. }
  15965. return fields
  15966. }
  15967. // AddedField returns the numeric value that was incremented/decremented on a field
  15968. // with the given name. The second boolean return value indicates that this field
  15969. // was not set, or was not defined in the schema.
  15970. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  15971. switch name {
  15972. case labeltagging.FieldStatus:
  15973. return m.AddedStatus()
  15974. case labeltagging.FieldOrganizationID:
  15975. return m.AddedOrganizationID()
  15976. case labeltagging.FieldType:
  15977. return m.AddedType()
  15978. }
  15979. return nil, false
  15980. }
  15981. // AddField adds the value to the field with the given name. It returns an error if
  15982. // the field is not defined in the schema, or if the type mismatched the field
  15983. // type.
  15984. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  15985. switch name {
  15986. case labeltagging.FieldStatus:
  15987. v, ok := value.(int8)
  15988. if !ok {
  15989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15990. }
  15991. m.AddStatus(v)
  15992. return nil
  15993. case labeltagging.FieldOrganizationID:
  15994. v, ok := value.(int64)
  15995. if !ok {
  15996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15997. }
  15998. m.AddOrganizationID(v)
  15999. return nil
  16000. case labeltagging.FieldType:
  16001. v, ok := value.(int)
  16002. if !ok {
  16003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16004. }
  16005. m.AddType(v)
  16006. return nil
  16007. }
  16008. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  16009. }
  16010. // ClearedFields returns all nullable fields that were cleared during this
  16011. // mutation.
  16012. func (m *LabelTaggingMutation) ClearedFields() []string {
  16013. var fields []string
  16014. if m.FieldCleared(labeltagging.FieldStatus) {
  16015. fields = append(fields, labeltagging.FieldStatus)
  16016. }
  16017. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  16018. fields = append(fields, labeltagging.FieldDeletedAt)
  16019. }
  16020. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  16021. fields = append(fields, labeltagging.FieldActionLabelAdd)
  16022. }
  16023. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  16024. fields = append(fields, labeltagging.FieldActionLabelDel)
  16025. }
  16026. return fields
  16027. }
  16028. // FieldCleared returns a boolean indicating if a field with the given name was
  16029. // cleared in this mutation.
  16030. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  16031. _, ok := m.clearedFields[name]
  16032. return ok
  16033. }
  16034. // ClearField clears the value of the field with the given name. It returns an
  16035. // error if the field is not defined in the schema.
  16036. func (m *LabelTaggingMutation) ClearField(name string) error {
  16037. switch name {
  16038. case labeltagging.FieldStatus:
  16039. m.ClearStatus()
  16040. return nil
  16041. case labeltagging.FieldDeletedAt:
  16042. m.ClearDeletedAt()
  16043. return nil
  16044. case labeltagging.FieldActionLabelAdd:
  16045. m.ClearActionLabelAdd()
  16046. return nil
  16047. case labeltagging.FieldActionLabelDel:
  16048. m.ClearActionLabelDel()
  16049. return nil
  16050. }
  16051. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  16052. }
  16053. // ResetField resets all changes in the mutation for the field with the given name.
  16054. // It returns an error if the field is not defined in the schema.
  16055. func (m *LabelTaggingMutation) ResetField(name string) error {
  16056. switch name {
  16057. case labeltagging.FieldCreatedAt:
  16058. m.ResetCreatedAt()
  16059. return nil
  16060. case labeltagging.FieldUpdatedAt:
  16061. m.ResetUpdatedAt()
  16062. return nil
  16063. case labeltagging.FieldStatus:
  16064. m.ResetStatus()
  16065. return nil
  16066. case labeltagging.FieldDeletedAt:
  16067. m.ResetDeletedAt()
  16068. return nil
  16069. case labeltagging.FieldOrganizationID:
  16070. m.ResetOrganizationID()
  16071. return nil
  16072. case labeltagging.FieldType:
  16073. m.ResetType()
  16074. return nil
  16075. case labeltagging.FieldConditions:
  16076. m.ResetConditions()
  16077. return nil
  16078. case labeltagging.FieldActionLabelAdd:
  16079. m.ResetActionLabelAdd()
  16080. return nil
  16081. case labeltagging.FieldActionLabelDel:
  16082. m.ResetActionLabelDel()
  16083. return nil
  16084. }
  16085. return fmt.Errorf("unknown LabelTagging field %s", name)
  16086. }
  16087. // AddedEdges returns all edge names that were set/added in this mutation.
  16088. func (m *LabelTaggingMutation) AddedEdges() []string {
  16089. edges := make([]string, 0, 0)
  16090. return edges
  16091. }
  16092. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16093. // name in this mutation.
  16094. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  16095. return nil
  16096. }
  16097. // RemovedEdges returns all edge names that were removed in this mutation.
  16098. func (m *LabelTaggingMutation) RemovedEdges() []string {
  16099. edges := make([]string, 0, 0)
  16100. return edges
  16101. }
  16102. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16103. // the given name in this mutation.
  16104. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  16105. return nil
  16106. }
  16107. // ClearedEdges returns all edge names that were cleared in this mutation.
  16108. func (m *LabelTaggingMutation) ClearedEdges() []string {
  16109. edges := make([]string, 0, 0)
  16110. return edges
  16111. }
  16112. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16113. // was cleared in this mutation.
  16114. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  16115. return false
  16116. }
  16117. // ClearEdge clears the value of the edge with the given name. It returns an error
  16118. // if that edge is not defined in the schema.
  16119. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  16120. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  16121. }
  16122. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16123. // It returns an error if the edge is not defined in the schema.
  16124. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  16125. return fmt.Errorf("unknown LabelTagging edge %s", name)
  16126. }
  16127. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  16128. type MessageMutation struct {
  16129. config
  16130. op Op
  16131. typ string
  16132. id *int
  16133. wx_wxid *string
  16134. wxid *string
  16135. content *string
  16136. clearedFields map[string]struct{}
  16137. done bool
  16138. oldValue func(context.Context) (*Message, error)
  16139. predicates []predicate.Message
  16140. }
  16141. var _ ent.Mutation = (*MessageMutation)(nil)
  16142. // messageOption allows management of the mutation configuration using functional options.
  16143. type messageOption func(*MessageMutation)
  16144. // newMessageMutation creates new mutation for the Message entity.
  16145. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  16146. m := &MessageMutation{
  16147. config: c,
  16148. op: op,
  16149. typ: TypeMessage,
  16150. clearedFields: make(map[string]struct{}),
  16151. }
  16152. for _, opt := range opts {
  16153. opt(m)
  16154. }
  16155. return m
  16156. }
  16157. // withMessageID sets the ID field of the mutation.
  16158. func withMessageID(id int) messageOption {
  16159. return func(m *MessageMutation) {
  16160. var (
  16161. err error
  16162. once sync.Once
  16163. value *Message
  16164. )
  16165. m.oldValue = func(ctx context.Context) (*Message, error) {
  16166. once.Do(func() {
  16167. if m.done {
  16168. err = errors.New("querying old values post mutation is not allowed")
  16169. } else {
  16170. value, err = m.Client().Message.Get(ctx, id)
  16171. }
  16172. })
  16173. return value, err
  16174. }
  16175. m.id = &id
  16176. }
  16177. }
  16178. // withMessage sets the old Message of the mutation.
  16179. func withMessage(node *Message) messageOption {
  16180. return func(m *MessageMutation) {
  16181. m.oldValue = func(context.Context) (*Message, error) {
  16182. return node, nil
  16183. }
  16184. m.id = &node.ID
  16185. }
  16186. }
  16187. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16188. // executed in a transaction (ent.Tx), a transactional client is returned.
  16189. func (m MessageMutation) Client() *Client {
  16190. client := &Client{config: m.config}
  16191. client.init()
  16192. return client
  16193. }
  16194. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16195. // it returns an error otherwise.
  16196. func (m MessageMutation) Tx() (*Tx, error) {
  16197. if _, ok := m.driver.(*txDriver); !ok {
  16198. return nil, errors.New("ent: mutation is not running in a transaction")
  16199. }
  16200. tx := &Tx{config: m.config}
  16201. tx.init()
  16202. return tx, nil
  16203. }
  16204. // ID returns the ID value in the mutation. Note that the ID is only available
  16205. // if it was provided to the builder or after it was returned from the database.
  16206. func (m *MessageMutation) ID() (id int, exists bool) {
  16207. if m.id == nil {
  16208. return
  16209. }
  16210. return *m.id, true
  16211. }
  16212. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16213. // That means, if the mutation is applied within a transaction with an isolation level such
  16214. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16215. // or updated by the mutation.
  16216. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  16217. switch {
  16218. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16219. id, exists := m.ID()
  16220. if exists {
  16221. return []int{id}, nil
  16222. }
  16223. fallthrough
  16224. case m.op.Is(OpUpdate | OpDelete):
  16225. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  16226. default:
  16227. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16228. }
  16229. }
  16230. // SetWxWxid sets the "wx_wxid" field.
  16231. func (m *MessageMutation) SetWxWxid(s string) {
  16232. m.wx_wxid = &s
  16233. }
  16234. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  16235. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  16236. v := m.wx_wxid
  16237. if v == nil {
  16238. return
  16239. }
  16240. return *v, true
  16241. }
  16242. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  16243. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16245. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  16246. if !m.op.Is(OpUpdateOne) {
  16247. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  16248. }
  16249. if m.id == nil || m.oldValue == nil {
  16250. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  16251. }
  16252. oldValue, err := m.oldValue(ctx)
  16253. if err != nil {
  16254. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  16255. }
  16256. return oldValue.WxWxid, nil
  16257. }
  16258. // ClearWxWxid clears the value of the "wx_wxid" field.
  16259. func (m *MessageMutation) ClearWxWxid() {
  16260. m.wx_wxid = nil
  16261. m.clearedFields[message.FieldWxWxid] = struct{}{}
  16262. }
  16263. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  16264. func (m *MessageMutation) WxWxidCleared() bool {
  16265. _, ok := m.clearedFields[message.FieldWxWxid]
  16266. return ok
  16267. }
  16268. // ResetWxWxid resets all changes to the "wx_wxid" field.
  16269. func (m *MessageMutation) ResetWxWxid() {
  16270. m.wx_wxid = nil
  16271. delete(m.clearedFields, message.FieldWxWxid)
  16272. }
  16273. // SetWxid sets the "wxid" field.
  16274. func (m *MessageMutation) SetWxid(s string) {
  16275. m.wxid = &s
  16276. }
  16277. // Wxid returns the value of the "wxid" field in the mutation.
  16278. func (m *MessageMutation) Wxid() (r string, exists bool) {
  16279. v := m.wxid
  16280. if v == nil {
  16281. return
  16282. }
  16283. return *v, true
  16284. }
  16285. // OldWxid returns the old "wxid" field's value of the Message entity.
  16286. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16288. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  16289. if !m.op.Is(OpUpdateOne) {
  16290. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  16291. }
  16292. if m.id == nil || m.oldValue == nil {
  16293. return v, errors.New("OldWxid requires an ID field in the mutation")
  16294. }
  16295. oldValue, err := m.oldValue(ctx)
  16296. if err != nil {
  16297. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  16298. }
  16299. return oldValue.Wxid, nil
  16300. }
  16301. // ResetWxid resets all changes to the "wxid" field.
  16302. func (m *MessageMutation) ResetWxid() {
  16303. m.wxid = nil
  16304. }
  16305. // SetContent sets the "content" field.
  16306. func (m *MessageMutation) SetContent(s string) {
  16307. m.content = &s
  16308. }
  16309. // Content returns the value of the "content" field in the mutation.
  16310. func (m *MessageMutation) Content() (r string, exists bool) {
  16311. v := m.content
  16312. if v == nil {
  16313. return
  16314. }
  16315. return *v, true
  16316. }
  16317. // OldContent returns the old "content" field's value of the Message entity.
  16318. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16320. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  16321. if !m.op.Is(OpUpdateOne) {
  16322. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  16323. }
  16324. if m.id == nil || m.oldValue == nil {
  16325. return v, errors.New("OldContent requires an ID field in the mutation")
  16326. }
  16327. oldValue, err := m.oldValue(ctx)
  16328. if err != nil {
  16329. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  16330. }
  16331. return oldValue.Content, nil
  16332. }
  16333. // ResetContent resets all changes to the "content" field.
  16334. func (m *MessageMutation) ResetContent() {
  16335. m.content = nil
  16336. }
  16337. // Where appends a list predicates to the MessageMutation builder.
  16338. func (m *MessageMutation) Where(ps ...predicate.Message) {
  16339. m.predicates = append(m.predicates, ps...)
  16340. }
  16341. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  16342. // users can use type-assertion to append predicates that do not depend on any generated package.
  16343. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  16344. p := make([]predicate.Message, len(ps))
  16345. for i := range ps {
  16346. p[i] = ps[i]
  16347. }
  16348. m.Where(p...)
  16349. }
  16350. // Op returns the operation name.
  16351. func (m *MessageMutation) Op() Op {
  16352. return m.op
  16353. }
  16354. // SetOp allows setting the mutation operation.
  16355. func (m *MessageMutation) SetOp(op Op) {
  16356. m.op = op
  16357. }
  16358. // Type returns the node type of this mutation (Message).
  16359. func (m *MessageMutation) Type() string {
  16360. return m.typ
  16361. }
  16362. // Fields returns all fields that were changed during this mutation. Note that in
  16363. // order to get all numeric fields that were incremented/decremented, call
  16364. // AddedFields().
  16365. func (m *MessageMutation) Fields() []string {
  16366. fields := make([]string, 0, 3)
  16367. if m.wx_wxid != nil {
  16368. fields = append(fields, message.FieldWxWxid)
  16369. }
  16370. if m.wxid != nil {
  16371. fields = append(fields, message.FieldWxid)
  16372. }
  16373. if m.content != nil {
  16374. fields = append(fields, message.FieldContent)
  16375. }
  16376. return fields
  16377. }
  16378. // Field returns the value of a field with the given name. The second boolean
  16379. // return value indicates that this field was not set, or was not defined in the
  16380. // schema.
  16381. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  16382. switch name {
  16383. case message.FieldWxWxid:
  16384. return m.WxWxid()
  16385. case message.FieldWxid:
  16386. return m.Wxid()
  16387. case message.FieldContent:
  16388. return m.Content()
  16389. }
  16390. return nil, false
  16391. }
  16392. // OldField returns the old value of the field from the database. An error is
  16393. // returned if the mutation operation is not UpdateOne, or the query to the
  16394. // database failed.
  16395. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16396. switch name {
  16397. case message.FieldWxWxid:
  16398. return m.OldWxWxid(ctx)
  16399. case message.FieldWxid:
  16400. return m.OldWxid(ctx)
  16401. case message.FieldContent:
  16402. return m.OldContent(ctx)
  16403. }
  16404. return nil, fmt.Errorf("unknown Message field %s", name)
  16405. }
  16406. // SetField sets the value of a field with the given name. It returns an error if
  16407. // the field is not defined in the schema, or if the type mismatched the field
  16408. // type.
  16409. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  16410. switch name {
  16411. case message.FieldWxWxid:
  16412. v, ok := value.(string)
  16413. if !ok {
  16414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16415. }
  16416. m.SetWxWxid(v)
  16417. return nil
  16418. case message.FieldWxid:
  16419. v, ok := value.(string)
  16420. if !ok {
  16421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16422. }
  16423. m.SetWxid(v)
  16424. return nil
  16425. case message.FieldContent:
  16426. v, ok := value.(string)
  16427. if !ok {
  16428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16429. }
  16430. m.SetContent(v)
  16431. return nil
  16432. }
  16433. return fmt.Errorf("unknown Message field %s", name)
  16434. }
  16435. // AddedFields returns all numeric fields that were incremented/decremented during
  16436. // this mutation.
  16437. func (m *MessageMutation) AddedFields() []string {
  16438. return nil
  16439. }
  16440. // AddedField returns the numeric value that was incremented/decremented on a field
  16441. // with the given name. The second boolean return value indicates that this field
  16442. // was not set, or was not defined in the schema.
  16443. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  16444. return nil, false
  16445. }
  16446. // AddField adds the value to the field with the given name. It returns an error if
  16447. // the field is not defined in the schema, or if the type mismatched the field
  16448. // type.
  16449. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  16450. switch name {
  16451. }
  16452. return fmt.Errorf("unknown Message numeric field %s", name)
  16453. }
  16454. // ClearedFields returns all nullable fields that were cleared during this
  16455. // mutation.
  16456. func (m *MessageMutation) ClearedFields() []string {
  16457. var fields []string
  16458. if m.FieldCleared(message.FieldWxWxid) {
  16459. fields = append(fields, message.FieldWxWxid)
  16460. }
  16461. return fields
  16462. }
  16463. // FieldCleared returns a boolean indicating if a field with the given name was
  16464. // cleared in this mutation.
  16465. func (m *MessageMutation) FieldCleared(name string) bool {
  16466. _, ok := m.clearedFields[name]
  16467. return ok
  16468. }
  16469. // ClearField clears the value of the field with the given name. It returns an
  16470. // error if the field is not defined in the schema.
  16471. func (m *MessageMutation) ClearField(name string) error {
  16472. switch name {
  16473. case message.FieldWxWxid:
  16474. m.ClearWxWxid()
  16475. return nil
  16476. }
  16477. return fmt.Errorf("unknown Message nullable field %s", name)
  16478. }
  16479. // ResetField resets all changes in the mutation for the field with the given name.
  16480. // It returns an error if the field is not defined in the schema.
  16481. func (m *MessageMutation) ResetField(name string) error {
  16482. switch name {
  16483. case message.FieldWxWxid:
  16484. m.ResetWxWxid()
  16485. return nil
  16486. case message.FieldWxid:
  16487. m.ResetWxid()
  16488. return nil
  16489. case message.FieldContent:
  16490. m.ResetContent()
  16491. return nil
  16492. }
  16493. return fmt.Errorf("unknown Message field %s", name)
  16494. }
  16495. // AddedEdges returns all edge names that were set/added in this mutation.
  16496. func (m *MessageMutation) AddedEdges() []string {
  16497. edges := make([]string, 0, 0)
  16498. return edges
  16499. }
  16500. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16501. // name in this mutation.
  16502. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  16503. return nil
  16504. }
  16505. // RemovedEdges returns all edge names that were removed in this mutation.
  16506. func (m *MessageMutation) RemovedEdges() []string {
  16507. edges := make([]string, 0, 0)
  16508. return edges
  16509. }
  16510. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16511. // the given name in this mutation.
  16512. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  16513. return nil
  16514. }
  16515. // ClearedEdges returns all edge names that were cleared in this mutation.
  16516. func (m *MessageMutation) ClearedEdges() []string {
  16517. edges := make([]string, 0, 0)
  16518. return edges
  16519. }
  16520. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16521. // was cleared in this mutation.
  16522. func (m *MessageMutation) EdgeCleared(name string) bool {
  16523. return false
  16524. }
  16525. // ClearEdge clears the value of the edge with the given name. It returns an error
  16526. // if that edge is not defined in the schema.
  16527. func (m *MessageMutation) ClearEdge(name string) error {
  16528. return fmt.Errorf("unknown Message unique edge %s", name)
  16529. }
  16530. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16531. // It returns an error if the edge is not defined in the schema.
  16532. func (m *MessageMutation) ResetEdge(name string) error {
  16533. return fmt.Errorf("unknown Message edge %s", name)
  16534. }
  16535. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  16536. type MessageRecordsMutation struct {
  16537. config
  16538. op Op
  16539. typ string
  16540. id *uint64
  16541. created_at *time.Time
  16542. updated_at *time.Time
  16543. status *uint8
  16544. addstatus *int8
  16545. bot_wxid *string
  16546. contact_type *int
  16547. addcontact_type *int
  16548. contact_wxid *string
  16549. content_type *int
  16550. addcontent_type *int
  16551. content *string
  16552. meta *custom_types.Meta
  16553. error_detail *string
  16554. send_time *time.Time
  16555. source_type *int
  16556. addsource_type *int
  16557. organization_id *uint64
  16558. addorganization_id *int64
  16559. clearedFields map[string]struct{}
  16560. sop_stage *uint64
  16561. clearedsop_stage bool
  16562. sop_node *uint64
  16563. clearedsop_node bool
  16564. message_contact *uint64
  16565. clearedmessage_contact bool
  16566. done bool
  16567. oldValue func(context.Context) (*MessageRecords, error)
  16568. predicates []predicate.MessageRecords
  16569. }
  16570. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  16571. // messagerecordsOption allows management of the mutation configuration using functional options.
  16572. type messagerecordsOption func(*MessageRecordsMutation)
  16573. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  16574. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  16575. m := &MessageRecordsMutation{
  16576. config: c,
  16577. op: op,
  16578. typ: TypeMessageRecords,
  16579. clearedFields: make(map[string]struct{}),
  16580. }
  16581. for _, opt := range opts {
  16582. opt(m)
  16583. }
  16584. return m
  16585. }
  16586. // withMessageRecordsID sets the ID field of the mutation.
  16587. func withMessageRecordsID(id uint64) messagerecordsOption {
  16588. return func(m *MessageRecordsMutation) {
  16589. var (
  16590. err error
  16591. once sync.Once
  16592. value *MessageRecords
  16593. )
  16594. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  16595. once.Do(func() {
  16596. if m.done {
  16597. err = errors.New("querying old values post mutation is not allowed")
  16598. } else {
  16599. value, err = m.Client().MessageRecords.Get(ctx, id)
  16600. }
  16601. })
  16602. return value, err
  16603. }
  16604. m.id = &id
  16605. }
  16606. }
  16607. // withMessageRecords sets the old MessageRecords of the mutation.
  16608. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  16609. return func(m *MessageRecordsMutation) {
  16610. m.oldValue = func(context.Context) (*MessageRecords, error) {
  16611. return node, nil
  16612. }
  16613. m.id = &node.ID
  16614. }
  16615. }
  16616. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16617. // executed in a transaction (ent.Tx), a transactional client is returned.
  16618. func (m MessageRecordsMutation) Client() *Client {
  16619. client := &Client{config: m.config}
  16620. client.init()
  16621. return client
  16622. }
  16623. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16624. // it returns an error otherwise.
  16625. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  16626. if _, ok := m.driver.(*txDriver); !ok {
  16627. return nil, errors.New("ent: mutation is not running in a transaction")
  16628. }
  16629. tx := &Tx{config: m.config}
  16630. tx.init()
  16631. return tx, nil
  16632. }
  16633. // SetID sets the value of the id field. Note that this
  16634. // operation is only accepted on creation of MessageRecords entities.
  16635. func (m *MessageRecordsMutation) SetID(id uint64) {
  16636. m.id = &id
  16637. }
  16638. // ID returns the ID value in the mutation. Note that the ID is only available
  16639. // if it was provided to the builder or after it was returned from the database.
  16640. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  16641. if m.id == nil {
  16642. return
  16643. }
  16644. return *m.id, true
  16645. }
  16646. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16647. // That means, if the mutation is applied within a transaction with an isolation level such
  16648. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16649. // or updated by the mutation.
  16650. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  16651. switch {
  16652. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16653. id, exists := m.ID()
  16654. if exists {
  16655. return []uint64{id}, nil
  16656. }
  16657. fallthrough
  16658. case m.op.Is(OpUpdate | OpDelete):
  16659. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  16660. default:
  16661. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16662. }
  16663. }
  16664. // SetCreatedAt sets the "created_at" field.
  16665. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  16666. m.created_at = &t
  16667. }
  16668. // CreatedAt returns the value of the "created_at" field in the mutation.
  16669. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  16670. v := m.created_at
  16671. if v == nil {
  16672. return
  16673. }
  16674. return *v, true
  16675. }
  16676. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  16677. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16679. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16680. if !m.op.Is(OpUpdateOne) {
  16681. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16682. }
  16683. if m.id == nil || m.oldValue == nil {
  16684. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16685. }
  16686. oldValue, err := m.oldValue(ctx)
  16687. if err != nil {
  16688. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16689. }
  16690. return oldValue.CreatedAt, nil
  16691. }
  16692. // ResetCreatedAt resets all changes to the "created_at" field.
  16693. func (m *MessageRecordsMutation) ResetCreatedAt() {
  16694. m.created_at = nil
  16695. }
  16696. // SetUpdatedAt sets the "updated_at" field.
  16697. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  16698. m.updated_at = &t
  16699. }
  16700. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16701. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  16702. v := m.updated_at
  16703. if v == nil {
  16704. return
  16705. }
  16706. return *v, true
  16707. }
  16708. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  16709. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16711. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16712. if !m.op.Is(OpUpdateOne) {
  16713. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16714. }
  16715. if m.id == nil || m.oldValue == nil {
  16716. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16717. }
  16718. oldValue, err := m.oldValue(ctx)
  16719. if err != nil {
  16720. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16721. }
  16722. return oldValue.UpdatedAt, nil
  16723. }
  16724. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16725. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  16726. m.updated_at = nil
  16727. }
  16728. // SetStatus sets the "status" field.
  16729. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  16730. m.status = &u
  16731. m.addstatus = nil
  16732. }
  16733. // Status returns the value of the "status" field in the mutation.
  16734. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  16735. v := m.status
  16736. if v == nil {
  16737. return
  16738. }
  16739. return *v, true
  16740. }
  16741. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  16742. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16744. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16745. if !m.op.Is(OpUpdateOne) {
  16746. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16747. }
  16748. if m.id == nil || m.oldValue == nil {
  16749. return v, errors.New("OldStatus requires an ID field in the mutation")
  16750. }
  16751. oldValue, err := m.oldValue(ctx)
  16752. if err != nil {
  16753. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16754. }
  16755. return oldValue.Status, nil
  16756. }
  16757. // AddStatus adds u to the "status" field.
  16758. func (m *MessageRecordsMutation) AddStatus(u int8) {
  16759. if m.addstatus != nil {
  16760. *m.addstatus += u
  16761. } else {
  16762. m.addstatus = &u
  16763. }
  16764. }
  16765. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16766. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  16767. v := m.addstatus
  16768. if v == nil {
  16769. return
  16770. }
  16771. return *v, true
  16772. }
  16773. // ClearStatus clears the value of the "status" field.
  16774. func (m *MessageRecordsMutation) ClearStatus() {
  16775. m.status = nil
  16776. m.addstatus = nil
  16777. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  16778. }
  16779. // StatusCleared returns if the "status" field was cleared in this mutation.
  16780. func (m *MessageRecordsMutation) StatusCleared() bool {
  16781. _, ok := m.clearedFields[messagerecords.FieldStatus]
  16782. return ok
  16783. }
  16784. // ResetStatus resets all changes to the "status" field.
  16785. func (m *MessageRecordsMutation) ResetStatus() {
  16786. m.status = nil
  16787. m.addstatus = nil
  16788. delete(m.clearedFields, messagerecords.FieldStatus)
  16789. }
  16790. // SetBotWxid sets the "bot_wxid" field.
  16791. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  16792. m.bot_wxid = &s
  16793. }
  16794. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  16795. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  16796. v := m.bot_wxid
  16797. if v == nil {
  16798. return
  16799. }
  16800. return *v, true
  16801. }
  16802. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  16803. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16805. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  16806. if !m.op.Is(OpUpdateOne) {
  16807. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  16808. }
  16809. if m.id == nil || m.oldValue == nil {
  16810. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  16811. }
  16812. oldValue, err := m.oldValue(ctx)
  16813. if err != nil {
  16814. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  16815. }
  16816. return oldValue.BotWxid, nil
  16817. }
  16818. // ResetBotWxid resets all changes to the "bot_wxid" field.
  16819. func (m *MessageRecordsMutation) ResetBotWxid() {
  16820. m.bot_wxid = nil
  16821. }
  16822. // SetContactID sets the "contact_id" field.
  16823. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  16824. m.message_contact = &u
  16825. }
  16826. // ContactID returns the value of the "contact_id" field in the mutation.
  16827. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  16828. v := m.message_contact
  16829. if v == nil {
  16830. return
  16831. }
  16832. return *v, true
  16833. }
  16834. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  16835. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16837. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  16838. if !m.op.Is(OpUpdateOne) {
  16839. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  16840. }
  16841. if m.id == nil || m.oldValue == nil {
  16842. return v, errors.New("OldContactID requires an ID field in the mutation")
  16843. }
  16844. oldValue, err := m.oldValue(ctx)
  16845. if err != nil {
  16846. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  16847. }
  16848. return oldValue.ContactID, nil
  16849. }
  16850. // ClearContactID clears the value of the "contact_id" field.
  16851. func (m *MessageRecordsMutation) ClearContactID() {
  16852. m.message_contact = nil
  16853. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  16854. }
  16855. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  16856. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  16857. _, ok := m.clearedFields[messagerecords.FieldContactID]
  16858. return ok
  16859. }
  16860. // ResetContactID resets all changes to the "contact_id" field.
  16861. func (m *MessageRecordsMutation) ResetContactID() {
  16862. m.message_contact = nil
  16863. delete(m.clearedFields, messagerecords.FieldContactID)
  16864. }
  16865. // SetContactType sets the "contact_type" field.
  16866. func (m *MessageRecordsMutation) SetContactType(i int) {
  16867. m.contact_type = &i
  16868. m.addcontact_type = nil
  16869. }
  16870. // ContactType returns the value of the "contact_type" field in the mutation.
  16871. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  16872. v := m.contact_type
  16873. if v == nil {
  16874. return
  16875. }
  16876. return *v, true
  16877. }
  16878. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  16879. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16881. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  16882. if !m.op.Is(OpUpdateOne) {
  16883. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  16884. }
  16885. if m.id == nil || m.oldValue == nil {
  16886. return v, errors.New("OldContactType requires an ID field in the mutation")
  16887. }
  16888. oldValue, err := m.oldValue(ctx)
  16889. if err != nil {
  16890. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  16891. }
  16892. return oldValue.ContactType, nil
  16893. }
  16894. // AddContactType adds i to the "contact_type" field.
  16895. func (m *MessageRecordsMutation) AddContactType(i int) {
  16896. if m.addcontact_type != nil {
  16897. *m.addcontact_type += i
  16898. } else {
  16899. m.addcontact_type = &i
  16900. }
  16901. }
  16902. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  16903. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  16904. v := m.addcontact_type
  16905. if v == nil {
  16906. return
  16907. }
  16908. return *v, true
  16909. }
  16910. // ResetContactType resets all changes to the "contact_type" field.
  16911. func (m *MessageRecordsMutation) ResetContactType() {
  16912. m.contact_type = nil
  16913. m.addcontact_type = nil
  16914. }
  16915. // SetContactWxid sets the "contact_wxid" field.
  16916. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  16917. m.contact_wxid = &s
  16918. }
  16919. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  16920. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  16921. v := m.contact_wxid
  16922. if v == nil {
  16923. return
  16924. }
  16925. return *v, true
  16926. }
  16927. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  16928. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16930. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  16931. if !m.op.Is(OpUpdateOne) {
  16932. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  16933. }
  16934. if m.id == nil || m.oldValue == nil {
  16935. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  16936. }
  16937. oldValue, err := m.oldValue(ctx)
  16938. if err != nil {
  16939. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  16940. }
  16941. return oldValue.ContactWxid, nil
  16942. }
  16943. // ResetContactWxid resets all changes to the "contact_wxid" field.
  16944. func (m *MessageRecordsMutation) ResetContactWxid() {
  16945. m.contact_wxid = nil
  16946. }
  16947. // SetContentType sets the "content_type" field.
  16948. func (m *MessageRecordsMutation) SetContentType(i int) {
  16949. m.content_type = &i
  16950. m.addcontent_type = nil
  16951. }
  16952. // ContentType returns the value of the "content_type" field in the mutation.
  16953. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  16954. v := m.content_type
  16955. if v == nil {
  16956. return
  16957. }
  16958. return *v, true
  16959. }
  16960. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  16961. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16962. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16963. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  16964. if !m.op.Is(OpUpdateOne) {
  16965. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  16966. }
  16967. if m.id == nil || m.oldValue == nil {
  16968. return v, errors.New("OldContentType requires an ID field in the mutation")
  16969. }
  16970. oldValue, err := m.oldValue(ctx)
  16971. if err != nil {
  16972. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  16973. }
  16974. return oldValue.ContentType, nil
  16975. }
  16976. // AddContentType adds i to the "content_type" field.
  16977. func (m *MessageRecordsMutation) AddContentType(i int) {
  16978. if m.addcontent_type != nil {
  16979. *m.addcontent_type += i
  16980. } else {
  16981. m.addcontent_type = &i
  16982. }
  16983. }
  16984. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  16985. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  16986. v := m.addcontent_type
  16987. if v == nil {
  16988. return
  16989. }
  16990. return *v, true
  16991. }
  16992. // ResetContentType resets all changes to the "content_type" field.
  16993. func (m *MessageRecordsMutation) ResetContentType() {
  16994. m.content_type = nil
  16995. m.addcontent_type = nil
  16996. }
  16997. // SetContent sets the "content" field.
  16998. func (m *MessageRecordsMutation) SetContent(s string) {
  16999. m.content = &s
  17000. }
  17001. // Content returns the value of the "content" field in the mutation.
  17002. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  17003. v := m.content
  17004. if v == nil {
  17005. return
  17006. }
  17007. return *v, true
  17008. }
  17009. // OldContent returns the old "content" field's value of the MessageRecords entity.
  17010. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17012. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  17013. if !m.op.Is(OpUpdateOne) {
  17014. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  17015. }
  17016. if m.id == nil || m.oldValue == nil {
  17017. return v, errors.New("OldContent requires an ID field in the mutation")
  17018. }
  17019. oldValue, err := m.oldValue(ctx)
  17020. if err != nil {
  17021. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  17022. }
  17023. return oldValue.Content, nil
  17024. }
  17025. // ResetContent resets all changes to the "content" field.
  17026. func (m *MessageRecordsMutation) ResetContent() {
  17027. m.content = nil
  17028. }
  17029. // SetMeta sets the "meta" field.
  17030. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  17031. m.meta = &ct
  17032. }
  17033. // Meta returns the value of the "meta" field in the mutation.
  17034. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  17035. v := m.meta
  17036. if v == nil {
  17037. return
  17038. }
  17039. return *v, true
  17040. }
  17041. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  17042. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17044. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  17045. if !m.op.Is(OpUpdateOne) {
  17046. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  17047. }
  17048. if m.id == nil || m.oldValue == nil {
  17049. return v, errors.New("OldMeta requires an ID field in the mutation")
  17050. }
  17051. oldValue, err := m.oldValue(ctx)
  17052. if err != nil {
  17053. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  17054. }
  17055. return oldValue.Meta, nil
  17056. }
  17057. // ClearMeta clears the value of the "meta" field.
  17058. func (m *MessageRecordsMutation) ClearMeta() {
  17059. m.meta = nil
  17060. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  17061. }
  17062. // MetaCleared returns if the "meta" field was cleared in this mutation.
  17063. func (m *MessageRecordsMutation) MetaCleared() bool {
  17064. _, ok := m.clearedFields[messagerecords.FieldMeta]
  17065. return ok
  17066. }
  17067. // ResetMeta resets all changes to the "meta" field.
  17068. func (m *MessageRecordsMutation) ResetMeta() {
  17069. m.meta = nil
  17070. delete(m.clearedFields, messagerecords.FieldMeta)
  17071. }
  17072. // SetErrorDetail sets the "error_detail" field.
  17073. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  17074. m.error_detail = &s
  17075. }
  17076. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  17077. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  17078. v := m.error_detail
  17079. if v == nil {
  17080. return
  17081. }
  17082. return *v, true
  17083. }
  17084. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  17085. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17087. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  17088. if !m.op.Is(OpUpdateOne) {
  17089. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  17090. }
  17091. if m.id == nil || m.oldValue == nil {
  17092. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  17093. }
  17094. oldValue, err := m.oldValue(ctx)
  17095. if err != nil {
  17096. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  17097. }
  17098. return oldValue.ErrorDetail, nil
  17099. }
  17100. // ResetErrorDetail resets all changes to the "error_detail" field.
  17101. func (m *MessageRecordsMutation) ResetErrorDetail() {
  17102. m.error_detail = nil
  17103. }
  17104. // SetSendTime sets the "send_time" field.
  17105. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  17106. m.send_time = &t
  17107. }
  17108. // SendTime returns the value of the "send_time" field in the mutation.
  17109. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  17110. v := m.send_time
  17111. if v == nil {
  17112. return
  17113. }
  17114. return *v, true
  17115. }
  17116. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  17117. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17118. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17119. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  17120. if !m.op.Is(OpUpdateOne) {
  17121. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  17122. }
  17123. if m.id == nil || m.oldValue == nil {
  17124. return v, errors.New("OldSendTime requires an ID field in the mutation")
  17125. }
  17126. oldValue, err := m.oldValue(ctx)
  17127. if err != nil {
  17128. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  17129. }
  17130. return oldValue.SendTime, nil
  17131. }
  17132. // ClearSendTime clears the value of the "send_time" field.
  17133. func (m *MessageRecordsMutation) ClearSendTime() {
  17134. m.send_time = nil
  17135. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  17136. }
  17137. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  17138. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  17139. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  17140. return ok
  17141. }
  17142. // ResetSendTime resets all changes to the "send_time" field.
  17143. func (m *MessageRecordsMutation) ResetSendTime() {
  17144. m.send_time = nil
  17145. delete(m.clearedFields, messagerecords.FieldSendTime)
  17146. }
  17147. // SetSourceType sets the "source_type" field.
  17148. func (m *MessageRecordsMutation) SetSourceType(i int) {
  17149. m.source_type = &i
  17150. m.addsource_type = nil
  17151. }
  17152. // SourceType returns the value of the "source_type" field in the mutation.
  17153. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  17154. v := m.source_type
  17155. if v == nil {
  17156. return
  17157. }
  17158. return *v, true
  17159. }
  17160. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  17161. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17162. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17163. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  17164. if !m.op.Is(OpUpdateOne) {
  17165. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  17166. }
  17167. if m.id == nil || m.oldValue == nil {
  17168. return v, errors.New("OldSourceType requires an ID field in the mutation")
  17169. }
  17170. oldValue, err := m.oldValue(ctx)
  17171. if err != nil {
  17172. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  17173. }
  17174. return oldValue.SourceType, nil
  17175. }
  17176. // AddSourceType adds i to the "source_type" field.
  17177. func (m *MessageRecordsMutation) AddSourceType(i int) {
  17178. if m.addsource_type != nil {
  17179. *m.addsource_type += i
  17180. } else {
  17181. m.addsource_type = &i
  17182. }
  17183. }
  17184. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  17185. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  17186. v := m.addsource_type
  17187. if v == nil {
  17188. return
  17189. }
  17190. return *v, true
  17191. }
  17192. // ResetSourceType resets all changes to the "source_type" field.
  17193. func (m *MessageRecordsMutation) ResetSourceType() {
  17194. m.source_type = nil
  17195. m.addsource_type = nil
  17196. }
  17197. // SetSourceID sets the "source_id" field.
  17198. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  17199. m.sop_stage = &u
  17200. }
  17201. // SourceID returns the value of the "source_id" field in the mutation.
  17202. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  17203. v := m.sop_stage
  17204. if v == nil {
  17205. return
  17206. }
  17207. return *v, true
  17208. }
  17209. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  17210. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17211. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17212. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  17213. if !m.op.Is(OpUpdateOne) {
  17214. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  17215. }
  17216. if m.id == nil || m.oldValue == nil {
  17217. return v, errors.New("OldSourceID requires an ID field in the mutation")
  17218. }
  17219. oldValue, err := m.oldValue(ctx)
  17220. if err != nil {
  17221. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  17222. }
  17223. return oldValue.SourceID, nil
  17224. }
  17225. // ClearSourceID clears the value of the "source_id" field.
  17226. func (m *MessageRecordsMutation) ClearSourceID() {
  17227. m.sop_stage = nil
  17228. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  17229. }
  17230. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  17231. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  17232. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  17233. return ok
  17234. }
  17235. // ResetSourceID resets all changes to the "source_id" field.
  17236. func (m *MessageRecordsMutation) ResetSourceID() {
  17237. m.sop_stage = nil
  17238. delete(m.clearedFields, messagerecords.FieldSourceID)
  17239. }
  17240. // SetSubSourceID sets the "sub_source_id" field.
  17241. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  17242. m.sop_node = &u
  17243. }
  17244. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  17245. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  17246. v := m.sop_node
  17247. if v == nil {
  17248. return
  17249. }
  17250. return *v, true
  17251. }
  17252. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  17253. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17255. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  17256. if !m.op.Is(OpUpdateOne) {
  17257. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  17258. }
  17259. if m.id == nil || m.oldValue == nil {
  17260. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  17261. }
  17262. oldValue, err := m.oldValue(ctx)
  17263. if err != nil {
  17264. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  17265. }
  17266. return oldValue.SubSourceID, nil
  17267. }
  17268. // ClearSubSourceID clears the value of the "sub_source_id" field.
  17269. func (m *MessageRecordsMutation) ClearSubSourceID() {
  17270. m.sop_node = nil
  17271. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  17272. }
  17273. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  17274. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  17275. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  17276. return ok
  17277. }
  17278. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  17279. func (m *MessageRecordsMutation) ResetSubSourceID() {
  17280. m.sop_node = nil
  17281. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  17282. }
  17283. // SetOrganizationID sets the "organization_id" field.
  17284. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  17285. m.organization_id = &u
  17286. m.addorganization_id = nil
  17287. }
  17288. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17289. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  17290. v := m.organization_id
  17291. if v == nil {
  17292. return
  17293. }
  17294. return *v, true
  17295. }
  17296. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  17297. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17299. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17300. if !m.op.Is(OpUpdateOne) {
  17301. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17302. }
  17303. if m.id == nil || m.oldValue == nil {
  17304. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17305. }
  17306. oldValue, err := m.oldValue(ctx)
  17307. if err != nil {
  17308. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17309. }
  17310. return oldValue.OrganizationID, nil
  17311. }
  17312. // AddOrganizationID adds u to the "organization_id" field.
  17313. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  17314. if m.addorganization_id != nil {
  17315. *m.addorganization_id += u
  17316. } else {
  17317. m.addorganization_id = &u
  17318. }
  17319. }
  17320. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17321. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  17322. v := m.addorganization_id
  17323. if v == nil {
  17324. return
  17325. }
  17326. return *v, true
  17327. }
  17328. // ClearOrganizationID clears the value of the "organization_id" field.
  17329. func (m *MessageRecordsMutation) ClearOrganizationID() {
  17330. m.organization_id = nil
  17331. m.addorganization_id = nil
  17332. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  17333. }
  17334. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17335. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  17336. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  17337. return ok
  17338. }
  17339. // ResetOrganizationID resets all changes to the "organization_id" field.
  17340. func (m *MessageRecordsMutation) ResetOrganizationID() {
  17341. m.organization_id = nil
  17342. m.addorganization_id = nil
  17343. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  17344. }
  17345. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  17346. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  17347. m.sop_stage = &id
  17348. }
  17349. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  17350. func (m *MessageRecordsMutation) ClearSopStage() {
  17351. m.clearedsop_stage = true
  17352. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  17353. }
  17354. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  17355. func (m *MessageRecordsMutation) SopStageCleared() bool {
  17356. return m.SourceIDCleared() || m.clearedsop_stage
  17357. }
  17358. // SopStageID returns the "sop_stage" edge ID in the mutation.
  17359. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  17360. if m.sop_stage != nil {
  17361. return *m.sop_stage, true
  17362. }
  17363. return
  17364. }
  17365. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  17366. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17367. // SopStageID instead. It exists only for internal usage by the builders.
  17368. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  17369. if id := m.sop_stage; id != nil {
  17370. ids = append(ids, *id)
  17371. }
  17372. return
  17373. }
  17374. // ResetSopStage resets all changes to the "sop_stage" edge.
  17375. func (m *MessageRecordsMutation) ResetSopStage() {
  17376. m.sop_stage = nil
  17377. m.clearedsop_stage = false
  17378. }
  17379. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  17380. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  17381. m.sop_node = &id
  17382. }
  17383. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  17384. func (m *MessageRecordsMutation) ClearSopNode() {
  17385. m.clearedsop_node = true
  17386. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  17387. }
  17388. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  17389. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  17390. return m.SubSourceIDCleared() || m.clearedsop_node
  17391. }
  17392. // SopNodeID returns the "sop_node" edge ID in the mutation.
  17393. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  17394. if m.sop_node != nil {
  17395. return *m.sop_node, true
  17396. }
  17397. return
  17398. }
  17399. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  17400. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17401. // SopNodeID instead. It exists only for internal usage by the builders.
  17402. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  17403. if id := m.sop_node; id != nil {
  17404. ids = append(ids, *id)
  17405. }
  17406. return
  17407. }
  17408. // ResetSopNode resets all changes to the "sop_node" edge.
  17409. func (m *MessageRecordsMutation) ResetSopNode() {
  17410. m.sop_node = nil
  17411. m.clearedsop_node = false
  17412. }
  17413. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  17414. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  17415. m.message_contact = &id
  17416. }
  17417. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  17418. func (m *MessageRecordsMutation) ClearMessageContact() {
  17419. m.clearedmessage_contact = true
  17420. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  17421. }
  17422. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  17423. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  17424. return m.ContactIDCleared() || m.clearedmessage_contact
  17425. }
  17426. // MessageContactID returns the "message_contact" edge ID in the mutation.
  17427. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  17428. if m.message_contact != nil {
  17429. return *m.message_contact, true
  17430. }
  17431. return
  17432. }
  17433. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  17434. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17435. // MessageContactID instead. It exists only for internal usage by the builders.
  17436. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  17437. if id := m.message_contact; id != nil {
  17438. ids = append(ids, *id)
  17439. }
  17440. return
  17441. }
  17442. // ResetMessageContact resets all changes to the "message_contact" edge.
  17443. func (m *MessageRecordsMutation) ResetMessageContact() {
  17444. m.message_contact = nil
  17445. m.clearedmessage_contact = false
  17446. }
  17447. // Where appends a list predicates to the MessageRecordsMutation builder.
  17448. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  17449. m.predicates = append(m.predicates, ps...)
  17450. }
  17451. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  17452. // users can use type-assertion to append predicates that do not depend on any generated package.
  17453. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  17454. p := make([]predicate.MessageRecords, len(ps))
  17455. for i := range ps {
  17456. p[i] = ps[i]
  17457. }
  17458. m.Where(p...)
  17459. }
  17460. // Op returns the operation name.
  17461. func (m *MessageRecordsMutation) Op() Op {
  17462. return m.op
  17463. }
  17464. // SetOp allows setting the mutation operation.
  17465. func (m *MessageRecordsMutation) SetOp(op Op) {
  17466. m.op = op
  17467. }
  17468. // Type returns the node type of this mutation (MessageRecords).
  17469. func (m *MessageRecordsMutation) Type() string {
  17470. return m.typ
  17471. }
  17472. // Fields returns all fields that were changed during this mutation. Note that in
  17473. // order to get all numeric fields that were incremented/decremented, call
  17474. // AddedFields().
  17475. func (m *MessageRecordsMutation) Fields() []string {
  17476. fields := make([]string, 0, 16)
  17477. if m.created_at != nil {
  17478. fields = append(fields, messagerecords.FieldCreatedAt)
  17479. }
  17480. if m.updated_at != nil {
  17481. fields = append(fields, messagerecords.FieldUpdatedAt)
  17482. }
  17483. if m.status != nil {
  17484. fields = append(fields, messagerecords.FieldStatus)
  17485. }
  17486. if m.bot_wxid != nil {
  17487. fields = append(fields, messagerecords.FieldBotWxid)
  17488. }
  17489. if m.message_contact != nil {
  17490. fields = append(fields, messagerecords.FieldContactID)
  17491. }
  17492. if m.contact_type != nil {
  17493. fields = append(fields, messagerecords.FieldContactType)
  17494. }
  17495. if m.contact_wxid != nil {
  17496. fields = append(fields, messagerecords.FieldContactWxid)
  17497. }
  17498. if m.content_type != nil {
  17499. fields = append(fields, messagerecords.FieldContentType)
  17500. }
  17501. if m.content != nil {
  17502. fields = append(fields, messagerecords.FieldContent)
  17503. }
  17504. if m.meta != nil {
  17505. fields = append(fields, messagerecords.FieldMeta)
  17506. }
  17507. if m.error_detail != nil {
  17508. fields = append(fields, messagerecords.FieldErrorDetail)
  17509. }
  17510. if m.send_time != nil {
  17511. fields = append(fields, messagerecords.FieldSendTime)
  17512. }
  17513. if m.source_type != nil {
  17514. fields = append(fields, messagerecords.FieldSourceType)
  17515. }
  17516. if m.sop_stage != nil {
  17517. fields = append(fields, messagerecords.FieldSourceID)
  17518. }
  17519. if m.sop_node != nil {
  17520. fields = append(fields, messagerecords.FieldSubSourceID)
  17521. }
  17522. if m.organization_id != nil {
  17523. fields = append(fields, messagerecords.FieldOrganizationID)
  17524. }
  17525. return fields
  17526. }
  17527. // Field returns the value of a field with the given name. The second boolean
  17528. // return value indicates that this field was not set, or was not defined in the
  17529. // schema.
  17530. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  17531. switch name {
  17532. case messagerecords.FieldCreatedAt:
  17533. return m.CreatedAt()
  17534. case messagerecords.FieldUpdatedAt:
  17535. return m.UpdatedAt()
  17536. case messagerecords.FieldStatus:
  17537. return m.Status()
  17538. case messagerecords.FieldBotWxid:
  17539. return m.BotWxid()
  17540. case messagerecords.FieldContactID:
  17541. return m.ContactID()
  17542. case messagerecords.FieldContactType:
  17543. return m.ContactType()
  17544. case messagerecords.FieldContactWxid:
  17545. return m.ContactWxid()
  17546. case messagerecords.FieldContentType:
  17547. return m.ContentType()
  17548. case messagerecords.FieldContent:
  17549. return m.Content()
  17550. case messagerecords.FieldMeta:
  17551. return m.Meta()
  17552. case messagerecords.FieldErrorDetail:
  17553. return m.ErrorDetail()
  17554. case messagerecords.FieldSendTime:
  17555. return m.SendTime()
  17556. case messagerecords.FieldSourceType:
  17557. return m.SourceType()
  17558. case messagerecords.FieldSourceID:
  17559. return m.SourceID()
  17560. case messagerecords.FieldSubSourceID:
  17561. return m.SubSourceID()
  17562. case messagerecords.FieldOrganizationID:
  17563. return m.OrganizationID()
  17564. }
  17565. return nil, false
  17566. }
  17567. // OldField returns the old value of the field from the database. An error is
  17568. // returned if the mutation operation is not UpdateOne, or the query to the
  17569. // database failed.
  17570. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17571. switch name {
  17572. case messagerecords.FieldCreatedAt:
  17573. return m.OldCreatedAt(ctx)
  17574. case messagerecords.FieldUpdatedAt:
  17575. return m.OldUpdatedAt(ctx)
  17576. case messagerecords.FieldStatus:
  17577. return m.OldStatus(ctx)
  17578. case messagerecords.FieldBotWxid:
  17579. return m.OldBotWxid(ctx)
  17580. case messagerecords.FieldContactID:
  17581. return m.OldContactID(ctx)
  17582. case messagerecords.FieldContactType:
  17583. return m.OldContactType(ctx)
  17584. case messagerecords.FieldContactWxid:
  17585. return m.OldContactWxid(ctx)
  17586. case messagerecords.FieldContentType:
  17587. return m.OldContentType(ctx)
  17588. case messagerecords.FieldContent:
  17589. return m.OldContent(ctx)
  17590. case messagerecords.FieldMeta:
  17591. return m.OldMeta(ctx)
  17592. case messagerecords.FieldErrorDetail:
  17593. return m.OldErrorDetail(ctx)
  17594. case messagerecords.FieldSendTime:
  17595. return m.OldSendTime(ctx)
  17596. case messagerecords.FieldSourceType:
  17597. return m.OldSourceType(ctx)
  17598. case messagerecords.FieldSourceID:
  17599. return m.OldSourceID(ctx)
  17600. case messagerecords.FieldSubSourceID:
  17601. return m.OldSubSourceID(ctx)
  17602. case messagerecords.FieldOrganizationID:
  17603. return m.OldOrganizationID(ctx)
  17604. }
  17605. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  17606. }
  17607. // SetField sets the value of a field with the given name. It returns an error if
  17608. // the field is not defined in the schema, or if the type mismatched the field
  17609. // type.
  17610. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  17611. switch name {
  17612. case messagerecords.FieldCreatedAt:
  17613. v, ok := value.(time.Time)
  17614. if !ok {
  17615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17616. }
  17617. m.SetCreatedAt(v)
  17618. return nil
  17619. case messagerecords.FieldUpdatedAt:
  17620. v, ok := value.(time.Time)
  17621. if !ok {
  17622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17623. }
  17624. m.SetUpdatedAt(v)
  17625. return nil
  17626. case messagerecords.FieldStatus:
  17627. v, ok := value.(uint8)
  17628. if !ok {
  17629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17630. }
  17631. m.SetStatus(v)
  17632. return nil
  17633. case messagerecords.FieldBotWxid:
  17634. v, ok := value.(string)
  17635. if !ok {
  17636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17637. }
  17638. m.SetBotWxid(v)
  17639. return nil
  17640. case messagerecords.FieldContactID:
  17641. v, ok := value.(uint64)
  17642. if !ok {
  17643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17644. }
  17645. m.SetContactID(v)
  17646. return nil
  17647. case messagerecords.FieldContactType:
  17648. v, ok := value.(int)
  17649. if !ok {
  17650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17651. }
  17652. m.SetContactType(v)
  17653. return nil
  17654. case messagerecords.FieldContactWxid:
  17655. v, ok := value.(string)
  17656. if !ok {
  17657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17658. }
  17659. m.SetContactWxid(v)
  17660. return nil
  17661. case messagerecords.FieldContentType:
  17662. v, ok := value.(int)
  17663. if !ok {
  17664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17665. }
  17666. m.SetContentType(v)
  17667. return nil
  17668. case messagerecords.FieldContent:
  17669. v, ok := value.(string)
  17670. if !ok {
  17671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17672. }
  17673. m.SetContent(v)
  17674. return nil
  17675. case messagerecords.FieldMeta:
  17676. v, ok := value.(custom_types.Meta)
  17677. if !ok {
  17678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17679. }
  17680. m.SetMeta(v)
  17681. return nil
  17682. case messagerecords.FieldErrorDetail:
  17683. v, ok := value.(string)
  17684. if !ok {
  17685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17686. }
  17687. m.SetErrorDetail(v)
  17688. return nil
  17689. case messagerecords.FieldSendTime:
  17690. v, ok := value.(time.Time)
  17691. if !ok {
  17692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17693. }
  17694. m.SetSendTime(v)
  17695. return nil
  17696. case messagerecords.FieldSourceType:
  17697. v, ok := value.(int)
  17698. if !ok {
  17699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17700. }
  17701. m.SetSourceType(v)
  17702. return nil
  17703. case messagerecords.FieldSourceID:
  17704. v, ok := value.(uint64)
  17705. if !ok {
  17706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17707. }
  17708. m.SetSourceID(v)
  17709. return nil
  17710. case messagerecords.FieldSubSourceID:
  17711. v, ok := value.(uint64)
  17712. if !ok {
  17713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17714. }
  17715. m.SetSubSourceID(v)
  17716. return nil
  17717. case messagerecords.FieldOrganizationID:
  17718. v, ok := value.(uint64)
  17719. if !ok {
  17720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17721. }
  17722. m.SetOrganizationID(v)
  17723. return nil
  17724. }
  17725. return fmt.Errorf("unknown MessageRecords field %s", name)
  17726. }
  17727. // AddedFields returns all numeric fields that were incremented/decremented during
  17728. // this mutation.
  17729. func (m *MessageRecordsMutation) AddedFields() []string {
  17730. var fields []string
  17731. if m.addstatus != nil {
  17732. fields = append(fields, messagerecords.FieldStatus)
  17733. }
  17734. if m.addcontact_type != nil {
  17735. fields = append(fields, messagerecords.FieldContactType)
  17736. }
  17737. if m.addcontent_type != nil {
  17738. fields = append(fields, messagerecords.FieldContentType)
  17739. }
  17740. if m.addsource_type != nil {
  17741. fields = append(fields, messagerecords.FieldSourceType)
  17742. }
  17743. if m.addorganization_id != nil {
  17744. fields = append(fields, messagerecords.FieldOrganizationID)
  17745. }
  17746. return fields
  17747. }
  17748. // AddedField returns the numeric value that was incremented/decremented on a field
  17749. // with the given name. The second boolean return value indicates that this field
  17750. // was not set, or was not defined in the schema.
  17751. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  17752. switch name {
  17753. case messagerecords.FieldStatus:
  17754. return m.AddedStatus()
  17755. case messagerecords.FieldContactType:
  17756. return m.AddedContactType()
  17757. case messagerecords.FieldContentType:
  17758. return m.AddedContentType()
  17759. case messagerecords.FieldSourceType:
  17760. return m.AddedSourceType()
  17761. case messagerecords.FieldOrganizationID:
  17762. return m.AddedOrganizationID()
  17763. }
  17764. return nil, false
  17765. }
  17766. // AddField adds the value to the field with the given name. It returns an error if
  17767. // the field is not defined in the schema, or if the type mismatched the field
  17768. // type.
  17769. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  17770. switch name {
  17771. case messagerecords.FieldStatus:
  17772. v, ok := value.(int8)
  17773. if !ok {
  17774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17775. }
  17776. m.AddStatus(v)
  17777. return nil
  17778. case messagerecords.FieldContactType:
  17779. v, ok := value.(int)
  17780. if !ok {
  17781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17782. }
  17783. m.AddContactType(v)
  17784. return nil
  17785. case messagerecords.FieldContentType:
  17786. v, ok := value.(int)
  17787. if !ok {
  17788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17789. }
  17790. m.AddContentType(v)
  17791. return nil
  17792. case messagerecords.FieldSourceType:
  17793. v, ok := value.(int)
  17794. if !ok {
  17795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17796. }
  17797. m.AddSourceType(v)
  17798. return nil
  17799. case messagerecords.FieldOrganizationID:
  17800. v, ok := value.(int64)
  17801. if !ok {
  17802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17803. }
  17804. m.AddOrganizationID(v)
  17805. return nil
  17806. }
  17807. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  17808. }
  17809. // ClearedFields returns all nullable fields that were cleared during this
  17810. // mutation.
  17811. func (m *MessageRecordsMutation) ClearedFields() []string {
  17812. var fields []string
  17813. if m.FieldCleared(messagerecords.FieldStatus) {
  17814. fields = append(fields, messagerecords.FieldStatus)
  17815. }
  17816. if m.FieldCleared(messagerecords.FieldContactID) {
  17817. fields = append(fields, messagerecords.FieldContactID)
  17818. }
  17819. if m.FieldCleared(messagerecords.FieldMeta) {
  17820. fields = append(fields, messagerecords.FieldMeta)
  17821. }
  17822. if m.FieldCleared(messagerecords.FieldSendTime) {
  17823. fields = append(fields, messagerecords.FieldSendTime)
  17824. }
  17825. if m.FieldCleared(messagerecords.FieldSourceID) {
  17826. fields = append(fields, messagerecords.FieldSourceID)
  17827. }
  17828. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  17829. fields = append(fields, messagerecords.FieldSubSourceID)
  17830. }
  17831. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  17832. fields = append(fields, messagerecords.FieldOrganizationID)
  17833. }
  17834. return fields
  17835. }
  17836. // FieldCleared returns a boolean indicating if a field with the given name was
  17837. // cleared in this mutation.
  17838. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  17839. _, ok := m.clearedFields[name]
  17840. return ok
  17841. }
  17842. // ClearField clears the value of the field with the given name. It returns an
  17843. // error if the field is not defined in the schema.
  17844. func (m *MessageRecordsMutation) ClearField(name string) error {
  17845. switch name {
  17846. case messagerecords.FieldStatus:
  17847. m.ClearStatus()
  17848. return nil
  17849. case messagerecords.FieldContactID:
  17850. m.ClearContactID()
  17851. return nil
  17852. case messagerecords.FieldMeta:
  17853. m.ClearMeta()
  17854. return nil
  17855. case messagerecords.FieldSendTime:
  17856. m.ClearSendTime()
  17857. return nil
  17858. case messagerecords.FieldSourceID:
  17859. m.ClearSourceID()
  17860. return nil
  17861. case messagerecords.FieldSubSourceID:
  17862. m.ClearSubSourceID()
  17863. return nil
  17864. case messagerecords.FieldOrganizationID:
  17865. m.ClearOrganizationID()
  17866. return nil
  17867. }
  17868. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  17869. }
  17870. // ResetField resets all changes in the mutation for the field with the given name.
  17871. // It returns an error if the field is not defined in the schema.
  17872. func (m *MessageRecordsMutation) ResetField(name string) error {
  17873. switch name {
  17874. case messagerecords.FieldCreatedAt:
  17875. m.ResetCreatedAt()
  17876. return nil
  17877. case messagerecords.FieldUpdatedAt:
  17878. m.ResetUpdatedAt()
  17879. return nil
  17880. case messagerecords.FieldStatus:
  17881. m.ResetStatus()
  17882. return nil
  17883. case messagerecords.FieldBotWxid:
  17884. m.ResetBotWxid()
  17885. return nil
  17886. case messagerecords.FieldContactID:
  17887. m.ResetContactID()
  17888. return nil
  17889. case messagerecords.FieldContactType:
  17890. m.ResetContactType()
  17891. return nil
  17892. case messagerecords.FieldContactWxid:
  17893. m.ResetContactWxid()
  17894. return nil
  17895. case messagerecords.FieldContentType:
  17896. m.ResetContentType()
  17897. return nil
  17898. case messagerecords.FieldContent:
  17899. m.ResetContent()
  17900. return nil
  17901. case messagerecords.FieldMeta:
  17902. m.ResetMeta()
  17903. return nil
  17904. case messagerecords.FieldErrorDetail:
  17905. m.ResetErrorDetail()
  17906. return nil
  17907. case messagerecords.FieldSendTime:
  17908. m.ResetSendTime()
  17909. return nil
  17910. case messagerecords.FieldSourceType:
  17911. m.ResetSourceType()
  17912. return nil
  17913. case messagerecords.FieldSourceID:
  17914. m.ResetSourceID()
  17915. return nil
  17916. case messagerecords.FieldSubSourceID:
  17917. m.ResetSubSourceID()
  17918. return nil
  17919. case messagerecords.FieldOrganizationID:
  17920. m.ResetOrganizationID()
  17921. return nil
  17922. }
  17923. return fmt.Errorf("unknown MessageRecords field %s", name)
  17924. }
  17925. // AddedEdges returns all edge names that were set/added in this mutation.
  17926. func (m *MessageRecordsMutation) AddedEdges() []string {
  17927. edges := make([]string, 0, 3)
  17928. if m.sop_stage != nil {
  17929. edges = append(edges, messagerecords.EdgeSopStage)
  17930. }
  17931. if m.sop_node != nil {
  17932. edges = append(edges, messagerecords.EdgeSopNode)
  17933. }
  17934. if m.message_contact != nil {
  17935. edges = append(edges, messagerecords.EdgeMessageContact)
  17936. }
  17937. return edges
  17938. }
  17939. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17940. // name in this mutation.
  17941. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  17942. switch name {
  17943. case messagerecords.EdgeSopStage:
  17944. if id := m.sop_stage; id != nil {
  17945. return []ent.Value{*id}
  17946. }
  17947. case messagerecords.EdgeSopNode:
  17948. if id := m.sop_node; id != nil {
  17949. return []ent.Value{*id}
  17950. }
  17951. case messagerecords.EdgeMessageContact:
  17952. if id := m.message_contact; id != nil {
  17953. return []ent.Value{*id}
  17954. }
  17955. }
  17956. return nil
  17957. }
  17958. // RemovedEdges returns all edge names that were removed in this mutation.
  17959. func (m *MessageRecordsMutation) RemovedEdges() []string {
  17960. edges := make([]string, 0, 3)
  17961. return edges
  17962. }
  17963. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17964. // the given name in this mutation.
  17965. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  17966. return nil
  17967. }
  17968. // ClearedEdges returns all edge names that were cleared in this mutation.
  17969. func (m *MessageRecordsMutation) ClearedEdges() []string {
  17970. edges := make([]string, 0, 3)
  17971. if m.clearedsop_stage {
  17972. edges = append(edges, messagerecords.EdgeSopStage)
  17973. }
  17974. if m.clearedsop_node {
  17975. edges = append(edges, messagerecords.EdgeSopNode)
  17976. }
  17977. if m.clearedmessage_contact {
  17978. edges = append(edges, messagerecords.EdgeMessageContact)
  17979. }
  17980. return edges
  17981. }
  17982. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17983. // was cleared in this mutation.
  17984. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  17985. switch name {
  17986. case messagerecords.EdgeSopStage:
  17987. return m.clearedsop_stage
  17988. case messagerecords.EdgeSopNode:
  17989. return m.clearedsop_node
  17990. case messagerecords.EdgeMessageContact:
  17991. return m.clearedmessage_contact
  17992. }
  17993. return false
  17994. }
  17995. // ClearEdge clears the value of the edge with the given name. It returns an error
  17996. // if that edge is not defined in the schema.
  17997. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  17998. switch name {
  17999. case messagerecords.EdgeSopStage:
  18000. m.ClearSopStage()
  18001. return nil
  18002. case messagerecords.EdgeSopNode:
  18003. m.ClearSopNode()
  18004. return nil
  18005. case messagerecords.EdgeMessageContact:
  18006. m.ClearMessageContact()
  18007. return nil
  18008. }
  18009. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  18010. }
  18011. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18012. // It returns an error if the edge is not defined in the schema.
  18013. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  18014. switch name {
  18015. case messagerecords.EdgeSopStage:
  18016. m.ResetSopStage()
  18017. return nil
  18018. case messagerecords.EdgeSopNode:
  18019. m.ResetSopNode()
  18020. return nil
  18021. case messagerecords.EdgeMessageContact:
  18022. m.ResetMessageContact()
  18023. return nil
  18024. }
  18025. return fmt.Errorf("unknown MessageRecords edge %s", name)
  18026. }
  18027. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  18028. type MsgMutation struct {
  18029. config
  18030. op Op
  18031. typ string
  18032. id *uint64
  18033. created_at *time.Time
  18034. updated_at *time.Time
  18035. deleted_at *time.Time
  18036. status *uint8
  18037. addstatus *int8
  18038. fromwxid *string
  18039. toid *string
  18040. msgtype *int32
  18041. addmsgtype *int32
  18042. msg *string
  18043. batch_no *string
  18044. clearedFields map[string]struct{}
  18045. done bool
  18046. oldValue func(context.Context) (*Msg, error)
  18047. predicates []predicate.Msg
  18048. }
  18049. var _ ent.Mutation = (*MsgMutation)(nil)
  18050. // msgOption allows management of the mutation configuration using functional options.
  18051. type msgOption func(*MsgMutation)
  18052. // newMsgMutation creates new mutation for the Msg entity.
  18053. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  18054. m := &MsgMutation{
  18055. config: c,
  18056. op: op,
  18057. typ: TypeMsg,
  18058. clearedFields: make(map[string]struct{}),
  18059. }
  18060. for _, opt := range opts {
  18061. opt(m)
  18062. }
  18063. return m
  18064. }
  18065. // withMsgID sets the ID field of the mutation.
  18066. func withMsgID(id uint64) msgOption {
  18067. return func(m *MsgMutation) {
  18068. var (
  18069. err error
  18070. once sync.Once
  18071. value *Msg
  18072. )
  18073. m.oldValue = func(ctx context.Context) (*Msg, error) {
  18074. once.Do(func() {
  18075. if m.done {
  18076. err = errors.New("querying old values post mutation is not allowed")
  18077. } else {
  18078. value, err = m.Client().Msg.Get(ctx, id)
  18079. }
  18080. })
  18081. return value, err
  18082. }
  18083. m.id = &id
  18084. }
  18085. }
  18086. // withMsg sets the old Msg of the mutation.
  18087. func withMsg(node *Msg) msgOption {
  18088. return func(m *MsgMutation) {
  18089. m.oldValue = func(context.Context) (*Msg, error) {
  18090. return node, nil
  18091. }
  18092. m.id = &node.ID
  18093. }
  18094. }
  18095. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18096. // executed in a transaction (ent.Tx), a transactional client is returned.
  18097. func (m MsgMutation) Client() *Client {
  18098. client := &Client{config: m.config}
  18099. client.init()
  18100. return client
  18101. }
  18102. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18103. // it returns an error otherwise.
  18104. func (m MsgMutation) Tx() (*Tx, error) {
  18105. if _, ok := m.driver.(*txDriver); !ok {
  18106. return nil, errors.New("ent: mutation is not running in a transaction")
  18107. }
  18108. tx := &Tx{config: m.config}
  18109. tx.init()
  18110. return tx, nil
  18111. }
  18112. // SetID sets the value of the id field. Note that this
  18113. // operation is only accepted on creation of Msg entities.
  18114. func (m *MsgMutation) SetID(id uint64) {
  18115. m.id = &id
  18116. }
  18117. // ID returns the ID value in the mutation. Note that the ID is only available
  18118. // if it was provided to the builder or after it was returned from the database.
  18119. func (m *MsgMutation) ID() (id uint64, exists bool) {
  18120. if m.id == nil {
  18121. return
  18122. }
  18123. return *m.id, true
  18124. }
  18125. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18126. // That means, if the mutation is applied within a transaction with an isolation level such
  18127. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18128. // or updated by the mutation.
  18129. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  18130. switch {
  18131. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18132. id, exists := m.ID()
  18133. if exists {
  18134. return []uint64{id}, nil
  18135. }
  18136. fallthrough
  18137. case m.op.Is(OpUpdate | OpDelete):
  18138. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  18139. default:
  18140. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18141. }
  18142. }
  18143. // SetCreatedAt sets the "created_at" field.
  18144. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  18145. m.created_at = &t
  18146. }
  18147. // CreatedAt returns the value of the "created_at" field in the mutation.
  18148. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  18149. v := m.created_at
  18150. if v == nil {
  18151. return
  18152. }
  18153. return *v, true
  18154. }
  18155. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  18156. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18158. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18159. if !m.op.Is(OpUpdateOne) {
  18160. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18161. }
  18162. if m.id == nil || m.oldValue == nil {
  18163. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18164. }
  18165. oldValue, err := m.oldValue(ctx)
  18166. if err != nil {
  18167. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18168. }
  18169. return oldValue.CreatedAt, nil
  18170. }
  18171. // ResetCreatedAt resets all changes to the "created_at" field.
  18172. func (m *MsgMutation) ResetCreatedAt() {
  18173. m.created_at = nil
  18174. }
  18175. // SetUpdatedAt sets the "updated_at" field.
  18176. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  18177. m.updated_at = &t
  18178. }
  18179. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18180. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  18181. v := m.updated_at
  18182. if v == nil {
  18183. return
  18184. }
  18185. return *v, true
  18186. }
  18187. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  18188. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18190. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18191. if !m.op.Is(OpUpdateOne) {
  18192. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18193. }
  18194. if m.id == nil || m.oldValue == nil {
  18195. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18196. }
  18197. oldValue, err := m.oldValue(ctx)
  18198. if err != nil {
  18199. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18200. }
  18201. return oldValue.UpdatedAt, nil
  18202. }
  18203. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18204. func (m *MsgMutation) ResetUpdatedAt() {
  18205. m.updated_at = nil
  18206. }
  18207. // SetDeletedAt sets the "deleted_at" field.
  18208. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  18209. m.deleted_at = &t
  18210. }
  18211. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18212. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  18213. v := m.deleted_at
  18214. if v == nil {
  18215. return
  18216. }
  18217. return *v, true
  18218. }
  18219. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  18220. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18222. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18223. if !m.op.Is(OpUpdateOne) {
  18224. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18225. }
  18226. if m.id == nil || m.oldValue == nil {
  18227. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18228. }
  18229. oldValue, err := m.oldValue(ctx)
  18230. if err != nil {
  18231. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18232. }
  18233. return oldValue.DeletedAt, nil
  18234. }
  18235. // ClearDeletedAt clears the value of the "deleted_at" field.
  18236. func (m *MsgMutation) ClearDeletedAt() {
  18237. m.deleted_at = nil
  18238. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  18239. }
  18240. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18241. func (m *MsgMutation) DeletedAtCleared() bool {
  18242. _, ok := m.clearedFields[msg.FieldDeletedAt]
  18243. return ok
  18244. }
  18245. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18246. func (m *MsgMutation) ResetDeletedAt() {
  18247. m.deleted_at = nil
  18248. delete(m.clearedFields, msg.FieldDeletedAt)
  18249. }
  18250. // SetStatus sets the "status" field.
  18251. func (m *MsgMutation) SetStatus(u uint8) {
  18252. m.status = &u
  18253. m.addstatus = nil
  18254. }
  18255. // Status returns the value of the "status" field in the mutation.
  18256. func (m *MsgMutation) Status() (r uint8, exists bool) {
  18257. v := m.status
  18258. if v == nil {
  18259. return
  18260. }
  18261. return *v, true
  18262. }
  18263. // OldStatus returns the old "status" field's value of the Msg entity.
  18264. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18266. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18267. if !m.op.Is(OpUpdateOne) {
  18268. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18269. }
  18270. if m.id == nil || m.oldValue == nil {
  18271. return v, errors.New("OldStatus requires an ID field in the mutation")
  18272. }
  18273. oldValue, err := m.oldValue(ctx)
  18274. if err != nil {
  18275. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18276. }
  18277. return oldValue.Status, nil
  18278. }
  18279. // AddStatus adds u to the "status" field.
  18280. func (m *MsgMutation) AddStatus(u int8) {
  18281. if m.addstatus != nil {
  18282. *m.addstatus += u
  18283. } else {
  18284. m.addstatus = &u
  18285. }
  18286. }
  18287. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18288. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  18289. v := m.addstatus
  18290. if v == nil {
  18291. return
  18292. }
  18293. return *v, true
  18294. }
  18295. // ClearStatus clears the value of the "status" field.
  18296. func (m *MsgMutation) ClearStatus() {
  18297. m.status = nil
  18298. m.addstatus = nil
  18299. m.clearedFields[msg.FieldStatus] = struct{}{}
  18300. }
  18301. // StatusCleared returns if the "status" field was cleared in this mutation.
  18302. func (m *MsgMutation) StatusCleared() bool {
  18303. _, ok := m.clearedFields[msg.FieldStatus]
  18304. return ok
  18305. }
  18306. // ResetStatus resets all changes to the "status" field.
  18307. func (m *MsgMutation) ResetStatus() {
  18308. m.status = nil
  18309. m.addstatus = nil
  18310. delete(m.clearedFields, msg.FieldStatus)
  18311. }
  18312. // SetFromwxid sets the "fromwxid" field.
  18313. func (m *MsgMutation) SetFromwxid(s string) {
  18314. m.fromwxid = &s
  18315. }
  18316. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  18317. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  18318. v := m.fromwxid
  18319. if v == nil {
  18320. return
  18321. }
  18322. return *v, true
  18323. }
  18324. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  18325. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18327. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  18328. if !m.op.Is(OpUpdateOne) {
  18329. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  18330. }
  18331. if m.id == nil || m.oldValue == nil {
  18332. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  18333. }
  18334. oldValue, err := m.oldValue(ctx)
  18335. if err != nil {
  18336. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  18337. }
  18338. return oldValue.Fromwxid, nil
  18339. }
  18340. // ClearFromwxid clears the value of the "fromwxid" field.
  18341. func (m *MsgMutation) ClearFromwxid() {
  18342. m.fromwxid = nil
  18343. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  18344. }
  18345. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  18346. func (m *MsgMutation) FromwxidCleared() bool {
  18347. _, ok := m.clearedFields[msg.FieldFromwxid]
  18348. return ok
  18349. }
  18350. // ResetFromwxid resets all changes to the "fromwxid" field.
  18351. func (m *MsgMutation) ResetFromwxid() {
  18352. m.fromwxid = nil
  18353. delete(m.clearedFields, msg.FieldFromwxid)
  18354. }
  18355. // SetToid sets the "toid" field.
  18356. func (m *MsgMutation) SetToid(s string) {
  18357. m.toid = &s
  18358. }
  18359. // Toid returns the value of the "toid" field in the mutation.
  18360. func (m *MsgMutation) Toid() (r string, exists bool) {
  18361. v := m.toid
  18362. if v == nil {
  18363. return
  18364. }
  18365. return *v, true
  18366. }
  18367. // OldToid returns the old "toid" field's value of the Msg entity.
  18368. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18370. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  18371. if !m.op.Is(OpUpdateOne) {
  18372. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  18373. }
  18374. if m.id == nil || m.oldValue == nil {
  18375. return v, errors.New("OldToid requires an ID field in the mutation")
  18376. }
  18377. oldValue, err := m.oldValue(ctx)
  18378. if err != nil {
  18379. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  18380. }
  18381. return oldValue.Toid, nil
  18382. }
  18383. // ClearToid clears the value of the "toid" field.
  18384. func (m *MsgMutation) ClearToid() {
  18385. m.toid = nil
  18386. m.clearedFields[msg.FieldToid] = struct{}{}
  18387. }
  18388. // ToidCleared returns if the "toid" field was cleared in this mutation.
  18389. func (m *MsgMutation) ToidCleared() bool {
  18390. _, ok := m.clearedFields[msg.FieldToid]
  18391. return ok
  18392. }
  18393. // ResetToid resets all changes to the "toid" field.
  18394. func (m *MsgMutation) ResetToid() {
  18395. m.toid = nil
  18396. delete(m.clearedFields, msg.FieldToid)
  18397. }
  18398. // SetMsgtype sets the "msgtype" field.
  18399. func (m *MsgMutation) SetMsgtype(i int32) {
  18400. m.msgtype = &i
  18401. m.addmsgtype = nil
  18402. }
  18403. // Msgtype returns the value of the "msgtype" field in the mutation.
  18404. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  18405. v := m.msgtype
  18406. if v == nil {
  18407. return
  18408. }
  18409. return *v, true
  18410. }
  18411. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  18412. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18414. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  18415. if !m.op.Is(OpUpdateOne) {
  18416. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  18417. }
  18418. if m.id == nil || m.oldValue == nil {
  18419. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  18420. }
  18421. oldValue, err := m.oldValue(ctx)
  18422. if err != nil {
  18423. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  18424. }
  18425. return oldValue.Msgtype, nil
  18426. }
  18427. // AddMsgtype adds i to the "msgtype" field.
  18428. func (m *MsgMutation) AddMsgtype(i int32) {
  18429. if m.addmsgtype != nil {
  18430. *m.addmsgtype += i
  18431. } else {
  18432. m.addmsgtype = &i
  18433. }
  18434. }
  18435. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  18436. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  18437. v := m.addmsgtype
  18438. if v == nil {
  18439. return
  18440. }
  18441. return *v, true
  18442. }
  18443. // ClearMsgtype clears the value of the "msgtype" field.
  18444. func (m *MsgMutation) ClearMsgtype() {
  18445. m.msgtype = nil
  18446. m.addmsgtype = nil
  18447. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  18448. }
  18449. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  18450. func (m *MsgMutation) MsgtypeCleared() bool {
  18451. _, ok := m.clearedFields[msg.FieldMsgtype]
  18452. return ok
  18453. }
  18454. // ResetMsgtype resets all changes to the "msgtype" field.
  18455. func (m *MsgMutation) ResetMsgtype() {
  18456. m.msgtype = nil
  18457. m.addmsgtype = nil
  18458. delete(m.clearedFields, msg.FieldMsgtype)
  18459. }
  18460. // SetMsg sets the "msg" field.
  18461. func (m *MsgMutation) SetMsg(s string) {
  18462. m.msg = &s
  18463. }
  18464. // Msg returns the value of the "msg" field in the mutation.
  18465. func (m *MsgMutation) Msg() (r string, exists bool) {
  18466. v := m.msg
  18467. if v == nil {
  18468. return
  18469. }
  18470. return *v, true
  18471. }
  18472. // OldMsg returns the old "msg" field's value of the Msg entity.
  18473. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18475. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  18476. if !m.op.Is(OpUpdateOne) {
  18477. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  18478. }
  18479. if m.id == nil || m.oldValue == nil {
  18480. return v, errors.New("OldMsg requires an ID field in the mutation")
  18481. }
  18482. oldValue, err := m.oldValue(ctx)
  18483. if err != nil {
  18484. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  18485. }
  18486. return oldValue.Msg, nil
  18487. }
  18488. // ClearMsg clears the value of the "msg" field.
  18489. func (m *MsgMutation) ClearMsg() {
  18490. m.msg = nil
  18491. m.clearedFields[msg.FieldMsg] = struct{}{}
  18492. }
  18493. // MsgCleared returns if the "msg" field was cleared in this mutation.
  18494. func (m *MsgMutation) MsgCleared() bool {
  18495. _, ok := m.clearedFields[msg.FieldMsg]
  18496. return ok
  18497. }
  18498. // ResetMsg resets all changes to the "msg" field.
  18499. func (m *MsgMutation) ResetMsg() {
  18500. m.msg = nil
  18501. delete(m.clearedFields, msg.FieldMsg)
  18502. }
  18503. // SetBatchNo sets the "batch_no" field.
  18504. func (m *MsgMutation) SetBatchNo(s string) {
  18505. m.batch_no = &s
  18506. }
  18507. // BatchNo returns the value of the "batch_no" field in the mutation.
  18508. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  18509. v := m.batch_no
  18510. if v == nil {
  18511. return
  18512. }
  18513. return *v, true
  18514. }
  18515. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  18516. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18518. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  18519. if !m.op.Is(OpUpdateOne) {
  18520. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  18521. }
  18522. if m.id == nil || m.oldValue == nil {
  18523. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  18524. }
  18525. oldValue, err := m.oldValue(ctx)
  18526. if err != nil {
  18527. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  18528. }
  18529. return oldValue.BatchNo, nil
  18530. }
  18531. // ClearBatchNo clears the value of the "batch_no" field.
  18532. func (m *MsgMutation) ClearBatchNo() {
  18533. m.batch_no = nil
  18534. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  18535. }
  18536. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  18537. func (m *MsgMutation) BatchNoCleared() bool {
  18538. _, ok := m.clearedFields[msg.FieldBatchNo]
  18539. return ok
  18540. }
  18541. // ResetBatchNo resets all changes to the "batch_no" field.
  18542. func (m *MsgMutation) ResetBatchNo() {
  18543. m.batch_no = nil
  18544. delete(m.clearedFields, msg.FieldBatchNo)
  18545. }
  18546. // Where appends a list predicates to the MsgMutation builder.
  18547. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  18548. m.predicates = append(m.predicates, ps...)
  18549. }
  18550. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  18551. // users can use type-assertion to append predicates that do not depend on any generated package.
  18552. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  18553. p := make([]predicate.Msg, len(ps))
  18554. for i := range ps {
  18555. p[i] = ps[i]
  18556. }
  18557. m.Where(p...)
  18558. }
  18559. // Op returns the operation name.
  18560. func (m *MsgMutation) Op() Op {
  18561. return m.op
  18562. }
  18563. // SetOp allows setting the mutation operation.
  18564. func (m *MsgMutation) SetOp(op Op) {
  18565. m.op = op
  18566. }
  18567. // Type returns the node type of this mutation (Msg).
  18568. func (m *MsgMutation) Type() string {
  18569. return m.typ
  18570. }
  18571. // Fields returns all fields that were changed during this mutation. Note that in
  18572. // order to get all numeric fields that were incremented/decremented, call
  18573. // AddedFields().
  18574. func (m *MsgMutation) Fields() []string {
  18575. fields := make([]string, 0, 9)
  18576. if m.created_at != nil {
  18577. fields = append(fields, msg.FieldCreatedAt)
  18578. }
  18579. if m.updated_at != nil {
  18580. fields = append(fields, msg.FieldUpdatedAt)
  18581. }
  18582. if m.deleted_at != nil {
  18583. fields = append(fields, msg.FieldDeletedAt)
  18584. }
  18585. if m.status != nil {
  18586. fields = append(fields, msg.FieldStatus)
  18587. }
  18588. if m.fromwxid != nil {
  18589. fields = append(fields, msg.FieldFromwxid)
  18590. }
  18591. if m.toid != nil {
  18592. fields = append(fields, msg.FieldToid)
  18593. }
  18594. if m.msgtype != nil {
  18595. fields = append(fields, msg.FieldMsgtype)
  18596. }
  18597. if m.msg != nil {
  18598. fields = append(fields, msg.FieldMsg)
  18599. }
  18600. if m.batch_no != nil {
  18601. fields = append(fields, msg.FieldBatchNo)
  18602. }
  18603. return fields
  18604. }
  18605. // Field returns the value of a field with the given name. The second boolean
  18606. // return value indicates that this field was not set, or was not defined in the
  18607. // schema.
  18608. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  18609. switch name {
  18610. case msg.FieldCreatedAt:
  18611. return m.CreatedAt()
  18612. case msg.FieldUpdatedAt:
  18613. return m.UpdatedAt()
  18614. case msg.FieldDeletedAt:
  18615. return m.DeletedAt()
  18616. case msg.FieldStatus:
  18617. return m.Status()
  18618. case msg.FieldFromwxid:
  18619. return m.Fromwxid()
  18620. case msg.FieldToid:
  18621. return m.Toid()
  18622. case msg.FieldMsgtype:
  18623. return m.Msgtype()
  18624. case msg.FieldMsg:
  18625. return m.Msg()
  18626. case msg.FieldBatchNo:
  18627. return m.BatchNo()
  18628. }
  18629. return nil, false
  18630. }
  18631. // OldField returns the old value of the field from the database. An error is
  18632. // returned if the mutation operation is not UpdateOne, or the query to the
  18633. // database failed.
  18634. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18635. switch name {
  18636. case msg.FieldCreatedAt:
  18637. return m.OldCreatedAt(ctx)
  18638. case msg.FieldUpdatedAt:
  18639. return m.OldUpdatedAt(ctx)
  18640. case msg.FieldDeletedAt:
  18641. return m.OldDeletedAt(ctx)
  18642. case msg.FieldStatus:
  18643. return m.OldStatus(ctx)
  18644. case msg.FieldFromwxid:
  18645. return m.OldFromwxid(ctx)
  18646. case msg.FieldToid:
  18647. return m.OldToid(ctx)
  18648. case msg.FieldMsgtype:
  18649. return m.OldMsgtype(ctx)
  18650. case msg.FieldMsg:
  18651. return m.OldMsg(ctx)
  18652. case msg.FieldBatchNo:
  18653. return m.OldBatchNo(ctx)
  18654. }
  18655. return nil, fmt.Errorf("unknown Msg field %s", name)
  18656. }
  18657. // SetField sets the value of a field with the given name. It returns an error if
  18658. // the field is not defined in the schema, or if the type mismatched the field
  18659. // type.
  18660. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  18661. switch name {
  18662. case msg.FieldCreatedAt:
  18663. v, ok := value.(time.Time)
  18664. if !ok {
  18665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18666. }
  18667. m.SetCreatedAt(v)
  18668. return nil
  18669. case msg.FieldUpdatedAt:
  18670. v, ok := value.(time.Time)
  18671. if !ok {
  18672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18673. }
  18674. m.SetUpdatedAt(v)
  18675. return nil
  18676. case msg.FieldDeletedAt:
  18677. v, ok := value.(time.Time)
  18678. if !ok {
  18679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18680. }
  18681. m.SetDeletedAt(v)
  18682. return nil
  18683. case msg.FieldStatus:
  18684. v, ok := value.(uint8)
  18685. if !ok {
  18686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18687. }
  18688. m.SetStatus(v)
  18689. return nil
  18690. case msg.FieldFromwxid:
  18691. v, ok := value.(string)
  18692. if !ok {
  18693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18694. }
  18695. m.SetFromwxid(v)
  18696. return nil
  18697. case msg.FieldToid:
  18698. v, ok := value.(string)
  18699. if !ok {
  18700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18701. }
  18702. m.SetToid(v)
  18703. return nil
  18704. case msg.FieldMsgtype:
  18705. v, ok := value.(int32)
  18706. if !ok {
  18707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18708. }
  18709. m.SetMsgtype(v)
  18710. return nil
  18711. case msg.FieldMsg:
  18712. v, ok := value.(string)
  18713. if !ok {
  18714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18715. }
  18716. m.SetMsg(v)
  18717. return nil
  18718. case msg.FieldBatchNo:
  18719. v, ok := value.(string)
  18720. if !ok {
  18721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18722. }
  18723. m.SetBatchNo(v)
  18724. return nil
  18725. }
  18726. return fmt.Errorf("unknown Msg field %s", name)
  18727. }
  18728. // AddedFields returns all numeric fields that were incremented/decremented during
  18729. // this mutation.
  18730. func (m *MsgMutation) AddedFields() []string {
  18731. var fields []string
  18732. if m.addstatus != nil {
  18733. fields = append(fields, msg.FieldStatus)
  18734. }
  18735. if m.addmsgtype != nil {
  18736. fields = append(fields, msg.FieldMsgtype)
  18737. }
  18738. return fields
  18739. }
  18740. // AddedField returns the numeric value that was incremented/decremented on a field
  18741. // with the given name. The second boolean return value indicates that this field
  18742. // was not set, or was not defined in the schema.
  18743. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  18744. switch name {
  18745. case msg.FieldStatus:
  18746. return m.AddedStatus()
  18747. case msg.FieldMsgtype:
  18748. return m.AddedMsgtype()
  18749. }
  18750. return nil, false
  18751. }
  18752. // AddField adds the value to the field with the given name. It returns an error if
  18753. // the field is not defined in the schema, or if the type mismatched the field
  18754. // type.
  18755. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  18756. switch name {
  18757. case msg.FieldStatus:
  18758. v, ok := value.(int8)
  18759. if !ok {
  18760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18761. }
  18762. m.AddStatus(v)
  18763. return nil
  18764. case msg.FieldMsgtype:
  18765. v, ok := value.(int32)
  18766. if !ok {
  18767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18768. }
  18769. m.AddMsgtype(v)
  18770. return nil
  18771. }
  18772. return fmt.Errorf("unknown Msg numeric field %s", name)
  18773. }
  18774. // ClearedFields returns all nullable fields that were cleared during this
  18775. // mutation.
  18776. func (m *MsgMutation) ClearedFields() []string {
  18777. var fields []string
  18778. if m.FieldCleared(msg.FieldDeletedAt) {
  18779. fields = append(fields, msg.FieldDeletedAt)
  18780. }
  18781. if m.FieldCleared(msg.FieldStatus) {
  18782. fields = append(fields, msg.FieldStatus)
  18783. }
  18784. if m.FieldCleared(msg.FieldFromwxid) {
  18785. fields = append(fields, msg.FieldFromwxid)
  18786. }
  18787. if m.FieldCleared(msg.FieldToid) {
  18788. fields = append(fields, msg.FieldToid)
  18789. }
  18790. if m.FieldCleared(msg.FieldMsgtype) {
  18791. fields = append(fields, msg.FieldMsgtype)
  18792. }
  18793. if m.FieldCleared(msg.FieldMsg) {
  18794. fields = append(fields, msg.FieldMsg)
  18795. }
  18796. if m.FieldCleared(msg.FieldBatchNo) {
  18797. fields = append(fields, msg.FieldBatchNo)
  18798. }
  18799. return fields
  18800. }
  18801. // FieldCleared returns a boolean indicating if a field with the given name was
  18802. // cleared in this mutation.
  18803. func (m *MsgMutation) FieldCleared(name string) bool {
  18804. _, ok := m.clearedFields[name]
  18805. return ok
  18806. }
  18807. // ClearField clears the value of the field with the given name. It returns an
  18808. // error if the field is not defined in the schema.
  18809. func (m *MsgMutation) ClearField(name string) error {
  18810. switch name {
  18811. case msg.FieldDeletedAt:
  18812. m.ClearDeletedAt()
  18813. return nil
  18814. case msg.FieldStatus:
  18815. m.ClearStatus()
  18816. return nil
  18817. case msg.FieldFromwxid:
  18818. m.ClearFromwxid()
  18819. return nil
  18820. case msg.FieldToid:
  18821. m.ClearToid()
  18822. return nil
  18823. case msg.FieldMsgtype:
  18824. m.ClearMsgtype()
  18825. return nil
  18826. case msg.FieldMsg:
  18827. m.ClearMsg()
  18828. return nil
  18829. case msg.FieldBatchNo:
  18830. m.ClearBatchNo()
  18831. return nil
  18832. }
  18833. return fmt.Errorf("unknown Msg nullable field %s", name)
  18834. }
  18835. // ResetField resets all changes in the mutation for the field with the given name.
  18836. // It returns an error if the field is not defined in the schema.
  18837. func (m *MsgMutation) ResetField(name string) error {
  18838. switch name {
  18839. case msg.FieldCreatedAt:
  18840. m.ResetCreatedAt()
  18841. return nil
  18842. case msg.FieldUpdatedAt:
  18843. m.ResetUpdatedAt()
  18844. return nil
  18845. case msg.FieldDeletedAt:
  18846. m.ResetDeletedAt()
  18847. return nil
  18848. case msg.FieldStatus:
  18849. m.ResetStatus()
  18850. return nil
  18851. case msg.FieldFromwxid:
  18852. m.ResetFromwxid()
  18853. return nil
  18854. case msg.FieldToid:
  18855. m.ResetToid()
  18856. return nil
  18857. case msg.FieldMsgtype:
  18858. m.ResetMsgtype()
  18859. return nil
  18860. case msg.FieldMsg:
  18861. m.ResetMsg()
  18862. return nil
  18863. case msg.FieldBatchNo:
  18864. m.ResetBatchNo()
  18865. return nil
  18866. }
  18867. return fmt.Errorf("unknown Msg field %s", name)
  18868. }
  18869. // AddedEdges returns all edge names that were set/added in this mutation.
  18870. func (m *MsgMutation) AddedEdges() []string {
  18871. edges := make([]string, 0, 0)
  18872. return edges
  18873. }
  18874. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18875. // name in this mutation.
  18876. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  18877. return nil
  18878. }
  18879. // RemovedEdges returns all edge names that were removed in this mutation.
  18880. func (m *MsgMutation) RemovedEdges() []string {
  18881. edges := make([]string, 0, 0)
  18882. return edges
  18883. }
  18884. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18885. // the given name in this mutation.
  18886. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  18887. return nil
  18888. }
  18889. // ClearedEdges returns all edge names that were cleared in this mutation.
  18890. func (m *MsgMutation) ClearedEdges() []string {
  18891. edges := make([]string, 0, 0)
  18892. return edges
  18893. }
  18894. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18895. // was cleared in this mutation.
  18896. func (m *MsgMutation) EdgeCleared(name string) bool {
  18897. return false
  18898. }
  18899. // ClearEdge clears the value of the edge with the given name. It returns an error
  18900. // if that edge is not defined in the schema.
  18901. func (m *MsgMutation) ClearEdge(name string) error {
  18902. return fmt.Errorf("unknown Msg unique edge %s", name)
  18903. }
  18904. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18905. // It returns an error if the edge is not defined in the schema.
  18906. func (m *MsgMutation) ResetEdge(name string) error {
  18907. return fmt.Errorf("unknown Msg edge %s", name)
  18908. }
  18909. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  18910. type PayRechargeMutation struct {
  18911. config
  18912. op Op
  18913. typ string
  18914. id *uint64
  18915. created_at *time.Time
  18916. updated_at *time.Time
  18917. deleted_at *time.Time
  18918. user_id *string
  18919. number *float32
  18920. addnumber *float32
  18921. status *int
  18922. addstatus *int
  18923. money *float32
  18924. addmoney *float32
  18925. out_trade_no *string
  18926. organization_id *uint64
  18927. addorganization_id *int64
  18928. clearedFields map[string]struct{}
  18929. done bool
  18930. oldValue func(context.Context) (*PayRecharge, error)
  18931. predicates []predicate.PayRecharge
  18932. }
  18933. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  18934. // payrechargeOption allows management of the mutation configuration using functional options.
  18935. type payrechargeOption func(*PayRechargeMutation)
  18936. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  18937. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  18938. m := &PayRechargeMutation{
  18939. config: c,
  18940. op: op,
  18941. typ: TypePayRecharge,
  18942. clearedFields: make(map[string]struct{}),
  18943. }
  18944. for _, opt := range opts {
  18945. opt(m)
  18946. }
  18947. return m
  18948. }
  18949. // withPayRechargeID sets the ID field of the mutation.
  18950. func withPayRechargeID(id uint64) payrechargeOption {
  18951. return func(m *PayRechargeMutation) {
  18952. var (
  18953. err error
  18954. once sync.Once
  18955. value *PayRecharge
  18956. )
  18957. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  18958. once.Do(func() {
  18959. if m.done {
  18960. err = errors.New("querying old values post mutation is not allowed")
  18961. } else {
  18962. value, err = m.Client().PayRecharge.Get(ctx, id)
  18963. }
  18964. })
  18965. return value, err
  18966. }
  18967. m.id = &id
  18968. }
  18969. }
  18970. // withPayRecharge sets the old PayRecharge of the mutation.
  18971. func withPayRecharge(node *PayRecharge) payrechargeOption {
  18972. return func(m *PayRechargeMutation) {
  18973. m.oldValue = func(context.Context) (*PayRecharge, error) {
  18974. return node, nil
  18975. }
  18976. m.id = &node.ID
  18977. }
  18978. }
  18979. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18980. // executed in a transaction (ent.Tx), a transactional client is returned.
  18981. func (m PayRechargeMutation) Client() *Client {
  18982. client := &Client{config: m.config}
  18983. client.init()
  18984. return client
  18985. }
  18986. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18987. // it returns an error otherwise.
  18988. func (m PayRechargeMutation) Tx() (*Tx, error) {
  18989. if _, ok := m.driver.(*txDriver); !ok {
  18990. return nil, errors.New("ent: mutation is not running in a transaction")
  18991. }
  18992. tx := &Tx{config: m.config}
  18993. tx.init()
  18994. return tx, nil
  18995. }
  18996. // SetID sets the value of the id field. Note that this
  18997. // operation is only accepted on creation of PayRecharge entities.
  18998. func (m *PayRechargeMutation) SetID(id uint64) {
  18999. m.id = &id
  19000. }
  19001. // ID returns the ID value in the mutation. Note that the ID is only available
  19002. // if it was provided to the builder or after it was returned from the database.
  19003. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  19004. if m.id == nil {
  19005. return
  19006. }
  19007. return *m.id, true
  19008. }
  19009. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19010. // That means, if the mutation is applied within a transaction with an isolation level such
  19011. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19012. // or updated by the mutation.
  19013. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  19014. switch {
  19015. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19016. id, exists := m.ID()
  19017. if exists {
  19018. return []uint64{id}, nil
  19019. }
  19020. fallthrough
  19021. case m.op.Is(OpUpdate | OpDelete):
  19022. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  19023. default:
  19024. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19025. }
  19026. }
  19027. // SetCreatedAt sets the "created_at" field.
  19028. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  19029. m.created_at = &t
  19030. }
  19031. // CreatedAt returns the value of the "created_at" field in the mutation.
  19032. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  19033. v := m.created_at
  19034. if v == nil {
  19035. return
  19036. }
  19037. return *v, true
  19038. }
  19039. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  19040. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19042. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19043. if !m.op.Is(OpUpdateOne) {
  19044. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19045. }
  19046. if m.id == nil || m.oldValue == nil {
  19047. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19048. }
  19049. oldValue, err := m.oldValue(ctx)
  19050. if err != nil {
  19051. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19052. }
  19053. return oldValue.CreatedAt, nil
  19054. }
  19055. // ResetCreatedAt resets all changes to the "created_at" field.
  19056. func (m *PayRechargeMutation) ResetCreatedAt() {
  19057. m.created_at = nil
  19058. }
  19059. // SetUpdatedAt sets the "updated_at" field.
  19060. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  19061. m.updated_at = &t
  19062. }
  19063. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19064. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  19065. v := m.updated_at
  19066. if v == nil {
  19067. return
  19068. }
  19069. return *v, true
  19070. }
  19071. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  19072. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19074. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19075. if !m.op.Is(OpUpdateOne) {
  19076. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19077. }
  19078. if m.id == nil || m.oldValue == nil {
  19079. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19080. }
  19081. oldValue, err := m.oldValue(ctx)
  19082. if err != nil {
  19083. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19084. }
  19085. return oldValue.UpdatedAt, nil
  19086. }
  19087. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19088. func (m *PayRechargeMutation) ResetUpdatedAt() {
  19089. m.updated_at = nil
  19090. }
  19091. // SetDeletedAt sets the "deleted_at" field.
  19092. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  19093. m.deleted_at = &t
  19094. }
  19095. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19096. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  19097. v := m.deleted_at
  19098. if v == nil {
  19099. return
  19100. }
  19101. return *v, true
  19102. }
  19103. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  19104. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19106. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19107. if !m.op.Is(OpUpdateOne) {
  19108. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19109. }
  19110. if m.id == nil || m.oldValue == nil {
  19111. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19112. }
  19113. oldValue, err := m.oldValue(ctx)
  19114. if err != nil {
  19115. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19116. }
  19117. return oldValue.DeletedAt, nil
  19118. }
  19119. // ClearDeletedAt clears the value of the "deleted_at" field.
  19120. func (m *PayRechargeMutation) ClearDeletedAt() {
  19121. m.deleted_at = nil
  19122. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  19123. }
  19124. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19125. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  19126. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  19127. return ok
  19128. }
  19129. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19130. func (m *PayRechargeMutation) ResetDeletedAt() {
  19131. m.deleted_at = nil
  19132. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  19133. }
  19134. // SetUserID sets the "user_id" field.
  19135. func (m *PayRechargeMutation) SetUserID(s string) {
  19136. m.user_id = &s
  19137. }
  19138. // UserID returns the value of the "user_id" field in the mutation.
  19139. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  19140. v := m.user_id
  19141. if v == nil {
  19142. return
  19143. }
  19144. return *v, true
  19145. }
  19146. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  19147. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19149. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  19150. if !m.op.Is(OpUpdateOne) {
  19151. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  19152. }
  19153. if m.id == nil || m.oldValue == nil {
  19154. return v, errors.New("OldUserID requires an ID field in the mutation")
  19155. }
  19156. oldValue, err := m.oldValue(ctx)
  19157. if err != nil {
  19158. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  19159. }
  19160. return oldValue.UserID, nil
  19161. }
  19162. // ResetUserID resets all changes to the "user_id" field.
  19163. func (m *PayRechargeMutation) ResetUserID() {
  19164. m.user_id = nil
  19165. }
  19166. // SetNumber sets the "number" field.
  19167. func (m *PayRechargeMutation) SetNumber(f float32) {
  19168. m.number = &f
  19169. m.addnumber = nil
  19170. }
  19171. // Number returns the value of the "number" field in the mutation.
  19172. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  19173. v := m.number
  19174. if v == nil {
  19175. return
  19176. }
  19177. return *v, true
  19178. }
  19179. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  19180. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19182. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  19183. if !m.op.Is(OpUpdateOne) {
  19184. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  19185. }
  19186. if m.id == nil || m.oldValue == nil {
  19187. return v, errors.New("OldNumber requires an ID field in the mutation")
  19188. }
  19189. oldValue, err := m.oldValue(ctx)
  19190. if err != nil {
  19191. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  19192. }
  19193. return oldValue.Number, nil
  19194. }
  19195. // AddNumber adds f to the "number" field.
  19196. func (m *PayRechargeMutation) AddNumber(f float32) {
  19197. if m.addnumber != nil {
  19198. *m.addnumber += f
  19199. } else {
  19200. m.addnumber = &f
  19201. }
  19202. }
  19203. // AddedNumber returns the value that was added to the "number" field in this mutation.
  19204. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  19205. v := m.addnumber
  19206. if v == nil {
  19207. return
  19208. }
  19209. return *v, true
  19210. }
  19211. // ResetNumber resets all changes to the "number" field.
  19212. func (m *PayRechargeMutation) ResetNumber() {
  19213. m.number = nil
  19214. m.addnumber = nil
  19215. }
  19216. // SetStatus sets the "status" field.
  19217. func (m *PayRechargeMutation) SetStatus(i int) {
  19218. m.status = &i
  19219. m.addstatus = nil
  19220. }
  19221. // Status returns the value of the "status" field in the mutation.
  19222. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  19223. v := m.status
  19224. if v == nil {
  19225. return
  19226. }
  19227. return *v, true
  19228. }
  19229. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  19230. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19232. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  19233. if !m.op.Is(OpUpdateOne) {
  19234. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19235. }
  19236. if m.id == nil || m.oldValue == nil {
  19237. return v, errors.New("OldStatus requires an ID field in the mutation")
  19238. }
  19239. oldValue, err := m.oldValue(ctx)
  19240. if err != nil {
  19241. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19242. }
  19243. return oldValue.Status, nil
  19244. }
  19245. // AddStatus adds i to the "status" field.
  19246. func (m *PayRechargeMutation) AddStatus(i int) {
  19247. if m.addstatus != nil {
  19248. *m.addstatus += i
  19249. } else {
  19250. m.addstatus = &i
  19251. }
  19252. }
  19253. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19254. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  19255. v := m.addstatus
  19256. if v == nil {
  19257. return
  19258. }
  19259. return *v, true
  19260. }
  19261. // ClearStatus clears the value of the "status" field.
  19262. func (m *PayRechargeMutation) ClearStatus() {
  19263. m.status = nil
  19264. m.addstatus = nil
  19265. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  19266. }
  19267. // StatusCleared returns if the "status" field was cleared in this mutation.
  19268. func (m *PayRechargeMutation) StatusCleared() bool {
  19269. _, ok := m.clearedFields[payrecharge.FieldStatus]
  19270. return ok
  19271. }
  19272. // ResetStatus resets all changes to the "status" field.
  19273. func (m *PayRechargeMutation) ResetStatus() {
  19274. m.status = nil
  19275. m.addstatus = nil
  19276. delete(m.clearedFields, payrecharge.FieldStatus)
  19277. }
  19278. // SetMoney sets the "money" field.
  19279. func (m *PayRechargeMutation) SetMoney(f float32) {
  19280. m.money = &f
  19281. m.addmoney = nil
  19282. }
  19283. // Money returns the value of the "money" field in the mutation.
  19284. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  19285. v := m.money
  19286. if v == nil {
  19287. return
  19288. }
  19289. return *v, true
  19290. }
  19291. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  19292. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19294. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  19295. if !m.op.Is(OpUpdateOne) {
  19296. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  19297. }
  19298. if m.id == nil || m.oldValue == nil {
  19299. return v, errors.New("OldMoney requires an ID field in the mutation")
  19300. }
  19301. oldValue, err := m.oldValue(ctx)
  19302. if err != nil {
  19303. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  19304. }
  19305. return oldValue.Money, nil
  19306. }
  19307. // AddMoney adds f to the "money" field.
  19308. func (m *PayRechargeMutation) AddMoney(f float32) {
  19309. if m.addmoney != nil {
  19310. *m.addmoney += f
  19311. } else {
  19312. m.addmoney = &f
  19313. }
  19314. }
  19315. // AddedMoney returns the value that was added to the "money" field in this mutation.
  19316. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  19317. v := m.addmoney
  19318. if v == nil {
  19319. return
  19320. }
  19321. return *v, true
  19322. }
  19323. // ClearMoney clears the value of the "money" field.
  19324. func (m *PayRechargeMutation) ClearMoney() {
  19325. m.money = nil
  19326. m.addmoney = nil
  19327. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  19328. }
  19329. // MoneyCleared returns if the "money" field was cleared in this mutation.
  19330. func (m *PayRechargeMutation) MoneyCleared() bool {
  19331. _, ok := m.clearedFields[payrecharge.FieldMoney]
  19332. return ok
  19333. }
  19334. // ResetMoney resets all changes to the "money" field.
  19335. func (m *PayRechargeMutation) ResetMoney() {
  19336. m.money = nil
  19337. m.addmoney = nil
  19338. delete(m.clearedFields, payrecharge.FieldMoney)
  19339. }
  19340. // SetOutTradeNo sets the "out_trade_no" field.
  19341. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  19342. m.out_trade_no = &s
  19343. }
  19344. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  19345. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  19346. v := m.out_trade_no
  19347. if v == nil {
  19348. return
  19349. }
  19350. return *v, true
  19351. }
  19352. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  19353. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19355. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  19356. if !m.op.Is(OpUpdateOne) {
  19357. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  19358. }
  19359. if m.id == nil || m.oldValue == nil {
  19360. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  19361. }
  19362. oldValue, err := m.oldValue(ctx)
  19363. if err != nil {
  19364. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  19365. }
  19366. return oldValue.OutTradeNo, nil
  19367. }
  19368. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  19369. func (m *PayRechargeMutation) ClearOutTradeNo() {
  19370. m.out_trade_no = nil
  19371. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  19372. }
  19373. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  19374. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  19375. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  19376. return ok
  19377. }
  19378. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  19379. func (m *PayRechargeMutation) ResetOutTradeNo() {
  19380. m.out_trade_no = nil
  19381. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  19382. }
  19383. // SetOrganizationID sets the "organization_id" field.
  19384. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  19385. m.organization_id = &u
  19386. m.addorganization_id = nil
  19387. }
  19388. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19389. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  19390. v := m.organization_id
  19391. if v == nil {
  19392. return
  19393. }
  19394. return *v, true
  19395. }
  19396. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  19397. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19399. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19400. if !m.op.Is(OpUpdateOne) {
  19401. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19402. }
  19403. if m.id == nil || m.oldValue == nil {
  19404. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19405. }
  19406. oldValue, err := m.oldValue(ctx)
  19407. if err != nil {
  19408. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19409. }
  19410. return oldValue.OrganizationID, nil
  19411. }
  19412. // AddOrganizationID adds u to the "organization_id" field.
  19413. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  19414. if m.addorganization_id != nil {
  19415. *m.addorganization_id += u
  19416. } else {
  19417. m.addorganization_id = &u
  19418. }
  19419. }
  19420. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19421. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  19422. v := m.addorganization_id
  19423. if v == nil {
  19424. return
  19425. }
  19426. return *v, true
  19427. }
  19428. // ResetOrganizationID resets all changes to the "organization_id" field.
  19429. func (m *PayRechargeMutation) ResetOrganizationID() {
  19430. m.organization_id = nil
  19431. m.addorganization_id = nil
  19432. }
  19433. // Where appends a list predicates to the PayRechargeMutation builder.
  19434. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  19435. m.predicates = append(m.predicates, ps...)
  19436. }
  19437. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  19438. // users can use type-assertion to append predicates that do not depend on any generated package.
  19439. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  19440. p := make([]predicate.PayRecharge, len(ps))
  19441. for i := range ps {
  19442. p[i] = ps[i]
  19443. }
  19444. m.Where(p...)
  19445. }
  19446. // Op returns the operation name.
  19447. func (m *PayRechargeMutation) Op() Op {
  19448. return m.op
  19449. }
  19450. // SetOp allows setting the mutation operation.
  19451. func (m *PayRechargeMutation) SetOp(op Op) {
  19452. m.op = op
  19453. }
  19454. // Type returns the node type of this mutation (PayRecharge).
  19455. func (m *PayRechargeMutation) Type() string {
  19456. return m.typ
  19457. }
  19458. // Fields returns all fields that were changed during this mutation. Note that in
  19459. // order to get all numeric fields that were incremented/decremented, call
  19460. // AddedFields().
  19461. func (m *PayRechargeMutation) Fields() []string {
  19462. fields := make([]string, 0, 9)
  19463. if m.created_at != nil {
  19464. fields = append(fields, payrecharge.FieldCreatedAt)
  19465. }
  19466. if m.updated_at != nil {
  19467. fields = append(fields, payrecharge.FieldUpdatedAt)
  19468. }
  19469. if m.deleted_at != nil {
  19470. fields = append(fields, payrecharge.FieldDeletedAt)
  19471. }
  19472. if m.user_id != nil {
  19473. fields = append(fields, payrecharge.FieldUserID)
  19474. }
  19475. if m.number != nil {
  19476. fields = append(fields, payrecharge.FieldNumber)
  19477. }
  19478. if m.status != nil {
  19479. fields = append(fields, payrecharge.FieldStatus)
  19480. }
  19481. if m.money != nil {
  19482. fields = append(fields, payrecharge.FieldMoney)
  19483. }
  19484. if m.out_trade_no != nil {
  19485. fields = append(fields, payrecharge.FieldOutTradeNo)
  19486. }
  19487. if m.organization_id != nil {
  19488. fields = append(fields, payrecharge.FieldOrganizationID)
  19489. }
  19490. return fields
  19491. }
  19492. // Field returns the value of a field with the given name. The second boolean
  19493. // return value indicates that this field was not set, or was not defined in the
  19494. // schema.
  19495. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  19496. switch name {
  19497. case payrecharge.FieldCreatedAt:
  19498. return m.CreatedAt()
  19499. case payrecharge.FieldUpdatedAt:
  19500. return m.UpdatedAt()
  19501. case payrecharge.FieldDeletedAt:
  19502. return m.DeletedAt()
  19503. case payrecharge.FieldUserID:
  19504. return m.UserID()
  19505. case payrecharge.FieldNumber:
  19506. return m.Number()
  19507. case payrecharge.FieldStatus:
  19508. return m.Status()
  19509. case payrecharge.FieldMoney:
  19510. return m.Money()
  19511. case payrecharge.FieldOutTradeNo:
  19512. return m.OutTradeNo()
  19513. case payrecharge.FieldOrganizationID:
  19514. return m.OrganizationID()
  19515. }
  19516. return nil, false
  19517. }
  19518. // OldField returns the old value of the field from the database. An error is
  19519. // returned if the mutation operation is not UpdateOne, or the query to the
  19520. // database failed.
  19521. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19522. switch name {
  19523. case payrecharge.FieldCreatedAt:
  19524. return m.OldCreatedAt(ctx)
  19525. case payrecharge.FieldUpdatedAt:
  19526. return m.OldUpdatedAt(ctx)
  19527. case payrecharge.FieldDeletedAt:
  19528. return m.OldDeletedAt(ctx)
  19529. case payrecharge.FieldUserID:
  19530. return m.OldUserID(ctx)
  19531. case payrecharge.FieldNumber:
  19532. return m.OldNumber(ctx)
  19533. case payrecharge.FieldStatus:
  19534. return m.OldStatus(ctx)
  19535. case payrecharge.FieldMoney:
  19536. return m.OldMoney(ctx)
  19537. case payrecharge.FieldOutTradeNo:
  19538. return m.OldOutTradeNo(ctx)
  19539. case payrecharge.FieldOrganizationID:
  19540. return m.OldOrganizationID(ctx)
  19541. }
  19542. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  19543. }
  19544. // SetField sets the value of a field with the given name. It returns an error if
  19545. // the field is not defined in the schema, or if the type mismatched the field
  19546. // type.
  19547. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  19548. switch name {
  19549. case payrecharge.FieldCreatedAt:
  19550. v, ok := value.(time.Time)
  19551. if !ok {
  19552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19553. }
  19554. m.SetCreatedAt(v)
  19555. return nil
  19556. case payrecharge.FieldUpdatedAt:
  19557. v, ok := value.(time.Time)
  19558. if !ok {
  19559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19560. }
  19561. m.SetUpdatedAt(v)
  19562. return nil
  19563. case payrecharge.FieldDeletedAt:
  19564. v, ok := value.(time.Time)
  19565. if !ok {
  19566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19567. }
  19568. m.SetDeletedAt(v)
  19569. return nil
  19570. case payrecharge.FieldUserID:
  19571. v, ok := value.(string)
  19572. if !ok {
  19573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19574. }
  19575. m.SetUserID(v)
  19576. return nil
  19577. case payrecharge.FieldNumber:
  19578. v, ok := value.(float32)
  19579. if !ok {
  19580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19581. }
  19582. m.SetNumber(v)
  19583. return nil
  19584. case payrecharge.FieldStatus:
  19585. v, ok := value.(int)
  19586. if !ok {
  19587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19588. }
  19589. m.SetStatus(v)
  19590. return nil
  19591. case payrecharge.FieldMoney:
  19592. v, ok := value.(float32)
  19593. if !ok {
  19594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19595. }
  19596. m.SetMoney(v)
  19597. return nil
  19598. case payrecharge.FieldOutTradeNo:
  19599. v, ok := value.(string)
  19600. if !ok {
  19601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19602. }
  19603. m.SetOutTradeNo(v)
  19604. return nil
  19605. case payrecharge.FieldOrganizationID:
  19606. v, ok := value.(uint64)
  19607. if !ok {
  19608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19609. }
  19610. m.SetOrganizationID(v)
  19611. return nil
  19612. }
  19613. return fmt.Errorf("unknown PayRecharge field %s", name)
  19614. }
  19615. // AddedFields returns all numeric fields that were incremented/decremented during
  19616. // this mutation.
  19617. func (m *PayRechargeMutation) AddedFields() []string {
  19618. var fields []string
  19619. if m.addnumber != nil {
  19620. fields = append(fields, payrecharge.FieldNumber)
  19621. }
  19622. if m.addstatus != nil {
  19623. fields = append(fields, payrecharge.FieldStatus)
  19624. }
  19625. if m.addmoney != nil {
  19626. fields = append(fields, payrecharge.FieldMoney)
  19627. }
  19628. if m.addorganization_id != nil {
  19629. fields = append(fields, payrecharge.FieldOrganizationID)
  19630. }
  19631. return fields
  19632. }
  19633. // AddedField returns the numeric value that was incremented/decremented on a field
  19634. // with the given name. The second boolean return value indicates that this field
  19635. // was not set, or was not defined in the schema.
  19636. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  19637. switch name {
  19638. case payrecharge.FieldNumber:
  19639. return m.AddedNumber()
  19640. case payrecharge.FieldStatus:
  19641. return m.AddedStatus()
  19642. case payrecharge.FieldMoney:
  19643. return m.AddedMoney()
  19644. case payrecharge.FieldOrganizationID:
  19645. return m.AddedOrganizationID()
  19646. }
  19647. return nil, false
  19648. }
  19649. // AddField adds the value to the field with the given name. It returns an error if
  19650. // the field is not defined in the schema, or if the type mismatched the field
  19651. // type.
  19652. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  19653. switch name {
  19654. case payrecharge.FieldNumber:
  19655. v, ok := value.(float32)
  19656. if !ok {
  19657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19658. }
  19659. m.AddNumber(v)
  19660. return nil
  19661. case payrecharge.FieldStatus:
  19662. v, ok := value.(int)
  19663. if !ok {
  19664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19665. }
  19666. m.AddStatus(v)
  19667. return nil
  19668. case payrecharge.FieldMoney:
  19669. v, ok := value.(float32)
  19670. if !ok {
  19671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19672. }
  19673. m.AddMoney(v)
  19674. return nil
  19675. case payrecharge.FieldOrganizationID:
  19676. v, ok := value.(int64)
  19677. if !ok {
  19678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19679. }
  19680. m.AddOrganizationID(v)
  19681. return nil
  19682. }
  19683. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  19684. }
  19685. // ClearedFields returns all nullable fields that were cleared during this
  19686. // mutation.
  19687. func (m *PayRechargeMutation) ClearedFields() []string {
  19688. var fields []string
  19689. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  19690. fields = append(fields, payrecharge.FieldDeletedAt)
  19691. }
  19692. if m.FieldCleared(payrecharge.FieldStatus) {
  19693. fields = append(fields, payrecharge.FieldStatus)
  19694. }
  19695. if m.FieldCleared(payrecharge.FieldMoney) {
  19696. fields = append(fields, payrecharge.FieldMoney)
  19697. }
  19698. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  19699. fields = append(fields, payrecharge.FieldOutTradeNo)
  19700. }
  19701. return fields
  19702. }
  19703. // FieldCleared returns a boolean indicating if a field with the given name was
  19704. // cleared in this mutation.
  19705. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  19706. _, ok := m.clearedFields[name]
  19707. return ok
  19708. }
  19709. // ClearField clears the value of the field with the given name. It returns an
  19710. // error if the field is not defined in the schema.
  19711. func (m *PayRechargeMutation) ClearField(name string) error {
  19712. switch name {
  19713. case payrecharge.FieldDeletedAt:
  19714. m.ClearDeletedAt()
  19715. return nil
  19716. case payrecharge.FieldStatus:
  19717. m.ClearStatus()
  19718. return nil
  19719. case payrecharge.FieldMoney:
  19720. m.ClearMoney()
  19721. return nil
  19722. case payrecharge.FieldOutTradeNo:
  19723. m.ClearOutTradeNo()
  19724. return nil
  19725. }
  19726. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  19727. }
  19728. // ResetField resets all changes in the mutation for the field with the given name.
  19729. // It returns an error if the field is not defined in the schema.
  19730. func (m *PayRechargeMutation) ResetField(name string) error {
  19731. switch name {
  19732. case payrecharge.FieldCreatedAt:
  19733. m.ResetCreatedAt()
  19734. return nil
  19735. case payrecharge.FieldUpdatedAt:
  19736. m.ResetUpdatedAt()
  19737. return nil
  19738. case payrecharge.FieldDeletedAt:
  19739. m.ResetDeletedAt()
  19740. return nil
  19741. case payrecharge.FieldUserID:
  19742. m.ResetUserID()
  19743. return nil
  19744. case payrecharge.FieldNumber:
  19745. m.ResetNumber()
  19746. return nil
  19747. case payrecharge.FieldStatus:
  19748. m.ResetStatus()
  19749. return nil
  19750. case payrecharge.FieldMoney:
  19751. m.ResetMoney()
  19752. return nil
  19753. case payrecharge.FieldOutTradeNo:
  19754. m.ResetOutTradeNo()
  19755. return nil
  19756. case payrecharge.FieldOrganizationID:
  19757. m.ResetOrganizationID()
  19758. return nil
  19759. }
  19760. return fmt.Errorf("unknown PayRecharge field %s", name)
  19761. }
  19762. // AddedEdges returns all edge names that were set/added in this mutation.
  19763. func (m *PayRechargeMutation) AddedEdges() []string {
  19764. edges := make([]string, 0, 0)
  19765. return edges
  19766. }
  19767. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19768. // name in this mutation.
  19769. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  19770. return nil
  19771. }
  19772. // RemovedEdges returns all edge names that were removed in this mutation.
  19773. func (m *PayRechargeMutation) RemovedEdges() []string {
  19774. edges := make([]string, 0, 0)
  19775. return edges
  19776. }
  19777. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19778. // the given name in this mutation.
  19779. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  19780. return nil
  19781. }
  19782. // ClearedEdges returns all edge names that were cleared in this mutation.
  19783. func (m *PayRechargeMutation) ClearedEdges() []string {
  19784. edges := make([]string, 0, 0)
  19785. return edges
  19786. }
  19787. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19788. // was cleared in this mutation.
  19789. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  19790. return false
  19791. }
  19792. // ClearEdge clears the value of the edge with the given name. It returns an error
  19793. // if that edge is not defined in the schema.
  19794. func (m *PayRechargeMutation) ClearEdge(name string) error {
  19795. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  19796. }
  19797. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19798. // It returns an error if the edge is not defined in the schema.
  19799. func (m *PayRechargeMutation) ResetEdge(name string) error {
  19800. return fmt.Errorf("unknown PayRecharge edge %s", name)
  19801. }
  19802. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  19803. type ServerMutation struct {
  19804. config
  19805. op Op
  19806. typ string
  19807. id *uint64
  19808. created_at *time.Time
  19809. updated_at *time.Time
  19810. status *uint8
  19811. addstatus *int8
  19812. deleted_at *time.Time
  19813. name *string
  19814. public_ip *string
  19815. private_ip *string
  19816. admin_port *string
  19817. clearedFields map[string]struct{}
  19818. wxs map[uint64]struct{}
  19819. removedwxs map[uint64]struct{}
  19820. clearedwxs bool
  19821. done bool
  19822. oldValue func(context.Context) (*Server, error)
  19823. predicates []predicate.Server
  19824. }
  19825. var _ ent.Mutation = (*ServerMutation)(nil)
  19826. // serverOption allows management of the mutation configuration using functional options.
  19827. type serverOption func(*ServerMutation)
  19828. // newServerMutation creates new mutation for the Server entity.
  19829. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  19830. m := &ServerMutation{
  19831. config: c,
  19832. op: op,
  19833. typ: TypeServer,
  19834. clearedFields: make(map[string]struct{}),
  19835. }
  19836. for _, opt := range opts {
  19837. opt(m)
  19838. }
  19839. return m
  19840. }
  19841. // withServerID sets the ID field of the mutation.
  19842. func withServerID(id uint64) serverOption {
  19843. return func(m *ServerMutation) {
  19844. var (
  19845. err error
  19846. once sync.Once
  19847. value *Server
  19848. )
  19849. m.oldValue = func(ctx context.Context) (*Server, error) {
  19850. once.Do(func() {
  19851. if m.done {
  19852. err = errors.New("querying old values post mutation is not allowed")
  19853. } else {
  19854. value, err = m.Client().Server.Get(ctx, id)
  19855. }
  19856. })
  19857. return value, err
  19858. }
  19859. m.id = &id
  19860. }
  19861. }
  19862. // withServer sets the old Server of the mutation.
  19863. func withServer(node *Server) serverOption {
  19864. return func(m *ServerMutation) {
  19865. m.oldValue = func(context.Context) (*Server, error) {
  19866. return node, nil
  19867. }
  19868. m.id = &node.ID
  19869. }
  19870. }
  19871. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19872. // executed in a transaction (ent.Tx), a transactional client is returned.
  19873. func (m ServerMutation) Client() *Client {
  19874. client := &Client{config: m.config}
  19875. client.init()
  19876. return client
  19877. }
  19878. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19879. // it returns an error otherwise.
  19880. func (m ServerMutation) Tx() (*Tx, error) {
  19881. if _, ok := m.driver.(*txDriver); !ok {
  19882. return nil, errors.New("ent: mutation is not running in a transaction")
  19883. }
  19884. tx := &Tx{config: m.config}
  19885. tx.init()
  19886. return tx, nil
  19887. }
  19888. // SetID sets the value of the id field. Note that this
  19889. // operation is only accepted on creation of Server entities.
  19890. func (m *ServerMutation) SetID(id uint64) {
  19891. m.id = &id
  19892. }
  19893. // ID returns the ID value in the mutation. Note that the ID is only available
  19894. // if it was provided to the builder or after it was returned from the database.
  19895. func (m *ServerMutation) ID() (id uint64, exists bool) {
  19896. if m.id == nil {
  19897. return
  19898. }
  19899. return *m.id, true
  19900. }
  19901. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19902. // That means, if the mutation is applied within a transaction with an isolation level such
  19903. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19904. // or updated by the mutation.
  19905. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  19906. switch {
  19907. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19908. id, exists := m.ID()
  19909. if exists {
  19910. return []uint64{id}, nil
  19911. }
  19912. fallthrough
  19913. case m.op.Is(OpUpdate | OpDelete):
  19914. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  19915. default:
  19916. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19917. }
  19918. }
  19919. // SetCreatedAt sets the "created_at" field.
  19920. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  19921. m.created_at = &t
  19922. }
  19923. // CreatedAt returns the value of the "created_at" field in the mutation.
  19924. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  19925. v := m.created_at
  19926. if v == nil {
  19927. return
  19928. }
  19929. return *v, true
  19930. }
  19931. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  19932. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  19933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19934. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19935. if !m.op.Is(OpUpdateOne) {
  19936. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19937. }
  19938. if m.id == nil || m.oldValue == nil {
  19939. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19940. }
  19941. oldValue, err := m.oldValue(ctx)
  19942. if err != nil {
  19943. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19944. }
  19945. return oldValue.CreatedAt, nil
  19946. }
  19947. // ResetCreatedAt resets all changes to the "created_at" field.
  19948. func (m *ServerMutation) ResetCreatedAt() {
  19949. m.created_at = nil
  19950. }
  19951. // SetUpdatedAt sets the "updated_at" field.
  19952. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  19953. m.updated_at = &t
  19954. }
  19955. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19956. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  19957. v := m.updated_at
  19958. if v == nil {
  19959. return
  19960. }
  19961. return *v, true
  19962. }
  19963. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  19964. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  19965. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19966. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19967. if !m.op.Is(OpUpdateOne) {
  19968. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19969. }
  19970. if m.id == nil || m.oldValue == nil {
  19971. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19972. }
  19973. oldValue, err := m.oldValue(ctx)
  19974. if err != nil {
  19975. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19976. }
  19977. return oldValue.UpdatedAt, nil
  19978. }
  19979. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19980. func (m *ServerMutation) ResetUpdatedAt() {
  19981. m.updated_at = nil
  19982. }
  19983. // SetStatus sets the "status" field.
  19984. func (m *ServerMutation) SetStatus(u uint8) {
  19985. m.status = &u
  19986. m.addstatus = nil
  19987. }
  19988. // Status returns the value of the "status" field in the mutation.
  19989. func (m *ServerMutation) Status() (r uint8, exists bool) {
  19990. v := m.status
  19991. if v == nil {
  19992. return
  19993. }
  19994. return *v, true
  19995. }
  19996. // OldStatus returns the old "status" field's value of the Server entity.
  19997. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  19998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19999. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20000. if !m.op.Is(OpUpdateOne) {
  20001. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20002. }
  20003. if m.id == nil || m.oldValue == nil {
  20004. return v, errors.New("OldStatus requires an ID field in the mutation")
  20005. }
  20006. oldValue, err := m.oldValue(ctx)
  20007. if err != nil {
  20008. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20009. }
  20010. return oldValue.Status, nil
  20011. }
  20012. // AddStatus adds u to the "status" field.
  20013. func (m *ServerMutation) AddStatus(u int8) {
  20014. if m.addstatus != nil {
  20015. *m.addstatus += u
  20016. } else {
  20017. m.addstatus = &u
  20018. }
  20019. }
  20020. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20021. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  20022. v := m.addstatus
  20023. if v == nil {
  20024. return
  20025. }
  20026. return *v, true
  20027. }
  20028. // ClearStatus clears the value of the "status" field.
  20029. func (m *ServerMutation) ClearStatus() {
  20030. m.status = nil
  20031. m.addstatus = nil
  20032. m.clearedFields[server.FieldStatus] = struct{}{}
  20033. }
  20034. // StatusCleared returns if the "status" field was cleared in this mutation.
  20035. func (m *ServerMutation) StatusCleared() bool {
  20036. _, ok := m.clearedFields[server.FieldStatus]
  20037. return ok
  20038. }
  20039. // ResetStatus resets all changes to the "status" field.
  20040. func (m *ServerMutation) ResetStatus() {
  20041. m.status = nil
  20042. m.addstatus = nil
  20043. delete(m.clearedFields, server.FieldStatus)
  20044. }
  20045. // SetDeletedAt sets the "deleted_at" field.
  20046. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  20047. m.deleted_at = &t
  20048. }
  20049. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20050. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  20051. v := m.deleted_at
  20052. if v == nil {
  20053. return
  20054. }
  20055. return *v, true
  20056. }
  20057. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  20058. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20059. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20060. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20061. if !m.op.Is(OpUpdateOne) {
  20062. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20063. }
  20064. if m.id == nil || m.oldValue == nil {
  20065. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20066. }
  20067. oldValue, err := m.oldValue(ctx)
  20068. if err != nil {
  20069. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20070. }
  20071. return oldValue.DeletedAt, nil
  20072. }
  20073. // ClearDeletedAt clears the value of the "deleted_at" field.
  20074. func (m *ServerMutation) ClearDeletedAt() {
  20075. m.deleted_at = nil
  20076. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  20077. }
  20078. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20079. func (m *ServerMutation) DeletedAtCleared() bool {
  20080. _, ok := m.clearedFields[server.FieldDeletedAt]
  20081. return ok
  20082. }
  20083. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20084. func (m *ServerMutation) ResetDeletedAt() {
  20085. m.deleted_at = nil
  20086. delete(m.clearedFields, server.FieldDeletedAt)
  20087. }
  20088. // SetName sets the "name" field.
  20089. func (m *ServerMutation) SetName(s string) {
  20090. m.name = &s
  20091. }
  20092. // Name returns the value of the "name" field in the mutation.
  20093. func (m *ServerMutation) Name() (r string, exists bool) {
  20094. v := m.name
  20095. if v == nil {
  20096. return
  20097. }
  20098. return *v, true
  20099. }
  20100. // OldName returns the old "name" field's value of the Server entity.
  20101. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20103. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  20104. if !m.op.Is(OpUpdateOne) {
  20105. return v, errors.New("OldName is only allowed on UpdateOne operations")
  20106. }
  20107. if m.id == nil || m.oldValue == nil {
  20108. return v, errors.New("OldName requires an ID field in the mutation")
  20109. }
  20110. oldValue, err := m.oldValue(ctx)
  20111. if err != nil {
  20112. return v, fmt.Errorf("querying old value for OldName: %w", err)
  20113. }
  20114. return oldValue.Name, nil
  20115. }
  20116. // ResetName resets all changes to the "name" field.
  20117. func (m *ServerMutation) ResetName() {
  20118. m.name = nil
  20119. }
  20120. // SetPublicIP sets the "public_ip" field.
  20121. func (m *ServerMutation) SetPublicIP(s string) {
  20122. m.public_ip = &s
  20123. }
  20124. // PublicIP returns the value of the "public_ip" field in the mutation.
  20125. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  20126. v := m.public_ip
  20127. if v == nil {
  20128. return
  20129. }
  20130. return *v, true
  20131. }
  20132. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  20133. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20135. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  20136. if !m.op.Is(OpUpdateOne) {
  20137. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  20138. }
  20139. if m.id == nil || m.oldValue == nil {
  20140. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  20141. }
  20142. oldValue, err := m.oldValue(ctx)
  20143. if err != nil {
  20144. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  20145. }
  20146. return oldValue.PublicIP, nil
  20147. }
  20148. // ResetPublicIP resets all changes to the "public_ip" field.
  20149. func (m *ServerMutation) ResetPublicIP() {
  20150. m.public_ip = nil
  20151. }
  20152. // SetPrivateIP sets the "private_ip" field.
  20153. func (m *ServerMutation) SetPrivateIP(s string) {
  20154. m.private_ip = &s
  20155. }
  20156. // PrivateIP returns the value of the "private_ip" field in the mutation.
  20157. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  20158. v := m.private_ip
  20159. if v == nil {
  20160. return
  20161. }
  20162. return *v, true
  20163. }
  20164. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  20165. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20167. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  20168. if !m.op.Is(OpUpdateOne) {
  20169. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  20170. }
  20171. if m.id == nil || m.oldValue == nil {
  20172. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  20173. }
  20174. oldValue, err := m.oldValue(ctx)
  20175. if err != nil {
  20176. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  20177. }
  20178. return oldValue.PrivateIP, nil
  20179. }
  20180. // ResetPrivateIP resets all changes to the "private_ip" field.
  20181. func (m *ServerMutation) ResetPrivateIP() {
  20182. m.private_ip = nil
  20183. }
  20184. // SetAdminPort sets the "admin_port" field.
  20185. func (m *ServerMutation) SetAdminPort(s string) {
  20186. m.admin_port = &s
  20187. }
  20188. // AdminPort returns the value of the "admin_port" field in the mutation.
  20189. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  20190. v := m.admin_port
  20191. if v == nil {
  20192. return
  20193. }
  20194. return *v, true
  20195. }
  20196. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  20197. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20199. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  20200. if !m.op.Is(OpUpdateOne) {
  20201. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  20202. }
  20203. if m.id == nil || m.oldValue == nil {
  20204. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  20205. }
  20206. oldValue, err := m.oldValue(ctx)
  20207. if err != nil {
  20208. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  20209. }
  20210. return oldValue.AdminPort, nil
  20211. }
  20212. // ResetAdminPort resets all changes to the "admin_port" field.
  20213. func (m *ServerMutation) ResetAdminPort() {
  20214. m.admin_port = nil
  20215. }
  20216. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  20217. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  20218. if m.wxs == nil {
  20219. m.wxs = make(map[uint64]struct{})
  20220. }
  20221. for i := range ids {
  20222. m.wxs[ids[i]] = struct{}{}
  20223. }
  20224. }
  20225. // ClearWxs clears the "wxs" edge to the Wx entity.
  20226. func (m *ServerMutation) ClearWxs() {
  20227. m.clearedwxs = true
  20228. }
  20229. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  20230. func (m *ServerMutation) WxsCleared() bool {
  20231. return m.clearedwxs
  20232. }
  20233. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  20234. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  20235. if m.removedwxs == nil {
  20236. m.removedwxs = make(map[uint64]struct{})
  20237. }
  20238. for i := range ids {
  20239. delete(m.wxs, ids[i])
  20240. m.removedwxs[ids[i]] = struct{}{}
  20241. }
  20242. }
  20243. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  20244. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  20245. for id := range m.removedwxs {
  20246. ids = append(ids, id)
  20247. }
  20248. return
  20249. }
  20250. // WxsIDs returns the "wxs" edge IDs in the mutation.
  20251. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  20252. for id := range m.wxs {
  20253. ids = append(ids, id)
  20254. }
  20255. return
  20256. }
  20257. // ResetWxs resets all changes to the "wxs" edge.
  20258. func (m *ServerMutation) ResetWxs() {
  20259. m.wxs = nil
  20260. m.clearedwxs = false
  20261. m.removedwxs = nil
  20262. }
  20263. // Where appends a list predicates to the ServerMutation builder.
  20264. func (m *ServerMutation) Where(ps ...predicate.Server) {
  20265. m.predicates = append(m.predicates, ps...)
  20266. }
  20267. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  20268. // users can use type-assertion to append predicates that do not depend on any generated package.
  20269. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  20270. p := make([]predicate.Server, len(ps))
  20271. for i := range ps {
  20272. p[i] = ps[i]
  20273. }
  20274. m.Where(p...)
  20275. }
  20276. // Op returns the operation name.
  20277. func (m *ServerMutation) Op() Op {
  20278. return m.op
  20279. }
  20280. // SetOp allows setting the mutation operation.
  20281. func (m *ServerMutation) SetOp(op Op) {
  20282. m.op = op
  20283. }
  20284. // Type returns the node type of this mutation (Server).
  20285. func (m *ServerMutation) Type() string {
  20286. return m.typ
  20287. }
  20288. // Fields returns all fields that were changed during this mutation. Note that in
  20289. // order to get all numeric fields that were incremented/decremented, call
  20290. // AddedFields().
  20291. func (m *ServerMutation) Fields() []string {
  20292. fields := make([]string, 0, 8)
  20293. if m.created_at != nil {
  20294. fields = append(fields, server.FieldCreatedAt)
  20295. }
  20296. if m.updated_at != nil {
  20297. fields = append(fields, server.FieldUpdatedAt)
  20298. }
  20299. if m.status != nil {
  20300. fields = append(fields, server.FieldStatus)
  20301. }
  20302. if m.deleted_at != nil {
  20303. fields = append(fields, server.FieldDeletedAt)
  20304. }
  20305. if m.name != nil {
  20306. fields = append(fields, server.FieldName)
  20307. }
  20308. if m.public_ip != nil {
  20309. fields = append(fields, server.FieldPublicIP)
  20310. }
  20311. if m.private_ip != nil {
  20312. fields = append(fields, server.FieldPrivateIP)
  20313. }
  20314. if m.admin_port != nil {
  20315. fields = append(fields, server.FieldAdminPort)
  20316. }
  20317. return fields
  20318. }
  20319. // Field returns the value of a field with the given name. The second boolean
  20320. // return value indicates that this field was not set, or was not defined in the
  20321. // schema.
  20322. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  20323. switch name {
  20324. case server.FieldCreatedAt:
  20325. return m.CreatedAt()
  20326. case server.FieldUpdatedAt:
  20327. return m.UpdatedAt()
  20328. case server.FieldStatus:
  20329. return m.Status()
  20330. case server.FieldDeletedAt:
  20331. return m.DeletedAt()
  20332. case server.FieldName:
  20333. return m.Name()
  20334. case server.FieldPublicIP:
  20335. return m.PublicIP()
  20336. case server.FieldPrivateIP:
  20337. return m.PrivateIP()
  20338. case server.FieldAdminPort:
  20339. return m.AdminPort()
  20340. }
  20341. return nil, false
  20342. }
  20343. // OldField returns the old value of the field from the database. An error is
  20344. // returned if the mutation operation is not UpdateOne, or the query to the
  20345. // database failed.
  20346. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20347. switch name {
  20348. case server.FieldCreatedAt:
  20349. return m.OldCreatedAt(ctx)
  20350. case server.FieldUpdatedAt:
  20351. return m.OldUpdatedAt(ctx)
  20352. case server.FieldStatus:
  20353. return m.OldStatus(ctx)
  20354. case server.FieldDeletedAt:
  20355. return m.OldDeletedAt(ctx)
  20356. case server.FieldName:
  20357. return m.OldName(ctx)
  20358. case server.FieldPublicIP:
  20359. return m.OldPublicIP(ctx)
  20360. case server.FieldPrivateIP:
  20361. return m.OldPrivateIP(ctx)
  20362. case server.FieldAdminPort:
  20363. return m.OldAdminPort(ctx)
  20364. }
  20365. return nil, fmt.Errorf("unknown Server field %s", name)
  20366. }
  20367. // SetField sets the value of a field with the given name. It returns an error if
  20368. // the field is not defined in the schema, or if the type mismatched the field
  20369. // type.
  20370. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  20371. switch name {
  20372. case server.FieldCreatedAt:
  20373. v, ok := value.(time.Time)
  20374. if !ok {
  20375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20376. }
  20377. m.SetCreatedAt(v)
  20378. return nil
  20379. case server.FieldUpdatedAt:
  20380. v, ok := value.(time.Time)
  20381. if !ok {
  20382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20383. }
  20384. m.SetUpdatedAt(v)
  20385. return nil
  20386. case server.FieldStatus:
  20387. v, ok := value.(uint8)
  20388. if !ok {
  20389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20390. }
  20391. m.SetStatus(v)
  20392. return nil
  20393. case server.FieldDeletedAt:
  20394. v, ok := value.(time.Time)
  20395. if !ok {
  20396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20397. }
  20398. m.SetDeletedAt(v)
  20399. return nil
  20400. case server.FieldName:
  20401. v, ok := value.(string)
  20402. if !ok {
  20403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20404. }
  20405. m.SetName(v)
  20406. return nil
  20407. case server.FieldPublicIP:
  20408. v, ok := value.(string)
  20409. if !ok {
  20410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20411. }
  20412. m.SetPublicIP(v)
  20413. return nil
  20414. case server.FieldPrivateIP:
  20415. v, ok := value.(string)
  20416. if !ok {
  20417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20418. }
  20419. m.SetPrivateIP(v)
  20420. return nil
  20421. case server.FieldAdminPort:
  20422. v, ok := value.(string)
  20423. if !ok {
  20424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20425. }
  20426. m.SetAdminPort(v)
  20427. return nil
  20428. }
  20429. return fmt.Errorf("unknown Server field %s", name)
  20430. }
  20431. // AddedFields returns all numeric fields that were incremented/decremented during
  20432. // this mutation.
  20433. func (m *ServerMutation) AddedFields() []string {
  20434. var fields []string
  20435. if m.addstatus != nil {
  20436. fields = append(fields, server.FieldStatus)
  20437. }
  20438. return fields
  20439. }
  20440. // AddedField returns the numeric value that was incremented/decremented on a field
  20441. // with the given name. The second boolean return value indicates that this field
  20442. // was not set, or was not defined in the schema.
  20443. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  20444. switch name {
  20445. case server.FieldStatus:
  20446. return m.AddedStatus()
  20447. }
  20448. return nil, false
  20449. }
  20450. // AddField adds the value to the field with the given name. It returns an error if
  20451. // the field is not defined in the schema, or if the type mismatched the field
  20452. // type.
  20453. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  20454. switch name {
  20455. case server.FieldStatus:
  20456. v, ok := value.(int8)
  20457. if !ok {
  20458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20459. }
  20460. m.AddStatus(v)
  20461. return nil
  20462. }
  20463. return fmt.Errorf("unknown Server numeric field %s", name)
  20464. }
  20465. // ClearedFields returns all nullable fields that were cleared during this
  20466. // mutation.
  20467. func (m *ServerMutation) ClearedFields() []string {
  20468. var fields []string
  20469. if m.FieldCleared(server.FieldStatus) {
  20470. fields = append(fields, server.FieldStatus)
  20471. }
  20472. if m.FieldCleared(server.FieldDeletedAt) {
  20473. fields = append(fields, server.FieldDeletedAt)
  20474. }
  20475. return fields
  20476. }
  20477. // FieldCleared returns a boolean indicating if a field with the given name was
  20478. // cleared in this mutation.
  20479. func (m *ServerMutation) FieldCleared(name string) bool {
  20480. _, ok := m.clearedFields[name]
  20481. return ok
  20482. }
  20483. // ClearField clears the value of the field with the given name. It returns an
  20484. // error if the field is not defined in the schema.
  20485. func (m *ServerMutation) ClearField(name string) error {
  20486. switch name {
  20487. case server.FieldStatus:
  20488. m.ClearStatus()
  20489. return nil
  20490. case server.FieldDeletedAt:
  20491. m.ClearDeletedAt()
  20492. return nil
  20493. }
  20494. return fmt.Errorf("unknown Server nullable field %s", name)
  20495. }
  20496. // ResetField resets all changes in the mutation for the field with the given name.
  20497. // It returns an error if the field is not defined in the schema.
  20498. func (m *ServerMutation) ResetField(name string) error {
  20499. switch name {
  20500. case server.FieldCreatedAt:
  20501. m.ResetCreatedAt()
  20502. return nil
  20503. case server.FieldUpdatedAt:
  20504. m.ResetUpdatedAt()
  20505. return nil
  20506. case server.FieldStatus:
  20507. m.ResetStatus()
  20508. return nil
  20509. case server.FieldDeletedAt:
  20510. m.ResetDeletedAt()
  20511. return nil
  20512. case server.FieldName:
  20513. m.ResetName()
  20514. return nil
  20515. case server.FieldPublicIP:
  20516. m.ResetPublicIP()
  20517. return nil
  20518. case server.FieldPrivateIP:
  20519. m.ResetPrivateIP()
  20520. return nil
  20521. case server.FieldAdminPort:
  20522. m.ResetAdminPort()
  20523. return nil
  20524. }
  20525. return fmt.Errorf("unknown Server field %s", name)
  20526. }
  20527. // AddedEdges returns all edge names that were set/added in this mutation.
  20528. func (m *ServerMutation) AddedEdges() []string {
  20529. edges := make([]string, 0, 1)
  20530. if m.wxs != nil {
  20531. edges = append(edges, server.EdgeWxs)
  20532. }
  20533. return edges
  20534. }
  20535. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20536. // name in this mutation.
  20537. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  20538. switch name {
  20539. case server.EdgeWxs:
  20540. ids := make([]ent.Value, 0, len(m.wxs))
  20541. for id := range m.wxs {
  20542. ids = append(ids, id)
  20543. }
  20544. return ids
  20545. }
  20546. return nil
  20547. }
  20548. // RemovedEdges returns all edge names that were removed in this mutation.
  20549. func (m *ServerMutation) RemovedEdges() []string {
  20550. edges := make([]string, 0, 1)
  20551. if m.removedwxs != nil {
  20552. edges = append(edges, server.EdgeWxs)
  20553. }
  20554. return edges
  20555. }
  20556. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20557. // the given name in this mutation.
  20558. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  20559. switch name {
  20560. case server.EdgeWxs:
  20561. ids := make([]ent.Value, 0, len(m.removedwxs))
  20562. for id := range m.removedwxs {
  20563. ids = append(ids, id)
  20564. }
  20565. return ids
  20566. }
  20567. return nil
  20568. }
  20569. // ClearedEdges returns all edge names that were cleared in this mutation.
  20570. func (m *ServerMutation) ClearedEdges() []string {
  20571. edges := make([]string, 0, 1)
  20572. if m.clearedwxs {
  20573. edges = append(edges, server.EdgeWxs)
  20574. }
  20575. return edges
  20576. }
  20577. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20578. // was cleared in this mutation.
  20579. func (m *ServerMutation) EdgeCleared(name string) bool {
  20580. switch name {
  20581. case server.EdgeWxs:
  20582. return m.clearedwxs
  20583. }
  20584. return false
  20585. }
  20586. // ClearEdge clears the value of the edge with the given name. It returns an error
  20587. // if that edge is not defined in the schema.
  20588. func (m *ServerMutation) ClearEdge(name string) error {
  20589. switch name {
  20590. }
  20591. return fmt.Errorf("unknown Server unique edge %s", name)
  20592. }
  20593. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20594. // It returns an error if the edge is not defined in the schema.
  20595. func (m *ServerMutation) ResetEdge(name string) error {
  20596. switch name {
  20597. case server.EdgeWxs:
  20598. m.ResetWxs()
  20599. return nil
  20600. }
  20601. return fmt.Errorf("unknown Server edge %s", name)
  20602. }
  20603. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  20604. type SopNodeMutation struct {
  20605. config
  20606. op Op
  20607. typ string
  20608. id *uint64
  20609. created_at *time.Time
  20610. updated_at *time.Time
  20611. status *uint8
  20612. addstatus *int8
  20613. deleted_at *time.Time
  20614. parent_id *uint64
  20615. addparent_id *int64
  20616. name *string
  20617. condition_type *int
  20618. addcondition_type *int
  20619. condition_list *[]string
  20620. appendcondition_list []string
  20621. no_reply_condition *uint64
  20622. addno_reply_condition *int64
  20623. no_reply_unit *string
  20624. action_message *[]custom_types.Action
  20625. appendaction_message []custom_types.Action
  20626. action_label_add *[]uint64
  20627. appendaction_label_add []uint64
  20628. action_label_del *[]uint64
  20629. appendaction_label_del []uint64
  20630. action_forward **custom_types.ActionForward
  20631. clearedFields map[string]struct{}
  20632. sop_stage *uint64
  20633. clearedsop_stage bool
  20634. node_messages map[uint64]struct{}
  20635. removednode_messages map[uint64]struct{}
  20636. clearednode_messages bool
  20637. done bool
  20638. oldValue func(context.Context) (*SopNode, error)
  20639. predicates []predicate.SopNode
  20640. }
  20641. var _ ent.Mutation = (*SopNodeMutation)(nil)
  20642. // sopnodeOption allows management of the mutation configuration using functional options.
  20643. type sopnodeOption func(*SopNodeMutation)
  20644. // newSopNodeMutation creates new mutation for the SopNode entity.
  20645. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  20646. m := &SopNodeMutation{
  20647. config: c,
  20648. op: op,
  20649. typ: TypeSopNode,
  20650. clearedFields: make(map[string]struct{}),
  20651. }
  20652. for _, opt := range opts {
  20653. opt(m)
  20654. }
  20655. return m
  20656. }
  20657. // withSopNodeID sets the ID field of the mutation.
  20658. func withSopNodeID(id uint64) sopnodeOption {
  20659. return func(m *SopNodeMutation) {
  20660. var (
  20661. err error
  20662. once sync.Once
  20663. value *SopNode
  20664. )
  20665. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  20666. once.Do(func() {
  20667. if m.done {
  20668. err = errors.New("querying old values post mutation is not allowed")
  20669. } else {
  20670. value, err = m.Client().SopNode.Get(ctx, id)
  20671. }
  20672. })
  20673. return value, err
  20674. }
  20675. m.id = &id
  20676. }
  20677. }
  20678. // withSopNode sets the old SopNode of the mutation.
  20679. func withSopNode(node *SopNode) sopnodeOption {
  20680. return func(m *SopNodeMutation) {
  20681. m.oldValue = func(context.Context) (*SopNode, error) {
  20682. return node, nil
  20683. }
  20684. m.id = &node.ID
  20685. }
  20686. }
  20687. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20688. // executed in a transaction (ent.Tx), a transactional client is returned.
  20689. func (m SopNodeMutation) Client() *Client {
  20690. client := &Client{config: m.config}
  20691. client.init()
  20692. return client
  20693. }
  20694. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20695. // it returns an error otherwise.
  20696. func (m SopNodeMutation) Tx() (*Tx, error) {
  20697. if _, ok := m.driver.(*txDriver); !ok {
  20698. return nil, errors.New("ent: mutation is not running in a transaction")
  20699. }
  20700. tx := &Tx{config: m.config}
  20701. tx.init()
  20702. return tx, nil
  20703. }
  20704. // SetID sets the value of the id field. Note that this
  20705. // operation is only accepted on creation of SopNode entities.
  20706. func (m *SopNodeMutation) SetID(id uint64) {
  20707. m.id = &id
  20708. }
  20709. // ID returns the ID value in the mutation. Note that the ID is only available
  20710. // if it was provided to the builder or after it was returned from the database.
  20711. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  20712. if m.id == nil {
  20713. return
  20714. }
  20715. return *m.id, true
  20716. }
  20717. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20718. // That means, if the mutation is applied within a transaction with an isolation level such
  20719. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20720. // or updated by the mutation.
  20721. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  20722. switch {
  20723. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20724. id, exists := m.ID()
  20725. if exists {
  20726. return []uint64{id}, nil
  20727. }
  20728. fallthrough
  20729. case m.op.Is(OpUpdate | OpDelete):
  20730. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  20731. default:
  20732. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20733. }
  20734. }
  20735. // SetCreatedAt sets the "created_at" field.
  20736. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  20737. m.created_at = &t
  20738. }
  20739. // CreatedAt returns the value of the "created_at" field in the mutation.
  20740. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  20741. v := m.created_at
  20742. if v == nil {
  20743. return
  20744. }
  20745. return *v, true
  20746. }
  20747. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  20748. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20750. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20751. if !m.op.Is(OpUpdateOne) {
  20752. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20753. }
  20754. if m.id == nil || m.oldValue == nil {
  20755. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20756. }
  20757. oldValue, err := m.oldValue(ctx)
  20758. if err != nil {
  20759. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20760. }
  20761. return oldValue.CreatedAt, nil
  20762. }
  20763. // ResetCreatedAt resets all changes to the "created_at" field.
  20764. func (m *SopNodeMutation) ResetCreatedAt() {
  20765. m.created_at = nil
  20766. }
  20767. // SetUpdatedAt sets the "updated_at" field.
  20768. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  20769. m.updated_at = &t
  20770. }
  20771. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20772. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  20773. v := m.updated_at
  20774. if v == nil {
  20775. return
  20776. }
  20777. return *v, true
  20778. }
  20779. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  20780. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20782. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20783. if !m.op.Is(OpUpdateOne) {
  20784. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20785. }
  20786. if m.id == nil || m.oldValue == nil {
  20787. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20788. }
  20789. oldValue, err := m.oldValue(ctx)
  20790. if err != nil {
  20791. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20792. }
  20793. return oldValue.UpdatedAt, nil
  20794. }
  20795. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20796. func (m *SopNodeMutation) ResetUpdatedAt() {
  20797. m.updated_at = nil
  20798. }
  20799. // SetStatus sets the "status" field.
  20800. func (m *SopNodeMutation) SetStatus(u uint8) {
  20801. m.status = &u
  20802. m.addstatus = nil
  20803. }
  20804. // Status returns the value of the "status" field in the mutation.
  20805. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  20806. v := m.status
  20807. if v == nil {
  20808. return
  20809. }
  20810. return *v, true
  20811. }
  20812. // OldStatus returns the old "status" field's value of the SopNode entity.
  20813. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20815. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20816. if !m.op.Is(OpUpdateOne) {
  20817. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20818. }
  20819. if m.id == nil || m.oldValue == nil {
  20820. return v, errors.New("OldStatus requires an ID field in the mutation")
  20821. }
  20822. oldValue, err := m.oldValue(ctx)
  20823. if err != nil {
  20824. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20825. }
  20826. return oldValue.Status, nil
  20827. }
  20828. // AddStatus adds u to the "status" field.
  20829. func (m *SopNodeMutation) AddStatus(u int8) {
  20830. if m.addstatus != nil {
  20831. *m.addstatus += u
  20832. } else {
  20833. m.addstatus = &u
  20834. }
  20835. }
  20836. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20837. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  20838. v := m.addstatus
  20839. if v == nil {
  20840. return
  20841. }
  20842. return *v, true
  20843. }
  20844. // ClearStatus clears the value of the "status" field.
  20845. func (m *SopNodeMutation) ClearStatus() {
  20846. m.status = nil
  20847. m.addstatus = nil
  20848. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  20849. }
  20850. // StatusCleared returns if the "status" field was cleared in this mutation.
  20851. func (m *SopNodeMutation) StatusCleared() bool {
  20852. _, ok := m.clearedFields[sopnode.FieldStatus]
  20853. return ok
  20854. }
  20855. // ResetStatus resets all changes to the "status" field.
  20856. func (m *SopNodeMutation) ResetStatus() {
  20857. m.status = nil
  20858. m.addstatus = nil
  20859. delete(m.clearedFields, sopnode.FieldStatus)
  20860. }
  20861. // SetDeletedAt sets the "deleted_at" field.
  20862. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  20863. m.deleted_at = &t
  20864. }
  20865. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20866. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  20867. v := m.deleted_at
  20868. if v == nil {
  20869. return
  20870. }
  20871. return *v, true
  20872. }
  20873. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  20874. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20876. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20877. if !m.op.Is(OpUpdateOne) {
  20878. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20879. }
  20880. if m.id == nil || m.oldValue == nil {
  20881. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20882. }
  20883. oldValue, err := m.oldValue(ctx)
  20884. if err != nil {
  20885. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20886. }
  20887. return oldValue.DeletedAt, nil
  20888. }
  20889. // ClearDeletedAt clears the value of the "deleted_at" field.
  20890. func (m *SopNodeMutation) ClearDeletedAt() {
  20891. m.deleted_at = nil
  20892. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  20893. }
  20894. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20895. func (m *SopNodeMutation) DeletedAtCleared() bool {
  20896. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  20897. return ok
  20898. }
  20899. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20900. func (m *SopNodeMutation) ResetDeletedAt() {
  20901. m.deleted_at = nil
  20902. delete(m.clearedFields, sopnode.FieldDeletedAt)
  20903. }
  20904. // SetStageID sets the "stage_id" field.
  20905. func (m *SopNodeMutation) SetStageID(u uint64) {
  20906. m.sop_stage = &u
  20907. }
  20908. // StageID returns the value of the "stage_id" field in the mutation.
  20909. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  20910. v := m.sop_stage
  20911. if v == nil {
  20912. return
  20913. }
  20914. return *v, true
  20915. }
  20916. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  20917. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20919. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  20920. if !m.op.Is(OpUpdateOne) {
  20921. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  20922. }
  20923. if m.id == nil || m.oldValue == nil {
  20924. return v, errors.New("OldStageID requires an ID field in the mutation")
  20925. }
  20926. oldValue, err := m.oldValue(ctx)
  20927. if err != nil {
  20928. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  20929. }
  20930. return oldValue.StageID, nil
  20931. }
  20932. // ResetStageID resets all changes to the "stage_id" field.
  20933. func (m *SopNodeMutation) ResetStageID() {
  20934. m.sop_stage = nil
  20935. }
  20936. // SetParentID sets the "parent_id" field.
  20937. func (m *SopNodeMutation) SetParentID(u uint64) {
  20938. m.parent_id = &u
  20939. m.addparent_id = nil
  20940. }
  20941. // ParentID returns the value of the "parent_id" field in the mutation.
  20942. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  20943. v := m.parent_id
  20944. if v == nil {
  20945. return
  20946. }
  20947. return *v, true
  20948. }
  20949. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  20950. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20951. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20952. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  20953. if !m.op.Is(OpUpdateOne) {
  20954. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  20955. }
  20956. if m.id == nil || m.oldValue == nil {
  20957. return v, errors.New("OldParentID requires an ID field in the mutation")
  20958. }
  20959. oldValue, err := m.oldValue(ctx)
  20960. if err != nil {
  20961. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  20962. }
  20963. return oldValue.ParentID, nil
  20964. }
  20965. // AddParentID adds u to the "parent_id" field.
  20966. func (m *SopNodeMutation) AddParentID(u int64) {
  20967. if m.addparent_id != nil {
  20968. *m.addparent_id += u
  20969. } else {
  20970. m.addparent_id = &u
  20971. }
  20972. }
  20973. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  20974. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  20975. v := m.addparent_id
  20976. if v == nil {
  20977. return
  20978. }
  20979. return *v, true
  20980. }
  20981. // ResetParentID resets all changes to the "parent_id" field.
  20982. func (m *SopNodeMutation) ResetParentID() {
  20983. m.parent_id = nil
  20984. m.addparent_id = nil
  20985. }
  20986. // SetName sets the "name" field.
  20987. func (m *SopNodeMutation) SetName(s string) {
  20988. m.name = &s
  20989. }
  20990. // Name returns the value of the "name" field in the mutation.
  20991. func (m *SopNodeMutation) Name() (r string, exists bool) {
  20992. v := m.name
  20993. if v == nil {
  20994. return
  20995. }
  20996. return *v, true
  20997. }
  20998. // OldName returns the old "name" field's value of the SopNode entity.
  20999. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21001. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  21002. if !m.op.Is(OpUpdateOne) {
  21003. return v, errors.New("OldName is only allowed on UpdateOne operations")
  21004. }
  21005. if m.id == nil || m.oldValue == nil {
  21006. return v, errors.New("OldName requires an ID field in the mutation")
  21007. }
  21008. oldValue, err := m.oldValue(ctx)
  21009. if err != nil {
  21010. return v, fmt.Errorf("querying old value for OldName: %w", err)
  21011. }
  21012. return oldValue.Name, nil
  21013. }
  21014. // ResetName resets all changes to the "name" field.
  21015. func (m *SopNodeMutation) ResetName() {
  21016. m.name = nil
  21017. }
  21018. // SetConditionType sets the "condition_type" field.
  21019. func (m *SopNodeMutation) SetConditionType(i int) {
  21020. m.condition_type = &i
  21021. m.addcondition_type = nil
  21022. }
  21023. // ConditionType returns the value of the "condition_type" field in the mutation.
  21024. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  21025. v := m.condition_type
  21026. if v == nil {
  21027. return
  21028. }
  21029. return *v, true
  21030. }
  21031. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  21032. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21034. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  21035. if !m.op.Is(OpUpdateOne) {
  21036. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  21037. }
  21038. if m.id == nil || m.oldValue == nil {
  21039. return v, errors.New("OldConditionType requires an ID field in the mutation")
  21040. }
  21041. oldValue, err := m.oldValue(ctx)
  21042. if err != nil {
  21043. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  21044. }
  21045. return oldValue.ConditionType, nil
  21046. }
  21047. // AddConditionType adds i to the "condition_type" field.
  21048. func (m *SopNodeMutation) AddConditionType(i int) {
  21049. if m.addcondition_type != nil {
  21050. *m.addcondition_type += i
  21051. } else {
  21052. m.addcondition_type = &i
  21053. }
  21054. }
  21055. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  21056. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  21057. v := m.addcondition_type
  21058. if v == nil {
  21059. return
  21060. }
  21061. return *v, true
  21062. }
  21063. // ResetConditionType resets all changes to the "condition_type" field.
  21064. func (m *SopNodeMutation) ResetConditionType() {
  21065. m.condition_type = nil
  21066. m.addcondition_type = nil
  21067. }
  21068. // SetConditionList sets the "condition_list" field.
  21069. func (m *SopNodeMutation) SetConditionList(s []string) {
  21070. m.condition_list = &s
  21071. m.appendcondition_list = nil
  21072. }
  21073. // ConditionList returns the value of the "condition_list" field in the mutation.
  21074. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  21075. v := m.condition_list
  21076. if v == nil {
  21077. return
  21078. }
  21079. return *v, true
  21080. }
  21081. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  21082. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21084. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  21085. if !m.op.Is(OpUpdateOne) {
  21086. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  21087. }
  21088. if m.id == nil || m.oldValue == nil {
  21089. return v, errors.New("OldConditionList requires an ID field in the mutation")
  21090. }
  21091. oldValue, err := m.oldValue(ctx)
  21092. if err != nil {
  21093. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  21094. }
  21095. return oldValue.ConditionList, nil
  21096. }
  21097. // AppendConditionList adds s to the "condition_list" field.
  21098. func (m *SopNodeMutation) AppendConditionList(s []string) {
  21099. m.appendcondition_list = append(m.appendcondition_list, s...)
  21100. }
  21101. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  21102. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  21103. if len(m.appendcondition_list) == 0 {
  21104. return nil, false
  21105. }
  21106. return m.appendcondition_list, true
  21107. }
  21108. // ClearConditionList clears the value of the "condition_list" field.
  21109. func (m *SopNodeMutation) ClearConditionList() {
  21110. m.condition_list = nil
  21111. m.appendcondition_list = nil
  21112. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  21113. }
  21114. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  21115. func (m *SopNodeMutation) ConditionListCleared() bool {
  21116. _, ok := m.clearedFields[sopnode.FieldConditionList]
  21117. return ok
  21118. }
  21119. // ResetConditionList resets all changes to the "condition_list" field.
  21120. func (m *SopNodeMutation) ResetConditionList() {
  21121. m.condition_list = nil
  21122. m.appendcondition_list = nil
  21123. delete(m.clearedFields, sopnode.FieldConditionList)
  21124. }
  21125. // SetNoReplyCondition sets the "no_reply_condition" field.
  21126. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  21127. m.no_reply_condition = &u
  21128. m.addno_reply_condition = nil
  21129. }
  21130. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  21131. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  21132. v := m.no_reply_condition
  21133. if v == nil {
  21134. return
  21135. }
  21136. return *v, true
  21137. }
  21138. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  21139. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21140. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21141. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  21142. if !m.op.Is(OpUpdateOne) {
  21143. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  21144. }
  21145. if m.id == nil || m.oldValue == nil {
  21146. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  21147. }
  21148. oldValue, err := m.oldValue(ctx)
  21149. if err != nil {
  21150. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  21151. }
  21152. return oldValue.NoReplyCondition, nil
  21153. }
  21154. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  21155. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  21156. if m.addno_reply_condition != nil {
  21157. *m.addno_reply_condition += u
  21158. } else {
  21159. m.addno_reply_condition = &u
  21160. }
  21161. }
  21162. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  21163. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  21164. v := m.addno_reply_condition
  21165. if v == nil {
  21166. return
  21167. }
  21168. return *v, true
  21169. }
  21170. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  21171. func (m *SopNodeMutation) ResetNoReplyCondition() {
  21172. m.no_reply_condition = nil
  21173. m.addno_reply_condition = nil
  21174. }
  21175. // SetNoReplyUnit sets the "no_reply_unit" field.
  21176. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  21177. m.no_reply_unit = &s
  21178. }
  21179. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  21180. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  21181. v := m.no_reply_unit
  21182. if v == nil {
  21183. return
  21184. }
  21185. return *v, true
  21186. }
  21187. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  21188. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21190. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  21191. if !m.op.Is(OpUpdateOne) {
  21192. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  21193. }
  21194. if m.id == nil || m.oldValue == nil {
  21195. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  21196. }
  21197. oldValue, err := m.oldValue(ctx)
  21198. if err != nil {
  21199. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  21200. }
  21201. return oldValue.NoReplyUnit, nil
  21202. }
  21203. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  21204. func (m *SopNodeMutation) ResetNoReplyUnit() {
  21205. m.no_reply_unit = nil
  21206. }
  21207. // SetActionMessage sets the "action_message" field.
  21208. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  21209. m.action_message = &ct
  21210. m.appendaction_message = nil
  21211. }
  21212. // ActionMessage returns the value of the "action_message" field in the mutation.
  21213. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  21214. v := m.action_message
  21215. if v == nil {
  21216. return
  21217. }
  21218. return *v, true
  21219. }
  21220. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  21221. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21223. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  21224. if !m.op.Is(OpUpdateOne) {
  21225. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  21226. }
  21227. if m.id == nil || m.oldValue == nil {
  21228. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  21229. }
  21230. oldValue, err := m.oldValue(ctx)
  21231. if err != nil {
  21232. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  21233. }
  21234. return oldValue.ActionMessage, nil
  21235. }
  21236. // AppendActionMessage adds ct to the "action_message" field.
  21237. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  21238. m.appendaction_message = append(m.appendaction_message, ct...)
  21239. }
  21240. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  21241. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  21242. if len(m.appendaction_message) == 0 {
  21243. return nil, false
  21244. }
  21245. return m.appendaction_message, true
  21246. }
  21247. // ClearActionMessage clears the value of the "action_message" field.
  21248. func (m *SopNodeMutation) ClearActionMessage() {
  21249. m.action_message = nil
  21250. m.appendaction_message = nil
  21251. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  21252. }
  21253. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  21254. func (m *SopNodeMutation) ActionMessageCleared() bool {
  21255. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  21256. return ok
  21257. }
  21258. // ResetActionMessage resets all changes to the "action_message" field.
  21259. func (m *SopNodeMutation) ResetActionMessage() {
  21260. m.action_message = nil
  21261. m.appendaction_message = nil
  21262. delete(m.clearedFields, sopnode.FieldActionMessage)
  21263. }
  21264. // SetActionLabelAdd sets the "action_label_add" field.
  21265. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  21266. m.action_label_add = &u
  21267. m.appendaction_label_add = nil
  21268. }
  21269. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  21270. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  21271. v := m.action_label_add
  21272. if v == nil {
  21273. return
  21274. }
  21275. return *v, true
  21276. }
  21277. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  21278. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21279. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21280. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  21281. if !m.op.Is(OpUpdateOne) {
  21282. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  21283. }
  21284. if m.id == nil || m.oldValue == nil {
  21285. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  21286. }
  21287. oldValue, err := m.oldValue(ctx)
  21288. if err != nil {
  21289. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  21290. }
  21291. return oldValue.ActionLabelAdd, nil
  21292. }
  21293. // AppendActionLabelAdd adds u to the "action_label_add" field.
  21294. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  21295. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  21296. }
  21297. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  21298. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  21299. if len(m.appendaction_label_add) == 0 {
  21300. return nil, false
  21301. }
  21302. return m.appendaction_label_add, true
  21303. }
  21304. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  21305. func (m *SopNodeMutation) ClearActionLabelAdd() {
  21306. m.action_label_add = nil
  21307. m.appendaction_label_add = nil
  21308. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  21309. }
  21310. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  21311. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  21312. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  21313. return ok
  21314. }
  21315. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  21316. func (m *SopNodeMutation) ResetActionLabelAdd() {
  21317. m.action_label_add = nil
  21318. m.appendaction_label_add = nil
  21319. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  21320. }
  21321. // SetActionLabelDel sets the "action_label_del" field.
  21322. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  21323. m.action_label_del = &u
  21324. m.appendaction_label_del = nil
  21325. }
  21326. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  21327. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  21328. v := m.action_label_del
  21329. if v == nil {
  21330. return
  21331. }
  21332. return *v, true
  21333. }
  21334. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  21335. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21337. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  21338. if !m.op.Is(OpUpdateOne) {
  21339. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  21340. }
  21341. if m.id == nil || m.oldValue == nil {
  21342. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  21343. }
  21344. oldValue, err := m.oldValue(ctx)
  21345. if err != nil {
  21346. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  21347. }
  21348. return oldValue.ActionLabelDel, nil
  21349. }
  21350. // AppendActionLabelDel adds u to the "action_label_del" field.
  21351. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  21352. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  21353. }
  21354. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  21355. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  21356. if len(m.appendaction_label_del) == 0 {
  21357. return nil, false
  21358. }
  21359. return m.appendaction_label_del, true
  21360. }
  21361. // ClearActionLabelDel clears the value of the "action_label_del" field.
  21362. func (m *SopNodeMutation) ClearActionLabelDel() {
  21363. m.action_label_del = nil
  21364. m.appendaction_label_del = nil
  21365. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  21366. }
  21367. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  21368. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  21369. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  21370. return ok
  21371. }
  21372. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  21373. func (m *SopNodeMutation) ResetActionLabelDel() {
  21374. m.action_label_del = nil
  21375. m.appendaction_label_del = nil
  21376. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  21377. }
  21378. // SetActionForward sets the "action_forward" field.
  21379. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  21380. m.action_forward = &ctf
  21381. }
  21382. // ActionForward returns the value of the "action_forward" field in the mutation.
  21383. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  21384. v := m.action_forward
  21385. if v == nil {
  21386. return
  21387. }
  21388. return *v, true
  21389. }
  21390. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  21391. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21393. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  21394. if !m.op.Is(OpUpdateOne) {
  21395. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  21396. }
  21397. if m.id == nil || m.oldValue == nil {
  21398. return v, errors.New("OldActionForward requires an ID field in the mutation")
  21399. }
  21400. oldValue, err := m.oldValue(ctx)
  21401. if err != nil {
  21402. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  21403. }
  21404. return oldValue.ActionForward, nil
  21405. }
  21406. // ClearActionForward clears the value of the "action_forward" field.
  21407. func (m *SopNodeMutation) ClearActionForward() {
  21408. m.action_forward = nil
  21409. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  21410. }
  21411. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  21412. func (m *SopNodeMutation) ActionForwardCleared() bool {
  21413. _, ok := m.clearedFields[sopnode.FieldActionForward]
  21414. return ok
  21415. }
  21416. // ResetActionForward resets all changes to the "action_forward" field.
  21417. func (m *SopNodeMutation) ResetActionForward() {
  21418. m.action_forward = nil
  21419. delete(m.clearedFields, sopnode.FieldActionForward)
  21420. }
  21421. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  21422. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  21423. m.sop_stage = &id
  21424. }
  21425. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  21426. func (m *SopNodeMutation) ClearSopStage() {
  21427. m.clearedsop_stage = true
  21428. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  21429. }
  21430. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  21431. func (m *SopNodeMutation) SopStageCleared() bool {
  21432. return m.clearedsop_stage
  21433. }
  21434. // SopStageID returns the "sop_stage" edge ID in the mutation.
  21435. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  21436. if m.sop_stage != nil {
  21437. return *m.sop_stage, true
  21438. }
  21439. return
  21440. }
  21441. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  21442. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21443. // SopStageID instead. It exists only for internal usage by the builders.
  21444. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  21445. if id := m.sop_stage; id != nil {
  21446. ids = append(ids, *id)
  21447. }
  21448. return
  21449. }
  21450. // ResetSopStage resets all changes to the "sop_stage" edge.
  21451. func (m *SopNodeMutation) ResetSopStage() {
  21452. m.sop_stage = nil
  21453. m.clearedsop_stage = false
  21454. }
  21455. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  21456. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  21457. if m.node_messages == nil {
  21458. m.node_messages = make(map[uint64]struct{})
  21459. }
  21460. for i := range ids {
  21461. m.node_messages[ids[i]] = struct{}{}
  21462. }
  21463. }
  21464. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  21465. func (m *SopNodeMutation) ClearNodeMessages() {
  21466. m.clearednode_messages = true
  21467. }
  21468. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  21469. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  21470. return m.clearednode_messages
  21471. }
  21472. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  21473. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  21474. if m.removednode_messages == nil {
  21475. m.removednode_messages = make(map[uint64]struct{})
  21476. }
  21477. for i := range ids {
  21478. delete(m.node_messages, ids[i])
  21479. m.removednode_messages[ids[i]] = struct{}{}
  21480. }
  21481. }
  21482. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  21483. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  21484. for id := range m.removednode_messages {
  21485. ids = append(ids, id)
  21486. }
  21487. return
  21488. }
  21489. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  21490. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  21491. for id := range m.node_messages {
  21492. ids = append(ids, id)
  21493. }
  21494. return
  21495. }
  21496. // ResetNodeMessages resets all changes to the "node_messages" edge.
  21497. func (m *SopNodeMutation) ResetNodeMessages() {
  21498. m.node_messages = nil
  21499. m.clearednode_messages = false
  21500. m.removednode_messages = nil
  21501. }
  21502. // Where appends a list predicates to the SopNodeMutation builder.
  21503. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  21504. m.predicates = append(m.predicates, ps...)
  21505. }
  21506. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  21507. // users can use type-assertion to append predicates that do not depend on any generated package.
  21508. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  21509. p := make([]predicate.SopNode, len(ps))
  21510. for i := range ps {
  21511. p[i] = ps[i]
  21512. }
  21513. m.Where(p...)
  21514. }
  21515. // Op returns the operation name.
  21516. func (m *SopNodeMutation) Op() Op {
  21517. return m.op
  21518. }
  21519. // SetOp allows setting the mutation operation.
  21520. func (m *SopNodeMutation) SetOp(op Op) {
  21521. m.op = op
  21522. }
  21523. // Type returns the node type of this mutation (SopNode).
  21524. func (m *SopNodeMutation) Type() string {
  21525. return m.typ
  21526. }
  21527. // Fields returns all fields that were changed during this mutation. Note that in
  21528. // order to get all numeric fields that were incremented/decremented, call
  21529. // AddedFields().
  21530. func (m *SopNodeMutation) Fields() []string {
  21531. fields := make([]string, 0, 15)
  21532. if m.created_at != nil {
  21533. fields = append(fields, sopnode.FieldCreatedAt)
  21534. }
  21535. if m.updated_at != nil {
  21536. fields = append(fields, sopnode.FieldUpdatedAt)
  21537. }
  21538. if m.status != nil {
  21539. fields = append(fields, sopnode.FieldStatus)
  21540. }
  21541. if m.deleted_at != nil {
  21542. fields = append(fields, sopnode.FieldDeletedAt)
  21543. }
  21544. if m.sop_stage != nil {
  21545. fields = append(fields, sopnode.FieldStageID)
  21546. }
  21547. if m.parent_id != nil {
  21548. fields = append(fields, sopnode.FieldParentID)
  21549. }
  21550. if m.name != nil {
  21551. fields = append(fields, sopnode.FieldName)
  21552. }
  21553. if m.condition_type != nil {
  21554. fields = append(fields, sopnode.FieldConditionType)
  21555. }
  21556. if m.condition_list != nil {
  21557. fields = append(fields, sopnode.FieldConditionList)
  21558. }
  21559. if m.no_reply_condition != nil {
  21560. fields = append(fields, sopnode.FieldNoReplyCondition)
  21561. }
  21562. if m.no_reply_unit != nil {
  21563. fields = append(fields, sopnode.FieldNoReplyUnit)
  21564. }
  21565. if m.action_message != nil {
  21566. fields = append(fields, sopnode.FieldActionMessage)
  21567. }
  21568. if m.action_label_add != nil {
  21569. fields = append(fields, sopnode.FieldActionLabelAdd)
  21570. }
  21571. if m.action_label_del != nil {
  21572. fields = append(fields, sopnode.FieldActionLabelDel)
  21573. }
  21574. if m.action_forward != nil {
  21575. fields = append(fields, sopnode.FieldActionForward)
  21576. }
  21577. return fields
  21578. }
  21579. // Field returns the value of a field with the given name. The second boolean
  21580. // return value indicates that this field was not set, or was not defined in the
  21581. // schema.
  21582. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  21583. switch name {
  21584. case sopnode.FieldCreatedAt:
  21585. return m.CreatedAt()
  21586. case sopnode.FieldUpdatedAt:
  21587. return m.UpdatedAt()
  21588. case sopnode.FieldStatus:
  21589. return m.Status()
  21590. case sopnode.FieldDeletedAt:
  21591. return m.DeletedAt()
  21592. case sopnode.FieldStageID:
  21593. return m.StageID()
  21594. case sopnode.FieldParentID:
  21595. return m.ParentID()
  21596. case sopnode.FieldName:
  21597. return m.Name()
  21598. case sopnode.FieldConditionType:
  21599. return m.ConditionType()
  21600. case sopnode.FieldConditionList:
  21601. return m.ConditionList()
  21602. case sopnode.FieldNoReplyCondition:
  21603. return m.NoReplyCondition()
  21604. case sopnode.FieldNoReplyUnit:
  21605. return m.NoReplyUnit()
  21606. case sopnode.FieldActionMessage:
  21607. return m.ActionMessage()
  21608. case sopnode.FieldActionLabelAdd:
  21609. return m.ActionLabelAdd()
  21610. case sopnode.FieldActionLabelDel:
  21611. return m.ActionLabelDel()
  21612. case sopnode.FieldActionForward:
  21613. return m.ActionForward()
  21614. }
  21615. return nil, false
  21616. }
  21617. // OldField returns the old value of the field from the database. An error is
  21618. // returned if the mutation operation is not UpdateOne, or the query to the
  21619. // database failed.
  21620. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21621. switch name {
  21622. case sopnode.FieldCreatedAt:
  21623. return m.OldCreatedAt(ctx)
  21624. case sopnode.FieldUpdatedAt:
  21625. return m.OldUpdatedAt(ctx)
  21626. case sopnode.FieldStatus:
  21627. return m.OldStatus(ctx)
  21628. case sopnode.FieldDeletedAt:
  21629. return m.OldDeletedAt(ctx)
  21630. case sopnode.FieldStageID:
  21631. return m.OldStageID(ctx)
  21632. case sopnode.FieldParentID:
  21633. return m.OldParentID(ctx)
  21634. case sopnode.FieldName:
  21635. return m.OldName(ctx)
  21636. case sopnode.FieldConditionType:
  21637. return m.OldConditionType(ctx)
  21638. case sopnode.FieldConditionList:
  21639. return m.OldConditionList(ctx)
  21640. case sopnode.FieldNoReplyCondition:
  21641. return m.OldNoReplyCondition(ctx)
  21642. case sopnode.FieldNoReplyUnit:
  21643. return m.OldNoReplyUnit(ctx)
  21644. case sopnode.FieldActionMessage:
  21645. return m.OldActionMessage(ctx)
  21646. case sopnode.FieldActionLabelAdd:
  21647. return m.OldActionLabelAdd(ctx)
  21648. case sopnode.FieldActionLabelDel:
  21649. return m.OldActionLabelDel(ctx)
  21650. case sopnode.FieldActionForward:
  21651. return m.OldActionForward(ctx)
  21652. }
  21653. return nil, fmt.Errorf("unknown SopNode field %s", name)
  21654. }
  21655. // SetField sets the value of a field with the given name. It returns an error if
  21656. // the field is not defined in the schema, or if the type mismatched the field
  21657. // type.
  21658. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  21659. switch name {
  21660. case sopnode.FieldCreatedAt:
  21661. v, ok := value.(time.Time)
  21662. if !ok {
  21663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21664. }
  21665. m.SetCreatedAt(v)
  21666. return nil
  21667. case sopnode.FieldUpdatedAt:
  21668. v, ok := value.(time.Time)
  21669. if !ok {
  21670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21671. }
  21672. m.SetUpdatedAt(v)
  21673. return nil
  21674. case sopnode.FieldStatus:
  21675. v, ok := value.(uint8)
  21676. if !ok {
  21677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21678. }
  21679. m.SetStatus(v)
  21680. return nil
  21681. case sopnode.FieldDeletedAt:
  21682. v, ok := value.(time.Time)
  21683. if !ok {
  21684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21685. }
  21686. m.SetDeletedAt(v)
  21687. return nil
  21688. case sopnode.FieldStageID:
  21689. v, ok := value.(uint64)
  21690. if !ok {
  21691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21692. }
  21693. m.SetStageID(v)
  21694. return nil
  21695. case sopnode.FieldParentID:
  21696. v, ok := value.(uint64)
  21697. if !ok {
  21698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21699. }
  21700. m.SetParentID(v)
  21701. return nil
  21702. case sopnode.FieldName:
  21703. v, ok := value.(string)
  21704. if !ok {
  21705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21706. }
  21707. m.SetName(v)
  21708. return nil
  21709. case sopnode.FieldConditionType:
  21710. v, ok := value.(int)
  21711. if !ok {
  21712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21713. }
  21714. m.SetConditionType(v)
  21715. return nil
  21716. case sopnode.FieldConditionList:
  21717. v, ok := value.([]string)
  21718. if !ok {
  21719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21720. }
  21721. m.SetConditionList(v)
  21722. return nil
  21723. case sopnode.FieldNoReplyCondition:
  21724. v, ok := value.(uint64)
  21725. if !ok {
  21726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21727. }
  21728. m.SetNoReplyCondition(v)
  21729. return nil
  21730. case sopnode.FieldNoReplyUnit:
  21731. v, ok := value.(string)
  21732. if !ok {
  21733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21734. }
  21735. m.SetNoReplyUnit(v)
  21736. return nil
  21737. case sopnode.FieldActionMessage:
  21738. v, ok := value.([]custom_types.Action)
  21739. if !ok {
  21740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21741. }
  21742. m.SetActionMessage(v)
  21743. return nil
  21744. case sopnode.FieldActionLabelAdd:
  21745. v, ok := value.([]uint64)
  21746. if !ok {
  21747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21748. }
  21749. m.SetActionLabelAdd(v)
  21750. return nil
  21751. case sopnode.FieldActionLabelDel:
  21752. v, ok := value.([]uint64)
  21753. if !ok {
  21754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21755. }
  21756. m.SetActionLabelDel(v)
  21757. return nil
  21758. case sopnode.FieldActionForward:
  21759. v, ok := value.(*custom_types.ActionForward)
  21760. if !ok {
  21761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21762. }
  21763. m.SetActionForward(v)
  21764. return nil
  21765. }
  21766. return fmt.Errorf("unknown SopNode field %s", name)
  21767. }
  21768. // AddedFields returns all numeric fields that were incremented/decremented during
  21769. // this mutation.
  21770. func (m *SopNodeMutation) AddedFields() []string {
  21771. var fields []string
  21772. if m.addstatus != nil {
  21773. fields = append(fields, sopnode.FieldStatus)
  21774. }
  21775. if m.addparent_id != nil {
  21776. fields = append(fields, sopnode.FieldParentID)
  21777. }
  21778. if m.addcondition_type != nil {
  21779. fields = append(fields, sopnode.FieldConditionType)
  21780. }
  21781. if m.addno_reply_condition != nil {
  21782. fields = append(fields, sopnode.FieldNoReplyCondition)
  21783. }
  21784. return fields
  21785. }
  21786. // AddedField returns the numeric value that was incremented/decremented on a field
  21787. // with the given name. The second boolean return value indicates that this field
  21788. // was not set, or was not defined in the schema.
  21789. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  21790. switch name {
  21791. case sopnode.FieldStatus:
  21792. return m.AddedStatus()
  21793. case sopnode.FieldParentID:
  21794. return m.AddedParentID()
  21795. case sopnode.FieldConditionType:
  21796. return m.AddedConditionType()
  21797. case sopnode.FieldNoReplyCondition:
  21798. return m.AddedNoReplyCondition()
  21799. }
  21800. return nil, false
  21801. }
  21802. // AddField adds the value to the field with the given name. It returns an error if
  21803. // the field is not defined in the schema, or if the type mismatched the field
  21804. // type.
  21805. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  21806. switch name {
  21807. case sopnode.FieldStatus:
  21808. v, ok := value.(int8)
  21809. if !ok {
  21810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21811. }
  21812. m.AddStatus(v)
  21813. return nil
  21814. case sopnode.FieldParentID:
  21815. v, ok := value.(int64)
  21816. if !ok {
  21817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21818. }
  21819. m.AddParentID(v)
  21820. return nil
  21821. case sopnode.FieldConditionType:
  21822. v, ok := value.(int)
  21823. if !ok {
  21824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21825. }
  21826. m.AddConditionType(v)
  21827. return nil
  21828. case sopnode.FieldNoReplyCondition:
  21829. v, ok := value.(int64)
  21830. if !ok {
  21831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21832. }
  21833. m.AddNoReplyCondition(v)
  21834. return nil
  21835. }
  21836. return fmt.Errorf("unknown SopNode numeric field %s", name)
  21837. }
  21838. // ClearedFields returns all nullable fields that were cleared during this
  21839. // mutation.
  21840. func (m *SopNodeMutation) ClearedFields() []string {
  21841. var fields []string
  21842. if m.FieldCleared(sopnode.FieldStatus) {
  21843. fields = append(fields, sopnode.FieldStatus)
  21844. }
  21845. if m.FieldCleared(sopnode.FieldDeletedAt) {
  21846. fields = append(fields, sopnode.FieldDeletedAt)
  21847. }
  21848. if m.FieldCleared(sopnode.FieldConditionList) {
  21849. fields = append(fields, sopnode.FieldConditionList)
  21850. }
  21851. if m.FieldCleared(sopnode.FieldActionMessage) {
  21852. fields = append(fields, sopnode.FieldActionMessage)
  21853. }
  21854. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  21855. fields = append(fields, sopnode.FieldActionLabelAdd)
  21856. }
  21857. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  21858. fields = append(fields, sopnode.FieldActionLabelDel)
  21859. }
  21860. if m.FieldCleared(sopnode.FieldActionForward) {
  21861. fields = append(fields, sopnode.FieldActionForward)
  21862. }
  21863. return fields
  21864. }
  21865. // FieldCleared returns a boolean indicating if a field with the given name was
  21866. // cleared in this mutation.
  21867. func (m *SopNodeMutation) FieldCleared(name string) bool {
  21868. _, ok := m.clearedFields[name]
  21869. return ok
  21870. }
  21871. // ClearField clears the value of the field with the given name. It returns an
  21872. // error if the field is not defined in the schema.
  21873. func (m *SopNodeMutation) ClearField(name string) error {
  21874. switch name {
  21875. case sopnode.FieldStatus:
  21876. m.ClearStatus()
  21877. return nil
  21878. case sopnode.FieldDeletedAt:
  21879. m.ClearDeletedAt()
  21880. return nil
  21881. case sopnode.FieldConditionList:
  21882. m.ClearConditionList()
  21883. return nil
  21884. case sopnode.FieldActionMessage:
  21885. m.ClearActionMessage()
  21886. return nil
  21887. case sopnode.FieldActionLabelAdd:
  21888. m.ClearActionLabelAdd()
  21889. return nil
  21890. case sopnode.FieldActionLabelDel:
  21891. m.ClearActionLabelDel()
  21892. return nil
  21893. case sopnode.FieldActionForward:
  21894. m.ClearActionForward()
  21895. return nil
  21896. }
  21897. return fmt.Errorf("unknown SopNode nullable field %s", name)
  21898. }
  21899. // ResetField resets all changes in the mutation for the field with the given name.
  21900. // It returns an error if the field is not defined in the schema.
  21901. func (m *SopNodeMutation) ResetField(name string) error {
  21902. switch name {
  21903. case sopnode.FieldCreatedAt:
  21904. m.ResetCreatedAt()
  21905. return nil
  21906. case sopnode.FieldUpdatedAt:
  21907. m.ResetUpdatedAt()
  21908. return nil
  21909. case sopnode.FieldStatus:
  21910. m.ResetStatus()
  21911. return nil
  21912. case sopnode.FieldDeletedAt:
  21913. m.ResetDeletedAt()
  21914. return nil
  21915. case sopnode.FieldStageID:
  21916. m.ResetStageID()
  21917. return nil
  21918. case sopnode.FieldParentID:
  21919. m.ResetParentID()
  21920. return nil
  21921. case sopnode.FieldName:
  21922. m.ResetName()
  21923. return nil
  21924. case sopnode.FieldConditionType:
  21925. m.ResetConditionType()
  21926. return nil
  21927. case sopnode.FieldConditionList:
  21928. m.ResetConditionList()
  21929. return nil
  21930. case sopnode.FieldNoReplyCondition:
  21931. m.ResetNoReplyCondition()
  21932. return nil
  21933. case sopnode.FieldNoReplyUnit:
  21934. m.ResetNoReplyUnit()
  21935. return nil
  21936. case sopnode.FieldActionMessage:
  21937. m.ResetActionMessage()
  21938. return nil
  21939. case sopnode.FieldActionLabelAdd:
  21940. m.ResetActionLabelAdd()
  21941. return nil
  21942. case sopnode.FieldActionLabelDel:
  21943. m.ResetActionLabelDel()
  21944. return nil
  21945. case sopnode.FieldActionForward:
  21946. m.ResetActionForward()
  21947. return nil
  21948. }
  21949. return fmt.Errorf("unknown SopNode field %s", name)
  21950. }
  21951. // AddedEdges returns all edge names that were set/added in this mutation.
  21952. func (m *SopNodeMutation) AddedEdges() []string {
  21953. edges := make([]string, 0, 2)
  21954. if m.sop_stage != nil {
  21955. edges = append(edges, sopnode.EdgeSopStage)
  21956. }
  21957. if m.node_messages != nil {
  21958. edges = append(edges, sopnode.EdgeNodeMessages)
  21959. }
  21960. return edges
  21961. }
  21962. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21963. // name in this mutation.
  21964. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  21965. switch name {
  21966. case sopnode.EdgeSopStage:
  21967. if id := m.sop_stage; id != nil {
  21968. return []ent.Value{*id}
  21969. }
  21970. case sopnode.EdgeNodeMessages:
  21971. ids := make([]ent.Value, 0, len(m.node_messages))
  21972. for id := range m.node_messages {
  21973. ids = append(ids, id)
  21974. }
  21975. return ids
  21976. }
  21977. return nil
  21978. }
  21979. // RemovedEdges returns all edge names that were removed in this mutation.
  21980. func (m *SopNodeMutation) RemovedEdges() []string {
  21981. edges := make([]string, 0, 2)
  21982. if m.removednode_messages != nil {
  21983. edges = append(edges, sopnode.EdgeNodeMessages)
  21984. }
  21985. return edges
  21986. }
  21987. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21988. // the given name in this mutation.
  21989. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  21990. switch name {
  21991. case sopnode.EdgeNodeMessages:
  21992. ids := make([]ent.Value, 0, len(m.removednode_messages))
  21993. for id := range m.removednode_messages {
  21994. ids = append(ids, id)
  21995. }
  21996. return ids
  21997. }
  21998. return nil
  21999. }
  22000. // ClearedEdges returns all edge names that were cleared in this mutation.
  22001. func (m *SopNodeMutation) ClearedEdges() []string {
  22002. edges := make([]string, 0, 2)
  22003. if m.clearedsop_stage {
  22004. edges = append(edges, sopnode.EdgeSopStage)
  22005. }
  22006. if m.clearednode_messages {
  22007. edges = append(edges, sopnode.EdgeNodeMessages)
  22008. }
  22009. return edges
  22010. }
  22011. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22012. // was cleared in this mutation.
  22013. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  22014. switch name {
  22015. case sopnode.EdgeSopStage:
  22016. return m.clearedsop_stage
  22017. case sopnode.EdgeNodeMessages:
  22018. return m.clearednode_messages
  22019. }
  22020. return false
  22021. }
  22022. // ClearEdge clears the value of the edge with the given name. It returns an error
  22023. // if that edge is not defined in the schema.
  22024. func (m *SopNodeMutation) ClearEdge(name string) error {
  22025. switch name {
  22026. case sopnode.EdgeSopStage:
  22027. m.ClearSopStage()
  22028. return nil
  22029. }
  22030. return fmt.Errorf("unknown SopNode unique edge %s", name)
  22031. }
  22032. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22033. // It returns an error if the edge is not defined in the schema.
  22034. func (m *SopNodeMutation) ResetEdge(name string) error {
  22035. switch name {
  22036. case sopnode.EdgeSopStage:
  22037. m.ResetSopStage()
  22038. return nil
  22039. case sopnode.EdgeNodeMessages:
  22040. m.ResetNodeMessages()
  22041. return nil
  22042. }
  22043. return fmt.Errorf("unknown SopNode edge %s", name)
  22044. }
  22045. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  22046. type SopStageMutation struct {
  22047. config
  22048. op Op
  22049. typ string
  22050. id *uint64
  22051. created_at *time.Time
  22052. updated_at *time.Time
  22053. status *uint8
  22054. addstatus *int8
  22055. deleted_at *time.Time
  22056. name *string
  22057. condition_type *int
  22058. addcondition_type *int
  22059. condition_operator *int
  22060. addcondition_operator *int
  22061. condition_list *[]custom_types.Condition
  22062. appendcondition_list []custom_types.Condition
  22063. action_message *[]custom_types.Action
  22064. appendaction_message []custom_types.Action
  22065. action_label_add *[]uint64
  22066. appendaction_label_add []uint64
  22067. action_label_del *[]uint64
  22068. appendaction_label_del []uint64
  22069. action_forward **custom_types.ActionForward
  22070. index_sort *int
  22071. addindex_sort *int
  22072. clearedFields map[string]struct{}
  22073. sop_task *uint64
  22074. clearedsop_task bool
  22075. stage_nodes map[uint64]struct{}
  22076. removedstage_nodes map[uint64]struct{}
  22077. clearedstage_nodes bool
  22078. stage_messages map[uint64]struct{}
  22079. removedstage_messages map[uint64]struct{}
  22080. clearedstage_messages bool
  22081. done bool
  22082. oldValue func(context.Context) (*SopStage, error)
  22083. predicates []predicate.SopStage
  22084. }
  22085. var _ ent.Mutation = (*SopStageMutation)(nil)
  22086. // sopstageOption allows management of the mutation configuration using functional options.
  22087. type sopstageOption func(*SopStageMutation)
  22088. // newSopStageMutation creates new mutation for the SopStage entity.
  22089. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  22090. m := &SopStageMutation{
  22091. config: c,
  22092. op: op,
  22093. typ: TypeSopStage,
  22094. clearedFields: make(map[string]struct{}),
  22095. }
  22096. for _, opt := range opts {
  22097. opt(m)
  22098. }
  22099. return m
  22100. }
  22101. // withSopStageID sets the ID field of the mutation.
  22102. func withSopStageID(id uint64) sopstageOption {
  22103. return func(m *SopStageMutation) {
  22104. var (
  22105. err error
  22106. once sync.Once
  22107. value *SopStage
  22108. )
  22109. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  22110. once.Do(func() {
  22111. if m.done {
  22112. err = errors.New("querying old values post mutation is not allowed")
  22113. } else {
  22114. value, err = m.Client().SopStage.Get(ctx, id)
  22115. }
  22116. })
  22117. return value, err
  22118. }
  22119. m.id = &id
  22120. }
  22121. }
  22122. // withSopStage sets the old SopStage of the mutation.
  22123. func withSopStage(node *SopStage) sopstageOption {
  22124. return func(m *SopStageMutation) {
  22125. m.oldValue = func(context.Context) (*SopStage, error) {
  22126. return node, nil
  22127. }
  22128. m.id = &node.ID
  22129. }
  22130. }
  22131. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22132. // executed in a transaction (ent.Tx), a transactional client is returned.
  22133. func (m SopStageMutation) Client() *Client {
  22134. client := &Client{config: m.config}
  22135. client.init()
  22136. return client
  22137. }
  22138. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22139. // it returns an error otherwise.
  22140. func (m SopStageMutation) Tx() (*Tx, error) {
  22141. if _, ok := m.driver.(*txDriver); !ok {
  22142. return nil, errors.New("ent: mutation is not running in a transaction")
  22143. }
  22144. tx := &Tx{config: m.config}
  22145. tx.init()
  22146. return tx, nil
  22147. }
  22148. // SetID sets the value of the id field. Note that this
  22149. // operation is only accepted on creation of SopStage entities.
  22150. func (m *SopStageMutation) SetID(id uint64) {
  22151. m.id = &id
  22152. }
  22153. // ID returns the ID value in the mutation. Note that the ID is only available
  22154. // if it was provided to the builder or after it was returned from the database.
  22155. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  22156. if m.id == nil {
  22157. return
  22158. }
  22159. return *m.id, true
  22160. }
  22161. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22162. // That means, if the mutation is applied within a transaction with an isolation level such
  22163. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22164. // or updated by the mutation.
  22165. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  22166. switch {
  22167. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22168. id, exists := m.ID()
  22169. if exists {
  22170. return []uint64{id}, nil
  22171. }
  22172. fallthrough
  22173. case m.op.Is(OpUpdate | OpDelete):
  22174. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  22175. default:
  22176. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22177. }
  22178. }
  22179. // SetCreatedAt sets the "created_at" field.
  22180. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  22181. m.created_at = &t
  22182. }
  22183. // CreatedAt returns the value of the "created_at" field in the mutation.
  22184. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  22185. v := m.created_at
  22186. if v == nil {
  22187. return
  22188. }
  22189. return *v, true
  22190. }
  22191. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  22192. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22193. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22194. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22195. if !m.op.Is(OpUpdateOne) {
  22196. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22197. }
  22198. if m.id == nil || m.oldValue == nil {
  22199. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22200. }
  22201. oldValue, err := m.oldValue(ctx)
  22202. if err != nil {
  22203. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22204. }
  22205. return oldValue.CreatedAt, nil
  22206. }
  22207. // ResetCreatedAt resets all changes to the "created_at" field.
  22208. func (m *SopStageMutation) ResetCreatedAt() {
  22209. m.created_at = nil
  22210. }
  22211. // SetUpdatedAt sets the "updated_at" field.
  22212. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  22213. m.updated_at = &t
  22214. }
  22215. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22216. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  22217. v := m.updated_at
  22218. if v == nil {
  22219. return
  22220. }
  22221. return *v, true
  22222. }
  22223. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  22224. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22225. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22226. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22227. if !m.op.Is(OpUpdateOne) {
  22228. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22229. }
  22230. if m.id == nil || m.oldValue == nil {
  22231. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22232. }
  22233. oldValue, err := m.oldValue(ctx)
  22234. if err != nil {
  22235. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22236. }
  22237. return oldValue.UpdatedAt, nil
  22238. }
  22239. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22240. func (m *SopStageMutation) ResetUpdatedAt() {
  22241. m.updated_at = nil
  22242. }
  22243. // SetStatus sets the "status" field.
  22244. func (m *SopStageMutation) SetStatus(u uint8) {
  22245. m.status = &u
  22246. m.addstatus = nil
  22247. }
  22248. // Status returns the value of the "status" field in the mutation.
  22249. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  22250. v := m.status
  22251. if v == nil {
  22252. return
  22253. }
  22254. return *v, true
  22255. }
  22256. // OldStatus returns the old "status" field's value of the SopStage entity.
  22257. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22259. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22260. if !m.op.Is(OpUpdateOne) {
  22261. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22262. }
  22263. if m.id == nil || m.oldValue == nil {
  22264. return v, errors.New("OldStatus requires an ID field in the mutation")
  22265. }
  22266. oldValue, err := m.oldValue(ctx)
  22267. if err != nil {
  22268. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22269. }
  22270. return oldValue.Status, nil
  22271. }
  22272. // AddStatus adds u to the "status" field.
  22273. func (m *SopStageMutation) AddStatus(u int8) {
  22274. if m.addstatus != nil {
  22275. *m.addstatus += u
  22276. } else {
  22277. m.addstatus = &u
  22278. }
  22279. }
  22280. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22281. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  22282. v := m.addstatus
  22283. if v == nil {
  22284. return
  22285. }
  22286. return *v, true
  22287. }
  22288. // ClearStatus clears the value of the "status" field.
  22289. func (m *SopStageMutation) ClearStatus() {
  22290. m.status = nil
  22291. m.addstatus = nil
  22292. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  22293. }
  22294. // StatusCleared returns if the "status" field was cleared in this mutation.
  22295. func (m *SopStageMutation) StatusCleared() bool {
  22296. _, ok := m.clearedFields[sopstage.FieldStatus]
  22297. return ok
  22298. }
  22299. // ResetStatus resets all changes to the "status" field.
  22300. func (m *SopStageMutation) ResetStatus() {
  22301. m.status = nil
  22302. m.addstatus = nil
  22303. delete(m.clearedFields, sopstage.FieldStatus)
  22304. }
  22305. // SetDeletedAt sets the "deleted_at" field.
  22306. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  22307. m.deleted_at = &t
  22308. }
  22309. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22310. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  22311. v := m.deleted_at
  22312. if v == nil {
  22313. return
  22314. }
  22315. return *v, true
  22316. }
  22317. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  22318. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22320. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22321. if !m.op.Is(OpUpdateOne) {
  22322. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22323. }
  22324. if m.id == nil || m.oldValue == nil {
  22325. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22326. }
  22327. oldValue, err := m.oldValue(ctx)
  22328. if err != nil {
  22329. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22330. }
  22331. return oldValue.DeletedAt, nil
  22332. }
  22333. // ClearDeletedAt clears the value of the "deleted_at" field.
  22334. func (m *SopStageMutation) ClearDeletedAt() {
  22335. m.deleted_at = nil
  22336. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  22337. }
  22338. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22339. func (m *SopStageMutation) DeletedAtCleared() bool {
  22340. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  22341. return ok
  22342. }
  22343. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22344. func (m *SopStageMutation) ResetDeletedAt() {
  22345. m.deleted_at = nil
  22346. delete(m.clearedFields, sopstage.FieldDeletedAt)
  22347. }
  22348. // SetTaskID sets the "task_id" field.
  22349. func (m *SopStageMutation) SetTaskID(u uint64) {
  22350. m.sop_task = &u
  22351. }
  22352. // TaskID returns the value of the "task_id" field in the mutation.
  22353. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  22354. v := m.sop_task
  22355. if v == nil {
  22356. return
  22357. }
  22358. return *v, true
  22359. }
  22360. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  22361. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22363. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  22364. if !m.op.Is(OpUpdateOne) {
  22365. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  22366. }
  22367. if m.id == nil || m.oldValue == nil {
  22368. return v, errors.New("OldTaskID requires an ID field in the mutation")
  22369. }
  22370. oldValue, err := m.oldValue(ctx)
  22371. if err != nil {
  22372. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  22373. }
  22374. return oldValue.TaskID, nil
  22375. }
  22376. // ResetTaskID resets all changes to the "task_id" field.
  22377. func (m *SopStageMutation) ResetTaskID() {
  22378. m.sop_task = nil
  22379. }
  22380. // SetName sets the "name" field.
  22381. func (m *SopStageMutation) SetName(s string) {
  22382. m.name = &s
  22383. }
  22384. // Name returns the value of the "name" field in the mutation.
  22385. func (m *SopStageMutation) Name() (r string, exists bool) {
  22386. v := m.name
  22387. if v == nil {
  22388. return
  22389. }
  22390. return *v, true
  22391. }
  22392. // OldName returns the old "name" field's value of the SopStage entity.
  22393. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22395. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  22396. if !m.op.Is(OpUpdateOne) {
  22397. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22398. }
  22399. if m.id == nil || m.oldValue == nil {
  22400. return v, errors.New("OldName requires an ID field in the mutation")
  22401. }
  22402. oldValue, err := m.oldValue(ctx)
  22403. if err != nil {
  22404. return v, fmt.Errorf("querying old value for OldName: %w", err)
  22405. }
  22406. return oldValue.Name, nil
  22407. }
  22408. // ResetName resets all changes to the "name" field.
  22409. func (m *SopStageMutation) ResetName() {
  22410. m.name = nil
  22411. }
  22412. // SetConditionType sets the "condition_type" field.
  22413. func (m *SopStageMutation) SetConditionType(i int) {
  22414. m.condition_type = &i
  22415. m.addcondition_type = nil
  22416. }
  22417. // ConditionType returns the value of the "condition_type" field in the mutation.
  22418. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  22419. v := m.condition_type
  22420. if v == nil {
  22421. return
  22422. }
  22423. return *v, true
  22424. }
  22425. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  22426. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22428. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  22429. if !m.op.Is(OpUpdateOne) {
  22430. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  22431. }
  22432. if m.id == nil || m.oldValue == nil {
  22433. return v, errors.New("OldConditionType requires an ID field in the mutation")
  22434. }
  22435. oldValue, err := m.oldValue(ctx)
  22436. if err != nil {
  22437. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  22438. }
  22439. return oldValue.ConditionType, nil
  22440. }
  22441. // AddConditionType adds i to the "condition_type" field.
  22442. func (m *SopStageMutation) AddConditionType(i int) {
  22443. if m.addcondition_type != nil {
  22444. *m.addcondition_type += i
  22445. } else {
  22446. m.addcondition_type = &i
  22447. }
  22448. }
  22449. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  22450. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  22451. v := m.addcondition_type
  22452. if v == nil {
  22453. return
  22454. }
  22455. return *v, true
  22456. }
  22457. // ResetConditionType resets all changes to the "condition_type" field.
  22458. func (m *SopStageMutation) ResetConditionType() {
  22459. m.condition_type = nil
  22460. m.addcondition_type = nil
  22461. }
  22462. // SetConditionOperator sets the "condition_operator" field.
  22463. func (m *SopStageMutation) SetConditionOperator(i int) {
  22464. m.condition_operator = &i
  22465. m.addcondition_operator = nil
  22466. }
  22467. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  22468. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  22469. v := m.condition_operator
  22470. if v == nil {
  22471. return
  22472. }
  22473. return *v, true
  22474. }
  22475. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  22476. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22478. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  22479. if !m.op.Is(OpUpdateOne) {
  22480. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  22481. }
  22482. if m.id == nil || m.oldValue == nil {
  22483. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  22484. }
  22485. oldValue, err := m.oldValue(ctx)
  22486. if err != nil {
  22487. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  22488. }
  22489. return oldValue.ConditionOperator, nil
  22490. }
  22491. // AddConditionOperator adds i to the "condition_operator" field.
  22492. func (m *SopStageMutation) AddConditionOperator(i int) {
  22493. if m.addcondition_operator != nil {
  22494. *m.addcondition_operator += i
  22495. } else {
  22496. m.addcondition_operator = &i
  22497. }
  22498. }
  22499. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  22500. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  22501. v := m.addcondition_operator
  22502. if v == nil {
  22503. return
  22504. }
  22505. return *v, true
  22506. }
  22507. // ResetConditionOperator resets all changes to the "condition_operator" field.
  22508. func (m *SopStageMutation) ResetConditionOperator() {
  22509. m.condition_operator = nil
  22510. m.addcondition_operator = nil
  22511. }
  22512. // SetConditionList sets the "condition_list" field.
  22513. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  22514. m.condition_list = &ct
  22515. m.appendcondition_list = nil
  22516. }
  22517. // ConditionList returns the value of the "condition_list" field in the mutation.
  22518. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  22519. v := m.condition_list
  22520. if v == nil {
  22521. return
  22522. }
  22523. return *v, true
  22524. }
  22525. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  22526. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22528. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  22529. if !m.op.Is(OpUpdateOne) {
  22530. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  22531. }
  22532. if m.id == nil || m.oldValue == nil {
  22533. return v, errors.New("OldConditionList requires an ID field in the mutation")
  22534. }
  22535. oldValue, err := m.oldValue(ctx)
  22536. if err != nil {
  22537. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  22538. }
  22539. return oldValue.ConditionList, nil
  22540. }
  22541. // AppendConditionList adds ct to the "condition_list" field.
  22542. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  22543. m.appendcondition_list = append(m.appendcondition_list, ct...)
  22544. }
  22545. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  22546. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  22547. if len(m.appendcondition_list) == 0 {
  22548. return nil, false
  22549. }
  22550. return m.appendcondition_list, true
  22551. }
  22552. // ResetConditionList resets all changes to the "condition_list" field.
  22553. func (m *SopStageMutation) ResetConditionList() {
  22554. m.condition_list = nil
  22555. m.appendcondition_list = nil
  22556. }
  22557. // SetActionMessage sets the "action_message" field.
  22558. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  22559. m.action_message = &ct
  22560. m.appendaction_message = nil
  22561. }
  22562. // ActionMessage returns the value of the "action_message" field in the mutation.
  22563. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  22564. v := m.action_message
  22565. if v == nil {
  22566. return
  22567. }
  22568. return *v, true
  22569. }
  22570. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  22571. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22572. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22573. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  22574. if !m.op.Is(OpUpdateOne) {
  22575. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  22576. }
  22577. if m.id == nil || m.oldValue == nil {
  22578. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  22579. }
  22580. oldValue, err := m.oldValue(ctx)
  22581. if err != nil {
  22582. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  22583. }
  22584. return oldValue.ActionMessage, nil
  22585. }
  22586. // AppendActionMessage adds ct to the "action_message" field.
  22587. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  22588. m.appendaction_message = append(m.appendaction_message, ct...)
  22589. }
  22590. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  22591. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  22592. if len(m.appendaction_message) == 0 {
  22593. return nil, false
  22594. }
  22595. return m.appendaction_message, true
  22596. }
  22597. // ClearActionMessage clears the value of the "action_message" field.
  22598. func (m *SopStageMutation) ClearActionMessage() {
  22599. m.action_message = nil
  22600. m.appendaction_message = nil
  22601. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  22602. }
  22603. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  22604. func (m *SopStageMutation) ActionMessageCleared() bool {
  22605. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  22606. return ok
  22607. }
  22608. // ResetActionMessage resets all changes to the "action_message" field.
  22609. func (m *SopStageMutation) ResetActionMessage() {
  22610. m.action_message = nil
  22611. m.appendaction_message = nil
  22612. delete(m.clearedFields, sopstage.FieldActionMessage)
  22613. }
  22614. // SetActionLabelAdd sets the "action_label_add" field.
  22615. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  22616. m.action_label_add = &u
  22617. m.appendaction_label_add = nil
  22618. }
  22619. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  22620. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  22621. v := m.action_label_add
  22622. if v == nil {
  22623. return
  22624. }
  22625. return *v, true
  22626. }
  22627. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  22628. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22630. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  22631. if !m.op.Is(OpUpdateOne) {
  22632. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  22633. }
  22634. if m.id == nil || m.oldValue == nil {
  22635. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  22636. }
  22637. oldValue, err := m.oldValue(ctx)
  22638. if err != nil {
  22639. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  22640. }
  22641. return oldValue.ActionLabelAdd, nil
  22642. }
  22643. // AppendActionLabelAdd adds u to the "action_label_add" field.
  22644. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  22645. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  22646. }
  22647. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  22648. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  22649. if len(m.appendaction_label_add) == 0 {
  22650. return nil, false
  22651. }
  22652. return m.appendaction_label_add, true
  22653. }
  22654. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  22655. func (m *SopStageMutation) ClearActionLabelAdd() {
  22656. m.action_label_add = nil
  22657. m.appendaction_label_add = nil
  22658. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  22659. }
  22660. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  22661. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  22662. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  22663. return ok
  22664. }
  22665. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  22666. func (m *SopStageMutation) ResetActionLabelAdd() {
  22667. m.action_label_add = nil
  22668. m.appendaction_label_add = nil
  22669. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  22670. }
  22671. // SetActionLabelDel sets the "action_label_del" field.
  22672. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  22673. m.action_label_del = &u
  22674. m.appendaction_label_del = nil
  22675. }
  22676. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  22677. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  22678. v := m.action_label_del
  22679. if v == nil {
  22680. return
  22681. }
  22682. return *v, true
  22683. }
  22684. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  22685. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22687. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  22688. if !m.op.Is(OpUpdateOne) {
  22689. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  22690. }
  22691. if m.id == nil || m.oldValue == nil {
  22692. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  22693. }
  22694. oldValue, err := m.oldValue(ctx)
  22695. if err != nil {
  22696. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  22697. }
  22698. return oldValue.ActionLabelDel, nil
  22699. }
  22700. // AppendActionLabelDel adds u to the "action_label_del" field.
  22701. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  22702. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  22703. }
  22704. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  22705. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  22706. if len(m.appendaction_label_del) == 0 {
  22707. return nil, false
  22708. }
  22709. return m.appendaction_label_del, true
  22710. }
  22711. // ClearActionLabelDel clears the value of the "action_label_del" field.
  22712. func (m *SopStageMutation) ClearActionLabelDel() {
  22713. m.action_label_del = nil
  22714. m.appendaction_label_del = nil
  22715. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  22716. }
  22717. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  22718. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  22719. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  22720. return ok
  22721. }
  22722. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  22723. func (m *SopStageMutation) ResetActionLabelDel() {
  22724. m.action_label_del = nil
  22725. m.appendaction_label_del = nil
  22726. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  22727. }
  22728. // SetActionForward sets the "action_forward" field.
  22729. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  22730. m.action_forward = &ctf
  22731. }
  22732. // ActionForward returns the value of the "action_forward" field in the mutation.
  22733. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  22734. v := m.action_forward
  22735. if v == nil {
  22736. return
  22737. }
  22738. return *v, true
  22739. }
  22740. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  22741. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22743. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  22744. if !m.op.Is(OpUpdateOne) {
  22745. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  22746. }
  22747. if m.id == nil || m.oldValue == nil {
  22748. return v, errors.New("OldActionForward requires an ID field in the mutation")
  22749. }
  22750. oldValue, err := m.oldValue(ctx)
  22751. if err != nil {
  22752. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  22753. }
  22754. return oldValue.ActionForward, nil
  22755. }
  22756. // ClearActionForward clears the value of the "action_forward" field.
  22757. func (m *SopStageMutation) ClearActionForward() {
  22758. m.action_forward = nil
  22759. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  22760. }
  22761. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  22762. func (m *SopStageMutation) ActionForwardCleared() bool {
  22763. _, ok := m.clearedFields[sopstage.FieldActionForward]
  22764. return ok
  22765. }
  22766. // ResetActionForward resets all changes to the "action_forward" field.
  22767. func (m *SopStageMutation) ResetActionForward() {
  22768. m.action_forward = nil
  22769. delete(m.clearedFields, sopstage.FieldActionForward)
  22770. }
  22771. // SetIndexSort sets the "index_sort" field.
  22772. func (m *SopStageMutation) SetIndexSort(i int) {
  22773. m.index_sort = &i
  22774. m.addindex_sort = nil
  22775. }
  22776. // IndexSort returns the value of the "index_sort" field in the mutation.
  22777. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  22778. v := m.index_sort
  22779. if v == nil {
  22780. return
  22781. }
  22782. return *v, true
  22783. }
  22784. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  22785. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22787. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  22788. if !m.op.Is(OpUpdateOne) {
  22789. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  22790. }
  22791. if m.id == nil || m.oldValue == nil {
  22792. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  22793. }
  22794. oldValue, err := m.oldValue(ctx)
  22795. if err != nil {
  22796. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  22797. }
  22798. return oldValue.IndexSort, nil
  22799. }
  22800. // AddIndexSort adds i to the "index_sort" field.
  22801. func (m *SopStageMutation) AddIndexSort(i int) {
  22802. if m.addindex_sort != nil {
  22803. *m.addindex_sort += i
  22804. } else {
  22805. m.addindex_sort = &i
  22806. }
  22807. }
  22808. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  22809. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  22810. v := m.addindex_sort
  22811. if v == nil {
  22812. return
  22813. }
  22814. return *v, true
  22815. }
  22816. // ClearIndexSort clears the value of the "index_sort" field.
  22817. func (m *SopStageMutation) ClearIndexSort() {
  22818. m.index_sort = nil
  22819. m.addindex_sort = nil
  22820. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  22821. }
  22822. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  22823. func (m *SopStageMutation) IndexSortCleared() bool {
  22824. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  22825. return ok
  22826. }
  22827. // ResetIndexSort resets all changes to the "index_sort" field.
  22828. func (m *SopStageMutation) ResetIndexSort() {
  22829. m.index_sort = nil
  22830. m.addindex_sort = nil
  22831. delete(m.clearedFields, sopstage.FieldIndexSort)
  22832. }
  22833. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  22834. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  22835. m.sop_task = &id
  22836. }
  22837. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  22838. func (m *SopStageMutation) ClearSopTask() {
  22839. m.clearedsop_task = true
  22840. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  22841. }
  22842. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  22843. func (m *SopStageMutation) SopTaskCleared() bool {
  22844. return m.clearedsop_task
  22845. }
  22846. // SopTaskID returns the "sop_task" edge ID in the mutation.
  22847. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  22848. if m.sop_task != nil {
  22849. return *m.sop_task, true
  22850. }
  22851. return
  22852. }
  22853. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  22854. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22855. // SopTaskID instead. It exists only for internal usage by the builders.
  22856. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  22857. if id := m.sop_task; id != nil {
  22858. ids = append(ids, *id)
  22859. }
  22860. return
  22861. }
  22862. // ResetSopTask resets all changes to the "sop_task" edge.
  22863. func (m *SopStageMutation) ResetSopTask() {
  22864. m.sop_task = nil
  22865. m.clearedsop_task = false
  22866. }
  22867. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  22868. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  22869. if m.stage_nodes == nil {
  22870. m.stage_nodes = make(map[uint64]struct{})
  22871. }
  22872. for i := range ids {
  22873. m.stage_nodes[ids[i]] = struct{}{}
  22874. }
  22875. }
  22876. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  22877. func (m *SopStageMutation) ClearStageNodes() {
  22878. m.clearedstage_nodes = true
  22879. }
  22880. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  22881. func (m *SopStageMutation) StageNodesCleared() bool {
  22882. return m.clearedstage_nodes
  22883. }
  22884. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  22885. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  22886. if m.removedstage_nodes == nil {
  22887. m.removedstage_nodes = make(map[uint64]struct{})
  22888. }
  22889. for i := range ids {
  22890. delete(m.stage_nodes, ids[i])
  22891. m.removedstage_nodes[ids[i]] = struct{}{}
  22892. }
  22893. }
  22894. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  22895. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  22896. for id := range m.removedstage_nodes {
  22897. ids = append(ids, id)
  22898. }
  22899. return
  22900. }
  22901. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  22902. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  22903. for id := range m.stage_nodes {
  22904. ids = append(ids, id)
  22905. }
  22906. return
  22907. }
  22908. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  22909. func (m *SopStageMutation) ResetStageNodes() {
  22910. m.stage_nodes = nil
  22911. m.clearedstage_nodes = false
  22912. m.removedstage_nodes = nil
  22913. }
  22914. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  22915. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  22916. if m.stage_messages == nil {
  22917. m.stage_messages = make(map[uint64]struct{})
  22918. }
  22919. for i := range ids {
  22920. m.stage_messages[ids[i]] = struct{}{}
  22921. }
  22922. }
  22923. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  22924. func (m *SopStageMutation) ClearStageMessages() {
  22925. m.clearedstage_messages = true
  22926. }
  22927. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  22928. func (m *SopStageMutation) StageMessagesCleared() bool {
  22929. return m.clearedstage_messages
  22930. }
  22931. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  22932. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  22933. if m.removedstage_messages == nil {
  22934. m.removedstage_messages = make(map[uint64]struct{})
  22935. }
  22936. for i := range ids {
  22937. delete(m.stage_messages, ids[i])
  22938. m.removedstage_messages[ids[i]] = struct{}{}
  22939. }
  22940. }
  22941. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  22942. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  22943. for id := range m.removedstage_messages {
  22944. ids = append(ids, id)
  22945. }
  22946. return
  22947. }
  22948. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  22949. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  22950. for id := range m.stage_messages {
  22951. ids = append(ids, id)
  22952. }
  22953. return
  22954. }
  22955. // ResetStageMessages resets all changes to the "stage_messages" edge.
  22956. func (m *SopStageMutation) ResetStageMessages() {
  22957. m.stage_messages = nil
  22958. m.clearedstage_messages = false
  22959. m.removedstage_messages = nil
  22960. }
  22961. // Where appends a list predicates to the SopStageMutation builder.
  22962. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  22963. m.predicates = append(m.predicates, ps...)
  22964. }
  22965. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  22966. // users can use type-assertion to append predicates that do not depend on any generated package.
  22967. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  22968. p := make([]predicate.SopStage, len(ps))
  22969. for i := range ps {
  22970. p[i] = ps[i]
  22971. }
  22972. m.Where(p...)
  22973. }
  22974. // Op returns the operation name.
  22975. func (m *SopStageMutation) Op() Op {
  22976. return m.op
  22977. }
  22978. // SetOp allows setting the mutation operation.
  22979. func (m *SopStageMutation) SetOp(op Op) {
  22980. m.op = op
  22981. }
  22982. // Type returns the node type of this mutation (SopStage).
  22983. func (m *SopStageMutation) Type() string {
  22984. return m.typ
  22985. }
  22986. // Fields returns all fields that were changed during this mutation. Note that in
  22987. // order to get all numeric fields that were incremented/decremented, call
  22988. // AddedFields().
  22989. func (m *SopStageMutation) Fields() []string {
  22990. fields := make([]string, 0, 14)
  22991. if m.created_at != nil {
  22992. fields = append(fields, sopstage.FieldCreatedAt)
  22993. }
  22994. if m.updated_at != nil {
  22995. fields = append(fields, sopstage.FieldUpdatedAt)
  22996. }
  22997. if m.status != nil {
  22998. fields = append(fields, sopstage.FieldStatus)
  22999. }
  23000. if m.deleted_at != nil {
  23001. fields = append(fields, sopstage.FieldDeletedAt)
  23002. }
  23003. if m.sop_task != nil {
  23004. fields = append(fields, sopstage.FieldTaskID)
  23005. }
  23006. if m.name != nil {
  23007. fields = append(fields, sopstage.FieldName)
  23008. }
  23009. if m.condition_type != nil {
  23010. fields = append(fields, sopstage.FieldConditionType)
  23011. }
  23012. if m.condition_operator != nil {
  23013. fields = append(fields, sopstage.FieldConditionOperator)
  23014. }
  23015. if m.condition_list != nil {
  23016. fields = append(fields, sopstage.FieldConditionList)
  23017. }
  23018. if m.action_message != nil {
  23019. fields = append(fields, sopstage.FieldActionMessage)
  23020. }
  23021. if m.action_label_add != nil {
  23022. fields = append(fields, sopstage.FieldActionLabelAdd)
  23023. }
  23024. if m.action_label_del != nil {
  23025. fields = append(fields, sopstage.FieldActionLabelDel)
  23026. }
  23027. if m.action_forward != nil {
  23028. fields = append(fields, sopstage.FieldActionForward)
  23029. }
  23030. if m.index_sort != nil {
  23031. fields = append(fields, sopstage.FieldIndexSort)
  23032. }
  23033. return fields
  23034. }
  23035. // Field returns the value of a field with the given name. The second boolean
  23036. // return value indicates that this field was not set, or was not defined in the
  23037. // schema.
  23038. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  23039. switch name {
  23040. case sopstage.FieldCreatedAt:
  23041. return m.CreatedAt()
  23042. case sopstage.FieldUpdatedAt:
  23043. return m.UpdatedAt()
  23044. case sopstage.FieldStatus:
  23045. return m.Status()
  23046. case sopstage.FieldDeletedAt:
  23047. return m.DeletedAt()
  23048. case sopstage.FieldTaskID:
  23049. return m.TaskID()
  23050. case sopstage.FieldName:
  23051. return m.Name()
  23052. case sopstage.FieldConditionType:
  23053. return m.ConditionType()
  23054. case sopstage.FieldConditionOperator:
  23055. return m.ConditionOperator()
  23056. case sopstage.FieldConditionList:
  23057. return m.ConditionList()
  23058. case sopstage.FieldActionMessage:
  23059. return m.ActionMessage()
  23060. case sopstage.FieldActionLabelAdd:
  23061. return m.ActionLabelAdd()
  23062. case sopstage.FieldActionLabelDel:
  23063. return m.ActionLabelDel()
  23064. case sopstage.FieldActionForward:
  23065. return m.ActionForward()
  23066. case sopstage.FieldIndexSort:
  23067. return m.IndexSort()
  23068. }
  23069. return nil, false
  23070. }
  23071. // OldField returns the old value of the field from the database. An error is
  23072. // returned if the mutation operation is not UpdateOne, or the query to the
  23073. // database failed.
  23074. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23075. switch name {
  23076. case sopstage.FieldCreatedAt:
  23077. return m.OldCreatedAt(ctx)
  23078. case sopstage.FieldUpdatedAt:
  23079. return m.OldUpdatedAt(ctx)
  23080. case sopstage.FieldStatus:
  23081. return m.OldStatus(ctx)
  23082. case sopstage.FieldDeletedAt:
  23083. return m.OldDeletedAt(ctx)
  23084. case sopstage.FieldTaskID:
  23085. return m.OldTaskID(ctx)
  23086. case sopstage.FieldName:
  23087. return m.OldName(ctx)
  23088. case sopstage.FieldConditionType:
  23089. return m.OldConditionType(ctx)
  23090. case sopstage.FieldConditionOperator:
  23091. return m.OldConditionOperator(ctx)
  23092. case sopstage.FieldConditionList:
  23093. return m.OldConditionList(ctx)
  23094. case sopstage.FieldActionMessage:
  23095. return m.OldActionMessage(ctx)
  23096. case sopstage.FieldActionLabelAdd:
  23097. return m.OldActionLabelAdd(ctx)
  23098. case sopstage.FieldActionLabelDel:
  23099. return m.OldActionLabelDel(ctx)
  23100. case sopstage.FieldActionForward:
  23101. return m.OldActionForward(ctx)
  23102. case sopstage.FieldIndexSort:
  23103. return m.OldIndexSort(ctx)
  23104. }
  23105. return nil, fmt.Errorf("unknown SopStage field %s", name)
  23106. }
  23107. // SetField sets the value of a field with the given name. It returns an error if
  23108. // the field is not defined in the schema, or if the type mismatched the field
  23109. // type.
  23110. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  23111. switch name {
  23112. case sopstage.FieldCreatedAt:
  23113. v, ok := value.(time.Time)
  23114. if !ok {
  23115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23116. }
  23117. m.SetCreatedAt(v)
  23118. return nil
  23119. case sopstage.FieldUpdatedAt:
  23120. v, ok := value.(time.Time)
  23121. if !ok {
  23122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23123. }
  23124. m.SetUpdatedAt(v)
  23125. return nil
  23126. case sopstage.FieldStatus:
  23127. v, ok := value.(uint8)
  23128. if !ok {
  23129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23130. }
  23131. m.SetStatus(v)
  23132. return nil
  23133. case sopstage.FieldDeletedAt:
  23134. v, ok := value.(time.Time)
  23135. if !ok {
  23136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23137. }
  23138. m.SetDeletedAt(v)
  23139. return nil
  23140. case sopstage.FieldTaskID:
  23141. v, ok := value.(uint64)
  23142. if !ok {
  23143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23144. }
  23145. m.SetTaskID(v)
  23146. return nil
  23147. case sopstage.FieldName:
  23148. v, ok := value.(string)
  23149. if !ok {
  23150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23151. }
  23152. m.SetName(v)
  23153. return nil
  23154. case sopstage.FieldConditionType:
  23155. v, ok := value.(int)
  23156. if !ok {
  23157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23158. }
  23159. m.SetConditionType(v)
  23160. return nil
  23161. case sopstage.FieldConditionOperator:
  23162. v, ok := value.(int)
  23163. if !ok {
  23164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23165. }
  23166. m.SetConditionOperator(v)
  23167. return nil
  23168. case sopstage.FieldConditionList:
  23169. v, ok := value.([]custom_types.Condition)
  23170. if !ok {
  23171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23172. }
  23173. m.SetConditionList(v)
  23174. return nil
  23175. case sopstage.FieldActionMessage:
  23176. v, ok := value.([]custom_types.Action)
  23177. if !ok {
  23178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23179. }
  23180. m.SetActionMessage(v)
  23181. return nil
  23182. case sopstage.FieldActionLabelAdd:
  23183. v, ok := value.([]uint64)
  23184. if !ok {
  23185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23186. }
  23187. m.SetActionLabelAdd(v)
  23188. return nil
  23189. case sopstage.FieldActionLabelDel:
  23190. v, ok := value.([]uint64)
  23191. if !ok {
  23192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23193. }
  23194. m.SetActionLabelDel(v)
  23195. return nil
  23196. case sopstage.FieldActionForward:
  23197. v, ok := value.(*custom_types.ActionForward)
  23198. if !ok {
  23199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23200. }
  23201. m.SetActionForward(v)
  23202. return nil
  23203. case sopstage.FieldIndexSort:
  23204. v, ok := value.(int)
  23205. if !ok {
  23206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23207. }
  23208. m.SetIndexSort(v)
  23209. return nil
  23210. }
  23211. return fmt.Errorf("unknown SopStage field %s", name)
  23212. }
  23213. // AddedFields returns all numeric fields that were incremented/decremented during
  23214. // this mutation.
  23215. func (m *SopStageMutation) AddedFields() []string {
  23216. var fields []string
  23217. if m.addstatus != nil {
  23218. fields = append(fields, sopstage.FieldStatus)
  23219. }
  23220. if m.addcondition_type != nil {
  23221. fields = append(fields, sopstage.FieldConditionType)
  23222. }
  23223. if m.addcondition_operator != nil {
  23224. fields = append(fields, sopstage.FieldConditionOperator)
  23225. }
  23226. if m.addindex_sort != nil {
  23227. fields = append(fields, sopstage.FieldIndexSort)
  23228. }
  23229. return fields
  23230. }
  23231. // AddedField returns the numeric value that was incremented/decremented on a field
  23232. // with the given name. The second boolean return value indicates that this field
  23233. // was not set, or was not defined in the schema.
  23234. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  23235. switch name {
  23236. case sopstage.FieldStatus:
  23237. return m.AddedStatus()
  23238. case sopstage.FieldConditionType:
  23239. return m.AddedConditionType()
  23240. case sopstage.FieldConditionOperator:
  23241. return m.AddedConditionOperator()
  23242. case sopstage.FieldIndexSort:
  23243. return m.AddedIndexSort()
  23244. }
  23245. return nil, false
  23246. }
  23247. // AddField adds the value to the field with the given name. It returns an error if
  23248. // the field is not defined in the schema, or if the type mismatched the field
  23249. // type.
  23250. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  23251. switch name {
  23252. case sopstage.FieldStatus:
  23253. v, ok := value.(int8)
  23254. if !ok {
  23255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23256. }
  23257. m.AddStatus(v)
  23258. return nil
  23259. case sopstage.FieldConditionType:
  23260. v, ok := value.(int)
  23261. if !ok {
  23262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23263. }
  23264. m.AddConditionType(v)
  23265. return nil
  23266. case sopstage.FieldConditionOperator:
  23267. v, ok := value.(int)
  23268. if !ok {
  23269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23270. }
  23271. m.AddConditionOperator(v)
  23272. return nil
  23273. case sopstage.FieldIndexSort:
  23274. v, ok := value.(int)
  23275. if !ok {
  23276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23277. }
  23278. m.AddIndexSort(v)
  23279. return nil
  23280. }
  23281. return fmt.Errorf("unknown SopStage numeric field %s", name)
  23282. }
  23283. // ClearedFields returns all nullable fields that were cleared during this
  23284. // mutation.
  23285. func (m *SopStageMutation) ClearedFields() []string {
  23286. var fields []string
  23287. if m.FieldCleared(sopstage.FieldStatus) {
  23288. fields = append(fields, sopstage.FieldStatus)
  23289. }
  23290. if m.FieldCleared(sopstage.FieldDeletedAt) {
  23291. fields = append(fields, sopstage.FieldDeletedAt)
  23292. }
  23293. if m.FieldCleared(sopstage.FieldActionMessage) {
  23294. fields = append(fields, sopstage.FieldActionMessage)
  23295. }
  23296. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  23297. fields = append(fields, sopstage.FieldActionLabelAdd)
  23298. }
  23299. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  23300. fields = append(fields, sopstage.FieldActionLabelDel)
  23301. }
  23302. if m.FieldCleared(sopstage.FieldActionForward) {
  23303. fields = append(fields, sopstage.FieldActionForward)
  23304. }
  23305. if m.FieldCleared(sopstage.FieldIndexSort) {
  23306. fields = append(fields, sopstage.FieldIndexSort)
  23307. }
  23308. return fields
  23309. }
  23310. // FieldCleared returns a boolean indicating if a field with the given name was
  23311. // cleared in this mutation.
  23312. func (m *SopStageMutation) FieldCleared(name string) bool {
  23313. _, ok := m.clearedFields[name]
  23314. return ok
  23315. }
  23316. // ClearField clears the value of the field with the given name. It returns an
  23317. // error if the field is not defined in the schema.
  23318. func (m *SopStageMutation) ClearField(name string) error {
  23319. switch name {
  23320. case sopstage.FieldStatus:
  23321. m.ClearStatus()
  23322. return nil
  23323. case sopstage.FieldDeletedAt:
  23324. m.ClearDeletedAt()
  23325. return nil
  23326. case sopstage.FieldActionMessage:
  23327. m.ClearActionMessage()
  23328. return nil
  23329. case sopstage.FieldActionLabelAdd:
  23330. m.ClearActionLabelAdd()
  23331. return nil
  23332. case sopstage.FieldActionLabelDel:
  23333. m.ClearActionLabelDel()
  23334. return nil
  23335. case sopstage.FieldActionForward:
  23336. m.ClearActionForward()
  23337. return nil
  23338. case sopstage.FieldIndexSort:
  23339. m.ClearIndexSort()
  23340. return nil
  23341. }
  23342. return fmt.Errorf("unknown SopStage nullable field %s", name)
  23343. }
  23344. // ResetField resets all changes in the mutation for the field with the given name.
  23345. // It returns an error if the field is not defined in the schema.
  23346. func (m *SopStageMutation) ResetField(name string) error {
  23347. switch name {
  23348. case sopstage.FieldCreatedAt:
  23349. m.ResetCreatedAt()
  23350. return nil
  23351. case sopstage.FieldUpdatedAt:
  23352. m.ResetUpdatedAt()
  23353. return nil
  23354. case sopstage.FieldStatus:
  23355. m.ResetStatus()
  23356. return nil
  23357. case sopstage.FieldDeletedAt:
  23358. m.ResetDeletedAt()
  23359. return nil
  23360. case sopstage.FieldTaskID:
  23361. m.ResetTaskID()
  23362. return nil
  23363. case sopstage.FieldName:
  23364. m.ResetName()
  23365. return nil
  23366. case sopstage.FieldConditionType:
  23367. m.ResetConditionType()
  23368. return nil
  23369. case sopstage.FieldConditionOperator:
  23370. m.ResetConditionOperator()
  23371. return nil
  23372. case sopstage.FieldConditionList:
  23373. m.ResetConditionList()
  23374. return nil
  23375. case sopstage.FieldActionMessage:
  23376. m.ResetActionMessage()
  23377. return nil
  23378. case sopstage.FieldActionLabelAdd:
  23379. m.ResetActionLabelAdd()
  23380. return nil
  23381. case sopstage.FieldActionLabelDel:
  23382. m.ResetActionLabelDel()
  23383. return nil
  23384. case sopstage.FieldActionForward:
  23385. m.ResetActionForward()
  23386. return nil
  23387. case sopstage.FieldIndexSort:
  23388. m.ResetIndexSort()
  23389. return nil
  23390. }
  23391. return fmt.Errorf("unknown SopStage field %s", name)
  23392. }
  23393. // AddedEdges returns all edge names that were set/added in this mutation.
  23394. func (m *SopStageMutation) AddedEdges() []string {
  23395. edges := make([]string, 0, 3)
  23396. if m.sop_task != nil {
  23397. edges = append(edges, sopstage.EdgeSopTask)
  23398. }
  23399. if m.stage_nodes != nil {
  23400. edges = append(edges, sopstage.EdgeStageNodes)
  23401. }
  23402. if m.stage_messages != nil {
  23403. edges = append(edges, sopstage.EdgeStageMessages)
  23404. }
  23405. return edges
  23406. }
  23407. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23408. // name in this mutation.
  23409. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  23410. switch name {
  23411. case sopstage.EdgeSopTask:
  23412. if id := m.sop_task; id != nil {
  23413. return []ent.Value{*id}
  23414. }
  23415. case sopstage.EdgeStageNodes:
  23416. ids := make([]ent.Value, 0, len(m.stage_nodes))
  23417. for id := range m.stage_nodes {
  23418. ids = append(ids, id)
  23419. }
  23420. return ids
  23421. case sopstage.EdgeStageMessages:
  23422. ids := make([]ent.Value, 0, len(m.stage_messages))
  23423. for id := range m.stage_messages {
  23424. ids = append(ids, id)
  23425. }
  23426. return ids
  23427. }
  23428. return nil
  23429. }
  23430. // RemovedEdges returns all edge names that were removed in this mutation.
  23431. func (m *SopStageMutation) RemovedEdges() []string {
  23432. edges := make([]string, 0, 3)
  23433. if m.removedstage_nodes != nil {
  23434. edges = append(edges, sopstage.EdgeStageNodes)
  23435. }
  23436. if m.removedstage_messages != nil {
  23437. edges = append(edges, sopstage.EdgeStageMessages)
  23438. }
  23439. return edges
  23440. }
  23441. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23442. // the given name in this mutation.
  23443. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  23444. switch name {
  23445. case sopstage.EdgeStageNodes:
  23446. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  23447. for id := range m.removedstage_nodes {
  23448. ids = append(ids, id)
  23449. }
  23450. return ids
  23451. case sopstage.EdgeStageMessages:
  23452. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  23453. for id := range m.removedstage_messages {
  23454. ids = append(ids, id)
  23455. }
  23456. return ids
  23457. }
  23458. return nil
  23459. }
  23460. // ClearedEdges returns all edge names that were cleared in this mutation.
  23461. func (m *SopStageMutation) ClearedEdges() []string {
  23462. edges := make([]string, 0, 3)
  23463. if m.clearedsop_task {
  23464. edges = append(edges, sopstage.EdgeSopTask)
  23465. }
  23466. if m.clearedstage_nodes {
  23467. edges = append(edges, sopstage.EdgeStageNodes)
  23468. }
  23469. if m.clearedstage_messages {
  23470. edges = append(edges, sopstage.EdgeStageMessages)
  23471. }
  23472. return edges
  23473. }
  23474. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23475. // was cleared in this mutation.
  23476. func (m *SopStageMutation) EdgeCleared(name string) bool {
  23477. switch name {
  23478. case sopstage.EdgeSopTask:
  23479. return m.clearedsop_task
  23480. case sopstage.EdgeStageNodes:
  23481. return m.clearedstage_nodes
  23482. case sopstage.EdgeStageMessages:
  23483. return m.clearedstage_messages
  23484. }
  23485. return false
  23486. }
  23487. // ClearEdge clears the value of the edge with the given name. It returns an error
  23488. // if that edge is not defined in the schema.
  23489. func (m *SopStageMutation) ClearEdge(name string) error {
  23490. switch name {
  23491. case sopstage.EdgeSopTask:
  23492. m.ClearSopTask()
  23493. return nil
  23494. }
  23495. return fmt.Errorf("unknown SopStage unique edge %s", name)
  23496. }
  23497. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23498. // It returns an error if the edge is not defined in the schema.
  23499. func (m *SopStageMutation) ResetEdge(name string) error {
  23500. switch name {
  23501. case sopstage.EdgeSopTask:
  23502. m.ResetSopTask()
  23503. return nil
  23504. case sopstage.EdgeStageNodes:
  23505. m.ResetStageNodes()
  23506. return nil
  23507. case sopstage.EdgeStageMessages:
  23508. m.ResetStageMessages()
  23509. return nil
  23510. }
  23511. return fmt.Errorf("unknown SopStage edge %s", name)
  23512. }
  23513. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  23514. type SopTaskMutation struct {
  23515. config
  23516. op Op
  23517. typ string
  23518. id *uint64
  23519. created_at *time.Time
  23520. updated_at *time.Time
  23521. status *uint8
  23522. addstatus *int8
  23523. deleted_at *time.Time
  23524. name *string
  23525. bot_wxid_list *[]string
  23526. appendbot_wxid_list []string
  23527. _type *int
  23528. add_type *int
  23529. plan_start_time *time.Time
  23530. plan_end_time *time.Time
  23531. creator_id *string
  23532. organization_id *uint64
  23533. addorganization_id *int64
  23534. token *[]string
  23535. appendtoken []string
  23536. clearedFields map[string]struct{}
  23537. task_stages map[uint64]struct{}
  23538. removedtask_stages map[uint64]struct{}
  23539. clearedtask_stages bool
  23540. done bool
  23541. oldValue func(context.Context) (*SopTask, error)
  23542. predicates []predicate.SopTask
  23543. }
  23544. var _ ent.Mutation = (*SopTaskMutation)(nil)
  23545. // soptaskOption allows management of the mutation configuration using functional options.
  23546. type soptaskOption func(*SopTaskMutation)
  23547. // newSopTaskMutation creates new mutation for the SopTask entity.
  23548. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  23549. m := &SopTaskMutation{
  23550. config: c,
  23551. op: op,
  23552. typ: TypeSopTask,
  23553. clearedFields: make(map[string]struct{}),
  23554. }
  23555. for _, opt := range opts {
  23556. opt(m)
  23557. }
  23558. return m
  23559. }
  23560. // withSopTaskID sets the ID field of the mutation.
  23561. func withSopTaskID(id uint64) soptaskOption {
  23562. return func(m *SopTaskMutation) {
  23563. var (
  23564. err error
  23565. once sync.Once
  23566. value *SopTask
  23567. )
  23568. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  23569. once.Do(func() {
  23570. if m.done {
  23571. err = errors.New("querying old values post mutation is not allowed")
  23572. } else {
  23573. value, err = m.Client().SopTask.Get(ctx, id)
  23574. }
  23575. })
  23576. return value, err
  23577. }
  23578. m.id = &id
  23579. }
  23580. }
  23581. // withSopTask sets the old SopTask of the mutation.
  23582. func withSopTask(node *SopTask) soptaskOption {
  23583. return func(m *SopTaskMutation) {
  23584. m.oldValue = func(context.Context) (*SopTask, error) {
  23585. return node, nil
  23586. }
  23587. m.id = &node.ID
  23588. }
  23589. }
  23590. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23591. // executed in a transaction (ent.Tx), a transactional client is returned.
  23592. func (m SopTaskMutation) Client() *Client {
  23593. client := &Client{config: m.config}
  23594. client.init()
  23595. return client
  23596. }
  23597. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23598. // it returns an error otherwise.
  23599. func (m SopTaskMutation) Tx() (*Tx, error) {
  23600. if _, ok := m.driver.(*txDriver); !ok {
  23601. return nil, errors.New("ent: mutation is not running in a transaction")
  23602. }
  23603. tx := &Tx{config: m.config}
  23604. tx.init()
  23605. return tx, nil
  23606. }
  23607. // SetID sets the value of the id field. Note that this
  23608. // operation is only accepted on creation of SopTask entities.
  23609. func (m *SopTaskMutation) SetID(id uint64) {
  23610. m.id = &id
  23611. }
  23612. // ID returns the ID value in the mutation. Note that the ID is only available
  23613. // if it was provided to the builder or after it was returned from the database.
  23614. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  23615. if m.id == nil {
  23616. return
  23617. }
  23618. return *m.id, true
  23619. }
  23620. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23621. // That means, if the mutation is applied within a transaction with an isolation level such
  23622. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23623. // or updated by the mutation.
  23624. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  23625. switch {
  23626. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23627. id, exists := m.ID()
  23628. if exists {
  23629. return []uint64{id}, nil
  23630. }
  23631. fallthrough
  23632. case m.op.Is(OpUpdate | OpDelete):
  23633. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  23634. default:
  23635. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23636. }
  23637. }
  23638. // SetCreatedAt sets the "created_at" field.
  23639. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  23640. m.created_at = &t
  23641. }
  23642. // CreatedAt returns the value of the "created_at" field in the mutation.
  23643. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  23644. v := m.created_at
  23645. if v == nil {
  23646. return
  23647. }
  23648. return *v, true
  23649. }
  23650. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  23651. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23653. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23654. if !m.op.Is(OpUpdateOne) {
  23655. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23656. }
  23657. if m.id == nil || m.oldValue == nil {
  23658. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23659. }
  23660. oldValue, err := m.oldValue(ctx)
  23661. if err != nil {
  23662. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23663. }
  23664. return oldValue.CreatedAt, nil
  23665. }
  23666. // ResetCreatedAt resets all changes to the "created_at" field.
  23667. func (m *SopTaskMutation) ResetCreatedAt() {
  23668. m.created_at = nil
  23669. }
  23670. // SetUpdatedAt sets the "updated_at" field.
  23671. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  23672. m.updated_at = &t
  23673. }
  23674. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23675. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  23676. v := m.updated_at
  23677. if v == nil {
  23678. return
  23679. }
  23680. return *v, true
  23681. }
  23682. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  23683. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23684. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23685. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23686. if !m.op.Is(OpUpdateOne) {
  23687. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23688. }
  23689. if m.id == nil || m.oldValue == nil {
  23690. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23691. }
  23692. oldValue, err := m.oldValue(ctx)
  23693. if err != nil {
  23694. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23695. }
  23696. return oldValue.UpdatedAt, nil
  23697. }
  23698. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23699. func (m *SopTaskMutation) ResetUpdatedAt() {
  23700. m.updated_at = nil
  23701. }
  23702. // SetStatus sets the "status" field.
  23703. func (m *SopTaskMutation) SetStatus(u uint8) {
  23704. m.status = &u
  23705. m.addstatus = nil
  23706. }
  23707. // Status returns the value of the "status" field in the mutation.
  23708. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  23709. v := m.status
  23710. if v == nil {
  23711. return
  23712. }
  23713. return *v, true
  23714. }
  23715. // OldStatus returns the old "status" field's value of the SopTask entity.
  23716. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23718. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23719. if !m.op.Is(OpUpdateOne) {
  23720. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23721. }
  23722. if m.id == nil || m.oldValue == nil {
  23723. return v, errors.New("OldStatus requires an ID field in the mutation")
  23724. }
  23725. oldValue, err := m.oldValue(ctx)
  23726. if err != nil {
  23727. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23728. }
  23729. return oldValue.Status, nil
  23730. }
  23731. // AddStatus adds u to the "status" field.
  23732. func (m *SopTaskMutation) AddStatus(u int8) {
  23733. if m.addstatus != nil {
  23734. *m.addstatus += u
  23735. } else {
  23736. m.addstatus = &u
  23737. }
  23738. }
  23739. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23740. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  23741. v := m.addstatus
  23742. if v == nil {
  23743. return
  23744. }
  23745. return *v, true
  23746. }
  23747. // ClearStatus clears the value of the "status" field.
  23748. func (m *SopTaskMutation) ClearStatus() {
  23749. m.status = nil
  23750. m.addstatus = nil
  23751. m.clearedFields[soptask.FieldStatus] = struct{}{}
  23752. }
  23753. // StatusCleared returns if the "status" field was cleared in this mutation.
  23754. func (m *SopTaskMutation) StatusCleared() bool {
  23755. _, ok := m.clearedFields[soptask.FieldStatus]
  23756. return ok
  23757. }
  23758. // ResetStatus resets all changes to the "status" field.
  23759. func (m *SopTaskMutation) ResetStatus() {
  23760. m.status = nil
  23761. m.addstatus = nil
  23762. delete(m.clearedFields, soptask.FieldStatus)
  23763. }
  23764. // SetDeletedAt sets the "deleted_at" field.
  23765. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  23766. m.deleted_at = &t
  23767. }
  23768. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23769. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  23770. v := m.deleted_at
  23771. if v == nil {
  23772. return
  23773. }
  23774. return *v, true
  23775. }
  23776. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  23777. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23779. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23780. if !m.op.Is(OpUpdateOne) {
  23781. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23782. }
  23783. if m.id == nil || m.oldValue == nil {
  23784. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23785. }
  23786. oldValue, err := m.oldValue(ctx)
  23787. if err != nil {
  23788. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23789. }
  23790. return oldValue.DeletedAt, nil
  23791. }
  23792. // ClearDeletedAt clears the value of the "deleted_at" field.
  23793. func (m *SopTaskMutation) ClearDeletedAt() {
  23794. m.deleted_at = nil
  23795. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  23796. }
  23797. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23798. func (m *SopTaskMutation) DeletedAtCleared() bool {
  23799. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  23800. return ok
  23801. }
  23802. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23803. func (m *SopTaskMutation) ResetDeletedAt() {
  23804. m.deleted_at = nil
  23805. delete(m.clearedFields, soptask.FieldDeletedAt)
  23806. }
  23807. // SetName sets the "name" field.
  23808. func (m *SopTaskMutation) SetName(s string) {
  23809. m.name = &s
  23810. }
  23811. // Name returns the value of the "name" field in the mutation.
  23812. func (m *SopTaskMutation) Name() (r string, exists bool) {
  23813. v := m.name
  23814. if v == nil {
  23815. return
  23816. }
  23817. return *v, true
  23818. }
  23819. // OldName returns the old "name" field's value of the SopTask entity.
  23820. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23821. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23822. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  23823. if !m.op.Is(OpUpdateOne) {
  23824. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23825. }
  23826. if m.id == nil || m.oldValue == nil {
  23827. return v, errors.New("OldName requires an ID field in the mutation")
  23828. }
  23829. oldValue, err := m.oldValue(ctx)
  23830. if err != nil {
  23831. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23832. }
  23833. return oldValue.Name, nil
  23834. }
  23835. // ResetName resets all changes to the "name" field.
  23836. func (m *SopTaskMutation) ResetName() {
  23837. m.name = nil
  23838. }
  23839. // SetBotWxidList sets the "bot_wxid_list" field.
  23840. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  23841. m.bot_wxid_list = &s
  23842. m.appendbot_wxid_list = nil
  23843. }
  23844. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  23845. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  23846. v := m.bot_wxid_list
  23847. if v == nil {
  23848. return
  23849. }
  23850. return *v, true
  23851. }
  23852. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  23853. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23855. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  23856. if !m.op.Is(OpUpdateOne) {
  23857. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  23858. }
  23859. if m.id == nil || m.oldValue == nil {
  23860. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  23861. }
  23862. oldValue, err := m.oldValue(ctx)
  23863. if err != nil {
  23864. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  23865. }
  23866. return oldValue.BotWxidList, nil
  23867. }
  23868. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  23869. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  23870. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  23871. }
  23872. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  23873. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  23874. if len(m.appendbot_wxid_list) == 0 {
  23875. return nil, false
  23876. }
  23877. return m.appendbot_wxid_list, true
  23878. }
  23879. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  23880. func (m *SopTaskMutation) ClearBotWxidList() {
  23881. m.bot_wxid_list = nil
  23882. m.appendbot_wxid_list = nil
  23883. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  23884. }
  23885. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  23886. func (m *SopTaskMutation) BotWxidListCleared() bool {
  23887. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  23888. return ok
  23889. }
  23890. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  23891. func (m *SopTaskMutation) ResetBotWxidList() {
  23892. m.bot_wxid_list = nil
  23893. m.appendbot_wxid_list = nil
  23894. delete(m.clearedFields, soptask.FieldBotWxidList)
  23895. }
  23896. // SetType sets the "type" field.
  23897. func (m *SopTaskMutation) SetType(i int) {
  23898. m._type = &i
  23899. m.add_type = nil
  23900. }
  23901. // GetType returns the value of the "type" field in the mutation.
  23902. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  23903. v := m._type
  23904. if v == nil {
  23905. return
  23906. }
  23907. return *v, true
  23908. }
  23909. // OldType returns the old "type" field's value of the SopTask entity.
  23910. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23912. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  23913. if !m.op.Is(OpUpdateOne) {
  23914. return v, errors.New("OldType is only allowed on UpdateOne operations")
  23915. }
  23916. if m.id == nil || m.oldValue == nil {
  23917. return v, errors.New("OldType requires an ID field in the mutation")
  23918. }
  23919. oldValue, err := m.oldValue(ctx)
  23920. if err != nil {
  23921. return v, fmt.Errorf("querying old value for OldType: %w", err)
  23922. }
  23923. return oldValue.Type, nil
  23924. }
  23925. // AddType adds i to the "type" field.
  23926. func (m *SopTaskMutation) AddType(i int) {
  23927. if m.add_type != nil {
  23928. *m.add_type += i
  23929. } else {
  23930. m.add_type = &i
  23931. }
  23932. }
  23933. // AddedType returns the value that was added to the "type" field in this mutation.
  23934. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  23935. v := m.add_type
  23936. if v == nil {
  23937. return
  23938. }
  23939. return *v, true
  23940. }
  23941. // ResetType resets all changes to the "type" field.
  23942. func (m *SopTaskMutation) ResetType() {
  23943. m._type = nil
  23944. m.add_type = nil
  23945. }
  23946. // SetPlanStartTime sets the "plan_start_time" field.
  23947. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  23948. m.plan_start_time = &t
  23949. }
  23950. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  23951. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  23952. v := m.plan_start_time
  23953. if v == nil {
  23954. return
  23955. }
  23956. return *v, true
  23957. }
  23958. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  23959. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23960. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23961. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  23962. if !m.op.Is(OpUpdateOne) {
  23963. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  23964. }
  23965. if m.id == nil || m.oldValue == nil {
  23966. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  23967. }
  23968. oldValue, err := m.oldValue(ctx)
  23969. if err != nil {
  23970. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  23971. }
  23972. return oldValue.PlanStartTime, nil
  23973. }
  23974. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  23975. func (m *SopTaskMutation) ClearPlanStartTime() {
  23976. m.plan_start_time = nil
  23977. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  23978. }
  23979. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  23980. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  23981. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  23982. return ok
  23983. }
  23984. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  23985. func (m *SopTaskMutation) ResetPlanStartTime() {
  23986. m.plan_start_time = nil
  23987. delete(m.clearedFields, soptask.FieldPlanStartTime)
  23988. }
  23989. // SetPlanEndTime sets the "plan_end_time" field.
  23990. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  23991. m.plan_end_time = &t
  23992. }
  23993. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  23994. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  23995. v := m.plan_end_time
  23996. if v == nil {
  23997. return
  23998. }
  23999. return *v, true
  24000. }
  24001. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  24002. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24004. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  24005. if !m.op.Is(OpUpdateOne) {
  24006. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  24007. }
  24008. if m.id == nil || m.oldValue == nil {
  24009. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  24010. }
  24011. oldValue, err := m.oldValue(ctx)
  24012. if err != nil {
  24013. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  24014. }
  24015. return oldValue.PlanEndTime, nil
  24016. }
  24017. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  24018. func (m *SopTaskMutation) ClearPlanEndTime() {
  24019. m.plan_end_time = nil
  24020. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  24021. }
  24022. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  24023. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  24024. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  24025. return ok
  24026. }
  24027. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  24028. func (m *SopTaskMutation) ResetPlanEndTime() {
  24029. m.plan_end_time = nil
  24030. delete(m.clearedFields, soptask.FieldPlanEndTime)
  24031. }
  24032. // SetCreatorID sets the "creator_id" field.
  24033. func (m *SopTaskMutation) SetCreatorID(s string) {
  24034. m.creator_id = &s
  24035. }
  24036. // CreatorID returns the value of the "creator_id" field in the mutation.
  24037. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  24038. v := m.creator_id
  24039. if v == nil {
  24040. return
  24041. }
  24042. return *v, true
  24043. }
  24044. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  24045. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24047. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  24048. if !m.op.Is(OpUpdateOne) {
  24049. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  24050. }
  24051. if m.id == nil || m.oldValue == nil {
  24052. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  24053. }
  24054. oldValue, err := m.oldValue(ctx)
  24055. if err != nil {
  24056. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  24057. }
  24058. return oldValue.CreatorID, nil
  24059. }
  24060. // ClearCreatorID clears the value of the "creator_id" field.
  24061. func (m *SopTaskMutation) ClearCreatorID() {
  24062. m.creator_id = nil
  24063. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  24064. }
  24065. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  24066. func (m *SopTaskMutation) CreatorIDCleared() bool {
  24067. _, ok := m.clearedFields[soptask.FieldCreatorID]
  24068. return ok
  24069. }
  24070. // ResetCreatorID resets all changes to the "creator_id" field.
  24071. func (m *SopTaskMutation) ResetCreatorID() {
  24072. m.creator_id = nil
  24073. delete(m.clearedFields, soptask.FieldCreatorID)
  24074. }
  24075. // SetOrganizationID sets the "organization_id" field.
  24076. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  24077. m.organization_id = &u
  24078. m.addorganization_id = nil
  24079. }
  24080. // OrganizationID returns the value of the "organization_id" field in the mutation.
  24081. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  24082. v := m.organization_id
  24083. if v == nil {
  24084. return
  24085. }
  24086. return *v, true
  24087. }
  24088. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  24089. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24090. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24091. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  24092. if !m.op.Is(OpUpdateOne) {
  24093. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  24094. }
  24095. if m.id == nil || m.oldValue == nil {
  24096. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  24097. }
  24098. oldValue, err := m.oldValue(ctx)
  24099. if err != nil {
  24100. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  24101. }
  24102. return oldValue.OrganizationID, nil
  24103. }
  24104. // AddOrganizationID adds u to the "organization_id" field.
  24105. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  24106. if m.addorganization_id != nil {
  24107. *m.addorganization_id += u
  24108. } else {
  24109. m.addorganization_id = &u
  24110. }
  24111. }
  24112. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  24113. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  24114. v := m.addorganization_id
  24115. if v == nil {
  24116. return
  24117. }
  24118. return *v, true
  24119. }
  24120. // ClearOrganizationID clears the value of the "organization_id" field.
  24121. func (m *SopTaskMutation) ClearOrganizationID() {
  24122. m.organization_id = nil
  24123. m.addorganization_id = nil
  24124. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  24125. }
  24126. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  24127. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  24128. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  24129. return ok
  24130. }
  24131. // ResetOrganizationID resets all changes to the "organization_id" field.
  24132. func (m *SopTaskMutation) ResetOrganizationID() {
  24133. m.organization_id = nil
  24134. m.addorganization_id = nil
  24135. delete(m.clearedFields, soptask.FieldOrganizationID)
  24136. }
  24137. // SetToken sets the "token" field.
  24138. func (m *SopTaskMutation) SetToken(s []string) {
  24139. m.token = &s
  24140. m.appendtoken = nil
  24141. }
  24142. // Token returns the value of the "token" field in the mutation.
  24143. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  24144. v := m.token
  24145. if v == nil {
  24146. return
  24147. }
  24148. return *v, true
  24149. }
  24150. // OldToken returns the old "token" field's value of the SopTask entity.
  24151. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24153. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  24154. if !m.op.Is(OpUpdateOne) {
  24155. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  24156. }
  24157. if m.id == nil || m.oldValue == nil {
  24158. return v, errors.New("OldToken requires an ID field in the mutation")
  24159. }
  24160. oldValue, err := m.oldValue(ctx)
  24161. if err != nil {
  24162. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  24163. }
  24164. return oldValue.Token, nil
  24165. }
  24166. // AppendToken adds s to the "token" field.
  24167. func (m *SopTaskMutation) AppendToken(s []string) {
  24168. m.appendtoken = append(m.appendtoken, s...)
  24169. }
  24170. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  24171. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  24172. if len(m.appendtoken) == 0 {
  24173. return nil, false
  24174. }
  24175. return m.appendtoken, true
  24176. }
  24177. // ClearToken clears the value of the "token" field.
  24178. func (m *SopTaskMutation) ClearToken() {
  24179. m.token = nil
  24180. m.appendtoken = nil
  24181. m.clearedFields[soptask.FieldToken] = struct{}{}
  24182. }
  24183. // TokenCleared returns if the "token" field was cleared in this mutation.
  24184. func (m *SopTaskMutation) TokenCleared() bool {
  24185. _, ok := m.clearedFields[soptask.FieldToken]
  24186. return ok
  24187. }
  24188. // ResetToken resets all changes to the "token" field.
  24189. func (m *SopTaskMutation) ResetToken() {
  24190. m.token = nil
  24191. m.appendtoken = nil
  24192. delete(m.clearedFields, soptask.FieldToken)
  24193. }
  24194. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  24195. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  24196. if m.task_stages == nil {
  24197. m.task_stages = make(map[uint64]struct{})
  24198. }
  24199. for i := range ids {
  24200. m.task_stages[ids[i]] = struct{}{}
  24201. }
  24202. }
  24203. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  24204. func (m *SopTaskMutation) ClearTaskStages() {
  24205. m.clearedtask_stages = true
  24206. }
  24207. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  24208. func (m *SopTaskMutation) TaskStagesCleared() bool {
  24209. return m.clearedtask_stages
  24210. }
  24211. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  24212. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  24213. if m.removedtask_stages == nil {
  24214. m.removedtask_stages = make(map[uint64]struct{})
  24215. }
  24216. for i := range ids {
  24217. delete(m.task_stages, ids[i])
  24218. m.removedtask_stages[ids[i]] = struct{}{}
  24219. }
  24220. }
  24221. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  24222. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  24223. for id := range m.removedtask_stages {
  24224. ids = append(ids, id)
  24225. }
  24226. return
  24227. }
  24228. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  24229. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  24230. for id := range m.task_stages {
  24231. ids = append(ids, id)
  24232. }
  24233. return
  24234. }
  24235. // ResetTaskStages resets all changes to the "task_stages" edge.
  24236. func (m *SopTaskMutation) ResetTaskStages() {
  24237. m.task_stages = nil
  24238. m.clearedtask_stages = false
  24239. m.removedtask_stages = nil
  24240. }
  24241. // Where appends a list predicates to the SopTaskMutation builder.
  24242. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  24243. m.predicates = append(m.predicates, ps...)
  24244. }
  24245. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  24246. // users can use type-assertion to append predicates that do not depend on any generated package.
  24247. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  24248. p := make([]predicate.SopTask, len(ps))
  24249. for i := range ps {
  24250. p[i] = ps[i]
  24251. }
  24252. m.Where(p...)
  24253. }
  24254. // Op returns the operation name.
  24255. func (m *SopTaskMutation) Op() Op {
  24256. return m.op
  24257. }
  24258. // SetOp allows setting the mutation operation.
  24259. func (m *SopTaskMutation) SetOp(op Op) {
  24260. m.op = op
  24261. }
  24262. // Type returns the node type of this mutation (SopTask).
  24263. func (m *SopTaskMutation) Type() string {
  24264. return m.typ
  24265. }
  24266. // Fields returns all fields that were changed during this mutation. Note that in
  24267. // order to get all numeric fields that were incremented/decremented, call
  24268. // AddedFields().
  24269. func (m *SopTaskMutation) Fields() []string {
  24270. fields := make([]string, 0, 12)
  24271. if m.created_at != nil {
  24272. fields = append(fields, soptask.FieldCreatedAt)
  24273. }
  24274. if m.updated_at != nil {
  24275. fields = append(fields, soptask.FieldUpdatedAt)
  24276. }
  24277. if m.status != nil {
  24278. fields = append(fields, soptask.FieldStatus)
  24279. }
  24280. if m.deleted_at != nil {
  24281. fields = append(fields, soptask.FieldDeletedAt)
  24282. }
  24283. if m.name != nil {
  24284. fields = append(fields, soptask.FieldName)
  24285. }
  24286. if m.bot_wxid_list != nil {
  24287. fields = append(fields, soptask.FieldBotWxidList)
  24288. }
  24289. if m._type != nil {
  24290. fields = append(fields, soptask.FieldType)
  24291. }
  24292. if m.plan_start_time != nil {
  24293. fields = append(fields, soptask.FieldPlanStartTime)
  24294. }
  24295. if m.plan_end_time != nil {
  24296. fields = append(fields, soptask.FieldPlanEndTime)
  24297. }
  24298. if m.creator_id != nil {
  24299. fields = append(fields, soptask.FieldCreatorID)
  24300. }
  24301. if m.organization_id != nil {
  24302. fields = append(fields, soptask.FieldOrganizationID)
  24303. }
  24304. if m.token != nil {
  24305. fields = append(fields, soptask.FieldToken)
  24306. }
  24307. return fields
  24308. }
  24309. // Field returns the value of a field with the given name. The second boolean
  24310. // return value indicates that this field was not set, or was not defined in the
  24311. // schema.
  24312. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  24313. switch name {
  24314. case soptask.FieldCreatedAt:
  24315. return m.CreatedAt()
  24316. case soptask.FieldUpdatedAt:
  24317. return m.UpdatedAt()
  24318. case soptask.FieldStatus:
  24319. return m.Status()
  24320. case soptask.FieldDeletedAt:
  24321. return m.DeletedAt()
  24322. case soptask.FieldName:
  24323. return m.Name()
  24324. case soptask.FieldBotWxidList:
  24325. return m.BotWxidList()
  24326. case soptask.FieldType:
  24327. return m.GetType()
  24328. case soptask.FieldPlanStartTime:
  24329. return m.PlanStartTime()
  24330. case soptask.FieldPlanEndTime:
  24331. return m.PlanEndTime()
  24332. case soptask.FieldCreatorID:
  24333. return m.CreatorID()
  24334. case soptask.FieldOrganizationID:
  24335. return m.OrganizationID()
  24336. case soptask.FieldToken:
  24337. return m.Token()
  24338. }
  24339. return nil, false
  24340. }
  24341. // OldField returns the old value of the field from the database. An error is
  24342. // returned if the mutation operation is not UpdateOne, or the query to the
  24343. // database failed.
  24344. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24345. switch name {
  24346. case soptask.FieldCreatedAt:
  24347. return m.OldCreatedAt(ctx)
  24348. case soptask.FieldUpdatedAt:
  24349. return m.OldUpdatedAt(ctx)
  24350. case soptask.FieldStatus:
  24351. return m.OldStatus(ctx)
  24352. case soptask.FieldDeletedAt:
  24353. return m.OldDeletedAt(ctx)
  24354. case soptask.FieldName:
  24355. return m.OldName(ctx)
  24356. case soptask.FieldBotWxidList:
  24357. return m.OldBotWxidList(ctx)
  24358. case soptask.FieldType:
  24359. return m.OldType(ctx)
  24360. case soptask.FieldPlanStartTime:
  24361. return m.OldPlanStartTime(ctx)
  24362. case soptask.FieldPlanEndTime:
  24363. return m.OldPlanEndTime(ctx)
  24364. case soptask.FieldCreatorID:
  24365. return m.OldCreatorID(ctx)
  24366. case soptask.FieldOrganizationID:
  24367. return m.OldOrganizationID(ctx)
  24368. case soptask.FieldToken:
  24369. return m.OldToken(ctx)
  24370. }
  24371. return nil, fmt.Errorf("unknown SopTask field %s", name)
  24372. }
  24373. // SetField sets the value of a field with the given name. It returns an error if
  24374. // the field is not defined in the schema, or if the type mismatched the field
  24375. // type.
  24376. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  24377. switch name {
  24378. case soptask.FieldCreatedAt:
  24379. v, ok := value.(time.Time)
  24380. if !ok {
  24381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24382. }
  24383. m.SetCreatedAt(v)
  24384. return nil
  24385. case soptask.FieldUpdatedAt:
  24386. v, ok := value.(time.Time)
  24387. if !ok {
  24388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24389. }
  24390. m.SetUpdatedAt(v)
  24391. return nil
  24392. case soptask.FieldStatus:
  24393. v, ok := value.(uint8)
  24394. if !ok {
  24395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24396. }
  24397. m.SetStatus(v)
  24398. return nil
  24399. case soptask.FieldDeletedAt:
  24400. v, ok := value.(time.Time)
  24401. if !ok {
  24402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24403. }
  24404. m.SetDeletedAt(v)
  24405. return nil
  24406. case soptask.FieldName:
  24407. v, ok := value.(string)
  24408. if !ok {
  24409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24410. }
  24411. m.SetName(v)
  24412. return nil
  24413. case soptask.FieldBotWxidList:
  24414. v, ok := value.([]string)
  24415. if !ok {
  24416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24417. }
  24418. m.SetBotWxidList(v)
  24419. return nil
  24420. case soptask.FieldType:
  24421. v, ok := value.(int)
  24422. if !ok {
  24423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24424. }
  24425. m.SetType(v)
  24426. return nil
  24427. case soptask.FieldPlanStartTime:
  24428. v, ok := value.(time.Time)
  24429. if !ok {
  24430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24431. }
  24432. m.SetPlanStartTime(v)
  24433. return nil
  24434. case soptask.FieldPlanEndTime:
  24435. v, ok := value.(time.Time)
  24436. if !ok {
  24437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24438. }
  24439. m.SetPlanEndTime(v)
  24440. return nil
  24441. case soptask.FieldCreatorID:
  24442. v, ok := value.(string)
  24443. if !ok {
  24444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24445. }
  24446. m.SetCreatorID(v)
  24447. return nil
  24448. case soptask.FieldOrganizationID:
  24449. v, ok := value.(uint64)
  24450. if !ok {
  24451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24452. }
  24453. m.SetOrganizationID(v)
  24454. return nil
  24455. case soptask.FieldToken:
  24456. v, ok := value.([]string)
  24457. if !ok {
  24458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24459. }
  24460. m.SetToken(v)
  24461. return nil
  24462. }
  24463. return fmt.Errorf("unknown SopTask field %s", name)
  24464. }
  24465. // AddedFields returns all numeric fields that were incremented/decremented during
  24466. // this mutation.
  24467. func (m *SopTaskMutation) AddedFields() []string {
  24468. var fields []string
  24469. if m.addstatus != nil {
  24470. fields = append(fields, soptask.FieldStatus)
  24471. }
  24472. if m.add_type != nil {
  24473. fields = append(fields, soptask.FieldType)
  24474. }
  24475. if m.addorganization_id != nil {
  24476. fields = append(fields, soptask.FieldOrganizationID)
  24477. }
  24478. return fields
  24479. }
  24480. // AddedField returns the numeric value that was incremented/decremented on a field
  24481. // with the given name. The second boolean return value indicates that this field
  24482. // was not set, or was not defined in the schema.
  24483. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  24484. switch name {
  24485. case soptask.FieldStatus:
  24486. return m.AddedStatus()
  24487. case soptask.FieldType:
  24488. return m.AddedType()
  24489. case soptask.FieldOrganizationID:
  24490. return m.AddedOrganizationID()
  24491. }
  24492. return nil, false
  24493. }
  24494. // AddField adds the value to the field with the given name. It returns an error if
  24495. // the field is not defined in the schema, or if the type mismatched the field
  24496. // type.
  24497. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  24498. switch name {
  24499. case soptask.FieldStatus:
  24500. v, ok := value.(int8)
  24501. if !ok {
  24502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24503. }
  24504. m.AddStatus(v)
  24505. return nil
  24506. case soptask.FieldType:
  24507. v, ok := value.(int)
  24508. if !ok {
  24509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24510. }
  24511. m.AddType(v)
  24512. return nil
  24513. case soptask.FieldOrganizationID:
  24514. v, ok := value.(int64)
  24515. if !ok {
  24516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24517. }
  24518. m.AddOrganizationID(v)
  24519. return nil
  24520. }
  24521. return fmt.Errorf("unknown SopTask numeric field %s", name)
  24522. }
  24523. // ClearedFields returns all nullable fields that were cleared during this
  24524. // mutation.
  24525. func (m *SopTaskMutation) ClearedFields() []string {
  24526. var fields []string
  24527. if m.FieldCleared(soptask.FieldStatus) {
  24528. fields = append(fields, soptask.FieldStatus)
  24529. }
  24530. if m.FieldCleared(soptask.FieldDeletedAt) {
  24531. fields = append(fields, soptask.FieldDeletedAt)
  24532. }
  24533. if m.FieldCleared(soptask.FieldBotWxidList) {
  24534. fields = append(fields, soptask.FieldBotWxidList)
  24535. }
  24536. if m.FieldCleared(soptask.FieldPlanStartTime) {
  24537. fields = append(fields, soptask.FieldPlanStartTime)
  24538. }
  24539. if m.FieldCleared(soptask.FieldPlanEndTime) {
  24540. fields = append(fields, soptask.FieldPlanEndTime)
  24541. }
  24542. if m.FieldCleared(soptask.FieldCreatorID) {
  24543. fields = append(fields, soptask.FieldCreatorID)
  24544. }
  24545. if m.FieldCleared(soptask.FieldOrganizationID) {
  24546. fields = append(fields, soptask.FieldOrganizationID)
  24547. }
  24548. if m.FieldCleared(soptask.FieldToken) {
  24549. fields = append(fields, soptask.FieldToken)
  24550. }
  24551. return fields
  24552. }
  24553. // FieldCleared returns a boolean indicating if a field with the given name was
  24554. // cleared in this mutation.
  24555. func (m *SopTaskMutation) FieldCleared(name string) bool {
  24556. _, ok := m.clearedFields[name]
  24557. return ok
  24558. }
  24559. // ClearField clears the value of the field with the given name. It returns an
  24560. // error if the field is not defined in the schema.
  24561. func (m *SopTaskMutation) ClearField(name string) error {
  24562. switch name {
  24563. case soptask.FieldStatus:
  24564. m.ClearStatus()
  24565. return nil
  24566. case soptask.FieldDeletedAt:
  24567. m.ClearDeletedAt()
  24568. return nil
  24569. case soptask.FieldBotWxidList:
  24570. m.ClearBotWxidList()
  24571. return nil
  24572. case soptask.FieldPlanStartTime:
  24573. m.ClearPlanStartTime()
  24574. return nil
  24575. case soptask.FieldPlanEndTime:
  24576. m.ClearPlanEndTime()
  24577. return nil
  24578. case soptask.FieldCreatorID:
  24579. m.ClearCreatorID()
  24580. return nil
  24581. case soptask.FieldOrganizationID:
  24582. m.ClearOrganizationID()
  24583. return nil
  24584. case soptask.FieldToken:
  24585. m.ClearToken()
  24586. return nil
  24587. }
  24588. return fmt.Errorf("unknown SopTask nullable field %s", name)
  24589. }
  24590. // ResetField resets all changes in the mutation for the field with the given name.
  24591. // It returns an error if the field is not defined in the schema.
  24592. func (m *SopTaskMutation) ResetField(name string) error {
  24593. switch name {
  24594. case soptask.FieldCreatedAt:
  24595. m.ResetCreatedAt()
  24596. return nil
  24597. case soptask.FieldUpdatedAt:
  24598. m.ResetUpdatedAt()
  24599. return nil
  24600. case soptask.FieldStatus:
  24601. m.ResetStatus()
  24602. return nil
  24603. case soptask.FieldDeletedAt:
  24604. m.ResetDeletedAt()
  24605. return nil
  24606. case soptask.FieldName:
  24607. m.ResetName()
  24608. return nil
  24609. case soptask.FieldBotWxidList:
  24610. m.ResetBotWxidList()
  24611. return nil
  24612. case soptask.FieldType:
  24613. m.ResetType()
  24614. return nil
  24615. case soptask.FieldPlanStartTime:
  24616. m.ResetPlanStartTime()
  24617. return nil
  24618. case soptask.FieldPlanEndTime:
  24619. m.ResetPlanEndTime()
  24620. return nil
  24621. case soptask.FieldCreatorID:
  24622. m.ResetCreatorID()
  24623. return nil
  24624. case soptask.FieldOrganizationID:
  24625. m.ResetOrganizationID()
  24626. return nil
  24627. case soptask.FieldToken:
  24628. m.ResetToken()
  24629. return nil
  24630. }
  24631. return fmt.Errorf("unknown SopTask field %s", name)
  24632. }
  24633. // AddedEdges returns all edge names that were set/added in this mutation.
  24634. func (m *SopTaskMutation) AddedEdges() []string {
  24635. edges := make([]string, 0, 1)
  24636. if m.task_stages != nil {
  24637. edges = append(edges, soptask.EdgeTaskStages)
  24638. }
  24639. return edges
  24640. }
  24641. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24642. // name in this mutation.
  24643. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  24644. switch name {
  24645. case soptask.EdgeTaskStages:
  24646. ids := make([]ent.Value, 0, len(m.task_stages))
  24647. for id := range m.task_stages {
  24648. ids = append(ids, id)
  24649. }
  24650. return ids
  24651. }
  24652. return nil
  24653. }
  24654. // RemovedEdges returns all edge names that were removed in this mutation.
  24655. func (m *SopTaskMutation) RemovedEdges() []string {
  24656. edges := make([]string, 0, 1)
  24657. if m.removedtask_stages != nil {
  24658. edges = append(edges, soptask.EdgeTaskStages)
  24659. }
  24660. return edges
  24661. }
  24662. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24663. // the given name in this mutation.
  24664. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  24665. switch name {
  24666. case soptask.EdgeTaskStages:
  24667. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  24668. for id := range m.removedtask_stages {
  24669. ids = append(ids, id)
  24670. }
  24671. return ids
  24672. }
  24673. return nil
  24674. }
  24675. // ClearedEdges returns all edge names that were cleared in this mutation.
  24676. func (m *SopTaskMutation) ClearedEdges() []string {
  24677. edges := make([]string, 0, 1)
  24678. if m.clearedtask_stages {
  24679. edges = append(edges, soptask.EdgeTaskStages)
  24680. }
  24681. return edges
  24682. }
  24683. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24684. // was cleared in this mutation.
  24685. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  24686. switch name {
  24687. case soptask.EdgeTaskStages:
  24688. return m.clearedtask_stages
  24689. }
  24690. return false
  24691. }
  24692. // ClearEdge clears the value of the edge with the given name. It returns an error
  24693. // if that edge is not defined in the schema.
  24694. func (m *SopTaskMutation) ClearEdge(name string) error {
  24695. switch name {
  24696. }
  24697. return fmt.Errorf("unknown SopTask unique edge %s", name)
  24698. }
  24699. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24700. // It returns an error if the edge is not defined in the schema.
  24701. func (m *SopTaskMutation) ResetEdge(name string) error {
  24702. switch name {
  24703. case soptask.EdgeTaskStages:
  24704. m.ResetTaskStages()
  24705. return nil
  24706. }
  24707. return fmt.Errorf("unknown SopTask edge %s", name)
  24708. }
  24709. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  24710. type TokenMutation struct {
  24711. config
  24712. op Op
  24713. typ string
  24714. id *uint64
  24715. created_at *time.Time
  24716. updated_at *time.Time
  24717. deleted_at *time.Time
  24718. expire_at *time.Time
  24719. token *string
  24720. mac *string
  24721. organization_id *uint64
  24722. addorganization_id *int64
  24723. custom_agent_base *string
  24724. custom_agent_key *string
  24725. openai_base *string
  24726. openai_key *string
  24727. clearedFields map[string]struct{}
  24728. agent *uint64
  24729. clearedagent bool
  24730. done bool
  24731. oldValue func(context.Context) (*Token, error)
  24732. predicates []predicate.Token
  24733. }
  24734. var _ ent.Mutation = (*TokenMutation)(nil)
  24735. // tokenOption allows management of the mutation configuration using functional options.
  24736. type tokenOption func(*TokenMutation)
  24737. // newTokenMutation creates new mutation for the Token entity.
  24738. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  24739. m := &TokenMutation{
  24740. config: c,
  24741. op: op,
  24742. typ: TypeToken,
  24743. clearedFields: make(map[string]struct{}),
  24744. }
  24745. for _, opt := range opts {
  24746. opt(m)
  24747. }
  24748. return m
  24749. }
  24750. // withTokenID sets the ID field of the mutation.
  24751. func withTokenID(id uint64) tokenOption {
  24752. return func(m *TokenMutation) {
  24753. var (
  24754. err error
  24755. once sync.Once
  24756. value *Token
  24757. )
  24758. m.oldValue = func(ctx context.Context) (*Token, error) {
  24759. once.Do(func() {
  24760. if m.done {
  24761. err = errors.New("querying old values post mutation is not allowed")
  24762. } else {
  24763. value, err = m.Client().Token.Get(ctx, id)
  24764. }
  24765. })
  24766. return value, err
  24767. }
  24768. m.id = &id
  24769. }
  24770. }
  24771. // withToken sets the old Token of the mutation.
  24772. func withToken(node *Token) tokenOption {
  24773. return func(m *TokenMutation) {
  24774. m.oldValue = func(context.Context) (*Token, error) {
  24775. return node, nil
  24776. }
  24777. m.id = &node.ID
  24778. }
  24779. }
  24780. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24781. // executed in a transaction (ent.Tx), a transactional client is returned.
  24782. func (m TokenMutation) Client() *Client {
  24783. client := &Client{config: m.config}
  24784. client.init()
  24785. return client
  24786. }
  24787. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24788. // it returns an error otherwise.
  24789. func (m TokenMutation) Tx() (*Tx, error) {
  24790. if _, ok := m.driver.(*txDriver); !ok {
  24791. return nil, errors.New("ent: mutation is not running in a transaction")
  24792. }
  24793. tx := &Tx{config: m.config}
  24794. tx.init()
  24795. return tx, nil
  24796. }
  24797. // SetID sets the value of the id field. Note that this
  24798. // operation is only accepted on creation of Token entities.
  24799. func (m *TokenMutation) SetID(id uint64) {
  24800. m.id = &id
  24801. }
  24802. // ID returns the ID value in the mutation. Note that the ID is only available
  24803. // if it was provided to the builder or after it was returned from the database.
  24804. func (m *TokenMutation) ID() (id uint64, exists bool) {
  24805. if m.id == nil {
  24806. return
  24807. }
  24808. return *m.id, true
  24809. }
  24810. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24811. // That means, if the mutation is applied within a transaction with an isolation level such
  24812. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24813. // or updated by the mutation.
  24814. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  24815. switch {
  24816. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24817. id, exists := m.ID()
  24818. if exists {
  24819. return []uint64{id}, nil
  24820. }
  24821. fallthrough
  24822. case m.op.Is(OpUpdate | OpDelete):
  24823. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  24824. default:
  24825. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24826. }
  24827. }
  24828. // SetCreatedAt sets the "created_at" field.
  24829. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  24830. m.created_at = &t
  24831. }
  24832. // CreatedAt returns the value of the "created_at" field in the mutation.
  24833. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  24834. v := m.created_at
  24835. if v == nil {
  24836. return
  24837. }
  24838. return *v, true
  24839. }
  24840. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  24841. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24843. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24844. if !m.op.Is(OpUpdateOne) {
  24845. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24846. }
  24847. if m.id == nil || m.oldValue == nil {
  24848. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24849. }
  24850. oldValue, err := m.oldValue(ctx)
  24851. if err != nil {
  24852. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24853. }
  24854. return oldValue.CreatedAt, nil
  24855. }
  24856. // ResetCreatedAt resets all changes to the "created_at" field.
  24857. func (m *TokenMutation) ResetCreatedAt() {
  24858. m.created_at = nil
  24859. }
  24860. // SetUpdatedAt sets the "updated_at" field.
  24861. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  24862. m.updated_at = &t
  24863. }
  24864. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24865. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  24866. v := m.updated_at
  24867. if v == nil {
  24868. return
  24869. }
  24870. return *v, true
  24871. }
  24872. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  24873. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24875. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24876. if !m.op.Is(OpUpdateOne) {
  24877. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24878. }
  24879. if m.id == nil || m.oldValue == nil {
  24880. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24881. }
  24882. oldValue, err := m.oldValue(ctx)
  24883. if err != nil {
  24884. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24885. }
  24886. return oldValue.UpdatedAt, nil
  24887. }
  24888. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24889. func (m *TokenMutation) ResetUpdatedAt() {
  24890. m.updated_at = nil
  24891. }
  24892. // SetDeletedAt sets the "deleted_at" field.
  24893. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  24894. m.deleted_at = &t
  24895. }
  24896. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24897. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  24898. v := m.deleted_at
  24899. if v == nil {
  24900. return
  24901. }
  24902. return *v, true
  24903. }
  24904. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  24905. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24907. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24908. if !m.op.Is(OpUpdateOne) {
  24909. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24910. }
  24911. if m.id == nil || m.oldValue == nil {
  24912. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24913. }
  24914. oldValue, err := m.oldValue(ctx)
  24915. if err != nil {
  24916. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24917. }
  24918. return oldValue.DeletedAt, nil
  24919. }
  24920. // ClearDeletedAt clears the value of the "deleted_at" field.
  24921. func (m *TokenMutation) ClearDeletedAt() {
  24922. m.deleted_at = nil
  24923. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  24924. }
  24925. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24926. func (m *TokenMutation) DeletedAtCleared() bool {
  24927. _, ok := m.clearedFields[token.FieldDeletedAt]
  24928. return ok
  24929. }
  24930. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24931. func (m *TokenMutation) ResetDeletedAt() {
  24932. m.deleted_at = nil
  24933. delete(m.clearedFields, token.FieldDeletedAt)
  24934. }
  24935. // SetExpireAt sets the "expire_at" field.
  24936. func (m *TokenMutation) SetExpireAt(t time.Time) {
  24937. m.expire_at = &t
  24938. }
  24939. // ExpireAt returns the value of the "expire_at" field in the mutation.
  24940. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  24941. v := m.expire_at
  24942. if v == nil {
  24943. return
  24944. }
  24945. return *v, true
  24946. }
  24947. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  24948. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24950. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  24951. if !m.op.Is(OpUpdateOne) {
  24952. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  24953. }
  24954. if m.id == nil || m.oldValue == nil {
  24955. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  24956. }
  24957. oldValue, err := m.oldValue(ctx)
  24958. if err != nil {
  24959. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  24960. }
  24961. return oldValue.ExpireAt, nil
  24962. }
  24963. // ClearExpireAt clears the value of the "expire_at" field.
  24964. func (m *TokenMutation) ClearExpireAt() {
  24965. m.expire_at = nil
  24966. m.clearedFields[token.FieldExpireAt] = struct{}{}
  24967. }
  24968. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  24969. func (m *TokenMutation) ExpireAtCleared() bool {
  24970. _, ok := m.clearedFields[token.FieldExpireAt]
  24971. return ok
  24972. }
  24973. // ResetExpireAt resets all changes to the "expire_at" field.
  24974. func (m *TokenMutation) ResetExpireAt() {
  24975. m.expire_at = nil
  24976. delete(m.clearedFields, token.FieldExpireAt)
  24977. }
  24978. // SetToken sets the "token" field.
  24979. func (m *TokenMutation) SetToken(s string) {
  24980. m.token = &s
  24981. }
  24982. // Token returns the value of the "token" field in the mutation.
  24983. func (m *TokenMutation) Token() (r string, exists bool) {
  24984. v := m.token
  24985. if v == nil {
  24986. return
  24987. }
  24988. return *v, true
  24989. }
  24990. // OldToken returns the old "token" field's value of the Token entity.
  24991. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24992. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24993. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  24994. if !m.op.Is(OpUpdateOne) {
  24995. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  24996. }
  24997. if m.id == nil || m.oldValue == nil {
  24998. return v, errors.New("OldToken requires an ID field in the mutation")
  24999. }
  25000. oldValue, err := m.oldValue(ctx)
  25001. if err != nil {
  25002. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  25003. }
  25004. return oldValue.Token, nil
  25005. }
  25006. // ClearToken clears the value of the "token" field.
  25007. func (m *TokenMutation) ClearToken() {
  25008. m.token = nil
  25009. m.clearedFields[token.FieldToken] = struct{}{}
  25010. }
  25011. // TokenCleared returns if the "token" field was cleared in this mutation.
  25012. func (m *TokenMutation) TokenCleared() bool {
  25013. _, ok := m.clearedFields[token.FieldToken]
  25014. return ok
  25015. }
  25016. // ResetToken resets all changes to the "token" field.
  25017. func (m *TokenMutation) ResetToken() {
  25018. m.token = nil
  25019. delete(m.clearedFields, token.FieldToken)
  25020. }
  25021. // SetMAC sets the "mac" field.
  25022. func (m *TokenMutation) SetMAC(s string) {
  25023. m.mac = &s
  25024. }
  25025. // MAC returns the value of the "mac" field in the mutation.
  25026. func (m *TokenMutation) MAC() (r string, exists bool) {
  25027. v := m.mac
  25028. if v == nil {
  25029. return
  25030. }
  25031. return *v, true
  25032. }
  25033. // OldMAC returns the old "mac" field's value of the Token entity.
  25034. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25035. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25036. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  25037. if !m.op.Is(OpUpdateOne) {
  25038. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  25039. }
  25040. if m.id == nil || m.oldValue == nil {
  25041. return v, errors.New("OldMAC requires an ID field in the mutation")
  25042. }
  25043. oldValue, err := m.oldValue(ctx)
  25044. if err != nil {
  25045. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  25046. }
  25047. return oldValue.MAC, nil
  25048. }
  25049. // ClearMAC clears the value of the "mac" field.
  25050. func (m *TokenMutation) ClearMAC() {
  25051. m.mac = nil
  25052. m.clearedFields[token.FieldMAC] = struct{}{}
  25053. }
  25054. // MACCleared returns if the "mac" field was cleared in this mutation.
  25055. func (m *TokenMutation) MACCleared() bool {
  25056. _, ok := m.clearedFields[token.FieldMAC]
  25057. return ok
  25058. }
  25059. // ResetMAC resets all changes to the "mac" field.
  25060. func (m *TokenMutation) ResetMAC() {
  25061. m.mac = nil
  25062. delete(m.clearedFields, token.FieldMAC)
  25063. }
  25064. // SetOrganizationID sets the "organization_id" field.
  25065. func (m *TokenMutation) SetOrganizationID(u uint64) {
  25066. m.organization_id = &u
  25067. m.addorganization_id = nil
  25068. }
  25069. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25070. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  25071. v := m.organization_id
  25072. if v == nil {
  25073. return
  25074. }
  25075. return *v, true
  25076. }
  25077. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  25078. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25080. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25081. if !m.op.Is(OpUpdateOne) {
  25082. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25083. }
  25084. if m.id == nil || m.oldValue == nil {
  25085. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25086. }
  25087. oldValue, err := m.oldValue(ctx)
  25088. if err != nil {
  25089. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25090. }
  25091. return oldValue.OrganizationID, nil
  25092. }
  25093. // AddOrganizationID adds u to the "organization_id" field.
  25094. func (m *TokenMutation) AddOrganizationID(u int64) {
  25095. if m.addorganization_id != nil {
  25096. *m.addorganization_id += u
  25097. } else {
  25098. m.addorganization_id = &u
  25099. }
  25100. }
  25101. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25102. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  25103. v := m.addorganization_id
  25104. if v == nil {
  25105. return
  25106. }
  25107. return *v, true
  25108. }
  25109. // ResetOrganizationID resets all changes to the "organization_id" field.
  25110. func (m *TokenMutation) ResetOrganizationID() {
  25111. m.organization_id = nil
  25112. m.addorganization_id = nil
  25113. }
  25114. // SetAgentID sets the "agent_id" field.
  25115. func (m *TokenMutation) SetAgentID(u uint64) {
  25116. m.agent = &u
  25117. }
  25118. // AgentID returns the value of the "agent_id" field in the mutation.
  25119. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  25120. v := m.agent
  25121. if v == nil {
  25122. return
  25123. }
  25124. return *v, true
  25125. }
  25126. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  25127. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25128. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25129. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  25130. if !m.op.Is(OpUpdateOne) {
  25131. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  25132. }
  25133. if m.id == nil || m.oldValue == nil {
  25134. return v, errors.New("OldAgentID requires an ID field in the mutation")
  25135. }
  25136. oldValue, err := m.oldValue(ctx)
  25137. if err != nil {
  25138. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  25139. }
  25140. return oldValue.AgentID, nil
  25141. }
  25142. // ResetAgentID resets all changes to the "agent_id" field.
  25143. func (m *TokenMutation) ResetAgentID() {
  25144. m.agent = nil
  25145. }
  25146. // SetCustomAgentBase sets the "custom_agent_base" field.
  25147. func (m *TokenMutation) SetCustomAgentBase(s string) {
  25148. m.custom_agent_base = &s
  25149. }
  25150. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  25151. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  25152. v := m.custom_agent_base
  25153. if v == nil {
  25154. return
  25155. }
  25156. return *v, true
  25157. }
  25158. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  25159. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25160. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25161. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  25162. if !m.op.Is(OpUpdateOne) {
  25163. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  25164. }
  25165. if m.id == nil || m.oldValue == nil {
  25166. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  25167. }
  25168. oldValue, err := m.oldValue(ctx)
  25169. if err != nil {
  25170. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  25171. }
  25172. return oldValue.CustomAgentBase, nil
  25173. }
  25174. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  25175. func (m *TokenMutation) ClearCustomAgentBase() {
  25176. m.custom_agent_base = nil
  25177. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  25178. }
  25179. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  25180. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  25181. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  25182. return ok
  25183. }
  25184. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  25185. func (m *TokenMutation) ResetCustomAgentBase() {
  25186. m.custom_agent_base = nil
  25187. delete(m.clearedFields, token.FieldCustomAgentBase)
  25188. }
  25189. // SetCustomAgentKey sets the "custom_agent_key" field.
  25190. func (m *TokenMutation) SetCustomAgentKey(s string) {
  25191. m.custom_agent_key = &s
  25192. }
  25193. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  25194. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  25195. v := m.custom_agent_key
  25196. if v == nil {
  25197. return
  25198. }
  25199. return *v, true
  25200. }
  25201. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  25202. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25204. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  25205. if !m.op.Is(OpUpdateOne) {
  25206. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  25207. }
  25208. if m.id == nil || m.oldValue == nil {
  25209. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  25210. }
  25211. oldValue, err := m.oldValue(ctx)
  25212. if err != nil {
  25213. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  25214. }
  25215. return oldValue.CustomAgentKey, nil
  25216. }
  25217. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  25218. func (m *TokenMutation) ClearCustomAgentKey() {
  25219. m.custom_agent_key = nil
  25220. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  25221. }
  25222. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  25223. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  25224. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  25225. return ok
  25226. }
  25227. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  25228. func (m *TokenMutation) ResetCustomAgentKey() {
  25229. m.custom_agent_key = nil
  25230. delete(m.clearedFields, token.FieldCustomAgentKey)
  25231. }
  25232. // SetOpenaiBase sets the "openai_base" field.
  25233. func (m *TokenMutation) SetOpenaiBase(s string) {
  25234. m.openai_base = &s
  25235. }
  25236. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  25237. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  25238. v := m.openai_base
  25239. if v == nil {
  25240. return
  25241. }
  25242. return *v, true
  25243. }
  25244. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  25245. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25247. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  25248. if !m.op.Is(OpUpdateOne) {
  25249. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  25250. }
  25251. if m.id == nil || m.oldValue == nil {
  25252. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  25253. }
  25254. oldValue, err := m.oldValue(ctx)
  25255. if err != nil {
  25256. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  25257. }
  25258. return oldValue.OpenaiBase, nil
  25259. }
  25260. // ClearOpenaiBase clears the value of the "openai_base" field.
  25261. func (m *TokenMutation) ClearOpenaiBase() {
  25262. m.openai_base = nil
  25263. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  25264. }
  25265. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  25266. func (m *TokenMutation) OpenaiBaseCleared() bool {
  25267. _, ok := m.clearedFields[token.FieldOpenaiBase]
  25268. return ok
  25269. }
  25270. // ResetOpenaiBase resets all changes to the "openai_base" field.
  25271. func (m *TokenMutation) ResetOpenaiBase() {
  25272. m.openai_base = nil
  25273. delete(m.clearedFields, token.FieldOpenaiBase)
  25274. }
  25275. // SetOpenaiKey sets the "openai_key" field.
  25276. func (m *TokenMutation) SetOpenaiKey(s string) {
  25277. m.openai_key = &s
  25278. }
  25279. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  25280. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  25281. v := m.openai_key
  25282. if v == nil {
  25283. return
  25284. }
  25285. return *v, true
  25286. }
  25287. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  25288. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25290. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  25291. if !m.op.Is(OpUpdateOne) {
  25292. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  25293. }
  25294. if m.id == nil || m.oldValue == nil {
  25295. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  25296. }
  25297. oldValue, err := m.oldValue(ctx)
  25298. if err != nil {
  25299. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  25300. }
  25301. return oldValue.OpenaiKey, nil
  25302. }
  25303. // ClearOpenaiKey clears the value of the "openai_key" field.
  25304. func (m *TokenMutation) ClearOpenaiKey() {
  25305. m.openai_key = nil
  25306. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  25307. }
  25308. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  25309. func (m *TokenMutation) OpenaiKeyCleared() bool {
  25310. _, ok := m.clearedFields[token.FieldOpenaiKey]
  25311. return ok
  25312. }
  25313. // ResetOpenaiKey resets all changes to the "openai_key" field.
  25314. func (m *TokenMutation) ResetOpenaiKey() {
  25315. m.openai_key = nil
  25316. delete(m.clearedFields, token.FieldOpenaiKey)
  25317. }
  25318. // ClearAgent clears the "agent" edge to the Agent entity.
  25319. func (m *TokenMutation) ClearAgent() {
  25320. m.clearedagent = true
  25321. m.clearedFields[token.FieldAgentID] = struct{}{}
  25322. }
  25323. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  25324. func (m *TokenMutation) AgentCleared() bool {
  25325. return m.clearedagent
  25326. }
  25327. // AgentIDs returns the "agent" edge IDs in the mutation.
  25328. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25329. // AgentID instead. It exists only for internal usage by the builders.
  25330. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  25331. if id := m.agent; id != nil {
  25332. ids = append(ids, *id)
  25333. }
  25334. return
  25335. }
  25336. // ResetAgent resets all changes to the "agent" edge.
  25337. func (m *TokenMutation) ResetAgent() {
  25338. m.agent = nil
  25339. m.clearedagent = false
  25340. }
  25341. // Where appends a list predicates to the TokenMutation builder.
  25342. func (m *TokenMutation) Where(ps ...predicate.Token) {
  25343. m.predicates = append(m.predicates, ps...)
  25344. }
  25345. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  25346. // users can use type-assertion to append predicates that do not depend on any generated package.
  25347. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  25348. p := make([]predicate.Token, len(ps))
  25349. for i := range ps {
  25350. p[i] = ps[i]
  25351. }
  25352. m.Where(p...)
  25353. }
  25354. // Op returns the operation name.
  25355. func (m *TokenMutation) Op() Op {
  25356. return m.op
  25357. }
  25358. // SetOp allows setting the mutation operation.
  25359. func (m *TokenMutation) SetOp(op Op) {
  25360. m.op = op
  25361. }
  25362. // Type returns the node type of this mutation (Token).
  25363. func (m *TokenMutation) Type() string {
  25364. return m.typ
  25365. }
  25366. // Fields returns all fields that were changed during this mutation. Note that in
  25367. // order to get all numeric fields that were incremented/decremented, call
  25368. // AddedFields().
  25369. func (m *TokenMutation) Fields() []string {
  25370. fields := make([]string, 0, 12)
  25371. if m.created_at != nil {
  25372. fields = append(fields, token.FieldCreatedAt)
  25373. }
  25374. if m.updated_at != nil {
  25375. fields = append(fields, token.FieldUpdatedAt)
  25376. }
  25377. if m.deleted_at != nil {
  25378. fields = append(fields, token.FieldDeletedAt)
  25379. }
  25380. if m.expire_at != nil {
  25381. fields = append(fields, token.FieldExpireAt)
  25382. }
  25383. if m.token != nil {
  25384. fields = append(fields, token.FieldToken)
  25385. }
  25386. if m.mac != nil {
  25387. fields = append(fields, token.FieldMAC)
  25388. }
  25389. if m.organization_id != nil {
  25390. fields = append(fields, token.FieldOrganizationID)
  25391. }
  25392. if m.agent != nil {
  25393. fields = append(fields, token.FieldAgentID)
  25394. }
  25395. if m.custom_agent_base != nil {
  25396. fields = append(fields, token.FieldCustomAgentBase)
  25397. }
  25398. if m.custom_agent_key != nil {
  25399. fields = append(fields, token.FieldCustomAgentKey)
  25400. }
  25401. if m.openai_base != nil {
  25402. fields = append(fields, token.FieldOpenaiBase)
  25403. }
  25404. if m.openai_key != nil {
  25405. fields = append(fields, token.FieldOpenaiKey)
  25406. }
  25407. return fields
  25408. }
  25409. // Field returns the value of a field with the given name. The second boolean
  25410. // return value indicates that this field was not set, or was not defined in the
  25411. // schema.
  25412. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  25413. switch name {
  25414. case token.FieldCreatedAt:
  25415. return m.CreatedAt()
  25416. case token.FieldUpdatedAt:
  25417. return m.UpdatedAt()
  25418. case token.FieldDeletedAt:
  25419. return m.DeletedAt()
  25420. case token.FieldExpireAt:
  25421. return m.ExpireAt()
  25422. case token.FieldToken:
  25423. return m.Token()
  25424. case token.FieldMAC:
  25425. return m.MAC()
  25426. case token.FieldOrganizationID:
  25427. return m.OrganizationID()
  25428. case token.FieldAgentID:
  25429. return m.AgentID()
  25430. case token.FieldCustomAgentBase:
  25431. return m.CustomAgentBase()
  25432. case token.FieldCustomAgentKey:
  25433. return m.CustomAgentKey()
  25434. case token.FieldOpenaiBase:
  25435. return m.OpenaiBase()
  25436. case token.FieldOpenaiKey:
  25437. return m.OpenaiKey()
  25438. }
  25439. return nil, false
  25440. }
  25441. // OldField returns the old value of the field from the database. An error is
  25442. // returned if the mutation operation is not UpdateOne, or the query to the
  25443. // database failed.
  25444. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25445. switch name {
  25446. case token.FieldCreatedAt:
  25447. return m.OldCreatedAt(ctx)
  25448. case token.FieldUpdatedAt:
  25449. return m.OldUpdatedAt(ctx)
  25450. case token.FieldDeletedAt:
  25451. return m.OldDeletedAt(ctx)
  25452. case token.FieldExpireAt:
  25453. return m.OldExpireAt(ctx)
  25454. case token.FieldToken:
  25455. return m.OldToken(ctx)
  25456. case token.FieldMAC:
  25457. return m.OldMAC(ctx)
  25458. case token.FieldOrganizationID:
  25459. return m.OldOrganizationID(ctx)
  25460. case token.FieldAgentID:
  25461. return m.OldAgentID(ctx)
  25462. case token.FieldCustomAgentBase:
  25463. return m.OldCustomAgentBase(ctx)
  25464. case token.FieldCustomAgentKey:
  25465. return m.OldCustomAgentKey(ctx)
  25466. case token.FieldOpenaiBase:
  25467. return m.OldOpenaiBase(ctx)
  25468. case token.FieldOpenaiKey:
  25469. return m.OldOpenaiKey(ctx)
  25470. }
  25471. return nil, fmt.Errorf("unknown Token field %s", name)
  25472. }
  25473. // SetField sets the value of a field with the given name. It returns an error if
  25474. // the field is not defined in the schema, or if the type mismatched the field
  25475. // type.
  25476. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  25477. switch name {
  25478. case token.FieldCreatedAt:
  25479. v, ok := value.(time.Time)
  25480. if !ok {
  25481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25482. }
  25483. m.SetCreatedAt(v)
  25484. return nil
  25485. case token.FieldUpdatedAt:
  25486. v, ok := value.(time.Time)
  25487. if !ok {
  25488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25489. }
  25490. m.SetUpdatedAt(v)
  25491. return nil
  25492. case token.FieldDeletedAt:
  25493. v, ok := value.(time.Time)
  25494. if !ok {
  25495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25496. }
  25497. m.SetDeletedAt(v)
  25498. return nil
  25499. case token.FieldExpireAt:
  25500. v, ok := value.(time.Time)
  25501. if !ok {
  25502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25503. }
  25504. m.SetExpireAt(v)
  25505. return nil
  25506. case token.FieldToken:
  25507. v, ok := value.(string)
  25508. if !ok {
  25509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25510. }
  25511. m.SetToken(v)
  25512. return nil
  25513. case token.FieldMAC:
  25514. v, ok := value.(string)
  25515. if !ok {
  25516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25517. }
  25518. m.SetMAC(v)
  25519. return nil
  25520. case token.FieldOrganizationID:
  25521. v, ok := value.(uint64)
  25522. if !ok {
  25523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25524. }
  25525. m.SetOrganizationID(v)
  25526. return nil
  25527. case token.FieldAgentID:
  25528. v, ok := value.(uint64)
  25529. if !ok {
  25530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25531. }
  25532. m.SetAgentID(v)
  25533. return nil
  25534. case token.FieldCustomAgentBase:
  25535. v, ok := value.(string)
  25536. if !ok {
  25537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25538. }
  25539. m.SetCustomAgentBase(v)
  25540. return nil
  25541. case token.FieldCustomAgentKey:
  25542. v, ok := value.(string)
  25543. if !ok {
  25544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25545. }
  25546. m.SetCustomAgentKey(v)
  25547. return nil
  25548. case token.FieldOpenaiBase:
  25549. v, ok := value.(string)
  25550. if !ok {
  25551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25552. }
  25553. m.SetOpenaiBase(v)
  25554. return nil
  25555. case token.FieldOpenaiKey:
  25556. v, ok := value.(string)
  25557. if !ok {
  25558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25559. }
  25560. m.SetOpenaiKey(v)
  25561. return nil
  25562. }
  25563. return fmt.Errorf("unknown Token field %s", name)
  25564. }
  25565. // AddedFields returns all numeric fields that were incremented/decremented during
  25566. // this mutation.
  25567. func (m *TokenMutation) AddedFields() []string {
  25568. var fields []string
  25569. if m.addorganization_id != nil {
  25570. fields = append(fields, token.FieldOrganizationID)
  25571. }
  25572. return fields
  25573. }
  25574. // AddedField returns the numeric value that was incremented/decremented on a field
  25575. // with the given name. The second boolean return value indicates that this field
  25576. // was not set, or was not defined in the schema.
  25577. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  25578. switch name {
  25579. case token.FieldOrganizationID:
  25580. return m.AddedOrganizationID()
  25581. }
  25582. return nil, false
  25583. }
  25584. // AddField adds the value to the field with the given name. It returns an error if
  25585. // the field is not defined in the schema, or if the type mismatched the field
  25586. // type.
  25587. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  25588. switch name {
  25589. case token.FieldOrganizationID:
  25590. v, ok := value.(int64)
  25591. if !ok {
  25592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25593. }
  25594. m.AddOrganizationID(v)
  25595. return nil
  25596. }
  25597. return fmt.Errorf("unknown Token numeric field %s", name)
  25598. }
  25599. // ClearedFields returns all nullable fields that were cleared during this
  25600. // mutation.
  25601. func (m *TokenMutation) ClearedFields() []string {
  25602. var fields []string
  25603. if m.FieldCleared(token.FieldDeletedAt) {
  25604. fields = append(fields, token.FieldDeletedAt)
  25605. }
  25606. if m.FieldCleared(token.FieldExpireAt) {
  25607. fields = append(fields, token.FieldExpireAt)
  25608. }
  25609. if m.FieldCleared(token.FieldToken) {
  25610. fields = append(fields, token.FieldToken)
  25611. }
  25612. if m.FieldCleared(token.FieldMAC) {
  25613. fields = append(fields, token.FieldMAC)
  25614. }
  25615. if m.FieldCleared(token.FieldCustomAgentBase) {
  25616. fields = append(fields, token.FieldCustomAgentBase)
  25617. }
  25618. if m.FieldCleared(token.FieldCustomAgentKey) {
  25619. fields = append(fields, token.FieldCustomAgentKey)
  25620. }
  25621. if m.FieldCleared(token.FieldOpenaiBase) {
  25622. fields = append(fields, token.FieldOpenaiBase)
  25623. }
  25624. if m.FieldCleared(token.FieldOpenaiKey) {
  25625. fields = append(fields, token.FieldOpenaiKey)
  25626. }
  25627. return fields
  25628. }
  25629. // FieldCleared returns a boolean indicating if a field with the given name was
  25630. // cleared in this mutation.
  25631. func (m *TokenMutation) FieldCleared(name string) bool {
  25632. _, ok := m.clearedFields[name]
  25633. return ok
  25634. }
  25635. // ClearField clears the value of the field with the given name. It returns an
  25636. // error if the field is not defined in the schema.
  25637. func (m *TokenMutation) ClearField(name string) error {
  25638. switch name {
  25639. case token.FieldDeletedAt:
  25640. m.ClearDeletedAt()
  25641. return nil
  25642. case token.FieldExpireAt:
  25643. m.ClearExpireAt()
  25644. return nil
  25645. case token.FieldToken:
  25646. m.ClearToken()
  25647. return nil
  25648. case token.FieldMAC:
  25649. m.ClearMAC()
  25650. return nil
  25651. case token.FieldCustomAgentBase:
  25652. m.ClearCustomAgentBase()
  25653. return nil
  25654. case token.FieldCustomAgentKey:
  25655. m.ClearCustomAgentKey()
  25656. return nil
  25657. case token.FieldOpenaiBase:
  25658. m.ClearOpenaiBase()
  25659. return nil
  25660. case token.FieldOpenaiKey:
  25661. m.ClearOpenaiKey()
  25662. return nil
  25663. }
  25664. return fmt.Errorf("unknown Token nullable field %s", name)
  25665. }
  25666. // ResetField resets all changes in the mutation for the field with the given name.
  25667. // It returns an error if the field is not defined in the schema.
  25668. func (m *TokenMutation) ResetField(name string) error {
  25669. switch name {
  25670. case token.FieldCreatedAt:
  25671. m.ResetCreatedAt()
  25672. return nil
  25673. case token.FieldUpdatedAt:
  25674. m.ResetUpdatedAt()
  25675. return nil
  25676. case token.FieldDeletedAt:
  25677. m.ResetDeletedAt()
  25678. return nil
  25679. case token.FieldExpireAt:
  25680. m.ResetExpireAt()
  25681. return nil
  25682. case token.FieldToken:
  25683. m.ResetToken()
  25684. return nil
  25685. case token.FieldMAC:
  25686. m.ResetMAC()
  25687. return nil
  25688. case token.FieldOrganizationID:
  25689. m.ResetOrganizationID()
  25690. return nil
  25691. case token.FieldAgentID:
  25692. m.ResetAgentID()
  25693. return nil
  25694. case token.FieldCustomAgentBase:
  25695. m.ResetCustomAgentBase()
  25696. return nil
  25697. case token.FieldCustomAgentKey:
  25698. m.ResetCustomAgentKey()
  25699. return nil
  25700. case token.FieldOpenaiBase:
  25701. m.ResetOpenaiBase()
  25702. return nil
  25703. case token.FieldOpenaiKey:
  25704. m.ResetOpenaiKey()
  25705. return nil
  25706. }
  25707. return fmt.Errorf("unknown Token field %s", name)
  25708. }
  25709. // AddedEdges returns all edge names that were set/added in this mutation.
  25710. func (m *TokenMutation) AddedEdges() []string {
  25711. edges := make([]string, 0, 1)
  25712. if m.agent != nil {
  25713. edges = append(edges, token.EdgeAgent)
  25714. }
  25715. return edges
  25716. }
  25717. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25718. // name in this mutation.
  25719. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  25720. switch name {
  25721. case token.EdgeAgent:
  25722. if id := m.agent; id != nil {
  25723. return []ent.Value{*id}
  25724. }
  25725. }
  25726. return nil
  25727. }
  25728. // RemovedEdges returns all edge names that were removed in this mutation.
  25729. func (m *TokenMutation) RemovedEdges() []string {
  25730. edges := make([]string, 0, 1)
  25731. return edges
  25732. }
  25733. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25734. // the given name in this mutation.
  25735. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  25736. return nil
  25737. }
  25738. // ClearedEdges returns all edge names that were cleared in this mutation.
  25739. func (m *TokenMutation) ClearedEdges() []string {
  25740. edges := make([]string, 0, 1)
  25741. if m.clearedagent {
  25742. edges = append(edges, token.EdgeAgent)
  25743. }
  25744. return edges
  25745. }
  25746. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25747. // was cleared in this mutation.
  25748. func (m *TokenMutation) EdgeCleared(name string) bool {
  25749. switch name {
  25750. case token.EdgeAgent:
  25751. return m.clearedagent
  25752. }
  25753. return false
  25754. }
  25755. // ClearEdge clears the value of the edge with the given name. It returns an error
  25756. // if that edge is not defined in the schema.
  25757. func (m *TokenMutation) ClearEdge(name string) error {
  25758. switch name {
  25759. case token.EdgeAgent:
  25760. m.ClearAgent()
  25761. return nil
  25762. }
  25763. return fmt.Errorf("unknown Token unique edge %s", name)
  25764. }
  25765. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25766. // It returns an error if the edge is not defined in the schema.
  25767. func (m *TokenMutation) ResetEdge(name string) error {
  25768. switch name {
  25769. case token.EdgeAgent:
  25770. m.ResetAgent()
  25771. return nil
  25772. }
  25773. return fmt.Errorf("unknown Token edge %s", name)
  25774. }
  25775. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  25776. type TutorialMutation struct {
  25777. config
  25778. op Op
  25779. typ string
  25780. id *uint64
  25781. created_at *time.Time
  25782. updated_at *time.Time
  25783. deleted_at *time.Time
  25784. index *int
  25785. addindex *int
  25786. title *string
  25787. content *string
  25788. organization_id *uint64
  25789. addorganization_id *int64
  25790. clearedFields map[string]struct{}
  25791. employee *uint64
  25792. clearedemployee bool
  25793. done bool
  25794. oldValue func(context.Context) (*Tutorial, error)
  25795. predicates []predicate.Tutorial
  25796. }
  25797. var _ ent.Mutation = (*TutorialMutation)(nil)
  25798. // tutorialOption allows management of the mutation configuration using functional options.
  25799. type tutorialOption func(*TutorialMutation)
  25800. // newTutorialMutation creates new mutation for the Tutorial entity.
  25801. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  25802. m := &TutorialMutation{
  25803. config: c,
  25804. op: op,
  25805. typ: TypeTutorial,
  25806. clearedFields: make(map[string]struct{}),
  25807. }
  25808. for _, opt := range opts {
  25809. opt(m)
  25810. }
  25811. return m
  25812. }
  25813. // withTutorialID sets the ID field of the mutation.
  25814. func withTutorialID(id uint64) tutorialOption {
  25815. return func(m *TutorialMutation) {
  25816. var (
  25817. err error
  25818. once sync.Once
  25819. value *Tutorial
  25820. )
  25821. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  25822. once.Do(func() {
  25823. if m.done {
  25824. err = errors.New("querying old values post mutation is not allowed")
  25825. } else {
  25826. value, err = m.Client().Tutorial.Get(ctx, id)
  25827. }
  25828. })
  25829. return value, err
  25830. }
  25831. m.id = &id
  25832. }
  25833. }
  25834. // withTutorial sets the old Tutorial of the mutation.
  25835. func withTutorial(node *Tutorial) tutorialOption {
  25836. return func(m *TutorialMutation) {
  25837. m.oldValue = func(context.Context) (*Tutorial, error) {
  25838. return node, nil
  25839. }
  25840. m.id = &node.ID
  25841. }
  25842. }
  25843. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25844. // executed in a transaction (ent.Tx), a transactional client is returned.
  25845. func (m TutorialMutation) Client() *Client {
  25846. client := &Client{config: m.config}
  25847. client.init()
  25848. return client
  25849. }
  25850. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25851. // it returns an error otherwise.
  25852. func (m TutorialMutation) Tx() (*Tx, error) {
  25853. if _, ok := m.driver.(*txDriver); !ok {
  25854. return nil, errors.New("ent: mutation is not running in a transaction")
  25855. }
  25856. tx := &Tx{config: m.config}
  25857. tx.init()
  25858. return tx, nil
  25859. }
  25860. // SetID sets the value of the id field. Note that this
  25861. // operation is only accepted on creation of Tutorial entities.
  25862. func (m *TutorialMutation) SetID(id uint64) {
  25863. m.id = &id
  25864. }
  25865. // ID returns the ID value in the mutation. Note that the ID is only available
  25866. // if it was provided to the builder or after it was returned from the database.
  25867. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  25868. if m.id == nil {
  25869. return
  25870. }
  25871. return *m.id, true
  25872. }
  25873. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25874. // That means, if the mutation is applied within a transaction with an isolation level such
  25875. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25876. // or updated by the mutation.
  25877. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  25878. switch {
  25879. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25880. id, exists := m.ID()
  25881. if exists {
  25882. return []uint64{id}, nil
  25883. }
  25884. fallthrough
  25885. case m.op.Is(OpUpdate | OpDelete):
  25886. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  25887. default:
  25888. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25889. }
  25890. }
  25891. // SetCreatedAt sets the "created_at" field.
  25892. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  25893. m.created_at = &t
  25894. }
  25895. // CreatedAt returns the value of the "created_at" field in the mutation.
  25896. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  25897. v := m.created_at
  25898. if v == nil {
  25899. return
  25900. }
  25901. return *v, true
  25902. }
  25903. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  25904. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  25905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25906. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25907. if !m.op.Is(OpUpdateOne) {
  25908. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25909. }
  25910. if m.id == nil || m.oldValue == nil {
  25911. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25912. }
  25913. oldValue, err := m.oldValue(ctx)
  25914. if err != nil {
  25915. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25916. }
  25917. return oldValue.CreatedAt, nil
  25918. }
  25919. // ResetCreatedAt resets all changes to the "created_at" field.
  25920. func (m *TutorialMutation) ResetCreatedAt() {
  25921. m.created_at = nil
  25922. }
  25923. // SetUpdatedAt sets the "updated_at" field.
  25924. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  25925. m.updated_at = &t
  25926. }
  25927. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25928. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  25929. v := m.updated_at
  25930. if v == nil {
  25931. return
  25932. }
  25933. return *v, true
  25934. }
  25935. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  25936. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  25937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25938. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25939. if !m.op.Is(OpUpdateOne) {
  25940. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25941. }
  25942. if m.id == nil || m.oldValue == nil {
  25943. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25944. }
  25945. oldValue, err := m.oldValue(ctx)
  25946. if err != nil {
  25947. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25948. }
  25949. return oldValue.UpdatedAt, nil
  25950. }
  25951. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25952. func (m *TutorialMutation) ResetUpdatedAt() {
  25953. m.updated_at = nil
  25954. }
  25955. // SetDeletedAt sets the "deleted_at" field.
  25956. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  25957. m.deleted_at = &t
  25958. }
  25959. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25960. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  25961. v := m.deleted_at
  25962. if v == nil {
  25963. return
  25964. }
  25965. return *v, true
  25966. }
  25967. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  25968. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  25969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25970. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25971. if !m.op.Is(OpUpdateOne) {
  25972. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25973. }
  25974. if m.id == nil || m.oldValue == nil {
  25975. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25976. }
  25977. oldValue, err := m.oldValue(ctx)
  25978. if err != nil {
  25979. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25980. }
  25981. return oldValue.DeletedAt, nil
  25982. }
  25983. // ClearDeletedAt clears the value of the "deleted_at" field.
  25984. func (m *TutorialMutation) ClearDeletedAt() {
  25985. m.deleted_at = nil
  25986. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  25987. }
  25988. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25989. func (m *TutorialMutation) DeletedAtCleared() bool {
  25990. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  25991. return ok
  25992. }
  25993. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25994. func (m *TutorialMutation) ResetDeletedAt() {
  25995. m.deleted_at = nil
  25996. delete(m.clearedFields, tutorial.FieldDeletedAt)
  25997. }
  25998. // SetEmployeeID sets the "employee_id" field.
  25999. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  26000. m.employee = &u
  26001. }
  26002. // EmployeeID returns the value of the "employee_id" field in the mutation.
  26003. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  26004. v := m.employee
  26005. if v == nil {
  26006. return
  26007. }
  26008. return *v, true
  26009. }
  26010. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  26011. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26013. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  26014. if !m.op.Is(OpUpdateOne) {
  26015. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  26016. }
  26017. if m.id == nil || m.oldValue == nil {
  26018. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  26019. }
  26020. oldValue, err := m.oldValue(ctx)
  26021. if err != nil {
  26022. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  26023. }
  26024. return oldValue.EmployeeID, nil
  26025. }
  26026. // ResetEmployeeID resets all changes to the "employee_id" field.
  26027. func (m *TutorialMutation) ResetEmployeeID() {
  26028. m.employee = nil
  26029. }
  26030. // SetIndex sets the "index" field.
  26031. func (m *TutorialMutation) SetIndex(i int) {
  26032. m.index = &i
  26033. m.addindex = nil
  26034. }
  26035. // Index returns the value of the "index" field in the mutation.
  26036. func (m *TutorialMutation) Index() (r int, exists bool) {
  26037. v := m.index
  26038. if v == nil {
  26039. return
  26040. }
  26041. return *v, true
  26042. }
  26043. // OldIndex returns the old "index" field's value of the Tutorial entity.
  26044. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26045. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26046. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  26047. if !m.op.Is(OpUpdateOne) {
  26048. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  26049. }
  26050. if m.id == nil || m.oldValue == nil {
  26051. return v, errors.New("OldIndex requires an ID field in the mutation")
  26052. }
  26053. oldValue, err := m.oldValue(ctx)
  26054. if err != nil {
  26055. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  26056. }
  26057. return oldValue.Index, nil
  26058. }
  26059. // AddIndex adds i to the "index" field.
  26060. func (m *TutorialMutation) AddIndex(i int) {
  26061. if m.addindex != nil {
  26062. *m.addindex += i
  26063. } else {
  26064. m.addindex = &i
  26065. }
  26066. }
  26067. // AddedIndex returns the value that was added to the "index" field in this mutation.
  26068. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  26069. v := m.addindex
  26070. if v == nil {
  26071. return
  26072. }
  26073. return *v, true
  26074. }
  26075. // ResetIndex resets all changes to the "index" field.
  26076. func (m *TutorialMutation) ResetIndex() {
  26077. m.index = nil
  26078. m.addindex = nil
  26079. }
  26080. // SetTitle sets the "title" field.
  26081. func (m *TutorialMutation) SetTitle(s string) {
  26082. m.title = &s
  26083. }
  26084. // Title returns the value of the "title" field in the mutation.
  26085. func (m *TutorialMutation) Title() (r string, exists bool) {
  26086. v := m.title
  26087. if v == nil {
  26088. return
  26089. }
  26090. return *v, true
  26091. }
  26092. // OldTitle returns the old "title" field's value of the Tutorial entity.
  26093. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26095. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  26096. if !m.op.Is(OpUpdateOne) {
  26097. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  26098. }
  26099. if m.id == nil || m.oldValue == nil {
  26100. return v, errors.New("OldTitle requires an ID field in the mutation")
  26101. }
  26102. oldValue, err := m.oldValue(ctx)
  26103. if err != nil {
  26104. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  26105. }
  26106. return oldValue.Title, nil
  26107. }
  26108. // ResetTitle resets all changes to the "title" field.
  26109. func (m *TutorialMutation) ResetTitle() {
  26110. m.title = nil
  26111. }
  26112. // SetContent sets the "content" field.
  26113. func (m *TutorialMutation) SetContent(s string) {
  26114. m.content = &s
  26115. }
  26116. // Content returns the value of the "content" field in the mutation.
  26117. func (m *TutorialMutation) Content() (r string, exists bool) {
  26118. v := m.content
  26119. if v == nil {
  26120. return
  26121. }
  26122. return *v, true
  26123. }
  26124. // OldContent returns the old "content" field's value of the Tutorial entity.
  26125. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26127. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  26128. if !m.op.Is(OpUpdateOne) {
  26129. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  26130. }
  26131. if m.id == nil || m.oldValue == nil {
  26132. return v, errors.New("OldContent requires an ID field in the mutation")
  26133. }
  26134. oldValue, err := m.oldValue(ctx)
  26135. if err != nil {
  26136. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  26137. }
  26138. return oldValue.Content, nil
  26139. }
  26140. // ResetContent resets all changes to the "content" field.
  26141. func (m *TutorialMutation) ResetContent() {
  26142. m.content = nil
  26143. }
  26144. // SetOrganizationID sets the "organization_id" field.
  26145. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  26146. m.organization_id = &u
  26147. m.addorganization_id = nil
  26148. }
  26149. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26150. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  26151. v := m.organization_id
  26152. if v == nil {
  26153. return
  26154. }
  26155. return *v, true
  26156. }
  26157. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  26158. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26160. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26161. if !m.op.Is(OpUpdateOne) {
  26162. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26163. }
  26164. if m.id == nil || m.oldValue == nil {
  26165. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26166. }
  26167. oldValue, err := m.oldValue(ctx)
  26168. if err != nil {
  26169. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26170. }
  26171. return oldValue.OrganizationID, nil
  26172. }
  26173. // AddOrganizationID adds u to the "organization_id" field.
  26174. func (m *TutorialMutation) AddOrganizationID(u int64) {
  26175. if m.addorganization_id != nil {
  26176. *m.addorganization_id += u
  26177. } else {
  26178. m.addorganization_id = &u
  26179. }
  26180. }
  26181. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26182. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  26183. v := m.addorganization_id
  26184. if v == nil {
  26185. return
  26186. }
  26187. return *v, true
  26188. }
  26189. // ResetOrganizationID resets all changes to the "organization_id" field.
  26190. func (m *TutorialMutation) ResetOrganizationID() {
  26191. m.organization_id = nil
  26192. m.addorganization_id = nil
  26193. }
  26194. // ClearEmployee clears the "employee" edge to the Employee entity.
  26195. func (m *TutorialMutation) ClearEmployee() {
  26196. m.clearedemployee = true
  26197. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  26198. }
  26199. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  26200. func (m *TutorialMutation) EmployeeCleared() bool {
  26201. return m.clearedemployee
  26202. }
  26203. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  26204. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  26205. // EmployeeID instead. It exists only for internal usage by the builders.
  26206. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  26207. if id := m.employee; id != nil {
  26208. ids = append(ids, *id)
  26209. }
  26210. return
  26211. }
  26212. // ResetEmployee resets all changes to the "employee" edge.
  26213. func (m *TutorialMutation) ResetEmployee() {
  26214. m.employee = nil
  26215. m.clearedemployee = false
  26216. }
  26217. // Where appends a list predicates to the TutorialMutation builder.
  26218. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  26219. m.predicates = append(m.predicates, ps...)
  26220. }
  26221. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  26222. // users can use type-assertion to append predicates that do not depend on any generated package.
  26223. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  26224. p := make([]predicate.Tutorial, len(ps))
  26225. for i := range ps {
  26226. p[i] = ps[i]
  26227. }
  26228. m.Where(p...)
  26229. }
  26230. // Op returns the operation name.
  26231. func (m *TutorialMutation) Op() Op {
  26232. return m.op
  26233. }
  26234. // SetOp allows setting the mutation operation.
  26235. func (m *TutorialMutation) SetOp(op Op) {
  26236. m.op = op
  26237. }
  26238. // Type returns the node type of this mutation (Tutorial).
  26239. func (m *TutorialMutation) Type() string {
  26240. return m.typ
  26241. }
  26242. // Fields returns all fields that were changed during this mutation. Note that in
  26243. // order to get all numeric fields that were incremented/decremented, call
  26244. // AddedFields().
  26245. func (m *TutorialMutation) Fields() []string {
  26246. fields := make([]string, 0, 8)
  26247. if m.created_at != nil {
  26248. fields = append(fields, tutorial.FieldCreatedAt)
  26249. }
  26250. if m.updated_at != nil {
  26251. fields = append(fields, tutorial.FieldUpdatedAt)
  26252. }
  26253. if m.deleted_at != nil {
  26254. fields = append(fields, tutorial.FieldDeletedAt)
  26255. }
  26256. if m.employee != nil {
  26257. fields = append(fields, tutorial.FieldEmployeeID)
  26258. }
  26259. if m.index != nil {
  26260. fields = append(fields, tutorial.FieldIndex)
  26261. }
  26262. if m.title != nil {
  26263. fields = append(fields, tutorial.FieldTitle)
  26264. }
  26265. if m.content != nil {
  26266. fields = append(fields, tutorial.FieldContent)
  26267. }
  26268. if m.organization_id != nil {
  26269. fields = append(fields, tutorial.FieldOrganizationID)
  26270. }
  26271. return fields
  26272. }
  26273. // Field returns the value of a field with the given name. The second boolean
  26274. // return value indicates that this field was not set, or was not defined in the
  26275. // schema.
  26276. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  26277. switch name {
  26278. case tutorial.FieldCreatedAt:
  26279. return m.CreatedAt()
  26280. case tutorial.FieldUpdatedAt:
  26281. return m.UpdatedAt()
  26282. case tutorial.FieldDeletedAt:
  26283. return m.DeletedAt()
  26284. case tutorial.FieldEmployeeID:
  26285. return m.EmployeeID()
  26286. case tutorial.FieldIndex:
  26287. return m.Index()
  26288. case tutorial.FieldTitle:
  26289. return m.Title()
  26290. case tutorial.FieldContent:
  26291. return m.Content()
  26292. case tutorial.FieldOrganizationID:
  26293. return m.OrganizationID()
  26294. }
  26295. return nil, false
  26296. }
  26297. // OldField returns the old value of the field from the database. An error is
  26298. // returned if the mutation operation is not UpdateOne, or the query to the
  26299. // database failed.
  26300. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26301. switch name {
  26302. case tutorial.FieldCreatedAt:
  26303. return m.OldCreatedAt(ctx)
  26304. case tutorial.FieldUpdatedAt:
  26305. return m.OldUpdatedAt(ctx)
  26306. case tutorial.FieldDeletedAt:
  26307. return m.OldDeletedAt(ctx)
  26308. case tutorial.FieldEmployeeID:
  26309. return m.OldEmployeeID(ctx)
  26310. case tutorial.FieldIndex:
  26311. return m.OldIndex(ctx)
  26312. case tutorial.FieldTitle:
  26313. return m.OldTitle(ctx)
  26314. case tutorial.FieldContent:
  26315. return m.OldContent(ctx)
  26316. case tutorial.FieldOrganizationID:
  26317. return m.OldOrganizationID(ctx)
  26318. }
  26319. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  26320. }
  26321. // SetField sets the value of a field with the given name. It returns an error if
  26322. // the field is not defined in the schema, or if the type mismatched the field
  26323. // type.
  26324. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  26325. switch name {
  26326. case tutorial.FieldCreatedAt:
  26327. v, ok := value.(time.Time)
  26328. if !ok {
  26329. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26330. }
  26331. m.SetCreatedAt(v)
  26332. return nil
  26333. case tutorial.FieldUpdatedAt:
  26334. v, ok := value.(time.Time)
  26335. if !ok {
  26336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26337. }
  26338. m.SetUpdatedAt(v)
  26339. return nil
  26340. case tutorial.FieldDeletedAt:
  26341. v, ok := value.(time.Time)
  26342. if !ok {
  26343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26344. }
  26345. m.SetDeletedAt(v)
  26346. return nil
  26347. case tutorial.FieldEmployeeID:
  26348. v, ok := value.(uint64)
  26349. if !ok {
  26350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26351. }
  26352. m.SetEmployeeID(v)
  26353. return nil
  26354. case tutorial.FieldIndex:
  26355. v, ok := value.(int)
  26356. if !ok {
  26357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26358. }
  26359. m.SetIndex(v)
  26360. return nil
  26361. case tutorial.FieldTitle:
  26362. v, ok := value.(string)
  26363. if !ok {
  26364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26365. }
  26366. m.SetTitle(v)
  26367. return nil
  26368. case tutorial.FieldContent:
  26369. v, ok := value.(string)
  26370. if !ok {
  26371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26372. }
  26373. m.SetContent(v)
  26374. return nil
  26375. case tutorial.FieldOrganizationID:
  26376. v, ok := value.(uint64)
  26377. if !ok {
  26378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26379. }
  26380. m.SetOrganizationID(v)
  26381. return nil
  26382. }
  26383. return fmt.Errorf("unknown Tutorial field %s", name)
  26384. }
  26385. // AddedFields returns all numeric fields that were incremented/decremented during
  26386. // this mutation.
  26387. func (m *TutorialMutation) AddedFields() []string {
  26388. var fields []string
  26389. if m.addindex != nil {
  26390. fields = append(fields, tutorial.FieldIndex)
  26391. }
  26392. if m.addorganization_id != nil {
  26393. fields = append(fields, tutorial.FieldOrganizationID)
  26394. }
  26395. return fields
  26396. }
  26397. // AddedField returns the numeric value that was incremented/decremented on a field
  26398. // with the given name. The second boolean return value indicates that this field
  26399. // was not set, or was not defined in the schema.
  26400. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  26401. switch name {
  26402. case tutorial.FieldIndex:
  26403. return m.AddedIndex()
  26404. case tutorial.FieldOrganizationID:
  26405. return m.AddedOrganizationID()
  26406. }
  26407. return nil, false
  26408. }
  26409. // AddField adds the value to the field with the given name. It returns an error if
  26410. // the field is not defined in the schema, or if the type mismatched the field
  26411. // type.
  26412. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  26413. switch name {
  26414. case tutorial.FieldIndex:
  26415. v, ok := value.(int)
  26416. if !ok {
  26417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26418. }
  26419. m.AddIndex(v)
  26420. return nil
  26421. case tutorial.FieldOrganizationID:
  26422. v, ok := value.(int64)
  26423. if !ok {
  26424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26425. }
  26426. m.AddOrganizationID(v)
  26427. return nil
  26428. }
  26429. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  26430. }
  26431. // ClearedFields returns all nullable fields that were cleared during this
  26432. // mutation.
  26433. func (m *TutorialMutation) ClearedFields() []string {
  26434. var fields []string
  26435. if m.FieldCleared(tutorial.FieldDeletedAt) {
  26436. fields = append(fields, tutorial.FieldDeletedAt)
  26437. }
  26438. return fields
  26439. }
  26440. // FieldCleared returns a boolean indicating if a field with the given name was
  26441. // cleared in this mutation.
  26442. func (m *TutorialMutation) FieldCleared(name string) bool {
  26443. _, ok := m.clearedFields[name]
  26444. return ok
  26445. }
  26446. // ClearField clears the value of the field with the given name. It returns an
  26447. // error if the field is not defined in the schema.
  26448. func (m *TutorialMutation) ClearField(name string) error {
  26449. switch name {
  26450. case tutorial.FieldDeletedAt:
  26451. m.ClearDeletedAt()
  26452. return nil
  26453. }
  26454. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  26455. }
  26456. // ResetField resets all changes in the mutation for the field with the given name.
  26457. // It returns an error if the field is not defined in the schema.
  26458. func (m *TutorialMutation) ResetField(name string) error {
  26459. switch name {
  26460. case tutorial.FieldCreatedAt:
  26461. m.ResetCreatedAt()
  26462. return nil
  26463. case tutorial.FieldUpdatedAt:
  26464. m.ResetUpdatedAt()
  26465. return nil
  26466. case tutorial.FieldDeletedAt:
  26467. m.ResetDeletedAt()
  26468. return nil
  26469. case tutorial.FieldEmployeeID:
  26470. m.ResetEmployeeID()
  26471. return nil
  26472. case tutorial.FieldIndex:
  26473. m.ResetIndex()
  26474. return nil
  26475. case tutorial.FieldTitle:
  26476. m.ResetTitle()
  26477. return nil
  26478. case tutorial.FieldContent:
  26479. m.ResetContent()
  26480. return nil
  26481. case tutorial.FieldOrganizationID:
  26482. m.ResetOrganizationID()
  26483. return nil
  26484. }
  26485. return fmt.Errorf("unknown Tutorial field %s", name)
  26486. }
  26487. // AddedEdges returns all edge names that were set/added in this mutation.
  26488. func (m *TutorialMutation) AddedEdges() []string {
  26489. edges := make([]string, 0, 1)
  26490. if m.employee != nil {
  26491. edges = append(edges, tutorial.EdgeEmployee)
  26492. }
  26493. return edges
  26494. }
  26495. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26496. // name in this mutation.
  26497. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  26498. switch name {
  26499. case tutorial.EdgeEmployee:
  26500. if id := m.employee; id != nil {
  26501. return []ent.Value{*id}
  26502. }
  26503. }
  26504. return nil
  26505. }
  26506. // RemovedEdges returns all edge names that were removed in this mutation.
  26507. func (m *TutorialMutation) RemovedEdges() []string {
  26508. edges := make([]string, 0, 1)
  26509. return edges
  26510. }
  26511. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26512. // the given name in this mutation.
  26513. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  26514. return nil
  26515. }
  26516. // ClearedEdges returns all edge names that were cleared in this mutation.
  26517. func (m *TutorialMutation) ClearedEdges() []string {
  26518. edges := make([]string, 0, 1)
  26519. if m.clearedemployee {
  26520. edges = append(edges, tutorial.EdgeEmployee)
  26521. }
  26522. return edges
  26523. }
  26524. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26525. // was cleared in this mutation.
  26526. func (m *TutorialMutation) EdgeCleared(name string) bool {
  26527. switch name {
  26528. case tutorial.EdgeEmployee:
  26529. return m.clearedemployee
  26530. }
  26531. return false
  26532. }
  26533. // ClearEdge clears the value of the edge with the given name. It returns an error
  26534. // if that edge is not defined in the schema.
  26535. func (m *TutorialMutation) ClearEdge(name string) error {
  26536. switch name {
  26537. case tutorial.EdgeEmployee:
  26538. m.ClearEmployee()
  26539. return nil
  26540. }
  26541. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  26542. }
  26543. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26544. // It returns an error if the edge is not defined in the schema.
  26545. func (m *TutorialMutation) ResetEdge(name string) error {
  26546. switch name {
  26547. case tutorial.EdgeEmployee:
  26548. m.ResetEmployee()
  26549. return nil
  26550. }
  26551. return fmt.Errorf("unknown Tutorial edge %s", name)
  26552. }
  26553. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  26554. type UsageDetailMutation struct {
  26555. config
  26556. op Op
  26557. typ string
  26558. id *uint64
  26559. created_at *time.Time
  26560. updated_at *time.Time
  26561. status *uint8
  26562. addstatus *int8
  26563. _type *int
  26564. add_type *int
  26565. bot_id *string
  26566. receiver_id *string
  26567. app *int
  26568. addapp *int
  26569. session_id *uint64
  26570. addsession_id *int64
  26571. request *string
  26572. response *string
  26573. original_data *custom_types.OriginalData
  26574. total_tokens *uint64
  26575. addtotal_tokens *int64
  26576. prompt_tokens *uint64
  26577. addprompt_tokens *int64
  26578. completion_tokens *uint64
  26579. addcompletion_tokens *int64
  26580. organization_id *uint64
  26581. addorganization_id *int64
  26582. clearedFields map[string]struct{}
  26583. done bool
  26584. oldValue func(context.Context) (*UsageDetail, error)
  26585. predicates []predicate.UsageDetail
  26586. }
  26587. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  26588. // usagedetailOption allows management of the mutation configuration using functional options.
  26589. type usagedetailOption func(*UsageDetailMutation)
  26590. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  26591. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  26592. m := &UsageDetailMutation{
  26593. config: c,
  26594. op: op,
  26595. typ: TypeUsageDetail,
  26596. clearedFields: make(map[string]struct{}),
  26597. }
  26598. for _, opt := range opts {
  26599. opt(m)
  26600. }
  26601. return m
  26602. }
  26603. // withUsageDetailID sets the ID field of the mutation.
  26604. func withUsageDetailID(id uint64) usagedetailOption {
  26605. return func(m *UsageDetailMutation) {
  26606. var (
  26607. err error
  26608. once sync.Once
  26609. value *UsageDetail
  26610. )
  26611. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  26612. once.Do(func() {
  26613. if m.done {
  26614. err = errors.New("querying old values post mutation is not allowed")
  26615. } else {
  26616. value, err = m.Client().UsageDetail.Get(ctx, id)
  26617. }
  26618. })
  26619. return value, err
  26620. }
  26621. m.id = &id
  26622. }
  26623. }
  26624. // withUsageDetail sets the old UsageDetail of the mutation.
  26625. func withUsageDetail(node *UsageDetail) usagedetailOption {
  26626. return func(m *UsageDetailMutation) {
  26627. m.oldValue = func(context.Context) (*UsageDetail, error) {
  26628. return node, nil
  26629. }
  26630. m.id = &node.ID
  26631. }
  26632. }
  26633. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26634. // executed in a transaction (ent.Tx), a transactional client is returned.
  26635. func (m UsageDetailMutation) Client() *Client {
  26636. client := &Client{config: m.config}
  26637. client.init()
  26638. return client
  26639. }
  26640. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26641. // it returns an error otherwise.
  26642. func (m UsageDetailMutation) Tx() (*Tx, error) {
  26643. if _, ok := m.driver.(*txDriver); !ok {
  26644. return nil, errors.New("ent: mutation is not running in a transaction")
  26645. }
  26646. tx := &Tx{config: m.config}
  26647. tx.init()
  26648. return tx, nil
  26649. }
  26650. // SetID sets the value of the id field. Note that this
  26651. // operation is only accepted on creation of UsageDetail entities.
  26652. func (m *UsageDetailMutation) SetID(id uint64) {
  26653. m.id = &id
  26654. }
  26655. // ID returns the ID value in the mutation. Note that the ID is only available
  26656. // if it was provided to the builder or after it was returned from the database.
  26657. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  26658. if m.id == nil {
  26659. return
  26660. }
  26661. return *m.id, true
  26662. }
  26663. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26664. // That means, if the mutation is applied within a transaction with an isolation level such
  26665. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26666. // or updated by the mutation.
  26667. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  26668. switch {
  26669. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26670. id, exists := m.ID()
  26671. if exists {
  26672. return []uint64{id}, nil
  26673. }
  26674. fallthrough
  26675. case m.op.Is(OpUpdate | OpDelete):
  26676. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  26677. default:
  26678. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26679. }
  26680. }
  26681. // SetCreatedAt sets the "created_at" field.
  26682. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  26683. m.created_at = &t
  26684. }
  26685. // CreatedAt returns the value of the "created_at" field in the mutation.
  26686. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  26687. v := m.created_at
  26688. if v == nil {
  26689. return
  26690. }
  26691. return *v, true
  26692. }
  26693. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  26694. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26696. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26697. if !m.op.Is(OpUpdateOne) {
  26698. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26699. }
  26700. if m.id == nil || m.oldValue == nil {
  26701. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26702. }
  26703. oldValue, err := m.oldValue(ctx)
  26704. if err != nil {
  26705. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26706. }
  26707. return oldValue.CreatedAt, nil
  26708. }
  26709. // ResetCreatedAt resets all changes to the "created_at" field.
  26710. func (m *UsageDetailMutation) ResetCreatedAt() {
  26711. m.created_at = nil
  26712. }
  26713. // SetUpdatedAt sets the "updated_at" field.
  26714. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  26715. m.updated_at = &t
  26716. }
  26717. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26718. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  26719. v := m.updated_at
  26720. if v == nil {
  26721. return
  26722. }
  26723. return *v, true
  26724. }
  26725. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  26726. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26728. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26729. if !m.op.Is(OpUpdateOne) {
  26730. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26731. }
  26732. if m.id == nil || m.oldValue == nil {
  26733. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26734. }
  26735. oldValue, err := m.oldValue(ctx)
  26736. if err != nil {
  26737. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26738. }
  26739. return oldValue.UpdatedAt, nil
  26740. }
  26741. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26742. func (m *UsageDetailMutation) ResetUpdatedAt() {
  26743. m.updated_at = nil
  26744. }
  26745. // SetStatus sets the "status" field.
  26746. func (m *UsageDetailMutation) SetStatus(u uint8) {
  26747. m.status = &u
  26748. m.addstatus = nil
  26749. }
  26750. // Status returns the value of the "status" field in the mutation.
  26751. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  26752. v := m.status
  26753. if v == nil {
  26754. return
  26755. }
  26756. return *v, true
  26757. }
  26758. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  26759. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26761. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26762. if !m.op.Is(OpUpdateOne) {
  26763. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26764. }
  26765. if m.id == nil || m.oldValue == nil {
  26766. return v, errors.New("OldStatus requires an ID field in the mutation")
  26767. }
  26768. oldValue, err := m.oldValue(ctx)
  26769. if err != nil {
  26770. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26771. }
  26772. return oldValue.Status, nil
  26773. }
  26774. // AddStatus adds u to the "status" field.
  26775. func (m *UsageDetailMutation) AddStatus(u int8) {
  26776. if m.addstatus != nil {
  26777. *m.addstatus += u
  26778. } else {
  26779. m.addstatus = &u
  26780. }
  26781. }
  26782. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26783. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  26784. v := m.addstatus
  26785. if v == nil {
  26786. return
  26787. }
  26788. return *v, true
  26789. }
  26790. // ClearStatus clears the value of the "status" field.
  26791. func (m *UsageDetailMutation) ClearStatus() {
  26792. m.status = nil
  26793. m.addstatus = nil
  26794. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  26795. }
  26796. // StatusCleared returns if the "status" field was cleared in this mutation.
  26797. func (m *UsageDetailMutation) StatusCleared() bool {
  26798. _, ok := m.clearedFields[usagedetail.FieldStatus]
  26799. return ok
  26800. }
  26801. // ResetStatus resets all changes to the "status" field.
  26802. func (m *UsageDetailMutation) ResetStatus() {
  26803. m.status = nil
  26804. m.addstatus = nil
  26805. delete(m.clearedFields, usagedetail.FieldStatus)
  26806. }
  26807. // SetType sets the "type" field.
  26808. func (m *UsageDetailMutation) SetType(i int) {
  26809. m._type = &i
  26810. m.add_type = nil
  26811. }
  26812. // GetType returns the value of the "type" field in the mutation.
  26813. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  26814. v := m._type
  26815. if v == nil {
  26816. return
  26817. }
  26818. return *v, true
  26819. }
  26820. // OldType returns the old "type" field's value of the UsageDetail entity.
  26821. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26823. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  26824. if !m.op.Is(OpUpdateOne) {
  26825. return v, errors.New("OldType is only allowed on UpdateOne operations")
  26826. }
  26827. if m.id == nil || m.oldValue == nil {
  26828. return v, errors.New("OldType requires an ID field in the mutation")
  26829. }
  26830. oldValue, err := m.oldValue(ctx)
  26831. if err != nil {
  26832. return v, fmt.Errorf("querying old value for OldType: %w", err)
  26833. }
  26834. return oldValue.Type, nil
  26835. }
  26836. // AddType adds i to the "type" field.
  26837. func (m *UsageDetailMutation) AddType(i int) {
  26838. if m.add_type != nil {
  26839. *m.add_type += i
  26840. } else {
  26841. m.add_type = &i
  26842. }
  26843. }
  26844. // AddedType returns the value that was added to the "type" field in this mutation.
  26845. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  26846. v := m.add_type
  26847. if v == nil {
  26848. return
  26849. }
  26850. return *v, true
  26851. }
  26852. // ClearType clears the value of the "type" field.
  26853. func (m *UsageDetailMutation) ClearType() {
  26854. m._type = nil
  26855. m.add_type = nil
  26856. m.clearedFields[usagedetail.FieldType] = struct{}{}
  26857. }
  26858. // TypeCleared returns if the "type" field was cleared in this mutation.
  26859. func (m *UsageDetailMutation) TypeCleared() bool {
  26860. _, ok := m.clearedFields[usagedetail.FieldType]
  26861. return ok
  26862. }
  26863. // ResetType resets all changes to the "type" field.
  26864. func (m *UsageDetailMutation) ResetType() {
  26865. m._type = nil
  26866. m.add_type = nil
  26867. delete(m.clearedFields, usagedetail.FieldType)
  26868. }
  26869. // SetBotID sets the "bot_id" field.
  26870. func (m *UsageDetailMutation) SetBotID(s string) {
  26871. m.bot_id = &s
  26872. }
  26873. // BotID returns the value of the "bot_id" field in the mutation.
  26874. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  26875. v := m.bot_id
  26876. if v == nil {
  26877. return
  26878. }
  26879. return *v, true
  26880. }
  26881. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  26882. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26883. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26884. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  26885. if !m.op.Is(OpUpdateOne) {
  26886. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  26887. }
  26888. if m.id == nil || m.oldValue == nil {
  26889. return v, errors.New("OldBotID requires an ID field in the mutation")
  26890. }
  26891. oldValue, err := m.oldValue(ctx)
  26892. if err != nil {
  26893. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  26894. }
  26895. return oldValue.BotID, nil
  26896. }
  26897. // ResetBotID resets all changes to the "bot_id" field.
  26898. func (m *UsageDetailMutation) ResetBotID() {
  26899. m.bot_id = nil
  26900. }
  26901. // SetReceiverID sets the "receiver_id" field.
  26902. func (m *UsageDetailMutation) SetReceiverID(s string) {
  26903. m.receiver_id = &s
  26904. }
  26905. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  26906. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  26907. v := m.receiver_id
  26908. if v == nil {
  26909. return
  26910. }
  26911. return *v, true
  26912. }
  26913. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  26914. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26915. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26916. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  26917. if !m.op.Is(OpUpdateOne) {
  26918. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  26919. }
  26920. if m.id == nil || m.oldValue == nil {
  26921. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  26922. }
  26923. oldValue, err := m.oldValue(ctx)
  26924. if err != nil {
  26925. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  26926. }
  26927. return oldValue.ReceiverID, nil
  26928. }
  26929. // ResetReceiverID resets all changes to the "receiver_id" field.
  26930. func (m *UsageDetailMutation) ResetReceiverID() {
  26931. m.receiver_id = nil
  26932. }
  26933. // SetApp sets the "app" field.
  26934. func (m *UsageDetailMutation) SetApp(i int) {
  26935. m.app = &i
  26936. m.addapp = nil
  26937. }
  26938. // App returns the value of the "app" field in the mutation.
  26939. func (m *UsageDetailMutation) App() (r int, exists bool) {
  26940. v := m.app
  26941. if v == nil {
  26942. return
  26943. }
  26944. return *v, true
  26945. }
  26946. // OldApp returns the old "app" field's value of the UsageDetail entity.
  26947. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26949. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  26950. if !m.op.Is(OpUpdateOne) {
  26951. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  26952. }
  26953. if m.id == nil || m.oldValue == nil {
  26954. return v, errors.New("OldApp requires an ID field in the mutation")
  26955. }
  26956. oldValue, err := m.oldValue(ctx)
  26957. if err != nil {
  26958. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  26959. }
  26960. return oldValue.App, nil
  26961. }
  26962. // AddApp adds i to the "app" field.
  26963. func (m *UsageDetailMutation) AddApp(i int) {
  26964. if m.addapp != nil {
  26965. *m.addapp += i
  26966. } else {
  26967. m.addapp = &i
  26968. }
  26969. }
  26970. // AddedApp returns the value that was added to the "app" field in this mutation.
  26971. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  26972. v := m.addapp
  26973. if v == nil {
  26974. return
  26975. }
  26976. return *v, true
  26977. }
  26978. // ClearApp clears the value of the "app" field.
  26979. func (m *UsageDetailMutation) ClearApp() {
  26980. m.app = nil
  26981. m.addapp = nil
  26982. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  26983. }
  26984. // AppCleared returns if the "app" field was cleared in this mutation.
  26985. func (m *UsageDetailMutation) AppCleared() bool {
  26986. _, ok := m.clearedFields[usagedetail.FieldApp]
  26987. return ok
  26988. }
  26989. // ResetApp resets all changes to the "app" field.
  26990. func (m *UsageDetailMutation) ResetApp() {
  26991. m.app = nil
  26992. m.addapp = nil
  26993. delete(m.clearedFields, usagedetail.FieldApp)
  26994. }
  26995. // SetSessionID sets the "session_id" field.
  26996. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  26997. m.session_id = &u
  26998. m.addsession_id = nil
  26999. }
  27000. // SessionID returns the value of the "session_id" field in the mutation.
  27001. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  27002. v := m.session_id
  27003. if v == nil {
  27004. return
  27005. }
  27006. return *v, true
  27007. }
  27008. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  27009. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27010. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27011. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  27012. if !m.op.Is(OpUpdateOne) {
  27013. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  27014. }
  27015. if m.id == nil || m.oldValue == nil {
  27016. return v, errors.New("OldSessionID requires an ID field in the mutation")
  27017. }
  27018. oldValue, err := m.oldValue(ctx)
  27019. if err != nil {
  27020. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  27021. }
  27022. return oldValue.SessionID, nil
  27023. }
  27024. // AddSessionID adds u to the "session_id" field.
  27025. func (m *UsageDetailMutation) AddSessionID(u int64) {
  27026. if m.addsession_id != nil {
  27027. *m.addsession_id += u
  27028. } else {
  27029. m.addsession_id = &u
  27030. }
  27031. }
  27032. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  27033. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  27034. v := m.addsession_id
  27035. if v == nil {
  27036. return
  27037. }
  27038. return *v, true
  27039. }
  27040. // ClearSessionID clears the value of the "session_id" field.
  27041. func (m *UsageDetailMutation) ClearSessionID() {
  27042. m.session_id = nil
  27043. m.addsession_id = nil
  27044. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  27045. }
  27046. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  27047. func (m *UsageDetailMutation) SessionIDCleared() bool {
  27048. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  27049. return ok
  27050. }
  27051. // ResetSessionID resets all changes to the "session_id" field.
  27052. func (m *UsageDetailMutation) ResetSessionID() {
  27053. m.session_id = nil
  27054. m.addsession_id = nil
  27055. delete(m.clearedFields, usagedetail.FieldSessionID)
  27056. }
  27057. // SetRequest sets the "request" field.
  27058. func (m *UsageDetailMutation) SetRequest(s string) {
  27059. m.request = &s
  27060. }
  27061. // Request returns the value of the "request" field in the mutation.
  27062. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  27063. v := m.request
  27064. if v == nil {
  27065. return
  27066. }
  27067. return *v, true
  27068. }
  27069. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  27070. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27072. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  27073. if !m.op.Is(OpUpdateOne) {
  27074. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  27075. }
  27076. if m.id == nil || m.oldValue == nil {
  27077. return v, errors.New("OldRequest requires an ID field in the mutation")
  27078. }
  27079. oldValue, err := m.oldValue(ctx)
  27080. if err != nil {
  27081. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  27082. }
  27083. return oldValue.Request, nil
  27084. }
  27085. // ResetRequest resets all changes to the "request" field.
  27086. func (m *UsageDetailMutation) ResetRequest() {
  27087. m.request = nil
  27088. }
  27089. // SetResponse sets the "response" field.
  27090. func (m *UsageDetailMutation) SetResponse(s string) {
  27091. m.response = &s
  27092. }
  27093. // Response returns the value of the "response" field in the mutation.
  27094. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  27095. v := m.response
  27096. if v == nil {
  27097. return
  27098. }
  27099. return *v, true
  27100. }
  27101. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  27102. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27104. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  27105. if !m.op.Is(OpUpdateOne) {
  27106. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  27107. }
  27108. if m.id == nil || m.oldValue == nil {
  27109. return v, errors.New("OldResponse requires an ID field in the mutation")
  27110. }
  27111. oldValue, err := m.oldValue(ctx)
  27112. if err != nil {
  27113. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  27114. }
  27115. return oldValue.Response, nil
  27116. }
  27117. // ResetResponse resets all changes to the "response" field.
  27118. func (m *UsageDetailMutation) ResetResponse() {
  27119. m.response = nil
  27120. }
  27121. // SetOriginalData sets the "original_data" field.
  27122. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  27123. m.original_data = &ctd
  27124. }
  27125. // OriginalData returns the value of the "original_data" field in the mutation.
  27126. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  27127. v := m.original_data
  27128. if v == nil {
  27129. return
  27130. }
  27131. return *v, true
  27132. }
  27133. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  27134. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27136. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  27137. if !m.op.Is(OpUpdateOne) {
  27138. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  27139. }
  27140. if m.id == nil || m.oldValue == nil {
  27141. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  27142. }
  27143. oldValue, err := m.oldValue(ctx)
  27144. if err != nil {
  27145. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  27146. }
  27147. return oldValue.OriginalData, nil
  27148. }
  27149. // ResetOriginalData resets all changes to the "original_data" field.
  27150. func (m *UsageDetailMutation) ResetOriginalData() {
  27151. m.original_data = nil
  27152. }
  27153. // SetTotalTokens sets the "total_tokens" field.
  27154. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  27155. m.total_tokens = &u
  27156. m.addtotal_tokens = nil
  27157. }
  27158. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  27159. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  27160. v := m.total_tokens
  27161. if v == nil {
  27162. return
  27163. }
  27164. return *v, true
  27165. }
  27166. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  27167. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27168. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27169. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  27170. if !m.op.Is(OpUpdateOne) {
  27171. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  27172. }
  27173. if m.id == nil || m.oldValue == nil {
  27174. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  27175. }
  27176. oldValue, err := m.oldValue(ctx)
  27177. if err != nil {
  27178. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  27179. }
  27180. return oldValue.TotalTokens, nil
  27181. }
  27182. // AddTotalTokens adds u to the "total_tokens" field.
  27183. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  27184. if m.addtotal_tokens != nil {
  27185. *m.addtotal_tokens += u
  27186. } else {
  27187. m.addtotal_tokens = &u
  27188. }
  27189. }
  27190. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  27191. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  27192. v := m.addtotal_tokens
  27193. if v == nil {
  27194. return
  27195. }
  27196. return *v, true
  27197. }
  27198. // ClearTotalTokens clears the value of the "total_tokens" field.
  27199. func (m *UsageDetailMutation) ClearTotalTokens() {
  27200. m.total_tokens = nil
  27201. m.addtotal_tokens = nil
  27202. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  27203. }
  27204. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  27205. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  27206. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  27207. return ok
  27208. }
  27209. // ResetTotalTokens resets all changes to the "total_tokens" field.
  27210. func (m *UsageDetailMutation) ResetTotalTokens() {
  27211. m.total_tokens = nil
  27212. m.addtotal_tokens = nil
  27213. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  27214. }
  27215. // SetPromptTokens sets the "prompt_tokens" field.
  27216. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  27217. m.prompt_tokens = &u
  27218. m.addprompt_tokens = nil
  27219. }
  27220. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  27221. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  27222. v := m.prompt_tokens
  27223. if v == nil {
  27224. return
  27225. }
  27226. return *v, true
  27227. }
  27228. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  27229. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27231. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  27232. if !m.op.Is(OpUpdateOne) {
  27233. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  27234. }
  27235. if m.id == nil || m.oldValue == nil {
  27236. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  27237. }
  27238. oldValue, err := m.oldValue(ctx)
  27239. if err != nil {
  27240. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  27241. }
  27242. return oldValue.PromptTokens, nil
  27243. }
  27244. // AddPromptTokens adds u to the "prompt_tokens" field.
  27245. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  27246. if m.addprompt_tokens != nil {
  27247. *m.addprompt_tokens += u
  27248. } else {
  27249. m.addprompt_tokens = &u
  27250. }
  27251. }
  27252. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  27253. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  27254. v := m.addprompt_tokens
  27255. if v == nil {
  27256. return
  27257. }
  27258. return *v, true
  27259. }
  27260. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  27261. func (m *UsageDetailMutation) ClearPromptTokens() {
  27262. m.prompt_tokens = nil
  27263. m.addprompt_tokens = nil
  27264. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  27265. }
  27266. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  27267. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  27268. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  27269. return ok
  27270. }
  27271. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  27272. func (m *UsageDetailMutation) ResetPromptTokens() {
  27273. m.prompt_tokens = nil
  27274. m.addprompt_tokens = nil
  27275. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  27276. }
  27277. // SetCompletionTokens sets the "completion_tokens" field.
  27278. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  27279. m.completion_tokens = &u
  27280. m.addcompletion_tokens = nil
  27281. }
  27282. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  27283. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  27284. v := m.completion_tokens
  27285. if v == nil {
  27286. return
  27287. }
  27288. return *v, true
  27289. }
  27290. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  27291. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27292. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27293. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  27294. if !m.op.Is(OpUpdateOne) {
  27295. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  27296. }
  27297. if m.id == nil || m.oldValue == nil {
  27298. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  27299. }
  27300. oldValue, err := m.oldValue(ctx)
  27301. if err != nil {
  27302. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  27303. }
  27304. return oldValue.CompletionTokens, nil
  27305. }
  27306. // AddCompletionTokens adds u to the "completion_tokens" field.
  27307. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  27308. if m.addcompletion_tokens != nil {
  27309. *m.addcompletion_tokens += u
  27310. } else {
  27311. m.addcompletion_tokens = &u
  27312. }
  27313. }
  27314. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  27315. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  27316. v := m.addcompletion_tokens
  27317. if v == nil {
  27318. return
  27319. }
  27320. return *v, true
  27321. }
  27322. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  27323. func (m *UsageDetailMutation) ClearCompletionTokens() {
  27324. m.completion_tokens = nil
  27325. m.addcompletion_tokens = nil
  27326. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  27327. }
  27328. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  27329. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  27330. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  27331. return ok
  27332. }
  27333. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  27334. func (m *UsageDetailMutation) ResetCompletionTokens() {
  27335. m.completion_tokens = nil
  27336. m.addcompletion_tokens = nil
  27337. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  27338. }
  27339. // SetOrganizationID sets the "organization_id" field.
  27340. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  27341. m.organization_id = &u
  27342. m.addorganization_id = nil
  27343. }
  27344. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27345. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  27346. v := m.organization_id
  27347. if v == nil {
  27348. return
  27349. }
  27350. return *v, true
  27351. }
  27352. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  27353. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27355. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27356. if !m.op.Is(OpUpdateOne) {
  27357. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27358. }
  27359. if m.id == nil || m.oldValue == nil {
  27360. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27361. }
  27362. oldValue, err := m.oldValue(ctx)
  27363. if err != nil {
  27364. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27365. }
  27366. return oldValue.OrganizationID, nil
  27367. }
  27368. // AddOrganizationID adds u to the "organization_id" field.
  27369. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  27370. if m.addorganization_id != nil {
  27371. *m.addorganization_id += u
  27372. } else {
  27373. m.addorganization_id = &u
  27374. }
  27375. }
  27376. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27377. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  27378. v := m.addorganization_id
  27379. if v == nil {
  27380. return
  27381. }
  27382. return *v, true
  27383. }
  27384. // ClearOrganizationID clears the value of the "organization_id" field.
  27385. func (m *UsageDetailMutation) ClearOrganizationID() {
  27386. m.organization_id = nil
  27387. m.addorganization_id = nil
  27388. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  27389. }
  27390. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  27391. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  27392. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  27393. return ok
  27394. }
  27395. // ResetOrganizationID resets all changes to the "organization_id" field.
  27396. func (m *UsageDetailMutation) ResetOrganizationID() {
  27397. m.organization_id = nil
  27398. m.addorganization_id = nil
  27399. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  27400. }
  27401. // Where appends a list predicates to the UsageDetailMutation builder.
  27402. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  27403. m.predicates = append(m.predicates, ps...)
  27404. }
  27405. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  27406. // users can use type-assertion to append predicates that do not depend on any generated package.
  27407. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  27408. p := make([]predicate.UsageDetail, len(ps))
  27409. for i := range ps {
  27410. p[i] = ps[i]
  27411. }
  27412. m.Where(p...)
  27413. }
  27414. // Op returns the operation name.
  27415. func (m *UsageDetailMutation) Op() Op {
  27416. return m.op
  27417. }
  27418. // SetOp allows setting the mutation operation.
  27419. func (m *UsageDetailMutation) SetOp(op Op) {
  27420. m.op = op
  27421. }
  27422. // Type returns the node type of this mutation (UsageDetail).
  27423. func (m *UsageDetailMutation) Type() string {
  27424. return m.typ
  27425. }
  27426. // Fields returns all fields that were changed during this mutation. Note that in
  27427. // order to get all numeric fields that were incremented/decremented, call
  27428. // AddedFields().
  27429. func (m *UsageDetailMutation) Fields() []string {
  27430. fields := make([]string, 0, 15)
  27431. if m.created_at != nil {
  27432. fields = append(fields, usagedetail.FieldCreatedAt)
  27433. }
  27434. if m.updated_at != nil {
  27435. fields = append(fields, usagedetail.FieldUpdatedAt)
  27436. }
  27437. if m.status != nil {
  27438. fields = append(fields, usagedetail.FieldStatus)
  27439. }
  27440. if m._type != nil {
  27441. fields = append(fields, usagedetail.FieldType)
  27442. }
  27443. if m.bot_id != nil {
  27444. fields = append(fields, usagedetail.FieldBotID)
  27445. }
  27446. if m.receiver_id != nil {
  27447. fields = append(fields, usagedetail.FieldReceiverID)
  27448. }
  27449. if m.app != nil {
  27450. fields = append(fields, usagedetail.FieldApp)
  27451. }
  27452. if m.session_id != nil {
  27453. fields = append(fields, usagedetail.FieldSessionID)
  27454. }
  27455. if m.request != nil {
  27456. fields = append(fields, usagedetail.FieldRequest)
  27457. }
  27458. if m.response != nil {
  27459. fields = append(fields, usagedetail.FieldResponse)
  27460. }
  27461. if m.original_data != nil {
  27462. fields = append(fields, usagedetail.FieldOriginalData)
  27463. }
  27464. if m.total_tokens != nil {
  27465. fields = append(fields, usagedetail.FieldTotalTokens)
  27466. }
  27467. if m.prompt_tokens != nil {
  27468. fields = append(fields, usagedetail.FieldPromptTokens)
  27469. }
  27470. if m.completion_tokens != nil {
  27471. fields = append(fields, usagedetail.FieldCompletionTokens)
  27472. }
  27473. if m.organization_id != nil {
  27474. fields = append(fields, usagedetail.FieldOrganizationID)
  27475. }
  27476. return fields
  27477. }
  27478. // Field returns the value of a field with the given name. The second boolean
  27479. // return value indicates that this field was not set, or was not defined in the
  27480. // schema.
  27481. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  27482. switch name {
  27483. case usagedetail.FieldCreatedAt:
  27484. return m.CreatedAt()
  27485. case usagedetail.FieldUpdatedAt:
  27486. return m.UpdatedAt()
  27487. case usagedetail.FieldStatus:
  27488. return m.Status()
  27489. case usagedetail.FieldType:
  27490. return m.GetType()
  27491. case usagedetail.FieldBotID:
  27492. return m.BotID()
  27493. case usagedetail.FieldReceiverID:
  27494. return m.ReceiverID()
  27495. case usagedetail.FieldApp:
  27496. return m.App()
  27497. case usagedetail.FieldSessionID:
  27498. return m.SessionID()
  27499. case usagedetail.FieldRequest:
  27500. return m.Request()
  27501. case usagedetail.FieldResponse:
  27502. return m.Response()
  27503. case usagedetail.FieldOriginalData:
  27504. return m.OriginalData()
  27505. case usagedetail.FieldTotalTokens:
  27506. return m.TotalTokens()
  27507. case usagedetail.FieldPromptTokens:
  27508. return m.PromptTokens()
  27509. case usagedetail.FieldCompletionTokens:
  27510. return m.CompletionTokens()
  27511. case usagedetail.FieldOrganizationID:
  27512. return m.OrganizationID()
  27513. }
  27514. return nil, false
  27515. }
  27516. // OldField returns the old value of the field from the database. An error is
  27517. // returned if the mutation operation is not UpdateOne, or the query to the
  27518. // database failed.
  27519. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27520. switch name {
  27521. case usagedetail.FieldCreatedAt:
  27522. return m.OldCreatedAt(ctx)
  27523. case usagedetail.FieldUpdatedAt:
  27524. return m.OldUpdatedAt(ctx)
  27525. case usagedetail.FieldStatus:
  27526. return m.OldStatus(ctx)
  27527. case usagedetail.FieldType:
  27528. return m.OldType(ctx)
  27529. case usagedetail.FieldBotID:
  27530. return m.OldBotID(ctx)
  27531. case usagedetail.FieldReceiverID:
  27532. return m.OldReceiverID(ctx)
  27533. case usagedetail.FieldApp:
  27534. return m.OldApp(ctx)
  27535. case usagedetail.FieldSessionID:
  27536. return m.OldSessionID(ctx)
  27537. case usagedetail.FieldRequest:
  27538. return m.OldRequest(ctx)
  27539. case usagedetail.FieldResponse:
  27540. return m.OldResponse(ctx)
  27541. case usagedetail.FieldOriginalData:
  27542. return m.OldOriginalData(ctx)
  27543. case usagedetail.FieldTotalTokens:
  27544. return m.OldTotalTokens(ctx)
  27545. case usagedetail.FieldPromptTokens:
  27546. return m.OldPromptTokens(ctx)
  27547. case usagedetail.FieldCompletionTokens:
  27548. return m.OldCompletionTokens(ctx)
  27549. case usagedetail.FieldOrganizationID:
  27550. return m.OldOrganizationID(ctx)
  27551. }
  27552. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  27553. }
  27554. // SetField sets the value of a field with the given name. It returns an error if
  27555. // the field is not defined in the schema, or if the type mismatched the field
  27556. // type.
  27557. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  27558. switch name {
  27559. case usagedetail.FieldCreatedAt:
  27560. v, ok := value.(time.Time)
  27561. if !ok {
  27562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27563. }
  27564. m.SetCreatedAt(v)
  27565. return nil
  27566. case usagedetail.FieldUpdatedAt:
  27567. v, ok := value.(time.Time)
  27568. if !ok {
  27569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27570. }
  27571. m.SetUpdatedAt(v)
  27572. return nil
  27573. case usagedetail.FieldStatus:
  27574. v, ok := value.(uint8)
  27575. if !ok {
  27576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27577. }
  27578. m.SetStatus(v)
  27579. return nil
  27580. case usagedetail.FieldType:
  27581. v, ok := value.(int)
  27582. if !ok {
  27583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27584. }
  27585. m.SetType(v)
  27586. return nil
  27587. case usagedetail.FieldBotID:
  27588. v, ok := value.(string)
  27589. if !ok {
  27590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27591. }
  27592. m.SetBotID(v)
  27593. return nil
  27594. case usagedetail.FieldReceiverID:
  27595. v, ok := value.(string)
  27596. if !ok {
  27597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27598. }
  27599. m.SetReceiverID(v)
  27600. return nil
  27601. case usagedetail.FieldApp:
  27602. v, ok := value.(int)
  27603. if !ok {
  27604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27605. }
  27606. m.SetApp(v)
  27607. return nil
  27608. case usagedetail.FieldSessionID:
  27609. v, ok := value.(uint64)
  27610. if !ok {
  27611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27612. }
  27613. m.SetSessionID(v)
  27614. return nil
  27615. case usagedetail.FieldRequest:
  27616. v, ok := value.(string)
  27617. if !ok {
  27618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27619. }
  27620. m.SetRequest(v)
  27621. return nil
  27622. case usagedetail.FieldResponse:
  27623. v, ok := value.(string)
  27624. if !ok {
  27625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27626. }
  27627. m.SetResponse(v)
  27628. return nil
  27629. case usagedetail.FieldOriginalData:
  27630. v, ok := value.(custom_types.OriginalData)
  27631. if !ok {
  27632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27633. }
  27634. m.SetOriginalData(v)
  27635. return nil
  27636. case usagedetail.FieldTotalTokens:
  27637. v, ok := value.(uint64)
  27638. if !ok {
  27639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27640. }
  27641. m.SetTotalTokens(v)
  27642. return nil
  27643. case usagedetail.FieldPromptTokens:
  27644. v, ok := value.(uint64)
  27645. if !ok {
  27646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27647. }
  27648. m.SetPromptTokens(v)
  27649. return nil
  27650. case usagedetail.FieldCompletionTokens:
  27651. v, ok := value.(uint64)
  27652. if !ok {
  27653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27654. }
  27655. m.SetCompletionTokens(v)
  27656. return nil
  27657. case usagedetail.FieldOrganizationID:
  27658. v, ok := value.(uint64)
  27659. if !ok {
  27660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27661. }
  27662. m.SetOrganizationID(v)
  27663. return nil
  27664. }
  27665. return fmt.Errorf("unknown UsageDetail field %s", name)
  27666. }
  27667. // AddedFields returns all numeric fields that were incremented/decremented during
  27668. // this mutation.
  27669. func (m *UsageDetailMutation) AddedFields() []string {
  27670. var fields []string
  27671. if m.addstatus != nil {
  27672. fields = append(fields, usagedetail.FieldStatus)
  27673. }
  27674. if m.add_type != nil {
  27675. fields = append(fields, usagedetail.FieldType)
  27676. }
  27677. if m.addapp != nil {
  27678. fields = append(fields, usagedetail.FieldApp)
  27679. }
  27680. if m.addsession_id != nil {
  27681. fields = append(fields, usagedetail.FieldSessionID)
  27682. }
  27683. if m.addtotal_tokens != nil {
  27684. fields = append(fields, usagedetail.FieldTotalTokens)
  27685. }
  27686. if m.addprompt_tokens != nil {
  27687. fields = append(fields, usagedetail.FieldPromptTokens)
  27688. }
  27689. if m.addcompletion_tokens != nil {
  27690. fields = append(fields, usagedetail.FieldCompletionTokens)
  27691. }
  27692. if m.addorganization_id != nil {
  27693. fields = append(fields, usagedetail.FieldOrganizationID)
  27694. }
  27695. return fields
  27696. }
  27697. // AddedField returns the numeric value that was incremented/decremented on a field
  27698. // with the given name. The second boolean return value indicates that this field
  27699. // was not set, or was not defined in the schema.
  27700. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  27701. switch name {
  27702. case usagedetail.FieldStatus:
  27703. return m.AddedStatus()
  27704. case usagedetail.FieldType:
  27705. return m.AddedType()
  27706. case usagedetail.FieldApp:
  27707. return m.AddedApp()
  27708. case usagedetail.FieldSessionID:
  27709. return m.AddedSessionID()
  27710. case usagedetail.FieldTotalTokens:
  27711. return m.AddedTotalTokens()
  27712. case usagedetail.FieldPromptTokens:
  27713. return m.AddedPromptTokens()
  27714. case usagedetail.FieldCompletionTokens:
  27715. return m.AddedCompletionTokens()
  27716. case usagedetail.FieldOrganizationID:
  27717. return m.AddedOrganizationID()
  27718. }
  27719. return nil, false
  27720. }
  27721. // AddField adds the value to the field with the given name. It returns an error if
  27722. // the field is not defined in the schema, or if the type mismatched the field
  27723. // type.
  27724. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  27725. switch name {
  27726. case usagedetail.FieldStatus:
  27727. v, ok := value.(int8)
  27728. if !ok {
  27729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27730. }
  27731. m.AddStatus(v)
  27732. return nil
  27733. case usagedetail.FieldType:
  27734. v, ok := value.(int)
  27735. if !ok {
  27736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27737. }
  27738. m.AddType(v)
  27739. return nil
  27740. case usagedetail.FieldApp:
  27741. v, ok := value.(int)
  27742. if !ok {
  27743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27744. }
  27745. m.AddApp(v)
  27746. return nil
  27747. case usagedetail.FieldSessionID:
  27748. v, ok := value.(int64)
  27749. if !ok {
  27750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27751. }
  27752. m.AddSessionID(v)
  27753. return nil
  27754. case usagedetail.FieldTotalTokens:
  27755. v, ok := value.(int64)
  27756. if !ok {
  27757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27758. }
  27759. m.AddTotalTokens(v)
  27760. return nil
  27761. case usagedetail.FieldPromptTokens:
  27762. v, ok := value.(int64)
  27763. if !ok {
  27764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27765. }
  27766. m.AddPromptTokens(v)
  27767. return nil
  27768. case usagedetail.FieldCompletionTokens:
  27769. v, ok := value.(int64)
  27770. if !ok {
  27771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27772. }
  27773. m.AddCompletionTokens(v)
  27774. return nil
  27775. case usagedetail.FieldOrganizationID:
  27776. v, ok := value.(int64)
  27777. if !ok {
  27778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27779. }
  27780. m.AddOrganizationID(v)
  27781. return nil
  27782. }
  27783. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  27784. }
  27785. // ClearedFields returns all nullable fields that were cleared during this
  27786. // mutation.
  27787. func (m *UsageDetailMutation) ClearedFields() []string {
  27788. var fields []string
  27789. if m.FieldCleared(usagedetail.FieldStatus) {
  27790. fields = append(fields, usagedetail.FieldStatus)
  27791. }
  27792. if m.FieldCleared(usagedetail.FieldType) {
  27793. fields = append(fields, usagedetail.FieldType)
  27794. }
  27795. if m.FieldCleared(usagedetail.FieldApp) {
  27796. fields = append(fields, usagedetail.FieldApp)
  27797. }
  27798. if m.FieldCleared(usagedetail.FieldSessionID) {
  27799. fields = append(fields, usagedetail.FieldSessionID)
  27800. }
  27801. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  27802. fields = append(fields, usagedetail.FieldTotalTokens)
  27803. }
  27804. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  27805. fields = append(fields, usagedetail.FieldPromptTokens)
  27806. }
  27807. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  27808. fields = append(fields, usagedetail.FieldCompletionTokens)
  27809. }
  27810. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  27811. fields = append(fields, usagedetail.FieldOrganizationID)
  27812. }
  27813. return fields
  27814. }
  27815. // FieldCleared returns a boolean indicating if a field with the given name was
  27816. // cleared in this mutation.
  27817. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  27818. _, ok := m.clearedFields[name]
  27819. return ok
  27820. }
  27821. // ClearField clears the value of the field with the given name. It returns an
  27822. // error if the field is not defined in the schema.
  27823. func (m *UsageDetailMutation) ClearField(name string) error {
  27824. switch name {
  27825. case usagedetail.FieldStatus:
  27826. m.ClearStatus()
  27827. return nil
  27828. case usagedetail.FieldType:
  27829. m.ClearType()
  27830. return nil
  27831. case usagedetail.FieldApp:
  27832. m.ClearApp()
  27833. return nil
  27834. case usagedetail.FieldSessionID:
  27835. m.ClearSessionID()
  27836. return nil
  27837. case usagedetail.FieldTotalTokens:
  27838. m.ClearTotalTokens()
  27839. return nil
  27840. case usagedetail.FieldPromptTokens:
  27841. m.ClearPromptTokens()
  27842. return nil
  27843. case usagedetail.FieldCompletionTokens:
  27844. m.ClearCompletionTokens()
  27845. return nil
  27846. case usagedetail.FieldOrganizationID:
  27847. m.ClearOrganizationID()
  27848. return nil
  27849. }
  27850. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  27851. }
  27852. // ResetField resets all changes in the mutation for the field with the given name.
  27853. // It returns an error if the field is not defined in the schema.
  27854. func (m *UsageDetailMutation) ResetField(name string) error {
  27855. switch name {
  27856. case usagedetail.FieldCreatedAt:
  27857. m.ResetCreatedAt()
  27858. return nil
  27859. case usagedetail.FieldUpdatedAt:
  27860. m.ResetUpdatedAt()
  27861. return nil
  27862. case usagedetail.FieldStatus:
  27863. m.ResetStatus()
  27864. return nil
  27865. case usagedetail.FieldType:
  27866. m.ResetType()
  27867. return nil
  27868. case usagedetail.FieldBotID:
  27869. m.ResetBotID()
  27870. return nil
  27871. case usagedetail.FieldReceiverID:
  27872. m.ResetReceiverID()
  27873. return nil
  27874. case usagedetail.FieldApp:
  27875. m.ResetApp()
  27876. return nil
  27877. case usagedetail.FieldSessionID:
  27878. m.ResetSessionID()
  27879. return nil
  27880. case usagedetail.FieldRequest:
  27881. m.ResetRequest()
  27882. return nil
  27883. case usagedetail.FieldResponse:
  27884. m.ResetResponse()
  27885. return nil
  27886. case usagedetail.FieldOriginalData:
  27887. m.ResetOriginalData()
  27888. return nil
  27889. case usagedetail.FieldTotalTokens:
  27890. m.ResetTotalTokens()
  27891. return nil
  27892. case usagedetail.FieldPromptTokens:
  27893. m.ResetPromptTokens()
  27894. return nil
  27895. case usagedetail.FieldCompletionTokens:
  27896. m.ResetCompletionTokens()
  27897. return nil
  27898. case usagedetail.FieldOrganizationID:
  27899. m.ResetOrganizationID()
  27900. return nil
  27901. }
  27902. return fmt.Errorf("unknown UsageDetail field %s", name)
  27903. }
  27904. // AddedEdges returns all edge names that were set/added in this mutation.
  27905. func (m *UsageDetailMutation) AddedEdges() []string {
  27906. edges := make([]string, 0, 0)
  27907. return edges
  27908. }
  27909. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27910. // name in this mutation.
  27911. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  27912. return nil
  27913. }
  27914. // RemovedEdges returns all edge names that were removed in this mutation.
  27915. func (m *UsageDetailMutation) RemovedEdges() []string {
  27916. edges := make([]string, 0, 0)
  27917. return edges
  27918. }
  27919. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27920. // the given name in this mutation.
  27921. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  27922. return nil
  27923. }
  27924. // ClearedEdges returns all edge names that were cleared in this mutation.
  27925. func (m *UsageDetailMutation) ClearedEdges() []string {
  27926. edges := make([]string, 0, 0)
  27927. return edges
  27928. }
  27929. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27930. // was cleared in this mutation.
  27931. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  27932. return false
  27933. }
  27934. // ClearEdge clears the value of the edge with the given name. It returns an error
  27935. // if that edge is not defined in the schema.
  27936. func (m *UsageDetailMutation) ClearEdge(name string) error {
  27937. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  27938. }
  27939. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27940. // It returns an error if the edge is not defined in the schema.
  27941. func (m *UsageDetailMutation) ResetEdge(name string) error {
  27942. return fmt.Errorf("unknown UsageDetail edge %s", name)
  27943. }
  27944. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  27945. type UsageStatisticDayMutation struct {
  27946. config
  27947. op Op
  27948. typ string
  27949. id *uint64
  27950. created_at *time.Time
  27951. updated_at *time.Time
  27952. status *uint8
  27953. addstatus *int8
  27954. deleted_at *time.Time
  27955. addtime *uint64
  27956. addaddtime *int64
  27957. _type *int
  27958. add_type *int
  27959. bot_id *string
  27960. organization_id *uint64
  27961. addorganization_id *int64
  27962. ai_response *uint64
  27963. addai_response *int64
  27964. sop_run *uint64
  27965. addsop_run *int64
  27966. total_friend *uint64
  27967. addtotal_friend *int64
  27968. total_group *uint64
  27969. addtotal_group *int64
  27970. account_balance *uint64
  27971. addaccount_balance *int64
  27972. consume_token *uint64
  27973. addconsume_token *int64
  27974. active_user *uint64
  27975. addactive_user *int64
  27976. new_user *int64
  27977. addnew_user *int64
  27978. label_dist *[]custom_types.LabelDist
  27979. appendlabel_dist []custom_types.LabelDist
  27980. clearedFields map[string]struct{}
  27981. done bool
  27982. oldValue func(context.Context) (*UsageStatisticDay, error)
  27983. predicates []predicate.UsageStatisticDay
  27984. }
  27985. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  27986. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  27987. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  27988. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  27989. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  27990. m := &UsageStatisticDayMutation{
  27991. config: c,
  27992. op: op,
  27993. typ: TypeUsageStatisticDay,
  27994. clearedFields: make(map[string]struct{}),
  27995. }
  27996. for _, opt := range opts {
  27997. opt(m)
  27998. }
  27999. return m
  28000. }
  28001. // withUsageStatisticDayID sets the ID field of the mutation.
  28002. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  28003. return func(m *UsageStatisticDayMutation) {
  28004. var (
  28005. err error
  28006. once sync.Once
  28007. value *UsageStatisticDay
  28008. )
  28009. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  28010. once.Do(func() {
  28011. if m.done {
  28012. err = errors.New("querying old values post mutation is not allowed")
  28013. } else {
  28014. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  28015. }
  28016. })
  28017. return value, err
  28018. }
  28019. m.id = &id
  28020. }
  28021. }
  28022. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  28023. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  28024. return func(m *UsageStatisticDayMutation) {
  28025. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  28026. return node, nil
  28027. }
  28028. m.id = &node.ID
  28029. }
  28030. }
  28031. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28032. // executed in a transaction (ent.Tx), a transactional client is returned.
  28033. func (m UsageStatisticDayMutation) Client() *Client {
  28034. client := &Client{config: m.config}
  28035. client.init()
  28036. return client
  28037. }
  28038. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28039. // it returns an error otherwise.
  28040. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  28041. if _, ok := m.driver.(*txDriver); !ok {
  28042. return nil, errors.New("ent: mutation is not running in a transaction")
  28043. }
  28044. tx := &Tx{config: m.config}
  28045. tx.init()
  28046. return tx, nil
  28047. }
  28048. // SetID sets the value of the id field. Note that this
  28049. // operation is only accepted on creation of UsageStatisticDay entities.
  28050. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  28051. m.id = &id
  28052. }
  28053. // ID returns the ID value in the mutation. Note that the ID is only available
  28054. // if it was provided to the builder or after it was returned from the database.
  28055. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  28056. if m.id == nil {
  28057. return
  28058. }
  28059. return *m.id, true
  28060. }
  28061. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28062. // That means, if the mutation is applied within a transaction with an isolation level such
  28063. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28064. // or updated by the mutation.
  28065. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  28066. switch {
  28067. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28068. id, exists := m.ID()
  28069. if exists {
  28070. return []uint64{id}, nil
  28071. }
  28072. fallthrough
  28073. case m.op.Is(OpUpdate | OpDelete):
  28074. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  28075. default:
  28076. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28077. }
  28078. }
  28079. // SetCreatedAt sets the "created_at" field.
  28080. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  28081. m.created_at = &t
  28082. }
  28083. // CreatedAt returns the value of the "created_at" field in the mutation.
  28084. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  28085. v := m.created_at
  28086. if v == nil {
  28087. return
  28088. }
  28089. return *v, true
  28090. }
  28091. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  28092. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28093. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28094. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28095. if !m.op.Is(OpUpdateOne) {
  28096. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28097. }
  28098. if m.id == nil || m.oldValue == nil {
  28099. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28100. }
  28101. oldValue, err := m.oldValue(ctx)
  28102. if err != nil {
  28103. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28104. }
  28105. return oldValue.CreatedAt, nil
  28106. }
  28107. // ResetCreatedAt resets all changes to the "created_at" field.
  28108. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  28109. m.created_at = nil
  28110. }
  28111. // SetUpdatedAt sets the "updated_at" field.
  28112. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  28113. m.updated_at = &t
  28114. }
  28115. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28116. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  28117. v := m.updated_at
  28118. if v == nil {
  28119. return
  28120. }
  28121. return *v, true
  28122. }
  28123. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  28124. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28125. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28126. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28127. if !m.op.Is(OpUpdateOne) {
  28128. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28129. }
  28130. if m.id == nil || m.oldValue == nil {
  28131. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28132. }
  28133. oldValue, err := m.oldValue(ctx)
  28134. if err != nil {
  28135. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28136. }
  28137. return oldValue.UpdatedAt, nil
  28138. }
  28139. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28140. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  28141. m.updated_at = nil
  28142. }
  28143. // SetStatus sets the "status" field.
  28144. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  28145. m.status = &u
  28146. m.addstatus = nil
  28147. }
  28148. // Status returns the value of the "status" field in the mutation.
  28149. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  28150. v := m.status
  28151. if v == nil {
  28152. return
  28153. }
  28154. return *v, true
  28155. }
  28156. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  28157. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28159. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28160. if !m.op.Is(OpUpdateOne) {
  28161. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28162. }
  28163. if m.id == nil || m.oldValue == nil {
  28164. return v, errors.New("OldStatus requires an ID field in the mutation")
  28165. }
  28166. oldValue, err := m.oldValue(ctx)
  28167. if err != nil {
  28168. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28169. }
  28170. return oldValue.Status, nil
  28171. }
  28172. // AddStatus adds u to the "status" field.
  28173. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  28174. if m.addstatus != nil {
  28175. *m.addstatus += u
  28176. } else {
  28177. m.addstatus = &u
  28178. }
  28179. }
  28180. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28181. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  28182. v := m.addstatus
  28183. if v == nil {
  28184. return
  28185. }
  28186. return *v, true
  28187. }
  28188. // ClearStatus clears the value of the "status" field.
  28189. func (m *UsageStatisticDayMutation) ClearStatus() {
  28190. m.status = nil
  28191. m.addstatus = nil
  28192. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  28193. }
  28194. // StatusCleared returns if the "status" field was cleared in this mutation.
  28195. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  28196. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  28197. return ok
  28198. }
  28199. // ResetStatus resets all changes to the "status" field.
  28200. func (m *UsageStatisticDayMutation) ResetStatus() {
  28201. m.status = nil
  28202. m.addstatus = nil
  28203. delete(m.clearedFields, usagestatisticday.FieldStatus)
  28204. }
  28205. // SetDeletedAt sets the "deleted_at" field.
  28206. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  28207. m.deleted_at = &t
  28208. }
  28209. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28210. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  28211. v := m.deleted_at
  28212. if v == nil {
  28213. return
  28214. }
  28215. return *v, true
  28216. }
  28217. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  28218. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28220. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28221. if !m.op.Is(OpUpdateOne) {
  28222. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28223. }
  28224. if m.id == nil || m.oldValue == nil {
  28225. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28226. }
  28227. oldValue, err := m.oldValue(ctx)
  28228. if err != nil {
  28229. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28230. }
  28231. return oldValue.DeletedAt, nil
  28232. }
  28233. // ClearDeletedAt clears the value of the "deleted_at" field.
  28234. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  28235. m.deleted_at = nil
  28236. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  28237. }
  28238. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28239. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  28240. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  28241. return ok
  28242. }
  28243. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28244. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  28245. m.deleted_at = nil
  28246. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  28247. }
  28248. // SetAddtime sets the "addtime" field.
  28249. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  28250. m.addtime = &u
  28251. m.addaddtime = nil
  28252. }
  28253. // Addtime returns the value of the "addtime" field in the mutation.
  28254. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  28255. v := m.addtime
  28256. if v == nil {
  28257. return
  28258. }
  28259. return *v, true
  28260. }
  28261. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  28262. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28264. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  28265. if !m.op.Is(OpUpdateOne) {
  28266. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  28267. }
  28268. if m.id == nil || m.oldValue == nil {
  28269. return v, errors.New("OldAddtime requires an ID field in the mutation")
  28270. }
  28271. oldValue, err := m.oldValue(ctx)
  28272. if err != nil {
  28273. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  28274. }
  28275. return oldValue.Addtime, nil
  28276. }
  28277. // AddAddtime adds u to the "addtime" field.
  28278. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  28279. if m.addaddtime != nil {
  28280. *m.addaddtime += u
  28281. } else {
  28282. m.addaddtime = &u
  28283. }
  28284. }
  28285. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  28286. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  28287. v := m.addaddtime
  28288. if v == nil {
  28289. return
  28290. }
  28291. return *v, true
  28292. }
  28293. // ResetAddtime resets all changes to the "addtime" field.
  28294. func (m *UsageStatisticDayMutation) ResetAddtime() {
  28295. m.addtime = nil
  28296. m.addaddtime = nil
  28297. }
  28298. // SetType sets the "type" field.
  28299. func (m *UsageStatisticDayMutation) SetType(i int) {
  28300. m._type = &i
  28301. m.add_type = nil
  28302. }
  28303. // GetType returns the value of the "type" field in the mutation.
  28304. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  28305. v := m._type
  28306. if v == nil {
  28307. return
  28308. }
  28309. return *v, true
  28310. }
  28311. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  28312. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28314. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  28315. if !m.op.Is(OpUpdateOne) {
  28316. return v, errors.New("OldType is only allowed on UpdateOne operations")
  28317. }
  28318. if m.id == nil || m.oldValue == nil {
  28319. return v, errors.New("OldType requires an ID field in the mutation")
  28320. }
  28321. oldValue, err := m.oldValue(ctx)
  28322. if err != nil {
  28323. return v, fmt.Errorf("querying old value for OldType: %w", err)
  28324. }
  28325. return oldValue.Type, nil
  28326. }
  28327. // AddType adds i to the "type" field.
  28328. func (m *UsageStatisticDayMutation) AddType(i int) {
  28329. if m.add_type != nil {
  28330. *m.add_type += i
  28331. } else {
  28332. m.add_type = &i
  28333. }
  28334. }
  28335. // AddedType returns the value that was added to the "type" field in this mutation.
  28336. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  28337. v := m.add_type
  28338. if v == nil {
  28339. return
  28340. }
  28341. return *v, true
  28342. }
  28343. // ResetType resets all changes to the "type" field.
  28344. func (m *UsageStatisticDayMutation) ResetType() {
  28345. m._type = nil
  28346. m.add_type = nil
  28347. }
  28348. // SetBotID sets the "bot_id" field.
  28349. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  28350. m.bot_id = &s
  28351. }
  28352. // BotID returns the value of the "bot_id" field in the mutation.
  28353. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  28354. v := m.bot_id
  28355. if v == nil {
  28356. return
  28357. }
  28358. return *v, true
  28359. }
  28360. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  28361. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28363. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  28364. if !m.op.Is(OpUpdateOne) {
  28365. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  28366. }
  28367. if m.id == nil || m.oldValue == nil {
  28368. return v, errors.New("OldBotID requires an ID field in the mutation")
  28369. }
  28370. oldValue, err := m.oldValue(ctx)
  28371. if err != nil {
  28372. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  28373. }
  28374. return oldValue.BotID, nil
  28375. }
  28376. // ClearBotID clears the value of the "bot_id" field.
  28377. func (m *UsageStatisticDayMutation) ClearBotID() {
  28378. m.bot_id = nil
  28379. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  28380. }
  28381. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  28382. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  28383. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  28384. return ok
  28385. }
  28386. // ResetBotID resets all changes to the "bot_id" field.
  28387. func (m *UsageStatisticDayMutation) ResetBotID() {
  28388. m.bot_id = nil
  28389. delete(m.clearedFields, usagestatisticday.FieldBotID)
  28390. }
  28391. // SetOrganizationID sets the "organization_id" field.
  28392. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  28393. m.organization_id = &u
  28394. m.addorganization_id = nil
  28395. }
  28396. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28397. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  28398. v := m.organization_id
  28399. if v == nil {
  28400. return
  28401. }
  28402. return *v, true
  28403. }
  28404. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  28405. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28407. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28408. if !m.op.Is(OpUpdateOne) {
  28409. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28410. }
  28411. if m.id == nil || m.oldValue == nil {
  28412. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28413. }
  28414. oldValue, err := m.oldValue(ctx)
  28415. if err != nil {
  28416. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28417. }
  28418. return oldValue.OrganizationID, nil
  28419. }
  28420. // AddOrganizationID adds u to the "organization_id" field.
  28421. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  28422. if m.addorganization_id != nil {
  28423. *m.addorganization_id += u
  28424. } else {
  28425. m.addorganization_id = &u
  28426. }
  28427. }
  28428. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28429. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  28430. v := m.addorganization_id
  28431. if v == nil {
  28432. return
  28433. }
  28434. return *v, true
  28435. }
  28436. // ClearOrganizationID clears the value of the "organization_id" field.
  28437. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  28438. m.organization_id = nil
  28439. m.addorganization_id = nil
  28440. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  28441. }
  28442. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28443. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  28444. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  28445. return ok
  28446. }
  28447. // ResetOrganizationID resets all changes to the "organization_id" field.
  28448. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  28449. m.organization_id = nil
  28450. m.addorganization_id = nil
  28451. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  28452. }
  28453. // SetAiResponse sets the "ai_response" field.
  28454. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  28455. m.ai_response = &u
  28456. m.addai_response = nil
  28457. }
  28458. // AiResponse returns the value of the "ai_response" field in the mutation.
  28459. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  28460. v := m.ai_response
  28461. if v == nil {
  28462. return
  28463. }
  28464. return *v, true
  28465. }
  28466. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  28467. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28469. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  28470. if !m.op.Is(OpUpdateOne) {
  28471. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  28472. }
  28473. if m.id == nil || m.oldValue == nil {
  28474. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  28475. }
  28476. oldValue, err := m.oldValue(ctx)
  28477. if err != nil {
  28478. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  28479. }
  28480. return oldValue.AiResponse, nil
  28481. }
  28482. // AddAiResponse adds u to the "ai_response" field.
  28483. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  28484. if m.addai_response != nil {
  28485. *m.addai_response += u
  28486. } else {
  28487. m.addai_response = &u
  28488. }
  28489. }
  28490. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  28491. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  28492. v := m.addai_response
  28493. if v == nil {
  28494. return
  28495. }
  28496. return *v, true
  28497. }
  28498. // ResetAiResponse resets all changes to the "ai_response" field.
  28499. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  28500. m.ai_response = nil
  28501. m.addai_response = nil
  28502. }
  28503. // SetSopRun sets the "sop_run" field.
  28504. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  28505. m.sop_run = &u
  28506. m.addsop_run = nil
  28507. }
  28508. // SopRun returns the value of the "sop_run" field in the mutation.
  28509. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  28510. v := m.sop_run
  28511. if v == nil {
  28512. return
  28513. }
  28514. return *v, true
  28515. }
  28516. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  28517. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28519. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  28520. if !m.op.Is(OpUpdateOne) {
  28521. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  28522. }
  28523. if m.id == nil || m.oldValue == nil {
  28524. return v, errors.New("OldSopRun requires an ID field in the mutation")
  28525. }
  28526. oldValue, err := m.oldValue(ctx)
  28527. if err != nil {
  28528. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  28529. }
  28530. return oldValue.SopRun, nil
  28531. }
  28532. // AddSopRun adds u to the "sop_run" field.
  28533. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  28534. if m.addsop_run != nil {
  28535. *m.addsop_run += u
  28536. } else {
  28537. m.addsop_run = &u
  28538. }
  28539. }
  28540. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  28541. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  28542. v := m.addsop_run
  28543. if v == nil {
  28544. return
  28545. }
  28546. return *v, true
  28547. }
  28548. // ResetSopRun resets all changes to the "sop_run" field.
  28549. func (m *UsageStatisticDayMutation) ResetSopRun() {
  28550. m.sop_run = nil
  28551. m.addsop_run = nil
  28552. }
  28553. // SetTotalFriend sets the "total_friend" field.
  28554. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  28555. m.total_friend = &u
  28556. m.addtotal_friend = nil
  28557. }
  28558. // TotalFriend returns the value of the "total_friend" field in the mutation.
  28559. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  28560. v := m.total_friend
  28561. if v == nil {
  28562. return
  28563. }
  28564. return *v, true
  28565. }
  28566. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  28567. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28569. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  28570. if !m.op.Is(OpUpdateOne) {
  28571. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  28572. }
  28573. if m.id == nil || m.oldValue == nil {
  28574. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  28575. }
  28576. oldValue, err := m.oldValue(ctx)
  28577. if err != nil {
  28578. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  28579. }
  28580. return oldValue.TotalFriend, nil
  28581. }
  28582. // AddTotalFriend adds u to the "total_friend" field.
  28583. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  28584. if m.addtotal_friend != nil {
  28585. *m.addtotal_friend += u
  28586. } else {
  28587. m.addtotal_friend = &u
  28588. }
  28589. }
  28590. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  28591. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  28592. v := m.addtotal_friend
  28593. if v == nil {
  28594. return
  28595. }
  28596. return *v, true
  28597. }
  28598. // ResetTotalFriend resets all changes to the "total_friend" field.
  28599. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  28600. m.total_friend = nil
  28601. m.addtotal_friend = nil
  28602. }
  28603. // SetTotalGroup sets the "total_group" field.
  28604. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  28605. m.total_group = &u
  28606. m.addtotal_group = nil
  28607. }
  28608. // TotalGroup returns the value of the "total_group" field in the mutation.
  28609. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  28610. v := m.total_group
  28611. if v == nil {
  28612. return
  28613. }
  28614. return *v, true
  28615. }
  28616. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  28617. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28619. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  28620. if !m.op.Is(OpUpdateOne) {
  28621. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  28622. }
  28623. if m.id == nil || m.oldValue == nil {
  28624. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  28625. }
  28626. oldValue, err := m.oldValue(ctx)
  28627. if err != nil {
  28628. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  28629. }
  28630. return oldValue.TotalGroup, nil
  28631. }
  28632. // AddTotalGroup adds u to the "total_group" field.
  28633. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  28634. if m.addtotal_group != nil {
  28635. *m.addtotal_group += u
  28636. } else {
  28637. m.addtotal_group = &u
  28638. }
  28639. }
  28640. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  28641. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  28642. v := m.addtotal_group
  28643. if v == nil {
  28644. return
  28645. }
  28646. return *v, true
  28647. }
  28648. // ResetTotalGroup resets all changes to the "total_group" field.
  28649. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  28650. m.total_group = nil
  28651. m.addtotal_group = nil
  28652. }
  28653. // SetAccountBalance sets the "account_balance" field.
  28654. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  28655. m.account_balance = &u
  28656. m.addaccount_balance = nil
  28657. }
  28658. // AccountBalance returns the value of the "account_balance" field in the mutation.
  28659. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  28660. v := m.account_balance
  28661. if v == nil {
  28662. return
  28663. }
  28664. return *v, true
  28665. }
  28666. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  28667. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28669. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  28670. if !m.op.Is(OpUpdateOne) {
  28671. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  28672. }
  28673. if m.id == nil || m.oldValue == nil {
  28674. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  28675. }
  28676. oldValue, err := m.oldValue(ctx)
  28677. if err != nil {
  28678. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  28679. }
  28680. return oldValue.AccountBalance, nil
  28681. }
  28682. // AddAccountBalance adds u to the "account_balance" field.
  28683. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  28684. if m.addaccount_balance != nil {
  28685. *m.addaccount_balance += u
  28686. } else {
  28687. m.addaccount_balance = &u
  28688. }
  28689. }
  28690. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  28691. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  28692. v := m.addaccount_balance
  28693. if v == nil {
  28694. return
  28695. }
  28696. return *v, true
  28697. }
  28698. // ResetAccountBalance resets all changes to the "account_balance" field.
  28699. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  28700. m.account_balance = nil
  28701. m.addaccount_balance = nil
  28702. }
  28703. // SetConsumeToken sets the "consume_token" field.
  28704. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  28705. m.consume_token = &u
  28706. m.addconsume_token = nil
  28707. }
  28708. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  28709. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  28710. v := m.consume_token
  28711. if v == nil {
  28712. return
  28713. }
  28714. return *v, true
  28715. }
  28716. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  28717. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28718. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28719. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  28720. if !m.op.Is(OpUpdateOne) {
  28721. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  28722. }
  28723. if m.id == nil || m.oldValue == nil {
  28724. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  28725. }
  28726. oldValue, err := m.oldValue(ctx)
  28727. if err != nil {
  28728. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  28729. }
  28730. return oldValue.ConsumeToken, nil
  28731. }
  28732. // AddConsumeToken adds u to the "consume_token" field.
  28733. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  28734. if m.addconsume_token != nil {
  28735. *m.addconsume_token += u
  28736. } else {
  28737. m.addconsume_token = &u
  28738. }
  28739. }
  28740. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  28741. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  28742. v := m.addconsume_token
  28743. if v == nil {
  28744. return
  28745. }
  28746. return *v, true
  28747. }
  28748. // ResetConsumeToken resets all changes to the "consume_token" field.
  28749. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  28750. m.consume_token = nil
  28751. m.addconsume_token = nil
  28752. }
  28753. // SetActiveUser sets the "active_user" field.
  28754. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  28755. m.active_user = &u
  28756. m.addactive_user = nil
  28757. }
  28758. // ActiveUser returns the value of the "active_user" field in the mutation.
  28759. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  28760. v := m.active_user
  28761. if v == nil {
  28762. return
  28763. }
  28764. return *v, true
  28765. }
  28766. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  28767. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28768. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28769. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  28770. if !m.op.Is(OpUpdateOne) {
  28771. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  28772. }
  28773. if m.id == nil || m.oldValue == nil {
  28774. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  28775. }
  28776. oldValue, err := m.oldValue(ctx)
  28777. if err != nil {
  28778. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  28779. }
  28780. return oldValue.ActiveUser, nil
  28781. }
  28782. // AddActiveUser adds u to the "active_user" field.
  28783. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  28784. if m.addactive_user != nil {
  28785. *m.addactive_user += u
  28786. } else {
  28787. m.addactive_user = &u
  28788. }
  28789. }
  28790. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  28791. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  28792. v := m.addactive_user
  28793. if v == nil {
  28794. return
  28795. }
  28796. return *v, true
  28797. }
  28798. // ResetActiveUser resets all changes to the "active_user" field.
  28799. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  28800. m.active_user = nil
  28801. m.addactive_user = nil
  28802. }
  28803. // SetNewUser sets the "new_user" field.
  28804. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  28805. m.new_user = &i
  28806. m.addnew_user = nil
  28807. }
  28808. // NewUser returns the value of the "new_user" field in the mutation.
  28809. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  28810. v := m.new_user
  28811. if v == nil {
  28812. return
  28813. }
  28814. return *v, true
  28815. }
  28816. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  28817. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28819. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  28820. if !m.op.Is(OpUpdateOne) {
  28821. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  28822. }
  28823. if m.id == nil || m.oldValue == nil {
  28824. return v, errors.New("OldNewUser requires an ID field in the mutation")
  28825. }
  28826. oldValue, err := m.oldValue(ctx)
  28827. if err != nil {
  28828. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  28829. }
  28830. return oldValue.NewUser, nil
  28831. }
  28832. // AddNewUser adds i to the "new_user" field.
  28833. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  28834. if m.addnew_user != nil {
  28835. *m.addnew_user += i
  28836. } else {
  28837. m.addnew_user = &i
  28838. }
  28839. }
  28840. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  28841. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  28842. v := m.addnew_user
  28843. if v == nil {
  28844. return
  28845. }
  28846. return *v, true
  28847. }
  28848. // ResetNewUser resets all changes to the "new_user" field.
  28849. func (m *UsageStatisticDayMutation) ResetNewUser() {
  28850. m.new_user = nil
  28851. m.addnew_user = nil
  28852. }
  28853. // SetLabelDist sets the "label_dist" field.
  28854. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  28855. m.label_dist = &ctd
  28856. m.appendlabel_dist = nil
  28857. }
  28858. // LabelDist returns the value of the "label_dist" field in the mutation.
  28859. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  28860. v := m.label_dist
  28861. if v == nil {
  28862. return
  28863. }
  28864. return *v, true
  28865. }
  28866. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  28867. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28869. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  28870. if !m.op.Is(OpUpdateOne) {
  28871. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  28872. }
  28873. if m.id == nil || m.oldValue == nil {
  28874. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  28875. }
  28876. oldValue, err := m.oldValue(ctx)
  28877. if err != nil {
  28878. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  28879. }
  28880. return oldValue.LabelDist, nil
  28881. }
  28882. // AppendLabelDist adds ctd to the "label_dist" field.
  28883. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  28884. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  28885. }
  28886. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  28887. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  28888. if len(m.appendlabel_dist) == 0 {
  28889. return nil, false
  28890. }
  28891. return m.appendlabel_dist, true
  28892. }
  28893. // ResetLabelDist resets all changes to the "label_dist" field.
  28894. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  28895. m.label_dist = nil
  28896. m.appendlabel_dist = nil
  28897. }
  28898. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  28899. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  28900. m.predicates = append(m.predicates, ps...)
  28901. }
  28902. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  28903. // users can use type-assertion to append predicates that do not depend on any generated package.
  28904. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  28905. p := make([]predicate.UsageStatisticDay, len(ps))
  28906. for i := range ps {
  28907. p[i] = ps[i]
  28908. }
  28909. m.Where(p...)
  28910. }
  28911. // Op returns the operation name.
  28912. func (m *UsageStatisticDayMutation) Op() Op {
  28913. return m.op
  28914. }
  28915. // SetOp allows setting the mutation operation.
  28916. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  28917. m.op = op
  28918. }
  28919. // Type returns the node type of this mutation (UsageStatisticDay).
  28920. func (m *UsageStatisticDayMutation) Type() string {
  28921. return m.typ
  28922. }
  28923. // Fields returns all fields that were changed during this mutation. Note that in
  28924. // order to get all numeric fields that were incremented/decremented, call
  28925. // AddedFields().
  28926. func (m *UsageStatisticDayMutation) Fields() []string {
  28927. fields := make([]string, 0, 17)
  28928. if m.created_at != nil {
  28929. fields = append(fields, usagestatisticday.FieldCreatedAt)
  28930. }
  28931. if m.updated_at != nil {
  28932. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  28933. }
  28934. if m.status != nil {
  28935. fields = append(fields, usagestatisticday.FieldStatus)
  28936. }
  28937. if m.deleted_at != nil {
  28938. fields = append(fields, usagestatisticday.FieldDeletedAt)
  28939. }
  28940. if m.addtime != nil {
  28941. fields = append(fields, usagestatisticday.FieldAddtime)
  28942. }
  28943. if m._type != nil {
  28944. fields = append(fields, usagestatisticday.FieldType)
  28945. }
  28946. if m.bot_id != nil {
  28947. fields = append(fields, usagestatisticday.FieldBotID)
  28948. }
  28949. if m.organization_id != nil {
  28950. fields = append(fields, usagestatisticday.FieldOrganizationID)
  28951. }
  28952. if m.ai_response != nil {
  28953. fields = append(fields, usagestatisticday.FieldAiResponse)
  28954. }
  28955. if m.sop_run != nil {
  28956. fields = append(fields, usagestatisticday.FieldSopRun)
  28957. }
  28958. if m.total_friend != nil {
  28959. fields = append(fields, usagestatisticday.FieldTotalFriend)
  28960. }
  28961. if m.total_group != nil {
  28962. fields = append(fields, usagestatisticday.FieldTotalGroup)
  28963. }
  28964. if m.account_balance != nil {
  28965. fields = append(fields, usagestatisticday.FieldAccountBalance)
  28966. }
  28967. if m.consume_token != nil {
  28968. fields = append(fields, usagestatisticday.FieldConsumeToken)
  28969. }
  28970. if m.active_user != nil {
  28971. fields = append(fields, usagestatisticday.FieldActiveUser)
  28972. }
  28973. if m.new_user != nil {
  28974. fields = append(fields, usagestatisticday.FieldNewUser)
  28975. }
  28976. if m.label_dist != nil {
  28977. fields = append(fields, usagestatisticday.FieldLabelDist)
  28978. }
  28979. return fields
  28980. }
  28981. // Field returns the value of a field with the given name. The second boolean
  28982. // return value indicates that this field was not set, or was not defined in the
  28983. // schema.
  28984. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  28985. switch name {
  28986. case usagestatisticday.FieldCreatedAt:
  28987. return m.CreatedAt()
  28988. case usagestatisticday.FieldUpdatedAt:
  28989. return m.UpdatedAt()
  28990. case usagestatisticday.FieldStatus:
  28991. return m.Status()
  28992. case usagestatisticday.FieldDeletedAt:
  28993. return m.DeletedAt()
  28994. case usagestatisticday.FieldAddtime:
  28995. return m.Addtime()
  28996. case usagestatisticday.FieldType:
  28997. return m.GetType()
  28998. case usagestatisticday.FieldBotID:
  28999. return m.BotID()
  29000. case usagestatisticday.FieldOrganizationID:
  29001. return m.OrganizationID()
  29002. case usagestatisticday.FieldAiResponse:
  29003. return m.AiResponse()
  29004. case usagestatisticday.FieldSopRun:
  29005. return m.SopRun()
  29006. case usagestatisticday.FieldTotalFriend:
  29007. return m.TotalFriend()
  29008. case usagestatisticday.FieldTotalGroup:
  29009. return m.TotalGroup()
  29010. case usagestatisticday.FieldAccountBalance:
  29011. return m.AccountBalance()
  29012. case usagestatisticday.FieldConsumeToken:
  29013. return m.ConsumeToken()
  29014. case usagestatisticday.FieldActiveUser:
  29015. return m.ActiveUser()
  29016. case usagestatisticday.FieldNewUser:
  29017. return m.NewUser()
  29018. case usagestatisticday.FieldLabelDist:
  29019. return m.LabelDist()
  29020. }
  29021. return nil, false
  29022. }
  29023. // OldField returns the old value of the field from the database. An error is
  29024. // returned if the mutation operation is not UpdateOne, or the query to the
  29025. // database failed.
  29026. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29027. switch name {
  29028. case usagestatisticday.FieldCreatedAt:
  29029. return m.OldCreatedAt(ctx)
  29030. case usagestatisticday.FieldUpdatedAt:
  29031. return m.OldUpdatedAt(ctx)
  29032. case usagestatisticday.FieldStatus:
  29033. return m.OldStatus(ctx)
  29034. case usagestatisticday.FieldDeletedAt:
  29035. return m.OldDeletedAt(ctx)
  29036. case usagestatisticday.FieldAddtime:
  29037. return m.OldAddtime(ctx)
  29038. case usagestatisticday.FieldType:
  29039. return m.OldType(ctx)
  29040. case usagestatisticday.FieldBotID:
  29041. return m.OldBotID(ctx)
  29042. case usagestatisticday.FieldOrganizationID:
  29043. return m.OldOrganizationID(ctx)
  29044. case usagestatisticday.FieldAiResponse:
  29045. return m.OldAiResponse(ctx)
  29046. case usagestatisticday.FieldSopRun:
  29047. return m.OldSopRun(ctx)
  29048. case usagestatisticday.FieldTotalFriend:
  29049. return m.OldTotalFriend(ctx)
  29050. case usagestatisticday.FieldTotalGroup:
  29051. return m.OldTotalGroup(ctx)
  29052. case usagestatisticday.FieldAccountBalance:
  29053. return m.OldAccountBalance(ctx)
  29054. case usagestatisticday.FieldConsumeToken:
  29055. return m.OldConsumeToken(ctx)
  29056. case usagestatisticday.FieldActiveUser:
  29057. return m.OldActiveUser(ctx)
  29058. case usagestatisticday.FieldNewUser:
  29059. return m.OldNewUser(ctx)
  29060. case usagestatisticday.FieldLabelDist:
  29061. return m.OldLabelDist(ctx)
  29062. }
  29063. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29064. }
  29065. // SetField sets the value of a field with the given name. It returns an error if
  29066. // the field is not defined in the schema, or if the type mismatched the field
  29067. // type.
  29068. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  29069. switch name {
  29070. case usagestatisticday.FieldCreatedAt:
  29071. v, ok := value.(time.Time)
  29072. if !ok {
  29073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29074. }
  29075. m.SetCreatedAt(v)
  29076. return nil
  29077. case usagestatisticday.FieldUpdatedAt:
  29078. v, ok := value.(time.Time)
  29079. if !ok {
  29080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29081. }
  29082. m.SetUpdatedAt(v)
  29083. return nil
  29084. case usagestatisticday.FieldStatus:
  29085. v, ok := value.(uint8)
  29086. if !ok {
  29087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29088. }
  29089. m.SetStatus(v)
  29090. return nil
  29091. case usagestatisticday.FieldDeletedAt:
  29092. v, ok := value.(time.Time)
  29093. if !ok {
  29094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29095. }
  29096. m.SetDeletedAt(v)
  29097. return nil
  29098. case usagestatisticday.FieldAddtime:
  29099. v, ok := value.(uint64)
  29100. if !ok {
  29101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29102. }
  29103. m.SetAddtime(v)
  29104. return nil
  29105. case usagestatisticday.FieldType:
  29106. v, ok := value.(int)
  29107. if !ok {
  29108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29109. }
  29110. m.SetType(v)
  29111. return nil
  29112. case usagestatisticday.FieldBotID:
  29113. v, ok := value.(string)
  29114. if !ok {
  29115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29116. }
  29117. m.SetBotID(v)
  29118. return nil
  29119. case usagestatisticday.FieldOrganizationID:
  29120. v, ok := value.(uint64)
  29121. if !ok {
  29122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29123. }
  29124. m.SetOrganizationID(v)
  29125. return nil
  29126. case usagestatisticday.FieldAiResponse:
  29127. v, ok := value.(uint64)
  29128. if !ok {
  29129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29130. }
  29131. m.SetAiResponse(v)
  29132. return nil
  29133. case usagestatisticday.FieldSopRun:
  29134. v, ok := value.(uint64)
  29135. if !ok {
  29136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29137. }
  29138. m.SetSopRun(v)
  29139. return nil
  29140. case usagestatisticday.FieldTotalFriend:
  29141. v, ok := value.(uint64)
  29142. if !ok {
  29143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29144. }
  29145. m.SetTotalFriend(v)
  29146. return nil
  29147. case usagestatisticday.FieldTotalGroup:
  29148. v, ok := value.(uint64)
  29149. if !ok {
  29150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29151. }
  29152. m.SetTotalGroup(v)
  29153. return nil
  29154. case usagestatisticday.FieldAccountBalance:
  29155. v, ok := value.(uint64)
  29156. if !ok {
  29157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29158. }
  29159. m.SetAccountBalance(v)
  29160. return nil
  29161. case usagestatisticday.FieldConsumeToken:
  29162. v, ok := value.(uint64)
  29163. if !ok {
  29164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29165. }
  29166. m.SetConsumeToken(v)
  29167. return nil
  29168. case usagestatisticday.FieldActiveUser:
  29169. v, ok := value.(uint64)
  29170. if !ok {
  29171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29172. }
  29173. m.SetActiveUser(v)
  29174. return nil
  29175. case usagestatisticday.FieldNewUser:
  29176. v, ok := value.(int64)
  29177. if !ok {
  29178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29179. }
  29180. m.SetNewUser(v)
  29181. return nil
  29182. case usagestatisticday.FieldLabelDist:
  29183. v, ok := value.([]custom_types.LabelDist)
  29184. if !ok {
  29185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29186. }
  29187. m.SetLabelDist(v)
  29188. return nil
  29189. }
  29190. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29191. }
  29192. // AddedFields returns all numeric fields that were incremented/decremented during
  29193. // this mutation.
  29194. func (m *UsageStatisticDayMutation) AddedFields() []string {
  29195. var fields []string
  29196. if m.addstatus != nil {
  29197. fields = append(fields, usagestatisticday.FieldStatus)
  29198. }
  29199. if m.addaddtime != nil {
  29200. fields = append(fields, usagestatisticday.FieldAddtime)
  29201. }
  29202. if m.add_type != nil {
  29203. fields = append(fields, usagestatisticday.FieldType)
  29204. }
  29205. if m.addorganization_id != nil {
  29206. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29207. }
  29208. if m.addai_response != nil {
  29209. fields = append(fields, usagestatisticday.FieldAiResponse)
  29210. }
  29211. if m.addsop_run != nil {
  29212. fields = append(fields, usagestatisticday.FieldSopRun)
  29213. }
  29214. if m.addtotal_friend != nil {
  29215. fields = append(fields, usagestatisticday.FieldTotalFriend)
  29216. }
  29217. if m.addtotal_group != nil {
  29218. fields = append(fields, usagestatisticday.FieldTotalGroup)
  29219. }
  29220. if m.addaccount_balance != nil {
  29221. fields = append(fields, usagestatisticday.FieldAccountBalance)
  29222. }
  29223. if m.addconsume_token != nil {
  29224. fields = append(fields, usagestatisticday.FieldConsumeToken)
  29225. }
  29226. if m.addactive_user != nil {
  29227. fields = append(fields, usagestatisticday.FieldActiveUser)
  29228. }
  29229. if m.addnew_user != nil {
  29230. fields = append(fields, usagestatisticday.FieldNewUser)
  29231. }
  29232. return fields
  29233. }
  29234. // AddedField returns the numeric value that was incremented/decremented on a field
  29235. // with the given name. The second boolean return value indicates that this field
  29236. // was not set, or was not defined in the schema.
  29237. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  29238. switch name {
  29239. case usagestatisticday.FieldStatus:
  29240. return m.AddedStatus()
  29241. case usagestatisticday.FieldAddtime:
  29242. return m.AddedAddtime()
  29243. case usagestatisticday.FieldType:
  29244. return m.AddedType()
  29245. case usagestatisticday.FieldOrganizationID:
  29246. return m.AddedOrganizationID()
  29247. case usagestatisticday.FieldAiResponse:
  29248. return m.AddedAiResponse()
  29249. case usagestatisticday.FieldSopRun:
  29250. return m.AddedSopRun()
  29251. case usagestatisticday.FieldTotalFriend:
  29252. return m.AddedTotalFriend()
  29253. case usagestatisticday.FieldTotalGroup:
  29254. return m.AddedTotalGroup()
  29255. case usagestatisticday.FieldAccountBalance:
  29256. return m.AddedAccountBalance()
  29257. case usagestatisticday.FieldConsumeToken:
  29258. return m.AddedConsumeToken()
  29259. case usagestatisticday.FieldActiveUser:
  29260. return m.AddedActiveUser()
  29261. case usagestatisticday.FieldNewUser:
  29262. return m.AddedNewUser()
  29263. }
  29264. return nil, false
  29265. }
  29266. // AddField adds the value to the field with the given name. It returns an error if
  29267. // the field is not defined in the schema, or if the type mismatched the field
  29268. // type.
  29269. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  29270. switch name {
  29271. case usagestatisticday.FieldStatus:
  29272. v, ok := value.(int8)
  29273. if !ok {
  29274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29275. }
  29276. m.AddStatus(v)
  29277. return nil
  29278. case usagestatisticday.FieldAddtime:
  29279. v, ok := value.(int64)
  29280. if !ok {
  29281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29282. }
  29283. m.AddAddtime(v)
  29284. return nil
  29285. case usagestatisticday.FieldType:
  29286. v, ok := value.(int)
  29287. if !ok {
  29288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29289. }
  29290. m.AddType(v)
  29291. return nil
  29292. case usagestatisticday.FieldOrganizationID:
  29293. v, ok := value.(int64)
  29294. if !ok {
  29295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29296. }
  29297. m.AddOrganizationID(v)
  29298. return nil
  29299. case usagestatisticday.FieldAiResponse:
  29300. v, ok := value.(int64)
  29301. if !ok {
  29302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29303. }
  29304. m.AddAiResponse(v)
  29305. return nil
  29306. case usagestatisticday.FieldSopRun:
  29307. v, ok := value.(int64)
  29308. if !ok {
  29309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29310. }
  29311. m.AddSopRun(v)
  29312. return nil
  29313. case usagestatisticday.FieldTotalFriend:
  29314. v, ok := value.(int64)
  29315. if !ok {
  29316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29317. }
  29318. m.AddTotalFriend(v)
  29319. return nil
  29320. case usagestatisticday.FieldTotalGroup:
  29321. v, ok := value.(int64)
  29322. if !ok {
  29323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29324. }
  29325. m.AddTotalGroup(v)
  29326. return nil
  29327. case usagestatisticday.FieldAccountBalance:
  29328. v, ok := value.(int64)
  29329. if !ok {
  29330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29331. }
  29332. m.AddAccountBalance(v)
  29333. return nil
  29334. case usagestatisticday.FieldConsumeToken:
  29335. v, ok := value.(int64)
  29336. if !ok {
  29337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29338. }
  29339. m.AddConsumeToken(v)
  29340. return nil
  29341. case usagestatisticday.FieldActiveUser:
  29342. v, ok := value.(int64)
  29343. if !ok {
  29344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29345. }
  29346. m.AddActiveUser(v)
  29347. return nil
  29348. case usagestatisticday.FieldNewUser:
  29349. v, ok := value.(int64)
  29350. if !ok {
  29351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29352. }
  29353. m.AddNewUser(v)
  29354. return nil
  29355. }
  29356. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  29357. }
  29358. // ClearedFields returns all nullable fields that were cleared during this
  29359. // mutation.
  29360. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  29361. var fields []string
  29362. if m.FieldCleared(usagestatisticday.FieldStatus) {
  29363. fields = append(fields, usagestatisticday.FieldStatus)
  29364. }
  29365. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  29366. fields = append(fields, usagestatisticday.FieldDeletedAt)
  29367. }
  29368. if m.FieldCleared(usagestatisticday.FieldBotID) {
  29369. fields = append(fields, usagestatisticday.FieldBotID)
  29370. }
  29371. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  29372. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29373. }
  29374. return fields
  29375. }
  29376. // FieldCleared returns a boolean indicating if a field with the given name was
  29377. // cleared in this mutation.
  29378. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  29379. _, ok := m.clearedFields[name]
  29380. return ok
  29381. }
  29382. // ClearField clears the value of the field with the given name. It returns an
  29383. // error if the field is not defined in the schema.
  29384. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  29385. switch name {
  29386. case usagestatisticday.FieldStatus:
  29387. m.ClearStatus()
  29388. return nil
  29389. case usagestatisticday.FieldDeletedAt:
  29390. m.ClearDeletedAt()
  29391. return nil
  29392. case usagestatisticday.FieldBotID:
  29393. m.ClearBotID()
  29394. return nil
  29395. case usagestatisticday.FieldOrganizationID:
  29396. m.ClearOrganizationID()
  29397. return nil
  29398. }
  29399. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  29400. }
  29401. // ResetField resets all changes in the mutation for the field with the given name.
  29402. // It returns an error if the field is not defined in the schema.
  29403. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  29404. switch name {
  29405. case usagestatisticday.FieldCreatedAt:
  29406. m.ResetCreatedAt()
  29407. return nil
  29408. case usagestatisticday.FieldUpdatedAt:
  29409. m.ResetUpdatedAt()
  29410. return nil
  29411. case usagestatisticday.FieldStatus:
  29412. m.ResetStatus()
  29413. return nil
  29414. case usagestatisticday.FieldDeletedAt:
  29415. m.ResetDeletedAt()
  29416. return nil
  29417. case usagestatisticday.FieldAddtime:
  29418. m.ResetAddtime()
  29419. return nil
  29420. case usagestatisticday.FieldType:
  29421. m.ResetType()
  29422. return nil
  29423. case usagestatisticday.FieldBotID:
  29424. m.ResetBotID()
  29425. return nil
  29426. case usagestatisticday.FieldOrganizationID:
  29427. m.ResetOrganizationID()
  29428. return nil
  29429. case usagestatisticday.FieldAiResponse:
  29430. m.ResetAiResponse()
  29431. return nil
  29432. case usagestatisticday.FieldSopRun:
  29433. m.ResetSopRun()
  29434. return nil
  29435. case usagestatisticday.FieldTotalFriend:
  29436. m.ResetTotalFriend()
  29437. return nil
  29438. case usagestatisticday.FieldTotalGroup:
  29439. m.ResetTotalGroup()
  29440. return nil
  29441. case usagestatisticday.FieldAccountBalance:
  29442. m.ResetAccountBalance()
  29443. return nil
  29444. case usagestatisticday.FieldConsumeToken:
  29445. m.ResetConsumeToken()
  29446. return nil
  29447. case usagestatisticday.FieldActiveUser:
  29448. m.ResetActiveUser()
  29449. return nil
  29450. case usagestatisticday.FieldNewUser:
  29451. m.ResetNewUser()
  29452. return nil
  29453. case usagestatisticday.FieldLabelDist:
  29454. m.ResetLabelDist()
  29455. return nil
  29456. }
  29457. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29458. }
  29459. // AddedEdges returns all edge names that were set/added in this mutation.
  29460. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  29461. edges := make([]string, 0, 0)
  29462. return edges
  29463. }
  29464. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29465. // name in this mutation.
  29466. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  29467. return nil
  29468. }
  29469. // RemovedEdges returns all edge names that were removed in this mutation.
  29470. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  29471. edges := make([]string, 0, 0)
  29472. return edges
  29473. }
  29474. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29475. // the given name in this mutation.
  29476. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  29477. return nil
  29478. }
  29479. // ClearedEdges returns all edge names that were cleared in this mutation.
  29480. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  29481. edges := make([]string, 0, 0)
  29482. return edges
  29483. }
  29484. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29485. // was cleared in this mutation.
  29486. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  29487. return false
  29488. }
  29489. // ClearEdge clears the value of the edge with the given name. It returns an error
  29490. // if that edge is not defined in the schema.
  29491. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  29492. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  29493. }
  29494. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29495. // It returns an error if the edge is not defined in the schema.
  29496. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  29497. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  29498. }
  29499. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  29500. type UsageStatisticHourMutation struct {
  29501. config
  29502. op Op
  29503. typ string
  29504. id *uint64
  29505. created_at *time.Time
  29506. updated_at *time.Time
  29507. status *uint8
  29508. addstatus *int8
  29509. deleted_at *time.Time
  29510. addtime *uint64
  29511. addaddtime *int64
  29512. _type *int
  29513. add_type *int
  29514. bot_id *string
  29515. organization_id *uint64
  29516. addorganization_id *int64
  29517. ai_response *uint64
  29518. addai_response *int64
  29519. sop_run *uint64
  29520. addsop_run *int64
  29521. total_friend *uint64
  29522. addtotal_friend *int64
  29523. total_group *uint64
  29524. addtotal_group *int64
  29525. account_balance *uint64
  29526. addaccount_balance *int64
  29527. consume_token *uint64
  29528. addconsume_token *int64
  29529. active_user *uint64
  29530. addactive_user *int64
  29531. new_user *int64
  29532. addnew_user *int64
  29533. label_dist *[]custom_types.LabelDist
  29534. appendlabel_dist []custom_types.LabelDist
  29535. clearedFields map[string]struct{}
  29536. done bool
  29537. oldValue func(context.Context) (*UsageStatisticHour, error)
  29538. predicates []predicate.UsageStatisticHour
  29539. }
  29540. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  29541. // usagestatistichourOption allows management of the mutation configuration using functional options.
  29542. type usagestatistichourOption func(*UsageStatisticHourMutation)
  29543. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  29544. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  29545. m := &UsageStatisticHourMutation{
  29546. config: c,
  29547. op: op,
  29548. typ: TypeUsageStatisticHour,
  29549. clearedFields: make(map[string]struct{}),
  29550. }
  29551. for _, opt := range opts {
  29552. opt(m)
  29553. }
  29554. return m
  29555. }
  29556. // withUsageStatisticHourID sets the ID field of the mutation.
  29557. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  29558. return func(m *UsageStatisticHourMutation) {
  29559. var (
  29560. err error
  29561. once sync.Once
  29562. value *UsageStatisticHour
  29563. )
  29564. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  29565. once.Do(func() {
  29566. if m.done {
  29567. err = errors.New("querying old values post mutation is not allowed")
  29568. } else {
  29569. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  29570. }
  29571. })
  29572. return value, err
  29573. }
  29574. m.id = &id
  29575. }
  29576. }
  29577. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  29578. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  29579. return func(m *UsageStatisticHourMutation) {
  29580. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  29581. return node, nil
  29582. }
  29583. m.id = &node.ID
  29584. }
  29585. }
  29586. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29587. // executed in a transaction (ent.Tx), a transactional client is returned.
  29588. func (m UsageStatisticHourMutation) Client() *Client {
  29589. client := &Client{config: m.config}
  29590. client.init()
  29591. return client
  29592. }
  29593. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29594. // it returns an error otherwise.
  29595. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  29596. if _, ok := m.driver.(*txDriver); !ok {
  29597. return nil, errors.New("ent: mutation is not running in a transaction")
  29598. }
  29599. tx := &Tx{config: m.config}
  29600. tx.init()
  29601. return tx, nil
  29602. }
  29603. // SetID sets the value of the id field. Note that this
  29604. // operation is only accepted on creation of UsageStatisticHour entities.
  29605. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  29606. m.id = &id
  29607. }
  29608. // ID returns the ID value in the mutation. Note that the ID is only available
  29609. // if it was provided to the builder or after it was returned from the database.
  29610. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  29611. if m.id == nil {
  29612. return
  29613. }
  29614. return *m.id, true
  29615. }
  29616. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29617. // That means, if the mutation is applied within a transaction with an isolation level such
  29618. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29619. // or updated by the mutation.
  29620. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  29621. switch {
  29622. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29623. id, exists := m.ID()
  29624. if exists {
  29625. return []uint64{id}, nil
  29626. }
  29627. fallthrough
  29628. case m.op.Is(OpUpdate | OpDelete):
  29629. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  29630. default:
  29631. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29632. }
  29633. }
  29634. // SetCreatedAt sets the "created_at" field.
  29635. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  29636. m.created_at = &t
  29637. }
  29638. // CreatedAt returns the value of the "created_at" field in the mutation.
  29639. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  29640. v := m.created_at
  29641. if v == nil {
  29642. return
  29643. }
  29644. return *v, true
  29645. }
  29646. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  29647. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29649. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29650. if !m.op.Is(OpUpdateOne) {
  29651. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29652. }
  29653. if m.id == nil || m.oldValue == nil {
  29654. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29655. }
  29656. oldValue, err := m.oldValue(ctx)
  29657. if err != nil {
  29658. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29659. }
  29660. return oldValue.CreatedAt, nil
  29661. }
  29662. // ResetCreatedAt resets all changes to the "created_at" field.
  29663. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  29664. m.created_at = nil
  29665. }
  29666. // SetUpdatedAt sets the "updated_at" field.
  29667. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  29668. m.updated_at = &t
  29669. }
  29670. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29671. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  29672. v := m.updated_at
  29673. if v == nil {
  29674. return
  29675. }
  29676. return *v, true
  29677. }
  29678. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  29679. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29681. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29682. if !m.op.Is(OpUpdateOne) {
  29683. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29684. }
  29685. if m.id == nil || m.oldValue == nil {
  29686. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29687. }
  29688. oldValue, err := m.oldValue(ctx)
  29689. if err != nil {
  29690. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29691. }
  29692. return oldValue.UpdatedAt, nil
  29693. }
  29694. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29695. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  29696. m.updated_at = nil
  29697. }
  29698. // SetStatus sets the "status" field.
  29699. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  29700. m.status = &u
  29701. m.addstatus = nil
  29702. }
  29703. // Status returns the value of the "status" field in the mutation.
  29704. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  29705. v := m.status
  29706. if v == nil {
  29707. return
  29708. }
  29709. return *v, true
  29710. }
  29711. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  29712. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29714. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29715. if !m.op.Is(OpUpdateOne) {
  29716. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29717. }
  29718. if m.id == nil || m.oldValue == nil {
  29719. return v, errors.New("OldStatus requires an ID field in the mutation")
  29720. }
  29721. oldValue, err := m.oldValue(ctx)
  29722. if err != nil {
  29723. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29724. }
  29725. return oldValue.Status, nil
  29726. }
  29727. // AddStatus adds u to the "status" field.
  29728. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  29729. if m.addstatus != nil {
  29730. *m.addstatus += u
  29731. } else {
  29732. m.addstatus = &u
  29733. }
  29734. }
  29735. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29736. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  29737. v := m.addstatus
  29738. if v == nil {
  29739. return
  29740. }
  29741. return *v, true
  29742. }
  29743. // ClearStatus clears the value of the "status" field.
  29744. func (m *UsageStatisticHourMutation) ClearStatus() {
  29745. m.status = nil
  29746. m.addstatus = nil
  29747. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  29748. }
  29749. // StatusCleared returns if the "status" field was cleared in this mutation.
  29750. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  29751. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  29752. return ok
  29753. }
  29754. // ResetStatus resets all changes to the "status" field.
  29755. func (m *UsageStatisticHourMutation) ResetStatus() {
  29756. m.status = nil
  29757. m.addstatus = nil
  29758. delete(m.clearedFields, usagestatistichour.FieldStatus)
  29759. }
  29760. // SetDeletedAt sets the "deleted_at" field.
  29761. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  29762. m.deleted_at = &t
  29763. }
  29764. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29765. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  29766. v := m.deleted_at
  29767. if v == nil {
  29768. return
  29769. }
  29770. return *v, true
  29771. }
  29772. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  29773. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29774. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29775. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29776. if !m.op.Is(OpUpdateOne) {
  29777. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29778. }
  29779. if m.id == nil || m.oldValue == nil {
  29780. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29781. }
  29782. oldValue, err := m.oldValue(ctx)
  29783. if err != nil {
  29784. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29785. }
  29786. return oldValue.DeletedAt, nil
  29787. }
  29788. // ClearDeletedAt clears the value of the "deleted_at" field.
  29789. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  29790. m.deleted_at = nil
  29791. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  29792. }
  29793. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29794. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  29795. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  29796. return ok
  29797. }
  29798. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29799. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  29800. m.deleted_at = nil
  29801. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  29802. }
  29803. // SetAddtime sets the "addtime" field.
  29804. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  29805. m.addtime = &u
  29806. m.addaddtime = nil
  29807. }
  29808. // Addtime returns the value of the "addtime" field in the mutation.
  29809. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  29810. v := m.addtime
  29811. if v == nil {
  29812. return
  29813. }
  29814. return *v, true
  29815. }
  29816. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  29817. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29819. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  29820. if !m.op.Is(OpUpdateOne) {
  29821. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  29822. }
  29823. if m.id == nil || m.oldValue == nil {
  29824. return v, errors.New("OldAddtime requires an ID field in the mutation")
  29825. }
  29826. oldValue, err := m.oldValue(ctx)
  29827. if err != nil {
  29828. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  29829. }
  29830. return oldValue.Addtime, nil
  29831. }
  29832. // AddAddtime adds u to the "addtime" field.
  29833. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  29834. if m.addaddtime != nil {
  29835. *m.addaddtime += u
  29836. } else {
  29837. m.addaddtime = &u
  29838. }
  29839. }
  29840. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  29841. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  29842. v := m.addaddtime
  29843. if v == nil {
  29844. return
  29845. }
  29846. return *v, true
  29847. }
  29848. // ResetAddtime resets all changes to the "addtime" field.
  29849. func (m *UsageStatisticHourMutation) ResetAddtime() {
  29850. m.addtime = nil
  29851. m.addaddtime = nil
  29852. }
  29853. // SetType sets the "type" field.
  29854. func (m *UsageStatisticHourMutation) SetType(i int) {
  29855. m._type = &i
  29856. m.add_type = nil
  29857. }
  29858. // GetType returns the value of the "type" field in the mutation.
  29859. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  29860. v := m._type
  29861. if v == nil {
  29862. return
  29863. }
  29864. return *v, true
  29865. }
  29866. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  29867. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29869. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  29870. if !m.op.Is(OpUpdateOne) {
  29871. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29872. }
  29873. if m.id == nil || m.oldValue == nil {
  29874. return v, errors.New("OldType requires an ID field in the mutation")
  29875. }
  29876. oldValue, err := m.oldValue(ctx)
  29877. if err != nil {
  29878. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29879. }
  29880. return oldValue.Type, nil
  29881. }
  29882. // AddType adds i to the "type" field.
  29883. func (m *UsageStatisticHourMutation) AddType(i int) {
  29884. if m.add_type != nil {
  29885. *m.add_type += i
  29886. } else {
  29887. m.add_type = &i
  29888. }
  29889. }
  29890. // AddedType returns the value that was added to the "type" field in this mutation.
  29891. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  29892. v := m.add_type
  29893. if v == nil {
  29894. return
  29895. }
  29896. return *v, true
  29897. }
  29898. // ResetType resets all changes to the "type" field.
  29899. func (m *UsageStatisticHourMutation) ResetType() {
  29900. m._type = nil
  29901. m.add_type = nil
  29902. }
  29903. // SetBotID sets the "bot_id" field.
  29904. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  29905. m.bot_id = &s
  29906. }
  29907. // BotID returns the value of the "bot_id" field in the mutation.
  29908. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  29909. v := m.bot_id
  29910. if v == nil {
  29911. return
  29912. }
  29913. return *v, true
  29914. }
  29915. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  29916. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29918. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  29919. if !m.op.Is(OpUpdateOne) {
  29920. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  29921. }
  29922. if m.id == nil || m.oldValue == nil {
  29923. return v, errors.New("OldBotID requires an ID field in the mutation")
  29924. }
  29925. oldValue, err := m.oldValue(ctx)
  29926. if err != nil {
  29927. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  29928. }
  29929. return oldValue.BotID, nil
  29930. }
  29931. // ClearBotID clears the value of the "bot_id" field.
  29932. func (m *UsageStatisticHourMutation) ClearBotID() {
  29933. m.bot_id = nil
  29934. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  29935. }
  29936. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  29937. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  29938. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  29939. return ok
  29940. }
  29941. // ResetBotID resets all changes to the "bot_id" field.
  29942. func (m *UsageStatisticHourMutation) ResetBotID() {
  29943. m.bot_id = nil
  29944. delete(m.clearedFields, usagestatistichour.FieldBotID)
  29945. }
  29946. // SetOrganizationID sets the "organization_id" field.
  29947. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  29948. m.organization_id = &u
  29949. m.addorganization_id = nil
  29950. }
  29951. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29952. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  29953. v := m.organization_id
  29954. if v == nil {
  29955. return
  29956. }
  29957. return *v, true
  29958. }
  29959. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  29960. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29961. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29962. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29963. if !m.op.Is(OpUpdateOne) {
  29964. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29965. }
  29966. if m.id == nil || m.oldValue == nil {
  29967. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29968. }
  29969. oldValue, err := m.oldValue(ctx)
  29970. if err != nil {
  29971. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29972. }
  29973. return oldValue.OrganizationID, nil
  29974. }
  29975. // AddOrganizationID adds u to the "organization_id" field.
  29976. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  29977. if m.addorganization_id != nil {
  29978. *m.addorganization_id += u
  29979. } else {
  29980. m.addorganization_id = &u
  29981. }
  29982. }
  29983. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29984. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  29985. v := m.addorganization_id
  29986. if v == nil {
  29987. return
  29988. }
  29989. return *v, true
  29990. }
  29991. // ClearOrganizationID clears the value of the "organization_id" field.
  29992. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  29993. m.organization_id = nil
  29994. m.addorganization_id = nil
  29995. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  29996. }
  29997. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  29998. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  29999. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  30000. return ok
  30001. }
  30002. // ResetOrganizationID resets all changes to the "organization_id" field.
  30003. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  30004. m.organization_id = nil
  30005. m.addorganization_id = nil
  30006. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  30007. }
  30008. // SetAiResponse sets the "ai_response" field.
  30009. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  30010. m.ai_response = &u
  30011. m.addai_response = nil
  30012. }
  30013. // AiResponse returns the value of the "ai_response" field in the mutation.
  30014. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  30015. v := m.ai_response
  30016. if v == nil {
  30017. return
  30018. }
  30019. return *v, true
  30020. }
  30021. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  30022. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30023. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30024. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  30025. if !m.op.Is(OpUpdateOne) {
  30026. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  30027. }
  30028. if m.id == nil || m.oldValue == nil {
  30029. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  30030. }
  30031. oldValue, err := m.oldValue(ctx)
  30032. if err != nil {
  30033. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  30034. }
  30035. return oldValue.AiResponse, nil
  30036. }
  30037. // AddAiResponse adds u to the "ai_response" field.
  30038. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  30039. if m.addai_response != nil {
  30040. *m.addai_response += u
  30041. } else {
  30042. m.addai_response = &u
  30043. }
  30044. }
  30045. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  30046. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  30047. v := m.addai_response
  30048. if v == nil {
  30049. return
  30050. }
  30051. return *v, true
  30052. }
  30053. // ResetAiResponse resets all changes to the "ai_response" field.
  30054. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  30055. m.ai_response = nil
  30056. m.addai_response = nil
  30057. }
  30058. // SetSopRun sets the "sop_run" field.
  30059. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  30060. m.sop_run = &u
  30061. m.addsop_run = nil
  30062. }
  30063. // SopRun returns the value of the "sop_run" field in the mutation.
  30064. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  30065. v := m.sop_run
  30066. if v == nil {
  30067. return
  30068. }
  30069. return *v, true
  30070. }
  30071. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  30072. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30074. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  30075. if !m.op.Is(OpUpdateOne) {
  30076. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  30077. }
  30078. if m.id == nil || m.oldValue == nil {
  30079. return v, errors.New("OldSopRun requires an ID field in the mutation")
  30080. }
  30081. oldValue, err := m.oldValue(ctx)
  30082. if err != nil {
  30083. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  30084. }
  30085. return oldValue.SopRun, nil
  30086. }
  30087. // AddSopRun adds u to the "sop_run" field.
  30088. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  30089. if m.addsop_run != nil {
  30090. *m.addsop_run += u
  30091. } else {
  30092. m.addsop_run = &u
  30093. }
  30094. }
  30095. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  30096. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  30097. v := m.addsop_run
  30098. if v == nil {
  30099. return
  30100. }
  30101. return *v, true
  30102. }
  30103. // ResetSopRun resets all changes to the "sop_run" field.
  30104. func (m *UsageStatisticHourMutation) ResetSopRun() {
  30105. m.sop_run = nil
  30106. m.addsop_run = nil
  30107. }
  30108. // SetTotalFriend sets the "total_friend" field.
  30109. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  30110. m.total_friend = &u
  30111. m.addtotal_friend = nil
  30112. }
  30113. // TotalFriend returns the value of the "total_friend" field in the mutation.
  30114. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  30115. v := m.total_friend
  30116. if v == nil {
  30117. return
  30118. }
  30119. return *v, true
  30120. }
  30121. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  30122. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30124. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  30125. if !m.op.Is(OpUpdateOne) {
  30126. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  30127. }
  30128. if m.id == nil || m.oldValue == nil {
  30129. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  30130. }
  30131. oldValue, err := m.oldValue(ctx)
  30132. if err != nil {
  30133. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  30134. }
  30135. return oldValue.TotalFriend, nil
  30136. }
  30137. // AddTotalFriend adds u to the "total_friend" field.
  30138. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  30139. if m.addtotal_friend != nil {
  30140. *m.addtotal_friend += u
  30141. } else {
  30142. m.addtotal_friend = &u
  30143. }
  30144. }
  30145. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  30146. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  30147. v := m.addtotal_friend
  30148. if v == nil {
  30149. return
  30150. }
  30151. return *v, true
  30152. }
  30153. // ResetTotalFriend resets all changes to the "total_friend" field.
  30154. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  30155. m.total_friend = nil
  30156. m.addtotal_friend = nil
  30157. }
  30158. // SetTotalGroup sets the "total_group" field.
  30159. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  30160. m.total_group = &u
  30161. m.addtotal_group = nil
  30162. }
  30163. // TotalGroup returns the value of the "total_group" field in the mutation.
  30164. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  30165. v := m.total_group
  30166. if v == nil {
  30167. return
  30168. }
  30169. return *v, true
  30170. }
  30171. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  30172. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30174. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  30175. if !m.op.Is(OpUpdateOne) {
  30176. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  30177. }
  30178. if m.id == nil || m.oldValue == nil {
  30179. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  30180. }
  30181. oldValue, err := m.oldValue(ctx)
  30182. if err != nil {
  30183. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  30184. }
  30185. return oldValue.TotalGroup, nil
  30186. }
  30187. // AddTotalGroup adds u to the "total_group" field.
  30188. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  30189. if m.addtotal_group != nil {
  30190. *m.addtotal_group += u
  30191. } else {
  30192. m.addtotal_group = &u
  30193. }
  30194. }
  30195. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  30196. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  30197. v := m.addtotal_group
  30198. if v == nil {
  30199. return
  30200. }
  30201. return *v, true
  30202. }
  30203. // ResetTotalGroup resets all changes to the "total_group" field.
  30204. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  30205. m.total_group = nil
  30206. m.addtotal_group = nil
  30207. }
  30208. // SetAccountBalance sets the "account_balance" field.
  30209. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  30210. m.account_balance = &u
  30211. m.addaccount_balance = nil
  30212. }
  30213. // AccountBalance returns the value of the "account_balance" field in the mutation.
  30214. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  30215. v := m.account_balance
  30216. if v == nil {
  30217. return
  30218. }
  30219. return *v, true
  30220. }
  30221. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  30222. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30224. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  30225. if !m.op.Is(OpUpdateOne) {
  30226. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  30227. }
  30228. if m.id == nil || m.oldValue == nil {
  30229. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  30230. }
  30231. oldValue, err := m.oldValue(ctx)
  30232. if err != nil {
  30233. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  30234. }
  30235. return oldValue.AccountBalance, nil
  30236. }
  30237. // AddAccountBalance adds u to the "account_balance" field.
  30238. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  30239. if m.addaccount_balance != nil {
  30240. *m.addaccount_balance += u
  30241. } else {
  30242. m.addaccount_balance = &u
  30243. }
  30244. }
  30245. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  30246. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  30247. v := m.addaccount_balance
  30248. if v == nil {
  30249. return
  30250. }
  30251. return *v, true
  30252. }
  30253. // ResetAccountBalance resets all changes to the "account_balance" field.
  30254. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  30255. m.account_balance = nil
  30256. m.addaccount_balance = nil
  30257. }
  30258. // SetConsumeToken sets the "consume_token" field.
  30259. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  30260. m.consume_token = &u
  30261. m.addconsume_token = nil
  30262. }
  30263. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  30264. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  30265. v := m.consume_token
  30266. if v == nil {
  30267. return
  30268. }
  30269. return *v, true
  30270. }
  30271. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  30272. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30274. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  30275. if !m.op.Is(OpUpdateOne) {
  30276. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  30277. }
  30278. if m.id == nil || m.oldValue == nil {
  30279. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  30280. }
  30281. oldValue, err := m.oldValue(ctx)
  30282. if err != nil {
  30283. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  30284. }
  30285. return oldValue.ConsumeToken, nil
  30286. }
  30287. // AddConsumeToken adds u to the "consume_token" field.
  30288. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  30289. if m.addconsume_token != nil {
  30290. *m.addconsume_token += u
  30291. } else {
  30292. m.addconsume_token = &u
  30293. }
  30294. }
  30295. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  30296. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  30297. v := m.addconsume_token
  30298. if v == nil {
  30299. return
  30300. }
  30301. return *v, true
  30302. }
  30303. // ResetConsumeToken resets all changes to the "consume_token" field.
  30304. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  30305. m.consume_token = nil
  30306. m.addconsume_token = nil
  30307. }
  30308. // SetActiveUser sets the "active_user" field.
  30309. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  30310. m.active_user = &u
  30311. m.addactive_user = nil
  30312. }
  30313. // ActiveUser returns the value of the "active_user" field in the mutation.
  30314. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  30315. v := m.active_user
  30316. if v == nil {
  30317. return
  30318. }
  30319. return *v, true
  30320. }
  30321. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  30322. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30324. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  30325. if !m.op.Is(OpUpdateOne) {
  30326. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  30327. }
  30328. if m.id == nil || m.oldValue == nil {
  30329. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  30330. }
  30331. oldValue, err := m.oldValue(ctx)
  30332. if err != nil {
  30333. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  30334. }
  30335. return oldValue.ActiveUser, nil
  30336. }
  30337. // AddActiveUser adds u to the "active_user" field.
  30338. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  30339. if m.addactive_user != nil {
  30340. *m.addactive_user += u
  30341. } else {
  30342. m.addactive_user = &u
  30343. }
  30344. }
  30345. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  30346. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  30347. v := m.addactive_user
  30348. if v == nil {
  30349. return
  30350. }
  30351. return *v, true
  30352. }
  30353. // ResetActiveUser resets all changes to the "active_user" field.
  30354. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  30355. m.active_user = nil
  30356. m.addactive_user = nil
  30357. }
  30358. // SetNewUser sets the "new_user" field.
  30359. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  30360. m.new_user = &i
  30361. m.addnew_user = nil
  30362. }
  30363. // NewUser returns the value of the "new_user" field in the mutation.
  30364. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  30365. v := m.new_user
  30366. if v == nil {
  30367. return
  30368. }
  30369. return *v, true
  30370. }
  30371. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  30372. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30374. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  30375. if !m.op.Is(OpUpdateOne) {
  30376. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  30377. }
  30378. if m.id == nil || m.oldValue == nil {
  30379. return v, errors.New("OldNewUser requires an ID field in the mutation")
  30380. }
  30381. oldValue, err := m.oldValue(ctx)
  30382. if err != nil {
  30383. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  30384. }
  30385. return oldValue.NewUser, nil
  30386. }
  30387. // AddNewUser adds i to the "new_user" field.
  30388. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  30389. if m.addnew_user != nil {
  30390. *m.addnew_user += i
  30391. } else {
  30392. m.addnew_user = &i
  30393. }
  30394. }
  30395. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  30396. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  30397. v := m.addnew_user
  30398. if v == nil {
  30399. return
  30400. }
  30401. return *v, true
  30402. }
  30403. // ResetNewUser resets all changes to the "new_user" field.
  30404. func (m *UsageStatisticHourMutation) ResetNewUser() {
  30405. m.new_user = nil
  30406. m.addnew_user = nil
  30407. }
  30408. // SetLabelDist sets the "label_dist" field.
  30409. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  30410. m.label_dist = &ctd
  30411. m.appendlabel_dist = nil
  30412. }
  30413. // LabelDist returns the value of the "label_dist" field in the mutation.
  30414. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  30415. v := m.label_dist
  30416. if v == nil {
  30417. return
  30418. }
  30419. return *v, true
  30420. }
  30421. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  30422. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30424. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  30425. if !m.op.Is(OpUpdateOne) {
  30426. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  30427. }
  30428. if m.id == nil || m.oldValue == nil {
  30429. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  30430. }
  30431. oldValue, err := m.oldValue(ctx)
  30432. if err != nil {
  30433. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  30434. }
  30435. return oldValue.LabelDist, nil
  30436. }
  30437. // AppendLabelDist adds ctd to the "label_dist" field.
  30438. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  30439. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  30440. }
  30441. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  30442. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  30443. if len(m.appendlabel_dist) == 0 {
  30444. return nil, false
  30445. }
  30446. return m.appendlabel_dist, true
  30447. }
  30448. // ResetLabelDist resets all changes to the "label_dist" field.
  30449. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  30450. m.label_dist = nil
  30451. m.appendlabel_dist = nil
  30452. }
  30453. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  30454. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  30455. m.predicates = append(m.predicates, ps...)
  30456. }
  30457. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  30458. // users can use type-assertion to append predicates that do not depend on any generated package.
  30459. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  30460. p := make([]predicate.UsageStatisticHour, len(ps))
  30461. for i := range ps {
  30462. p[i] = ps[i]
  30463. }
  30464. m.Where(p...)
  30465. }
  30466. // Op returns the operation name.
  30467. func (m *UsageStatisticHourMutation) Op() Op {
  30468. return m.op
  30469. }
  30470. // SetOp allows setting the mutation operation.
  30471. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  30472. m.op = op
  30473. }
  30474. // Type returns the node type of this mutation (UsageStatisticHour).
  30475. func (m *UsageStatisticHourMutation) Type() string {
  30476. return m.typ
  30477. }
  30478. // Fields returns all fields that were changed during this mutation. Note that in
  30479. // order to get all numeric fields that were incremented/decremented, call
  30480. // AddedFields().
  30481. func (m *UsageStatisticHourMutation) Fields() []string {
  30482. fields := make([]string, 0, 17)
  30483. if m.created_at != nil {
  30484. fields = append(fields, usagestatistichour.FieldCreatedAt)
  30485. }
  30486. if m.updated_at != nil {
  30487. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  30488. }
  30489. if m.status != nil {
  30490. fields = append(fields, usagestatistichour.FieldStatus)
  30491. }
  30492. if m.deleted_at != nil {
  30493. fields = append(fields, usagestatistichour.FieldDeletedAt)
  30494. }
  30495. if m.addtime != nil {
  30496. fields = append(fields, usagestatistichour.FieldAddtime)
  30497. }
  30498. if m._type != nil {
  30499. fields = append(fields, usagestatistichour.FieldType)
  30500. }
  30501. if m.bot_id != nil {
  30502. fields = append(fields, usagestatistichour.FieldBotID)
  30503. }
  30504. if m.organization_id != nil {
  30505. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30506. }
  30507. if m.ai_response != nil {
  30508. fields = append(fields, usagestatistichour.FieldAiResponse)
  30509. }
  30510. if m.sop_run != nil {
  30511. fields = append(fields, usagestatistichour.FieldSopRun)
  30512. }
  30513. if m.total_friend != nil {
  30514. fields = append(fields, usagestatistichour.FieldTotalFriend)
  30515. }
  30516. if m.total_group != nil {
  30517. fields = append(fields, usagestatistichour.FieldTotalGroup)
  30518. }
  30519. if m.account_balance != nil {
  30520. fields = append(fields, usagestatistichour.FieldAccountBalance)
  30521. }
  30522. if m.consume_token != nil {
  30523. fields = append(fields, usagestatistichour.FieldConsumeToken)
  30524. }
  30525. if m.active_user != nil {
  30526. fields = append(fields, usagestatistichour.FieldActiveUser)
  30527. }
  30528. if m.new_user != nil {
  30529. fields = append(fields, usagestatistichour.FieldNewUser)
  30530. }
  30531. if m.label_dist != nil {
  30532. fields = append(fields, usagestatistichour.FieldLabelDist)
  30533. }
  30534. return fields
  30535. }
  30536. // Field returns the value of a field with the given name. The second boolean
  30537. // return value indicates that this field was not set, or was not defined in the
  30538. // schema.
  30539. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  30540. switch name {
  30541. case usagestatistichour.FieldCreatedAt:
  30542. return m.CreatedAt()
  30543. case usagestatistichour.FieldUpdatedAt:
  30544. return m.UpdatedAt()
  30545. case usagestatistichour.FieldStatus:
  30546. return m.Status()
  30547. case usagestatistichour.FieldDeletedAt:
  30548. return m.DeletedAt()
  30549. case usagestatistichour.FieldAddtime:
  30550. return m.Addtime()
  30551. case usagestatistichour.FieldType:
  30552. return m.GetType()
  30553. case usagestatistichour.FieldBotID:
  30554. return m.BotID()
  30555. case usagestatistichour.FieldOrganizationID:
  30556. return m.OrganizationID()
  30557. case usagestatistichour.FieldAiResponse:
  30558. return m.AiResponse()
  30559. case usagestatistichour.FieldSopRun:
  30560. return m.SopRun()
  30561. case usagestatistichour.FieldTotalFriend:
  30562. return m.TotalFriend()
  30563. case usagestatistichour.FieldTotalGroup:
  30564. return m.TotalGroup()
  30565. case usagestatistichour.FieldAccountBalance:
  30566. return m.AccountBalance()
  30567. case usagestatistichour.FieldConsumeToken:
  30568. return m.ConsumeToken()
  30569. case usagestatistichour.FieldActiveUser:
  30570. return m.ActiveUser()
  30571. case usagestatistichour.FieldNewUser:
  30572. return m.NewUser()
  30573. case usagestatistichour.FieldLabelDist:
  30574. return m.LabelDist()
  30575. }
  30576. return nil, false
  30577. }
  30578. // OldField returns the old value of the field from the database. An error is
  30579. // returned if the mutation operation is not UpdateOne, or the query to the
  30580. // database failed.
  30581. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30582. switch name {
  30583. case usagestatistichour.FieldCreatedAt:
  30584. return m.OldCreatedAt(ctx)
  30585. case usagestatistichour.FieldUpdatedAt:
  30586. return m.OldUpdatedAt(ctx)
  30587. case usagestatistichour.FieldStatus:
  30588. return m.OldStatus(ctx)
  30589. case usagestatistichour.FieldDeletedAt:
  30590. return m.OldDeletedAt(ctx)
  30591. case usagestatistichour.FieldAddtime:
  30592. return m.OldAddtime(ctx)
  30593. case usagestatistichour.FieldType:
  30594. return m.OldType(ctx)
  30595. case usagestatistichour.FieldBotID:
  30596. return m.OldBotID(ctx)
  30597. case usagestatistichour.FieldOrganizationID:
  30598. return m.OldOrganizationID(ctx)
  30599. case usagestatistichour.FieldAiResponse:
  30600. return m.OldAiResponse(ctx)
  30601. case usagestatistichour.FieldSopRun:
  30602. return m.OldSopRun(ctx)
  30603. case usagestatistichour.FieldTotalFriend:
  30604. return m.OldTotalFriend(ctx)
  30605. case usagestatistichour.FieldTotalGroup:
  30606. return m.OldTotalGroup(ctx)
  30607. case usagestatistichour.FieldAccountBalance:
  30608. return m.OldAccountBalance(ctx)
  30609. case usagestatistichour.FieldConsumeToken:
  30610. return m.OldConsumeToken(ctx)
  30611. case usagestatistichour.FieldActiveUser:
  30612. return m.OldActiveUser(ctx)
  30613. case usagestatistichour.FieldNewUser:
  30614. return m.OldNewUser(ctx)
  30615. case usagestatistichour.FieldLabelDist:
  30616. return m.OldLabelDist(ctx)
  30617. }
  30618. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  30619. }
  30620. // SetField sets the value of a field with the given name. It returns an error if
  30621. // the field is not defined in the schema, or if the type mismatched the field
  30622. // type.
  30623. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  30624. switch name {
  30625. case usagestatistichour.FieldCreatedAt:
  30626. v, ok := value.(time.Time)
  30627. if !ok {
  30628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30629. }
  30630. m.SetCreatedAt(v)
  30631. return nil
  30632. case usagestatistichour.FieldUpdatedAt:
  30633. v, ok := value.(time.Time)
  30634. if !ok {
  30635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30636. }
  30637. m.SetUpdatedAt(v)
  30638. return nil
  30639. case usagestatistichour.FieldStatus:
  30640. v, ok := value.(uint8)
  30641. if !ok {
  30642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30643. }
  30644. m.SetStatus(v)
  30645. return nil
  30646. case usagestatistichour.FieldDeletedAt:
  30647. v, ok := value.(time.Time)
  30648. if !ok {
  30649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30650. }
  30651. m.SetDeletedAt(v)
  30652. return nil
  30653. case usagestatistichour.FieldAddtime:
  30654. v, ok := value.(uint64)
  30655. if !ok {
  30656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30657. }
  30658. m.SetAddtime(v)
  30659. return nil
  30660. case usagestatistichour.FieldType:
  30661. v, ok := value.(int)
  30662. if !ok {
  30663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30664. }
  30665. m.SetType(v)
  30666. return nil
  30667. case usagestatistichour.FieldBotID:
  30668. v, ok := value.(string)
  30669. if !ok {
  30670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30671. }
  30672. m.SetBotID(v)
  30673. return nil
  30674. case usagestatistichour.FieldOrganizationID:
  30675. v, ok := value.(uint64)
  30676. if !ok {
  30677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30678. }
  30679. m.SetOrganizationID(v)
  30680. return nil
  30681. case usagestatistichour.FieldAiResponse:
  30682. v, ok := value.(uint64)
  30683. if !ok {
  30684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30685. }
  30686. m.SetAiResponse(v)
  30687. return nil
  30688. case usagestatistichour.FieldSopRun:
  30689. v, ok := value.(uint64)
  30690. if !ok {
  30691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30692. }
  30693. m.SetSopRun(v)
  30694. return nil
  30695. case usagestatistichour.FieldTotalFriend:
  30696. v, ok := value.(uint64)
  30697. if !ok {
  30698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30699. }
  30700. m.SetTotalFriend(v)
  30701. return nil
  30702. case usagestatistichour.FieldTotalGroup:
  30703. v, ok := value.(uint64)
  30704. if !ok {
  30705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30706. }
  30707. m.SetTotalGroup(v)
  30708. return nil
  30709. case usagestatistichour.FieldAccountBalance:
  30710. v, ok := value.(uint64)
  30711. if !ok {
  30712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30713. }
  30714. m.SetAccountBalance(v)
  30715. return nil
  30716. case usagestatistichour.FieldConsumeToken:
  30717. v, ok := value.(uint64)
  30718. if !ok {
  30719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30720. }
  30721. m.SetConsumeToken(v)
  30722. return nil
  30723. case usagestatistichour.FieldActiveUser:
  30724. v, ok := value.(uint64)
  30725. if !ok {
  30726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30727. }
  30728. m.SetActiveUser(v)
  30729. return nil
  30730. case usagestatistichour.FieldNewUser:
  30731. v, ok := value.(int64)
  30732. if !ok {
  30733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30734. }
  30735. m.SetNewUser(v)
  30736. return nil
  30737. case usagestatistichour.FieldLabelDist:
  30738. v, ok := value.([]custom_types.LabelDist)
  30739. if !ok {
  30740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30741. }
  30742. m.SetLabelDist(v)
  30743. return nil
  30744. }
  30745. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  30746. }
  30747. // AddedFields returns all numeric fields that were incremented/decremented during
  30748. // this mutation.
  30749. func (m *UsageStatisticHourMutation) AddedFields() []string {
  30750. var fields []string
  30751. if m.addstatus != nil {
  30752. fields = append(fields, usagestatistichour.FieldStatus)
  30753. }
  30754. if m.addaddtime != nil {
  30755. fields = append(fields, usagestatistichour.FieldAddtime)
  30756. }
  30757. if m.add_type != nil {
  30758. fields = append(fields, usagestatistichour.FieldType)
  30759. }
  30760. if m.addorganization_id != nil {
  30761. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30762. }
  30763. if m.addai_response != nil {
  30764. fields = append(fields, usagestatistichour.FieldAiResponse)
  30765. }
  30766. if m.addsop_run != nil {
  30767. fields = append(fields, usagestatistichour.FieldSopRun)
  30768. }
  30769. if m.addtotal_friend != nil {
  30770. fields = append(fields, usagestatistichour.FieldTotalFriend)
  30771. }
  30772. if m.addtotal_group != nil {
  30773. fields = append(fields, usagestatistichour.FieldTotalGroup)
  30774. }
  30775. if m.addaccount_balance != nil {
  30776. fields = append(fields, usagestatistichour.FieldAccountBalance)
  30777. }
  30778. if m.addconsume_token != nil {
  30779. fields = append(fields, usagestatistichour.FieldConsumeToken)
  30780. }
  30781. if m.addactive_user != nil {
  30782. fields = append(fields, usagestatistichour.FieldActiveUser)
  30783. }
  30784. if m.addnew_user != nil {
  30785. fields = append(fields, usagestatistichour.FieldNewUser)
  30786. }
  30787. return fields
  30788. }
  30789. // AddedField returns the numeric value that was incremented/decremented on a field
  30790. // with the given name. The second boolean return value indicates that this field
  30791. // was not set, or was not defined in the schema.
  30792. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  30793. switch name {
  30794. case usagestatistichour.FieldStatus:
  30795. return m.AddedStatus()
  30796. case usagestatistichour.FieldAddtime:
  30797. return m.AddedAddtime()
  30798. case usagestatistichour.FieldType:
  30799. return m.AddedType()
  30800. case usagestatistichour.FieldOrganizationID:
  30801. return m.AddedOrganizationID()
  30802. case usagestatistichour.FieldAiResponse:
  30803. return m.AddedAiResponse()
  30804. case usagestatistichour.FieldSopRun:
  30805. return m.AddedSopRun()
  30806. case usagestatistichour.FieldTotalFriend:
  30807. return m.AddedTotalFriend()
  30808. case usagestatistichour.FieldTotalGroup:
  30809. return m.AddedTotalGroup()
  30810. case usagestatistichour.FieldAccountBalance:
  30811. return m.AddedAccountBalance()
  30812. case usagestatistichour.FieldConsumeToken:
  30813. return m.AddedConsumeToken()
  30814. case usagestatistichour.FieldActiveUser:
  30815. return m.AddedActiveUser()
  30816. case usagestatistichour.FieldNewUser:
  30817. return m.AddedNewUser()
  30818. }
  30819. return nil, false
  30820. }
  30821. // AddField adds the value to the field with the given name. It returns an error if
  30822. // the field is not defined in the schema, or if the type mismatched the field
  30823. // type.
  30824. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  30825. switch name {
  30826. case usagestatistichour.FieldStatus:
  30827. v, ok := value.(int8)
  30828. if !ok {
  30829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30830. }
  30831. m.AddStatus(v)
  30832. return nil
  30833. case usagestatistichour.FieldAddtime:
  30834. v, ok := value.(int64)
  30835. if !ok {
  30836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30837. }
  30838. m.AddAddtime(v)
  30839. return nil
  30840. case usagestatistichour.FieldType:
  30841. v, ok := value.(int)
  30842. if !ok {
  30843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30844. }
  30845. m.AddType(v)
  30846. return nil
  30847. case usagestatistichour.FieldOrganizationID:
  30848. v, ok := value.(int64)
  30849. if !ok {
  30850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30851. }
  30852. m.AddOrganizationID(v)
  30853. return nil
  30854. case usagestatistichour.FieldAiResponse:
  30855. v, ok := value.(int64)
  30856. if !ok {
  30857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30858. }
  30859. m.AddAiResponse(v)
  30860. return nil
  30861. case usagestatistichour.FieldSopRun:
  30862. v, ok := value.(int64)
  30863. if !ok {
  30864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30865. }
  30866. m.AddSopRun(v)
  30867. return nil
  30868. case usagestatistichour.FieldTotalFriend:
  30869. v, ok := value.(int64)
  30870. if !ok {
  30871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30872. }
  30873. m.AddTotalFriend(v)
  30874. return nil
  30875. case usagestatistichour.FieldTotalGroup:
  30876. v, ok := value.(int64)
  30877. if !ok {
  30878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30879. }
  30880. m.AddTotalGroup(v)
  30881. return nil
  30882. case usagestatistichour.FieldAccountBalance:
  30883. v, ok := value.(int64)
  30884. if !ok {
  30885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30886. }
  30887. m.AddAccountBalance(v)
  30888. return nil
  30889. case usagestatistichour.FieldConsumeToken:
  30890. v, ok := value.(int64)
  30891. if !ok {
  30892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30893. }
  30894. m.AddConsumeToken(v)
  30895. return nil
  30896. case usagestatistichour.FieldActiveUser:
  30897. v, ok := value.(int64)
  30898. if !ok {
  30899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30900. }
  30901. m.AddActiveUser(v)
  30902. return nil
  30903. case usagestatistichour.FieldNewUser:
  30904. v, ok := value.(int64)
  30905. if !ok {
  30906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30907. }
  30908. m.AddNewUser(v)
  30909. return nil
  30910. }
  30911. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  30912. }
  30913. // ClearedFields returns all nullable fields that were cleared during this
  30914. // mutation.
  30915. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  30916. var fields []string
  30917. if m.FieldCleared(usagestatistichour.FieldStatus) {
  30918. fields = append(fields, usagestatistichour.FieldStatus)
  30919. }
  30920. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  30921. fields = append(fields, usagestatistichour.FieldDeletedAt)
  30922. }
  30923. if m.FieldCleared(usagestatistichour.FieldBotID) {
  30924. fields = append(fields, usagestatistichour.FieldBotID)
  30925. }
  30926. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  30927. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30928. }
  30929. return fields
  30930. }
  30931. // FieldCleared returns a boolean indicating if a field with the given name was
  30932. // cleared in this mutation.
  30933. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  30934. _, ok := m.clearedFields[name]
  30935. return ok
  30936. }
  30937. // ClearField clears the value of the field with the given name. It returns an
  30938. // error if the field is not defined in the schema.
  30939. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  30940. switch name {
  30941. case usagestatistichour.FieldStatus:
  30942. m.ClearStatus()
  30943. return nil
  30944. case usagestatistichour.FieldDeletedAt:
  30945. m.ClearDeletedAt()
  30946. return nil
  30947. case usagestatistichour.FieldBotID:
  30948. m.ClearBotID()
  30949. return nil
  30950. case usagestatistichour.FieldOrganizationID:
  30951. m.ClearOrganizationID()
  30952. return nil
  30953. }
  30954. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  30955. }
  30956. // ResetField resets all changes in the mutation for the field with the given name.
  30957. // It returns an error if the field is not defined in the schema.
  30958. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  30959. switch name {
  30960. case usagestatistichour.FieldCreatedAt:
  30961. m.ResetCreatedAt()
  30962. return nil
  30963. case usagestatistichour.FieldUpdatedAt:
  30964. m.ResetUpdatedAt()
  30965. return nil
  30966. case usagestatistichour.FieldStatus:
  30967. m.ResetStatus()
  30968. return nil
  30969. case usagestatistichour.FieldDeletedAt:
  30970. m.ResetDeletedAt()
  30971. return nil
  30972. case usagestatistichour.FieldAddtime:
  30973. m.ResetAddtime()
  30974. return nil
  30975. case usagestatistichour.FieldType:
  30976. m.ResetType()
  30977. return nil
  30978. case usagestatistichour.FieldBotID:
  30979. m.ResetBotID()
  30980. return nil
  30981. case usagestatistichour.FieldOrganizationID:
  30982. m.ResetOrganizationID()
  30983. return nil
  30984. case usagestatistichour.FieldAiResponse:
  30985. m.ResetAiResponse()
  30986. return nil
  30987. case usagestatistichour.FieldSopRun:
  30988. m.ResetSopRun()
  30989. return nil
  30990. case usagestatistichour.FieldTotalFriend:
  30991. m.ResetTotalFriend()
  30992. return nil
  30993. case usagestatistichour.FieldTotalGroup:
  30994. m.ResetTotalGroup()
  30995. return nil
  30996. case usagestatistichour.FieldAccountBalance:
  30997. m.ResetAccountBalance()
  30998. return nil
  30999. case usagestatistichour.FieldConsumeToken:
  31000. m.ResetConsumeToken()
  31001. return nil
  31002. case usagestatistichour.FieldActiveUser:
  31003. m.ResetActiveUser()
  31004. return nil
  31005. case usagestatistichour.FieldNewUser:
  31006. m.ResetNewUser()
  31007. return nil
  31008. case usagestatistichour.FieldLabelDist:
  31009. m.ResetLabelDist()
  31010. return nil
  31011. }
  31012. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  31013. }
  31014. // AddedEdges returns all edge names that were set/added in this mutation.
  31015. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  31016. edges := make([]string, 0, 0)
  31017. return edges
  31018. }
  31019. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31020. // name in this mutation.
  31021. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  31022. return nil
  31023. }
  31024. // RemovedEdges returns all edge names that were removed in this mutation.
  31025. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  31026. edges := make([]string, 0, 0)
  31027. return edges
  31028. }
  31029. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31030. // the given name in this mutation.
  31031. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  31032. return nil
  31033. }
  31034. // ClearedEdges returns all edge names that were cleared in this mutation.
  31035. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  31036. edges := make([]string, 0, 0)
  31037. return edges
  31038. }
  31039. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31040. // was cleared in this mutation.
  31041. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  31042. return false
  31043. }
  31044. // ClearEdge clears the value of the edge with the given name. It returns an error
  31045. // if that edge is not defined in the schema.
  31046. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  31047. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  31048. }
  31049. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31050. // It returns an error if the edge is not defined in the schema.
  31051. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  31052. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  31053. }
  31054. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  31055. type UsageStatisticMonthMutation struct {
  31056. config
  31057. op Op
  31058. typ string
  31059. id *uint64
  31060. created_at *time.Time
  31061. updated_at *time.Time
  31062. status *uint8
  31063. addstatus *int8
  31064. deleted_at *time.Time
  31065. addtime *uint64
  31066. addaddtime *int64
  31067. _type *int
  31068. add_type *int
  31069. bot_id *string
  31070. organization_id *uint64
  31071. addorganization_id *int64
  31072. ai_response *uint64
  31073. addai_response *int64
  31074. sop_run *uint64
  31075. addsop_run *int64
  31076. total_friend *uint64
  31077. addtotal_friend *int64
  31078. total_group *uint64
  31079. addtotal_group *int64
  31080. account_balance *uint64
  31081. addaccount_balance *int64
  31082. consume_token *uint64
  31083. addconsume_token *int64
  31084. active_user *uint64
  31085. addactive_user *int64
  31086. new_user *int64
  31087. addnew_user *int64
  31088. label_dist *[]custom_types.LabelDist
  31089. appendlabel_dist []custom_types.LabelDist
  31090. clearedFields map[string]struct{}
  31091. done bool
  31092. oldValue func(context.Context) (*UsageStatisticMonth, error)
  31093. predicates []predicate.UsageStatisticMonth
  31094. }
  31095. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  31096. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  31097. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  31098. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  31099. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  31100. m := &UsageStatisticMonthMutation{
  31101. config: c,
  31102. op: op,
  31103. typ: TypeUsageStatisticMonth,
  31104. clearedFields: make(map[string]struct{}),
  31105. }
  31106. for _, opt := range opts {
  31107. opt(m)
  31108. }
  31109. return m
  31110. }
  31111. // withUsageStatisticMonthID sets the ID field of the mutation.
  31112. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  31113. return func(m *UsageStatisticMonthMutation) {
  31114. var (
  31115. err error
  31116. once sync.Once
  31117. value *UsageStatisticMonth
  31118. )
  31119. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  31120. once.Do(func() {
  31121. if m.done {
  31122. err = errors.New("querying old values post mutation is not allowed")
  31123. } else {
  31124. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  31125. }
  31126. })
  31127. return value, err
  31128. }
  31129. m.id = &id
  31130. }
  31131. }
  31132. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  31133. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  31134. return func(m *UsageStatisticMonthMutation) {
  31135. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  31136. return node, nil
  31137. }
  31138. m.id = &node.ID
  31139. }
  31140. }
  31141. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31142. // executed in a transaction (ent.Tx), a transactional client is returned.
  31143. func (m UsageStatisticMonthMutation) Client() *Client {
  31144. client := &Client{config: m.config}
  31145. client.init()
  31146. return client
  31147. }
  31148. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31149. // it returns an error otherwise.
  31150. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  31151. if _, ok := m.driver.(*txDriver); !ok {
  31152. return nil, errors.New("ent: mutation is not running in a transaction")
  31153. }
  31154. tx := &Tx{config: m.config}
  31155. tx.init()
  31156. return tx, nil
  31157. }
  31158. // SetID sets the value of the id field. Note that this
  31159. // operation is only accepted on creation of UsageStatisticMonth entities.
  31160. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  31161. m.id = &id
  31162. }
  31163. // ID returns the ID value in the mutation. Note that the ID is only available
  31164. // if it was provided to the builder or after it was returned from the database.
  31165. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  31166. if m.id == nil {
  31167. return
  31168. }
  31169. return *m.id, true
  31170. }
  31171. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31172. // That means, if the mutation is applied within a transaction with an isolation level such
  31173. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31174. // or updated by the mutation.
  31175. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  31176. switch {
  31177. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31178. id, exists := m.ID()
  31179. if exists {
  31180. return []uint64{id}, nil
  31181. }
  31182. fallthrough
  31183. case m.op.Is(OpUpdate | OpDelete):
  31184. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  31185. default:
  31186. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31187. }
  31188. }
  31189. // SetCreatedAt sets the "created_at" field.
  31190. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  31191. m.created_at = &t
  31192. }
  31193. // CreatedAt returns the value of the "created_at" field in the mutation.
  31194. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  31195. v := m.created_at
  31196. if v == nil {
  31197. return
  31198. }
  31199. return *v, true
  31200. }
  31201. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  31202. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31204. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31205. if !m.op.Is(OpUpdateOne) {
  31206. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31207. }
  31208. if m.id == nil || m.oldValue == nil {
  31209. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31210. }
  31211. oldValue, err := m.oldValue(ctx)
  31212. if err != nil {
  31213. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31214. }
  31215. return oldValue.CreatedAt, nil
  31216. }
  31217. // ResetCreatedAt resets all changes to the "created_at" field.
  31218. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  31219. m.created_at = nil
  31220. }
  31221. // SetUpdatedAt sets the "updated_at" field.
  31222. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  31223. m.updated_at = &t
  31224. }
  31225. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31226. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  31227. v := m.updated_at
  31228. if v == nil {
  31229. return
  31230. }
  31231. return *v, true
  31232. }
  31233. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  31234. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31236. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31237. if !m.op.Is(OpUpdateOne) {
  31238. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31239. }
  31240. if m.id == nil || m.oldValue == nil {
  31241. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31242. }
  31243. oldValue, err := m.oldValue(ctx)
  31244. if err != nil {
  31245. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31246. }
  31247. return oldValue.UpdatedAt, nil
  31248. }
  31249. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31250. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  31251. m.updated_at = nil
  31252. }
  31253. // SetStatus sets the "status" field.
  31254. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  31255. m.status = &u
  31256. m.addstatus = nil
  31257. }
  31258. // Status returns the value of the "status" field in the mutation.
  31259. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  31260. v := m.status
  31261. if v == nil {
  31262. return
  31263. }
  31264. return *v, true
  31265. }
  31266. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  31267. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31269. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31270. if !m.op.Is(OpUpdateOne) {
  31271. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31272. }
  31273. if m.id == nil || m.oldValue == nil {
  31274. return v, errors.New("OldStatus requires an ID field in the mutation")
  31275. }
  31276. oldValue, err := m.oldValue(ctx)
  31277. if err != nil {
  31278. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31279. }
  31280. return oldValue.Status, nil
  31281. }
  31282. // AddStatus adds u to the "status" field.
  31283. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  31284. if m.addstatus != nil {
  31285. *m.addstatus += u
  31286. } else {
  31287. m.addstatus = &u
  31288. }
  31289. }
  31290. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31291. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  31292. v := m.addstatus
  31293. if v == nil {
  31294. return
  31295. }
  31296. return *v, true
  31297. }
  31298. // ClearStatus clears the value of the "status" field.
  31299. func (m *UsageStatisticMonthMutation) ClearStatus() {
  31300. m.status = nil
  31301. m.addstatus = nil
  31302. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  31303. }
  31304. // StatusCleared returns if the "status" field was cleared in this mutation.
  31305. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  31306. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  31307. return ok
  31308. }
  31309. // ResetStatus resets all changes to the "status" field.
  31310. func (m *UsageStatisticMonthMutation) ResetStatus() {
  31311. m.status = nil
  31312. m.addstatus = nil
  31313. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  31314. }
  31315. // SetDeletedAt sets the "deleted_at" field.
  31316. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  31317. m.deleted_at = &t
  31318. }
  31319. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31320. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  31321. v := m.deleted_at
  31322. if v == nil {
  31323. return
  31324. }
  31325. return *v, true
  31326. }
  31327. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  31328. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31330. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31331. if !m.op.Is(OpUpdateOne) {
  31332. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31333. }
  31334. if m.id == nil || m.oldValue == nil {
  31335. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31336. }
  31337. oldValue, err := m.oldValue(ctx)
  31338. if err != nil {
  31339. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31340. }
  31341. return oldValue.DeletedAt, nil
  31342. }
  31343. // ClearDeletedAt clears the value of the "deleted_at" field.
  31344. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  31345. m.deleted_at = nil
  31346. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  31347. }
  31348. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31349. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  31350. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  31351. return ok
  31352. }
  31353. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31354. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  31355. m.deleted_at = nil
  31356. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  31357. }
  31358. // SetAddtime sets the "addtime" field.
  31359. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  31360. m.addtime = &u
  31361. m.addaddtime = nil
  31362. }
  31363. // Addtime returns the value of the "addtime" field in the mutation.
  31364. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  31365. v := m.addtime
  31366. if v == nil {
  31367. return
  31368. }
  31369. return *v, true
  31370. }
  31371. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  31372. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31374. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  31375. if !m.op.Is(OpUpdateOne) {
  31376. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  31377. }
  31378. if m.id == nil || m.oldValue == nil {
  31379. return v, errors.New("OldAddtime requires an ID field in the mutation")
  31380. }
  31381. oldValue, err := m.oldValue(ctx)
  31382. if err != nil {
  31383. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  31384. }
  31385. return oldValue.Addtime, nil
  31386. }
  31387. // AddAddtime adds u to the "addtime" field.
  31388. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  31389. if m.addaddtime != nil {
  31390. *m.addaddtime += u
  31391. } else {
  31392. m.addaddtime = &u
  31393. }
  31394. }
  31395. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  31396. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  31397. v := m.addaddtime
  31398. if v == nil {
  31399. return
  31400. }
  31401. return *v, true
  31402. }
  31403. // ResetAddtime resets all changes to the "addtime" field.
  31404. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  31405. m.addtime = nil
  31406. m.addaddtime = nil
  31407. }
  31408. // SetType sets the "type" field.
  31409. func (m *UsageStatisticMonthMutation) SetType(i int) {
  31410. m._type = &i
  31411. m.add_type = nil
  31412. }
  31413. // GetType returns the value of the "type" field in the mutation.
  31414. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  31415. v := m._type
  31416. if v == nil {
  31417. return
  31418. }
  31419. return *v, true
  31420. }
  31421. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  31422. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31424. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  31425. if !m.op.Is(OpUpdateOne) {
  31426. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31427. }
  31428. if m.id == nil || m.oldValue == nil {
  31429. return v, errors.New("OldType requires an ID field in the mutation")
  31430. }
  31431. oldValue, err := m.oldValue(ctx)
  31432. if err != nil {
  31433. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31434. }
  31435. return oldValue.Type, nil
  31436. }
  31437. // AddType adds i to the "type" field.
  31438. func (m *UsageStatisticMonthMutation) AddType(i int) {
  31439. if m.add_type != nil {
  31440. *m.add_type += i
  31441. } else {
  31442. m.add_type = &i
  31443. }
  31444. }
  31445. // AddedType returns the value that was added to the "type" field in this mutation.
  31446. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  31447. v := m.add_type
  31448. if v == nil {
  31449. return
  31450. }
  31451. return *v, true
  31452. }
  31453. // ResetType resets all changes to the "type" field.
  31454. func (m *UsageStatisticMonthMutation) ResetType() {
  31455. m._type = nil
  31456. m.add_type = nil
  31457. }
  31458. // SetBotID sets the "bot_id" field.
  31459. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  31460. m.bot_id = &s
  31461. }
  31462. // BotID returns the value of the "bot_id" field in the mutation.
  31463. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  31464. v := m.bot_id
  31465. if v == nil {
  31466. return
  31467. }
  31468. return *v, true
  31469. }
  31470. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  31471. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31473. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  31474. if !m.op.Is(OpUpdateOne) {
  31475. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31476. }
  31477. if m.id == nil || m.oldValue == nil {
  31478. return v, errors.New("OldBotID requires an ID field in the mutation")
  31479. }
  31480. oldValue, err := m.oldValue(ctx)
  31481. if err != nil {
  31482. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31483. }
  31484. return oldValue.BotID, nil
  31485. }
  31486. // ClearBotID clears the value of the "bot_id" field.
  31487. func (m *UsageStatisticMonthMutation) ClearBotID() {
  31488. m.bot_id = nil
  31489. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  31490. }
  31491. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  31492. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  31493. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  31494. return ok
  31495. }
  31496. // ResetBotID resets all changes to the "bot_id" field.
  31497. func (m *UsageStatisticMonthMutation) ResetBotID() {
  31498. m.bot_id = nil
  31499. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  31500. }
  31501. // SetOrganizationID sets the "organization_id" field.
  31502. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  31503. m.organization_id = &u
  31504. m.addorganization_id = nil
  31505. }
  31506. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31507. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  31508. v := m.organization_id
  31509. if v == nil {
  31510. return
  31511. }
  31512. return *v, true
  31513. }
  31514. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  31515. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31516. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31517. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31518. if !m.op.Is(OpUpdateOne) {
  31519. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31520. }
  31521. if m.id == nil || m.oldValue == nil {
  31522. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31523. }
  31524. oldValue, err := m.oldValue(ctx)
  31525. if err != nil {
  31526. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31527. }
  31528. return oldValue.OrganizationID, nil
  31529. }
  31530. // AddOrganizationID adds u to the "organization_id" field.
  31531. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  31532. if m.addorganization_id != nil {
  31533. *m.addorganization_id += u
  31534. } else {
  31535. m.addorganization_id = &u
  31536. }
  31537. }
  31538. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31539. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  31540. v := m.addorganization_id
  31541. if v == nil {
  31542. return
  31543. }
  31544. return *v, true
  31545. }
  31546. // ClearOrganizationID clears the value of the "organization_id" field.
  31547. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  31548. m.organization_id = nil
  31549. m.addorganization_id = nil
  31550. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  31551. }
  31552. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31553. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  31554. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  31555. return ok
  31556. }
  31557. // ResetOrganizationID resets all changes to the "organization_id" field.
  31558. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  31559. m.organization_id = nil
  31560. m.addorganization_id = nil
  31561. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  31562. }
  31563. // SetAiResponse sets the "ai_response" field.
  31564. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  31565. m.ai_response = &u
  31566. m.addai_response = nil
  31567. }
  31568. // AiResponse returns the value of the "ai_response" field in the mutation.
  31569. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  31570. v := m.ai_response
  31571. if v == nil {
  31572. return
  31573. }
  31574. return *v, true
  31575. }
  31576. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  31577. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31579. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  31580. if !m.op.Is(OpUpdateOne) {
  31581. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  31582. }
  31583. if m.id == nil || m.oldValue == nil {
  31584. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  31585. }
  31586. oldValue, err := m.oldValue(ctx)
  31587. if err != nil {
  31588. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  31589. }
  31590. return oldValue.AiResponse, nil
  31591. }
  31592. // AddAiResponse adds u to the "ai_response" field.
  31593. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  31594. if m.addai_response != nil {
  31595. *m.addai_response += u
  31596. } else {
  31597. m.addai_response = &u
  31598. }
  31599. }
  31600. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  31601. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  31602. v := m.addai_response
  31603. if v == nil {
  31604. return
  31605. }
  31606. return *v, true
  31607. }
  31608. // ResetAiResponse resets all changes to the "ai_response" field.
  31609. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  31610. m.ai_response = nil
  31611. m.addai_response = nil
  31612. }
  31613. // SetSopRun sets the "sop_run" field.
  31614. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  31615. m.sop_run = &u
  31616. m.addsop_run = nil
  31617. }
  31618. // SopRun returns the value of the "sop_run" field in the mutation.
  31619. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  31620. v := m.sop_run
  31621. if v == nil {
  31622. return
  31623. }
  31624. return *v, true
  31625. }
  31626. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  31627. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31629. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  31630. if !m.op.Is(OpUpdateOne) {
  31631. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  31632. }
  31633. if m.id == nil || m.oldValue == nil {
  31634. return v, errors.New("OldSopRun requires an ID field in the mutation")
  31635. }
  31636. oldValue, err := m.oldValue(ctx)
  31637. if err != nil {
  31638. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  31639. }
  31640. return oldValue.SopRun, nil
  31641. }
  31642. // AddSopRun adds u to the "sop_run" field.
  31643. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  31644. if m.addsop_run != nil {
  31645. *m.addsop_run += u
  31646. } else {
  31647. m.addsop_run = &u
  31648. }
  31649. }
  31650. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  31651. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  31652. v := m.addsop_run
  31653. if v == nil {
  31654. return
  31655. }
  31656. return *v, true
  31657. }
  31658. // ResetSopRun resets all changes to the "sop_run" field.
  31659. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  31660. m.sop_run = nil
  31661. m.addsop_run = nil
  31662. }
  31663. // SetTotalFriend sets the "total_friend" field.
  31664. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  31665. m.total_friend = &u
  31666. m.addtotal_friend = nil
  31667. }
  31668. // TotalFriend returns the value of the "total_friend" field in the mutation.
  31669. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  31670. v := m.total_friend
  31671. if v == nil {
  31672. return
  31673. }
  31674. return *v, true
  31675. }
  31676. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  31677. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31679. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  31680. if !m.op.Is(OpUpdateOne) {
  31681. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  31682. }
  31683. if m.id == nil || m.oldValue == nil {
  31684. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  31685. }
  31686. oldValue, err := m.oldValue(ctx)
  31687. if err != nil {
  31688. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  31689. }
  31690. return oldValue.TotalFriend, nil
  31691. }
  31692. // AddTotalFriend adds u to the "total_friend" field.
  31693. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  31694. if m.addtotal_friend != nil {
  31695. *m.addtotal_friend += u
  31696. } else {
  31697. m.addtotal_friend = &u
  31698. }
  31699. }
  31700. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  31701. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  31702. v := m.addtotal_friend
  31703. if v == nil {
  31704. return
  31705. }
  31706. return *v, true
  31707. }
  31708. // ResetTotalFriend resets all changes to the "total_friend" field.
  31709. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  31710. m.total_friend = nil
  31711. m.addtotal_friend = nil
  31712. }
  31713. // SetTotalGroup sets the "total_group" field.
  31714. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  31715. m.total_group = &u
  31716. m.addtotal_group = nil
  31717. }
  31718. // TotalGroup returns the value of the "total_group" field in the mutation.
  31719. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  31720. v := m.total_group
  31721. if v == nil {
  31722. return
  31723. }
  31724. return *v, true
  31725. }
  31726. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  31727. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31729. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  31730. if !m.op.Is(OpUpdateOne) {
  31731. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  31732. }
  31733. if m.id == nil || m.oldValue == nil {
  31734. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  31735. }
  31736. oldValue, err := m.oldValue(ctx)
  31737. if err != nil {
  31738. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  31739. }
  31740. return oldValue.TotalGroup, nil
  31741. }
  31742. // AddTotalGroup adds u to the "total_group" field.
  31743. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  31744. if m.addtotal_group != nil {
  31745. *m.addtotal_group += u
  31746. } else {
  31747. m.addtotal_group = &u
  31748. }
  31749. }
  31750. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  31751. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  31752. v := m.addtotal_group
  31753. if v == nil {
  31754. return
  31755. }
  31756. return *v, true
  31757. }
  31758. // ResetTotalGroup resets all changes to the "total_group" field.
  31759. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  31760. m.total_group = nil
  31761. m.addtotal_group = nil
  31762. }
  31763. // SetAccountBalance sets the "account_balance" field.
  31764. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  31765. m.account_balance = &u
  31766. m.addaccount_balance = nil
  31767. }
  31768. // AccountBalance returns the value of the "account_balance" field in the mutation.
  31769. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  31770. v := m.account_balance
  31771. if v == nil {
  31772. return
  31773. }
  31774. return *v, true
  31775. }
  31776. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  31777. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31779. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  31780. if !m.op.Is(OpUpdateOne) {
  31781. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  31782. }
  31783. if m.id == nil || m.oldValue == nil {
  31784. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  31785. }
  31786. oldValue, err := m.oldValue(ctx)
  31787. if err != nil {
  31788. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  31789. }
  31790. return oldValue.AccountBalance, nil
  31791. }
  31792. // AddAccountBalance adds u to the "account_balance" field.
  31793. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  31794. if m.addaccount_balance != nil {
  31795. *m.addaccount_balance += u
  31796. } else {
  31797. m.addaccount_balance = &u
  31798. }
  31799. }
  31800. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  31801. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  31802. v := m.addaccount_balance
  31803. if v == nil {
  31804. return
  31805. }
  31806. return *v, true
  31807. }
  31808. // ResetAccountBalance resets all changes to the "account_balance" field.
  31809. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  31810. m.account_balance = nil
  31811. m.addaccount_balance = nil
  31812. }
  31813. // SetConsumeToken sets the "consume_token" field.
  31814. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  31815. m.consume_token = &u
  31816. m.addconsume_token = nil
  31817. }
  31818. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  31819. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  31820. v := m.consume_token
  31821. if v == nil {
  31822. return
  31823. }
  31824. return *v, true
  31825. }
  31826. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  31827. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31829. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31830. if !m.op.Is(OpUpdateOne) {
  31831. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31832. }
  31833. if m.id == nil || m.oldValue == nil {
  31834. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31835. }
  31836. oldValue, err := m.oldValue(ctx)
  31837. if err != nil {
  31838. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31839. }
  31840. return oldValue.ConsumeToken, nil
  31841. }
  31842. // AddConsumeToken adds u to the "consume_token" field.
  31843. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  31844. if m.addconsume_token != nil {
  31845. *m.addconsume_token += u
  31846. } else {
  31847. m.addconsume_token = &u
  31848. }
  31849. }
  31850. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31851. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  31852. v := m.addconsume_token
  31853. if v == nil {
  31854. return
  31855. }
  31856. return *v, true
  31857. }
  31858. // ResetConsumeToken resets all changes to the "consume_token" field.
  31859. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  31860. m.consume_token = nil
  31861. m.addconsume_token = nil
  31862. }
  31863. // SetActiveUser sets the "active_user" field.
  31864. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  31865. m.active_user = &u
  31866. m.addactive_user = nil
  31867. }
  31868. // ActiveUser returns the value of the "active_user" field in the mutation.
  31869. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  31870. v := m.active_user
  31871. if v == nil {
  31872. return
  31873. }
  31874. return *v, true
  31875. }
  31876. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  31877. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31879. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  31880. if !m.op.Is(OpUpdateOne) {
  31881. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  31882. }
  31883. if m.id == nil || m.oldValue == nil {
  31884. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  31885. }
  31886. oldValue, err := m.oldValue(ctx)
  31887. if err != nil {
  31888. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  31889. }
  31890. return oldValue.ActiveUser, nil
  31891. }
  31892. // AddActiveUser adds u to the "active_user" field.
  31893. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  31894. if m.addactive_user != nil {
  31895. *m.addactive_user += u
  31896. } else {
  31897. m.addactive_user = &u
  31898. }
  31899. }
  31900. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  31901. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  31902. v := m.addactive_user
  31903. if v == nil {
  31904. return
  31905. }
  31906. return *v, true
  31907. }
  31908. // ResetActiveUser resets all changes to the "active_user" field.
  31909. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  31910. m.active_user = nil
  31911. m.addactive_user = nil
  31912. }
  31913. // SetNewUser sets the "new_user" field.
  31914. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  31915. m.new_user = &i
  31916. m.addnew_user = nil
  31917. }
  31918. // NewUser returns the value of the "new_user" field in the mutation.
  31919. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  31920. v := m.new_user
  31921. if v == nil {
  31922. return
  31923. }
  31924. return *v, true
  31925. }
  31926. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  31927. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31929. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  31930. if !m.op.Is(OpUpdateOne) {
  31931. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  31932. }
  31933. if m.id == nil || m.oldValue == nil {
  31934. return v, errors.New("OldNewUser requires an ID field in the mutation")
  31935. }
  31936. oldValue, err := m.oldValue(ctx)
  31937. if err != nil {
  31938. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  31939. }
  31940. return oldValue.NewUser, nil
  31941. }
  31942. // AddNewUser adds i to the "new_user" field.
  31943. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  31944. if m.addnew_user != nil {
  31945. *m.addnew_user += i
  31946. } else {
  31947. m.addnew_user = &i
  31948. }
  31949. }
  31950. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  31951. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  31952. v := m.addnew_user
  31953. if v == nil {
  31954. return
  31955. }
  31956. return *v, true
  31957. }
  31958. // ResetNewUser resets all changes to the "new_user" field.
  31959. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  31960. m.new_user = nil
  31961. m.addnew_user = nil
  31962. }
  31963. // SetLabelDist sets the "label_dist" field.
  31964. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  31965. m.label_dist = &ctd
  31966. m.appendlabel_dist = nil
  31967. }
  31968. // LabelDist returns the value of the "label_dist" field in the mutation.
  31969. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  31970. v := m.label_dist
  31971. if v == nil {
  31972. return
  31973. }
  31974. return *v, true
  31975. }
  31976. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  31977. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31978. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31979. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  31980. if !m.op.Is(OpUpdateOne) {
  31981. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  31982. }
  31983. if m.id == nil || m.oldValue == nil {
  31984. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  31985. }
  31986. oldValue, err := m.oldValue(ctx)
  31987. if err != nil {
  31988. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  31989. }
  31990. return oldValue.LabelDist, nil
  31991. }
  31992. // AppendLabelDist adds ctd to the "label_dist" field.
  31993. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  31994. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  31995. }
  31996. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  31997. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  31998. if len(m.appendlabel_dist) == 0 {
  31999. return nil, false
  32000. }
  32001. return m.appendlabel_dist, true
  32002. }
  32003. // ResetLabelDist resets all changes to the "label_dist" field.
  32004. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  32005. m.label_dist = nil
  32006. m.appendlabel_dist = nil
  32007. }
  32008. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  32009. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  32010. m.predicates = append(m.predicates, ps...)
  32011. }
  32012. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  32013. // users can use type-assertion to append predicates that do not depend on any generated package.
  32014. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  32015. p := make([]predicate.UsageStatisticMonth, len(ps))
  32016. for i := range ps {
  32017. p[i] = ps[i]
  32018. }
  32019. m.Where(p...)
  32020. }
  32021. // Op returns the operation name.
  32022. func (m *UsageStatisticMonthMutation) Op() Op {
  32023. return m.op
  32024. }
  32025. // SetOp allows setting the mutation operation.
  32026. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  32027. m.op = op
  32028. }
  32029. // Type returns the node type of this mutation (UsageStatisticMonth).
  32030. func (m *UsageStatisticMonthMutation) Type() string {
  32031. return m.typ
  32032. }
  32033. // Fields returns all fields that were changed during this mutation. Note that in
  32034. // order to get all numeric fields that were incremented/decremented, call
  32035. // AddedFields().
  32036. func (m *UsageStatisticMonthMutation) Fields() []string {
  32037. fields := make([]string, 0, 17)
  32038. if m.created_at != nil {
  32039. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  32040. }
  32041. if m.updated_at != nil {
  32042. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  32043. }
  32044. if m.status != nil {
  32045. fields = append(fields, usagestatisticmonth.FieldStatus)
  32046. }
  32047. if m.deleted_at != nil {
  32048. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  32049. }
  32050. if m.addtime != nil {
  32051. fields = append(fields, usagestatisticmonth.FieldAddtime)
  32052. }
  32053. if m._type != nil {
  32054. fields = append(fields, usagestatisticmonth.FieldType)
  32055. }
  32056. if m.bot_id != nil {
  32057. fields = append(fields, usagestatisticmonth.FieldBotID)
  32058. }
  32059. if m.organization_id != nil {
  32060. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32061. }
  32062. if m.ai_response != nil {
  32063. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  32064. }
  32065. if m.sop_run != nil {
  32066. fields = append(fields, usagestatisticmonth.FieldSopRun)
  32067. }
  32068. if m.total_friend != nil {
  32069. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  32070. }
  32071. if m.total_group != nil {
  32072. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  32073. }
  32074. if m.account_balance != nil {
  32075. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  32076. }
  32077. if m.consume_token != nil {
  32078. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  32079. }
  32080. if m.active_user != nil {
  32081. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  32082. }
  32083. if m.new_user != nil {
  32084. fields = append(fields, usagestatisticmonth.FieldNewUser)
  32085. }
  32086. if m.label_dist != nil {
  32087. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  32088. }
  32089. return fields
  32090. }
  32091. // Field returns the value of a field with the given name. The second boolean
  32092. // return value indicates that this field was not set, or was not defined in the
  32093. // schema.
  32094. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  32095. switch name {
  32096. case usagestatisticmonth.FieldCreatedAt:
  32097. return m.CreatedAt()
  32098. case usagestatisticmonth.FieldUpdatedAt:
  32099. return m.UpdatedAt()
  32100. case usagestatisticmonth.FieldStatus:
  32101. return m.Status()
  32102. case usagestatisticmonth.FieldDeletedAt:
  32103. return m.DeletedAt()
  32104. case usagestatisticmonth.FieldAddtime:
  32105. return m.Addtime()
  32106. case usagestatisticmonth.FieldType:
  32107. return m.GetType()
  32108. case usagestatisticmonth.FieldBotID:
  32109. return m.BotID()
  32110. case usagestatisticmonth.FieldOrganizationID:
  32111. return m.OrganizationID()
  32112. case usagestatisticmonth.FieldAiResponse:
  32113. return m.AiResponse()
  32114. case usagestatisticmonth.FieldSopRun:
  32115. return m.SopRun()
  32116. case usagestatisticmonth.FieldTotalFriend:
  32117. return m.TotalFriend()
  32118. case usagestatisticmonth.FieldTotalGroup:
  32119. return m.TotalGroup()
  32120. case usagestatisticmonth.FieldAccountBalance:
  32121. return m.AccountBalance()
  32122. case usagestatisticmonth.FieldConsumeToken:
  32123. return m.ConsumeToken()
  32124. case usagestatisticmonth.FieldActiveUser:
  32125. return m.ActiveUser()
  32126. case usagestatisticmonth.FieldNewUser:
  32127. return m.NewUser()
  32128. case usagestatisticmonth.FieldLabelDist:
  32129. return m.LabelDist()
  32130. }
  32131. return nil, false
  32132. }
  32133. // OldField returns the old value of the field from the database. An error is
  32134. // returned if the mutation operation is not UpdateOne, or the query to the
  32135. // database failed.
  32136. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32137. switch name {
  32138. case usagestatisticmonth.FieldCreatedAt:
  32139. return m.OldCreatedAt(ctx)
  32140. case usagestatisticmonth.FieldUpdatedAt:
  32141. return m.OldUpdatedAt(ctx)
  32142. case usagestatisticmonth.FieldStatus:
  32143. return m.OldStatus(ctx)
  32144. case usagestatisticmonth.FieldDeletedAt:
  32145. return m.OldDeletedAt(ctx)
  32146. case usagestatisticmonth.FieldAddtime:
  32147. return m.OldAddtime(ctx)
  32148. case usagestatisticmonth.FieldType:
  32149. return m.OldType(ctx)
  32150. case usagestatisticmonth.FieldBotID:
  32151. return m.OldBotID(ctx)
  32152. case usagestatisticmonth.FieldOrganizationID:
  32153. return m.OldOrganizationID(ctx)
  32154. case usagestatisticmonth.FieldAiResponse:
  32155. return m.OldAiResponse(ctx)
  32156. case usagestatisticmonth.FieldSopRun:
  32157. return m.OldSopRun(ctx)
  32158. case usagestatisticmonth.FieldTotalFriend:
  32159. return m.OldTotalFriend(ctx)
  32160. case usagestatisticmonth.FieldTotalGroup:
  32161. return m.OldTotalGroup(ctx)
  32162. case usagestatisticmonth.FieldAccountBalance:
  32163. return m.OldAccountBalance(ctx)
  32164. case usagestatisticmonth.FieldConsumeToken:
  32165. return m.OldConsumeToken(ctx)
  32166. case usagestatisticmonth.FieldActiveUser:
  32167. return m.OldActiveUser(ctx)
  32168. case usagestatisticmonth.FieldNewUser:
  32169. return m.OldNewUser(ctx)
  32170. case usagestatisticmonth.FieldLabelDist:
  32171. return m.OldLabelDist(ctx)
  32172. }
  32173. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32174. }
  32175. // SetField sets the value of a field with the given name. It returns an error if
  32176. // the field is not defined in the schema, or if the type mismatched the field
  32177. // type.
  32178. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  32179. switch name {
  32180. case usagestatisticmonth.FieldCreatedAt:
  32181. v, ok := value.(time.Time)
  32182. if !ok {
  32183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32184. }
  32185. m.SetCreatedAt(v)
  32186. return nil
  32187. case usagestatisticmonth.FieldUpdatedAt:
  32188. v, ok := value.(time.Time)
  32189. if !ok {
  32190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32191. }
  32192. m.SetUpdatedAt(v)
  32193. return nil
  32194. case usagestatisticmonth.FieldStatus:
  32195. v, ok := value.(uint8)
  32196. if !ok {
  32197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32198. }
  32199. m.SetStatus(v)
  32200. return nil
  32201. case usagestatisticmonth.FieldDeletedAt:
  32202. v, ok := value.(time.Time)
  32203. if !ok {
  32204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32205. }
  32206. m.SetDeletedAt(v)
  32207. return nil
  32208. case usagestatisticmonth.FieldAddtime:
  32209. v, ok := value.(uint64)
  32210. if !ok {
  32211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32212. }
  32213. m.SetAddtime(v)
  32214. return nil
  32215. case usagestatisticmonth.FieldType:
  32216. v, ok := value.(int)
  32217. if !ok {
  32218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32219. }
  32220. m.SetType(v)
  32221. return nil
  32222. case usagestatisticmonth.FieldBotID:
  32223. v, ok := value.(string)
  32224. if !ok {
  32225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32226. }
  32227. m.SetBotID(v)
  32228. return nil
  32229. case usagestatisticmonth.FieldOrganizationID:
  32230. v, ok := value.(uint64)
  32231. if !ok {
  32232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32233. }
  32234. m.SetOrganizationID(v)
  32235. return nil
  32236. case usagestatisticmonth.FieldAiResponse:
  32237. v, ok := value.(uint64)
  32238. if !ok {
  32239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32240. }
  32241. m.SetAiResponse(v)
  32242. return nil
  32243. case usagestatisticmonth.FieldSopRun:
  32244. v, ok := value.(uint64)
  32245. if !ok {
  32246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32247. }
  32248. m.SetSopRun(v)
  32249. return nil
  32250. case usagestatisticmonth.FieldTotalFriend:
  32251. v, ok := value.(uint64)
  32252. if !ok {
  32253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32254. }
  32255. m.SetTotalFriend(v)
  32256. return nil
  32257. case usagestatisticmonth.FieldTotalGroup:
  32258. v, ok := value.(uint64)
  32259. if !ok {
  32260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32261. }
  32262. m.SetTotalGroup(v)
  32263. return nil
  32264. case usagestatisticmonth.FieldAccountBalance:
  32265. v, ok := value.(uint64)
  32266. if !ok {
  32267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32268. }
  32269. m.SetAccountBalance(v)
  32270. return nil
  32271. case usagestatisticmonth.FieldConsumeToken:
  32272. v, ok := value.(uint64)
  32273. if !ok {
  32274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32275. }
  32276. m.SetConsumeToken(v)
  32277. return nil
  32278. case usagestatisticmonth.FieldActiveUser:
  32279. v, ok := value.(uint64)
  32280. if !ok {
  32281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32282. }
  32283. m.SetActiveUser(v)
  32284. return nil
  32285. case usagestatisticmonth.FieldNewUser:
  32286. v, ok := value.(int64)
  32287. if !ok {
  32288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32289. }
  32290. m.SetNewUser(v)
  32291. return nil
  32292. case usagestatisticmonth.FieldLabelDist:
  32293. v, ok := value.([]custom_types.LabelDist)
  32294. if !ok {
  32295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32296. }
  32297. m.SetLabelDist(v)
  32298. return nil
  32299. }
  32300. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32301. }
  32302. // AddedFields returns all numeric fields that were incremented/decremented during
  32303. // this mutation.
  32304. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  32305. var fields []string
  32306. if m.addstatus != nil {
  32307. fields = append(fields, usagestatisticmonth.FieldStatus)
  32308. }
  32309. if m.addaddtime != nil {
  32310. fields = append(fields, usagestatisticmonth.FieldAddtime)
  32311. }
  32312. if m.add_type != nil {
  32313. fields = append(fields, usagestatisticmonth.FieldType)
  32314. }
  32315. if m.addorganization_id != nil {
  32316. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32317. }
  32318. if m.addai_response != nil {
  32319. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  32320. }
  32321. if m.addsop_run != nil {
  32322. fields = append(fields, usagestatisticmonth.FieldSopRun)
  32323. }
  32324. if m.addtotal_friend != nil {
  32325. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  32326. }
  32327. if m.addtotal_group != nil {
  32328. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  32329. }
  32330. if m.addaccount_balance != nil {
  32331. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  32332. }
  32333. if m.addconsume_token != nil {
  32334. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  32335. }
  32336. if m.addactive_user != nil {
  32337. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  32338. }
  32339. if m.addnew_user != nil {
  32340. fields = append(fields, usagestatisticmonth.FieldNewUser)
  32341. }
  32342. return fields
  32343. }
  32344. // AddedField returns the numeric value that was incremented/decremented on a field
  32345. // with the given name. The second boolean return value indicates that this field
  32346. // was not set, or was not defined in the schema.
  32347. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  32348. switch name {
  32349. case usagestatisticmonth.FieldStatus:
  32350. return m.AddedStatus()
  32351. case usagestatisticmonth.FieldAddtime:
  32352. return m.AddedAddtime()
  32353. case usagestatisticmonth.FieldType:
  32354. return m.AddedType()
  32355. case usagestatisticmonth.FieldOrganizationID:
  32356. return m.AddedOrganizationID()
  32357. case usagestatisticmonth.FieldAiResponse:
  32358. return m.AddedAiResponse()
  32359. case usagestatisticmonth.FieldSopRun:
  32360. return m.AddedSopRun()
  32361. case usagestatisticmonth.FieldTotalFriend:
  32362. return m.AddedTotalFriend()
  32363. case usagestatisticmonth.FieldTotalGroup:
  32364. return m.AddedTotalGroup()
  32365. case usagestatisticmonth.FieldAccountBalance:
  32366. return m.AddedAccountBalance()
  32367. case usagestatisticmonth.FieldConsumeToken:
  32368. return m.AddedConsumeToken()
  32369. case usagestatisticmonth.FieldActiveUser:
  32370. return m.AddedActiveUser()
  32371. case usagestatisticmonth.FieldNewUser:
  32372. return m.AddedNewUser()
  32373. }
  32374. return nil, false
  32375. }
  32376. // AddField adds the value to the field with the given name. It returns an error if
  32377. // the field is not defined in the schema, or if the type mismatched the field
  32378. // type.
  32379. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  32380. switch name {
  32381. case usagestatisticmonth.FieldStatus:
  32382. v, ok := value.(int8)
  32383. if !ok {
  32384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32385. }
  32386. m.AddStatus(v)
  32387. return nil
  32388. case usagestatisticmonth.FieldAddtime:
  32389. v, ok := value.(int64)
  32390. if !ok {
  32391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32392. }
  32393. m.AddAddtime(v)
  32394. return nil
  32395. case usagestatisticmonth.FieldType:
  32396. v, ok := value.(int)
  32397. if !ok {
  32398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32399. }
  32400. m.AddType(v)
  32401. return nil
  32402. case usagestatisticmonth.FieldOrganizationID:
  32403. v, ok := value.(int64)
  32404. if !ok {
  32405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32406. }
  32407. m.AddOrganizationID(v)
  32408. return nil
  32409. case usagestatisticmonth.FieldAiResponse:
  32410. v, ok := value.(int64)
  32411. if !ok {
  32412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32413. }
  32414. m.AddAiResponse(v)
  32415. return nil
  32416. case usagestatisticmonth.FieldSopRun:
  32417. v, ok := value.(int64)
  32418. if !ok {
  32419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32420. }
  32421. m.AddSopRun(v)
  32422. return nil
  32423. case usagestatisticmonth.FieldTotalFriend:
  32424. v, ok := value.(int64)
  32425. if !ok {
  32426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32427. }
  32428. m.AddTotalFriend(v)
  32429. return nil
  32430. case usagestatisticmonth.FieldTotalGroup:
  32431. v, ok := value.(int64)
  32432. if !ok {
  32433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32434. }
  32435. m.AddTotalGroup(v)
  32436. return nil
  32437. case usagestatisticmonth.FieldAccountBalance:
  32438. v, ok := value.(int64)
  32439. if !ok {
  32440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32441. }
  32442. m.AddAccountBalance(v)
  32443. return nil
  32444. case usagestatisticmonth.FieldConsumeToken:
  32445. v, ok := value.(int64)
  32446. if !ok {
  32447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32448. }
  32449. m.AddConsumeToken(v)
  32450. return nil
  32451. case usagestatisticmonth.FieldActiveUser:
  32452. v, ok := value.(int64)
  32453. if !ok {
  32454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32455. }
  32456. m.AddActiveUser(v)
  32457. return nil
  32458. case usagestatisticmonth.FieldNewUser:
  32459. v, ok := value.(int64)
  32460. if !ok {
  32461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32462. }
  32463. m.AddNewUser(v)
  32464. return nil
  32465. }
  32466. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  32467. }
  32468. // ClearedFields returns all nullable fields that were cleared during this
  32469. // mutation.
  32470. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  32471. var fields []string
  32472. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  32473. fields = append(fields, usagestatisticmonth.FieldStatus)
  32474. }
  32475. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  32476. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  32477. }
  32478. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  32479. fields = append(fields, usagestatisticmonth.FieldBotID)
  32480. }
  32481. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  32482. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32483. }
  32484. return fields
  32485. }
  32486. // FieldCleared returns a boolean indicating if a field with the given name was
  32487. // cleared in this mutation.
  32488. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  32489. _, ok := m.clearedFields[name]
  32490. return ok
  32491. }
  32492. // ClearField clears the value of the field with the given name. It returns an
  32493. // error if the field is not defined in the schema.
  32494. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  32495. switch name {
  32496. case usagestatisticmonth.FieldStatus:
  32497. m.ClearStatus()
  32498. return nil
  32499. case usagestatisticmonth.FieldDeletedAt:
  32500. m.ClearDeletedAt()
  32501. return nil
  32502. case usagestatisticmonth.FieldBotID:
  32503. m.ClearBotID()
  32504. return nil
  32505. case usagestatisticmonth.FieldOrganizationID:
  32506. m.ClearOrganizationID()
  32507. return nil
  32508. }
  32509. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  32510. }
  32511. // ResetField resets all changes in the mutation for the field with the given name.
  32512. // It returns an error if the field is not defined in the schema.
  32513. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  32514. switch name {
  32515. case usagestatisticmonth.FieldCreatedAt:
  32516. m.ResetCreatedAt()
  32517. return nil
  32518. case usagestatisticmonth.FieldUpdatedAt:
  32519. m.ResetUpdatedAt()
  32520. return nil
  32521. case usagestatisticmonth.FieldStatus:
  32522. m.ResetStatus()
  32523. return nil
  32524. case usagestatisticmonth.FieldDeletedAt:
  32525. m.ResetDeletedAt()
  32526. return nil
  32527. case usagestatisticmonth.FieldAddtime:
  32528. m.ResetAddtime()
  32529. return nil
  32530. case usagestatisticmonth.FieldType:
  32531. m.ResetType()
  32532. return nil
  32533. case usagestatisticmonth.FieldBotID:
  32534. m.ResetBotID()
  32535. return nil
  32536. case usagestatisticmonth.FieldOrganizationID:
  32537. m.ResetOrganizationID()
  32538. return nil
  32539. case usagestatisticmonth.FieldAiResponse:
  32540. m.ResetAiResponse()
  32541. return nil
  32542. case usagestatisticmonth.FieldSopRun:
  32543. m.ResetSopRun()
  32544. return nil
  32545. case usagestatisticmonth.FieldTotalFriend:
  32546. m.ResetTotalFriend()
  32547. return nil
  32548. case usagestatisticmonth.FieldTotalGroup:
  32549. m.ResetTotalGroup()
  32550. return nil
  32551. case usagestatisticmonth.FieldAccountBalance:
  32552. m.ResetAccountBalance()
  32553. return nil
  32554. case usagestatisticmonth.FieldConsumeToken:
  32555. m.ResetConsumeToken()
  32556. return nil
  32557. case usagestatisticmonth.FieldActiveUser:
  32558. m.ResetActiveUser()
  32559. return nil
  32560. case usagestatisticmonth.FieldNewUser:
  32561. m.ResetNewUser()
  32562. return nil
  32563. case usagestatisticmonth.FieldLabelDist:
  32564. m.ResetLabelDist()
  32565. return nil
  32566. }
  32567. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32568. }
  32569. // AddedEdges returns all edge names that were set/added in this mutation.
  32570. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  32571. edges := make([]string, 0, 0)
  32572. return edges
  32573. }
  32574. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32575. // name in this mutation.
  32576. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  32577. return nil
  32578. }
  32579. // RemovedEdges returns all edge names that were removed in this mutation.
  32580. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  32581. edges := make([]string, 0, 0)
  32582. return edges
  32583. }
  32584. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32585. // the given name in this mutation.
  32586. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  32587. return nil
  32588. }
  32589. // ClearedEdges returns all edge names that were cleared in this mutation.
  32590. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  32591. edges := make([]string, 0, 0)
  32592. return edges
  32593. }
  32594. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32595. // was cleared in this mutation.
  32596. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  32597. return false
  32598. }
  32599. // ClearEdge clears the value of the edge with the given name. It returns an error
  32600. // if that edge is not defined in the schema.
  32601. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  32602. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  32603. }
  32604. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32605. // It returns an error if the edge is not defined in the schema.
  32606. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  32607. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  32608. }
  32609. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  32610. type UsageTotalMutation struct {
  32611. config
  32612. op Op
  32613. typ string
  32614. id *uint64
  32615. created_at *time.Time
  32616. updated_at *time.Time
  32617. status *uint8
  32618. addstatus *int8
  32619. _type *int
  32620. add_type *int
  32621. bot_id *string
  32622. total_tokens *uint64
  32623. addtotal_tokens *int64
  32624. start_index *uint64
  32625. addstart_index *int64
  32626. end_index *uint64
  32627. addend_index *int64
  32628. organization_id *uint64
  32629. addorganization_id *int64
  32630. clearedFields map[string]struct{}
  32631. done bool
  32632. oldValue func(context.Context) (*UsageTotal, error)
  32633. predicates []predicate.UsageTotal
  32634. }
  32635. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  32636. // usagetotalOption allows management of the mutation configuration using functional options.
  32637. type usagetotalOption func(*UsageTotalMutation)
  32638. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  32639. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  32640. m := &UsageTotalMutation{
  32641. config: c,
  32642. op: op,
  32643. typ: TypeUsageTotal,
  32644. clearedFields: make(map[string]struct{}),
  32645. }
  32646. for _, opt := range opts {
  32647. opt(m)
  32648. }
  32649. return m
  32650. }
  32651. // withUsageTotalID sets the ID field of the mutation.
  32652. func withUsageTotalID(id uint64) usagetotalOption {
  32653. return func(m *UsageTotalMutation) {
  32654. var (
  32655. err error
  32656. once sync.Once
  32657. value *UsageTotal
  32658. )
  32659. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  32660. once.Do(func() {
  32661. if m.done {
  32662. err = errors.New("querying old values post mutation is not allowed")
  32663. } else {
  32664. value, err = m.Client().UsageTotal.Get(ctx, id)
  32665. }
  32666. })
  32667. return value, err
  32668. }
  32669. m.id = &id
  32670. }
  32671. }
  32672. // withUsageTotal sets the old UsageTotal of the mutation.
  32673. func withUsageTotal(node *UsageTotal) usagetotalOption {
  32674. return func(m *UsageTotalMutation) {
  32675. m.oldValue = func(context.Context) (*UsageTotal, error) {
  32676. return node, nil
  32677. }
  32678. m.id = &node.ID
  32679. }
  32680. }
  32681. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32682. // executed in a transaction (ent.Tx), a transactional client is returned.
  32683. func (m UsageTotalMutation) Client() *Client {
  32684. client := &Client{config: m.config}
  32685. client.init()
  32686. return client
  32687. }
  32688. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32689. // it returns an error otherwise.
  32690. func (m UsageTotalMutation) Tx() (*Tx, error) {
  32691. if _, ok := m.driver.(*txDriver); !ok {
  32692. return nil, errors.New("ent: mutation is not running in a transaction")
  32693. }
  32694. tx := &Tx{config: m.config}
  32695. tx.init()
  32696. return tx, nil
  32697. }
  32698. // SetID sets the value of the id field. Note that this
  32699. // operation is only accepted on creation of UsageTotal entities.
  32700. func (m *UsageTotalMutation) SetID(id uint64) {
  32701. m.id = &id
  32702. }
  32703. // ID returns the ID value in the mutation. Note that the ID is only available
  32704. // if it was provided to the builder or after it was returned from the database.
  32705. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  32706. if m.id == nil {
  32707. return
  32708. }
  32709. return *m.id, true
  32710. }
  32711. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32712. // That means, if the mutation is applied within a transaction with an isolation level such
  32713. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32714. // or updated by the mutation.
  32715. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  32716. switch {
  32717. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32718. id, exists := m.ID()
  32719. if exists {
  32720. return []uint64{id}, nil
  32721. }
  32722. fallthrough
  32723. case m.op.Is(OpUpdate | OpDelete):
  32724. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  32725. default:
  32726. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32727. }
  32728. }
  32729. // SetCreatedAt sets the "created_at" field.
  32730. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  32731. m.created_at = &t
  32732. }
  32733. // CreatedAt returns the value of the "created_at" field in the mutation.
  32734. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  32735. v := m.created_at
  32736. if v == nil {
  32737. return
  32738. }
  32739. return *v, true
  32740. }
  32741. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  32742. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32744. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32745. if !m.op.Is(OpUpdateOne) {
  32746. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32747. }
  32748. if m.id == nil || m.oldValue == nil {
  32749. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32750. }
  32751. oldValue, err := m.oldValue(ctx)
  32752. if err != nil {
  32753. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32754. }
  32755. return oldValue.CreatedAt, nil
  32756. }
  32757. // ResetCreatedAt resets all changes to the "created_at" field.
  32758. func (m *UsageTotalMutation) ResetCreatedAt() {
  32759. m.created_at = nil
  32760. }
  32761. // SetUpdatedAt sets the "updated_at" field.
  32762. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  32763. m.updated_at = &t
  32764. }
  32765. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32766. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  32767. v := m.updated_at
  32768. if v == nil {
  32769. return
  32770. }
  32771. return *v, true
  32772. }
  32773. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  32774. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32776. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32777. if !m.op.Is(OpUpdateOne) {
  32778. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32779. }
  32780. if m.id == nil || m.oldValue == nil {
  32781. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32782. }
  32783. oldValue, err := m.oldValue(ctx)
  32784. if err != nil {
  32785. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32786. }
  32787. return oldValue.UpdatedAt, nil
  32788. }
  32789. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32790. func (m *UsageTotalMutation) ResetUpdatedAt() {
  32791. m.updated_at = nil
  32792. }
  32793. // SetStatus sets the "status" field.
  32794. func (m *UsageTotalMutation) SetStatus(u uint8) {
  32795. m.status = &u
  32796. m.addstatus = nil
  32797. }
  32798. // Status returns the value of the "status" field in the mutation.
  32799. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  32800. v := m.status
  32801. if v == nil {
  32802. return
  32803. }
  32804. return *v, true
  32805. }
  32806. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  32807. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32808. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32809. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32810. if !m.op.Is(OpUpdateOne) {
  32811. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32812. }
  32813. if m.id == nil || m.oldValue == nil {
  32814. return v, errors.New("OldStatus requires an ID field in the mutation")
  32815. }
  32816. oldValue, err := m.oldValue(ctx)
  32817. if err != nil {
  32818. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32819. }
  32820. return oldValue.Status, nil
  32821. }
  32822. // AddStatus adds u to the "status" field.
  32823. func (m *UsageTotalMutation) AddStatus(u int8) {
  32824. if m.addstatus != nil {
  32825. *m.addstatus += u
  32826. } else {
  32827. m.addstatus = &u
  32828. }
  32829. }
  32830. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32831. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  32832. v := m.addstatus
  32833. if v == nil {
  32834. return
  32835. }
  32836. return *v, true
  32837. }
  32838. // ClearStatus clears the value of the "status" field.
  32839. func (m *UsageTotalMutation) ClearStatus() {
  32840. m.status = nil
  32841. m.addstatus = nil
  32842. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  32843. }
  32844. // StatusCleared returns if the "status" field was cleared in this mutation.
  32845. func (m *UsageTotalMutation) StatusCleared() bool {
  32846. _, ok := m.clearedFields[usagetotal.FieldStatus]
  32847. return ok
  32848. }
  32849. // ResetStatus resets all changes to the "status" field.
  32850. func (m *UsageTotalMutation) ResetStatus() {
  32851. m.status = nil
  32852. m.addstatus = nil
  32853. delete(m.clearedFields, usagetotal.FieldStatus)
  32854. }
  32855. // SetType sets the "type" field.
  32856. func (m *UsageTotalMutation) SetType(i int) {
  32857. m._type = &i
  32858. m.add_type = nil
  32859. }
  32860. // GetType returns the value of the "type" field in the mutation.
  32861. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  32862. v := m._type
  32863. if v == nil {
  32864. return
  32865. }
  32866. return *v, true
  32867. }
  32868. // OldType returns the old "type" field's value of the UsageTotal entity.
  32869. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32871. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  32872. if !m.op.Is(OpUpdateOne) {
  32873. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32874. }
  32875. if m.id == nil || m.oldValue == nil {
  32876. return v, errors.New("OldType requires an ID field in the mutation")
  32877. }
  32878. oldValue, err := m.oldValue(ctx)
  32879. if err != nil {
  32880. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32881. }
  32882. return oldValue.Type, nil
  32883. }
  32884. // AddType adds i to the "type" field.
  32885. func (m *UsageTotalMutation) AddType(i int) {
  32886. if m.add_type != nil {
  32887. *m.add_type += i
  32888. } else {
  32889. m.add_type = &i
  32890. }
  32891. }
  32892. // AddedType returns the value that was added to the "type" field in this mutation.
  32893. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  32894. v := m.add_type
  32895. if v == nil {
  32896. return
  32897. }
  32898. return *v, true
  32899. }
  32900. // ClearType clears the value of the "type" field.
  32901. func (m *UsageTotalMutation) ClearType() {
  32902. m._type = nil
  32903. m.add_type = nil
  32904. m.clearedFields[usagetotal.FieldType] = struct{}{}
  32905. }
  32906. // TypeCleared returns if the "type" field was cleared in this mutation.
  32907. func (m *UsageTotalMutation) TypeCleared() bool {
  32908. _, ok := m.clearedFields[usagetotal.FieldType]
  32909. return ok
  32910. }
  32911. // ResetType resets all changes to the "type" field.
  32912. func (m *UsageTotalMutation) ResetType() {
  32913. m._type = nil
  32914. m.add_type = nil
  32915. delete(m.clearedFields, usagetotal.FieldType)
  32916. }
  32917. // SetBotID sets the "bot_id" field.
  32918. func (m *UsageTotalMutation) SetBotID(s string) {
  32919. m.bot_id = &s
  32920. }
  32921. // BotID returns the value of the "bot_id" field in the mutation.
  32922. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  32923. v := m.bot_id
  32924. if v == nil {
  32925. return
  32926. }
  32927. return *v, true
  32928. }
  32929. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  32930. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32932. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  32933. if !m.op.Is(OpUpdateOne) {
  32934. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32935. }
  32936. if m.id == nil || m.oldValue == nil {
  32937. return v, errors.New("OldBotID requires an ID field in the mutation")
  32938. }
  32939. oldValue, err := m.oldValue(ctx)
  32940. if err != nil {
  32941. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32942. }
  32943. return oldValue.BotID, nil
  32944. }
  32945. // ResetBotID resets all changes to the "bot_id" field.
  32946. func (m *UsageTotalMutation) ResetBotID() {
  32947. m.bot_id = nil
  32948. }
  32949. // SetTotalTokens sets the "total_tokens" field.
  32950. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  32951. m.total_tokens = &u
  32952. m.addtotal_tokens = nil
  32953. }
  32954. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  32955. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  32956. v := m.total_tokens
  32957. if v == nil {
  32958. return
  32959. }
  32960. return *v, true
  32961. }
  32962. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  32963. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32964. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32965. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  32966. if !m.op.Is(OpUpdateOne) {
  32967. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  32968. }
  32969. if m.id == nil || m.oldValue == nil {
  32970. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  32971. }
  32972. oldValue, err := m.oldValue(ctx)
  32973. if err != nil {
  32974. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  32975. }
  32976. return oldValue.TotalTokens, nil
  32977. }
  32978. // AddTotalTokens adds u to the "total_tokens" field.
  32979. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  32980. if m.addtotal_tokens != nil {
  32981. *m.addtotal_tokens += u
  32982. } else {
  32983. m.addtotal_tokens = &u
  32984. }
  32985. }
  32986. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  32987. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  32988. v := m.addtotal_tokens
  32989. if v == nil {
  32990. return
  32991. }
  32992. return *v, true
  32993. }
  32994. // ClearTotalTokens clears the value of the "total_tokens" field.
  32995. func (m *UsageTotalMutation) ClearTotalTokens() {
  32996. m.total_tokens = nil
  32997. m.addtotal_tokens = nil
  32998. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  32999. }
  33000. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  33001. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  33002. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  33003. return ok
  33004. }
  33005. // ResetTotalTokens resets all changes to the "total_tokens" field.
  33006. func (m *UsageTotalMutation) ResetTotalTokens() {
  33007. m.total_tokens = nil
  33008. m.addtotal_tokens = nil
  33009. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  33010. }
  33011. // SetStartIndex sets the "start_index" field.
  33012. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  33013. m.start_index = &u
  33014. m.addstart_index = nil
  33015. }
  33016. // StartIndex returns the value of the "start_index" field in the mutation.
  33017. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  33018. v := m.start_index
  33019. if v == nil {
  33020. return
  33021. }
  33022. return *v, true
  33023. }
  33024. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  33025. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33027. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  33028. if !m.op.Is(OpUpdateOne) {
  33029. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  33030. }
  33031. if m.id == nil || m.oldValue == nil {
  33032. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  33033. }
  33034. oldValue, err := m.oldValue(ctx)
  33035. if err != nil {
  33036. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  33037. }
  33038. return oldValue.StartIndex, nil
  33039. }
  33040. // AddStartIndex adds u to the "start_index" field.
  33041. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  33042. if m.addstart_index != nil {
  33043. *m.addstart_index += u
  33044. } else {
  33045. m.addstart_index = &u
  33046. }
  33047. }
  33048. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  33049. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  33050. v := m.addstart_index
  33051. if v == nil {
  33052. return
  33053. }
  33054. return *v, true
  33055. }
  33056. // ClearStartIndex clears the value of the "start_index" field.
  33057. func (m *UsageTotalMutation) ClearStartIndex() {
  33058. m.start_index = nil
  33059. m.addstart_index = nil
  33060. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  33061. }
  33062. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  33063. func (m *UsageTotalMutation) StartIndexCleared() bool {
  33064. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  33065. return ok
  33066. }
  33067. // ResetStartIndex resets all changes to the "start_index" field.
  33068. func (m *UsageTotalMutation) ResetStartIndex() {
  33069. m.start_index = nil
  33070. m.addstart_index = nil
  33071. delete(m.clearedFields, usagetotal.FieldStartIndex)
  33072. }
  33073. // SetEndIndex sets the "end_index" field.
  33074. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  33075. m.end_index = &u
  33076. m.addend_index = nil
  33077. }
  33078. // EndIndex returns the value of the "end_index" field in the mutation.
  33079. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  33080. v := m.end_index
  33081. if v == nil {
  33082. return
  33083. }
  33084. return *v, true
  33085. }
  33086. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  33087. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33089. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  33090. if !m.op.Is(OpUpdateOne) {
  33091. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  33092. }
  33093. if m.id == nil || m.oldValue == nil {
  33094. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  33095. }
  33096. oldValue, err := m.oldValue(ctx)
  33097. if err != nil {
  33098. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  33099. }
  33100. return oldValue.EndIndex, nil
  33101. }
  33102. // AddEndIndex adds u to the "end_index" field.
  33103. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  33104. if m.addend_index != nil {
  33105. *m.addend_index += u
  33106. } else {
  33107. m.addend_index = &u
  33108. }
  33109. }
  33110. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  33111. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  33112. v := m.addend_index
  33113. if v == nil {
  33114. return
  33115. }
  33116. return *v, true
  33117. }
  33118. // ClearEndIndex clears the value of the "end_index" field.
  33119. func (m *UsageTotalMutation) ClearEndIndex() {
  33120. m.end_index = nil
  33121. m.addend_index = nil
  33122. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  33123. }
  33124. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  33125. func (m *UsageTotalMutation) EndIndexCleared() bool {
  33126. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  33127. return ok
  33128. }
  33129. // ResetEndIndex resets all changes to the "end_index" field.
  33130. func (m *UsageTotalMutation) ResetEndIndex() {
  33131. m.end_index = nil
  33132. m.addend_index = nil
  33133. delete(m.clearedFields, usagetotal.FieldEndIndex)
  33134. }
  33135. // SetOrganizationID sets the "organization_id" field.
  33136. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  33137. m.organization_id = &u
  33138. m.addorganization_id = nil
  33139. }
  33140. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33141. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  33142. v := m.organization_id
  33143. if v == nil {
  33144. return
  33145. }
  33146. return *v, true
  33147. }
  33148. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  33149. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33151. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33152. if !m.op.Is(OpUpdateOne) {
  33153. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33154. }
  33155. if m.id == nil || m.oldValue == nil {
  33156. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33157. }
  33158. oldValue, err := m.oldValue(ctx)
  33159. if err != nil {
  33160. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33161. }
  33162. return oldValue.OrganizationID, nil
  33163. }
  33164. // AddOrganizationID adds u to the "organization_id" field.
  33165. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  33166. if m.addorganization_id != nil {
  33167. *m.addorganization_id += u
  33168. } else {
  33169. m.addorganization_id = &u
  33170. }
  33171. }
  33172. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33173. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  33174. v := m.addorganization_id
  33175. if v == nil {
  33176. return
  33177. }
  33178. return *v, true
  33179. }
  33180. // ClearOrganizationID clears the value of the "organization_id" field.
  33181. func (m *UsageTotalMutation) ClearOrganizationID() {
  33182. m.organization_id = nil
  33183. m.addorganization_id = nil
  33184. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  33185. }
  33186. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33187. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  33188. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  33189. return ok
  33190. }
  33191. // ResetOrganizationID resets all changes to the "organization_id" field.
  33192. func (m *UsageTotalMutation) ResetOrganizationID() {
  33193. m.organization_id = nil
  33194. m.addorganization_id = nil
  33195. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  33196. }
  33197. // Where appends a list predicates to the UsageTotalMutation builder.
  33198. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  33199. m.predicates = append(m.predicates, ps...)
  33200. }
  33201. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  33202. // users can use type-assertion to append predicates that do not depend on any generated package.
  33203. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  33204. p := make([]predicate.UsageTotal, len(ps))
  33205. for i := range ps {
  33206. p[i] = ps[i]
  33207. }
  33208. m.Where(p...)
  33209. }
  33210. // Op returns the operation name.
  33211. func (m *UsageTotalMutation) Op() Op {
  33212. return m.op
  33213. }
  33214. // SetOp allows setting the mutation operation.
  33215. func (m *UsageTotalMutation) SetOp(op Op) {
  33216. m.op = op
  33217. }
  33218. // Type returns the node type of this mutation (UsageTotal).
  33219. func (m *UsageTotalMutation) Type() string {
  33220. return m.typ
  33221. }
  33222. // Fields returns all fields that were changed during this mutation. Note that in
  33223. // order to get all numeric fields that were incremented/decremented, call
  33224. // AddedFields().
  33225. func (m *UsageTotalMutation) Fields() []string {
  33226. fields := make([]string, 0, 9)
  33227. if m.created_at != nil {
  33228. fields = append(fields, usagetotal.FieldCreatedAt)
  33229. }
  33230. if m.updated_at != nil {
  33231. fields = append(fields, usagetotal.FieldUpdatedAt)
  33232. }
  33233. if m.status != nil {
  33234. fields = append(fields, usagetotal.FieldStatus)
  33235. }
  33236. if m._type != nil {
  33237. fields = append(fields, usagetotal.FieldType)
  33238. }
  33239. if m.bot_id != nil {
  33240. fields = append(fields, usagetotal.FieldBotID)
  33241. }
  33242. if m.total_tokens != nil {
  33243. fields = append(fields, usagetotal.FieldTotalTokens)
  33244. }
  33245. if m.start_index != nil {
  33246. fields = append(fields, usagetotal.FieldStartIndex)
  33247. }
  33248. if m.end_index != nil {
  33249. fields = append(fields, usagetotal.FieldEndIndex)
  33250. }
  33251. if m.organization_id != nil {
  33252. fields = append(fields, usagetotal.FieldOrganizationID)
  33253. }
  33254. return fields
  33255. }
  33256. // Field returns the value of a field with the given name. The second boolean
  33257. // return value indicates that this field was not set, or was not defined in the
  33258. // schema.
  33259. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  33260. switch name {
  33261. case usagetotal.FieldCreatedAt:
  33262. return m.CreatedAt()
  33263. case usagetotal.FieldUpdatedAt:
  33264. return m.UpdatedAt()
  33265. case usagetotal.FieldStatus:
  33266. return m.Status()
  33267. case usagetotal.FieldType:
  33268. return m.GetType()
  33269. case usagetotal.FieldBotID:
  33270. return m.BotID()
  33271. case usagetotal.FieldTotalTokens:
  33272. return m.TotalTokens()
  33273. case usagetotal.FieldStartIndex:
  33274. return m.StartIndex()
  33275. case usagetotal.FieldEndIndex:
  33276. return m.EndIndex()
  33277. case usagetotal.FieldOrganizationID:
  33278. return m.OrganizationID()
  33279. }
  33280. return nil, false
  33281. }
  33282. // OldField returns the old value of the field from the database. An error is
  33283. // returned if the mutation operation is not UpdateOne, or the query to the
  33284. // database failed.
  33285. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33286. switch name {
  33287. case usagetotal.FieldCreatedAt:
  33288. return m.OldCreatedAt(ctx)
  33289. case usagetotal.FieldUpdatedAt:
  33290. return m.OldUpdatedAt(ctx)
  33291. case usagetotal.FieldStatus:
  33292. return m.OldStatus(ctx)
  33293. case usagetotal.FieldType:
  33294. return m.OldType(ctx)
  33295. case usagetotal.FieldBotID:
  33296. return m.OldBotID(ctx)
  33297. case usagetotal.FieldTotalTokens:
  33298. return m.OldTotalTokens(ctx)
  33299. case usagetotal.FieldStartIndex:
  33300. return m.OldStartIndex(ctx)
  33301. case usagetotal.FieldEndIndex:
  33302. return m.OldEndIndex(ctx)
  33303. case usagetotal.FieldOrganizationID:
  33304. return m.OldOrganizationID(ctx)
  33305. }
  33306. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  33307. }
  33308. // SetField sets the value of a field with the given name. It returns an error if
  33309. // the field is not defined in the schema, or if the type mismatched the field
  33310. // type.
  33311. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  33312. switch name {
  33313. case usagetotal.FieldCreatedAt:
  33314. v, ok := value.(time.Time)
  33315. if !ok {
  33316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33317. }
  33318. m.SetCreatedAt(v)
  33319. return nil
  33320. case usagetotal.FieldUpdatedAt:
  33321. v, ok := value.(time.Time)
  33322. if !ok {
  33323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33324. }
  33325. m.SetUpdatedAt(v)
  33326. return nil
  33327. case usagetotal.FieldStatus:
  33328. v, ok := value.(uint8)
  33329. if !ok {
  33330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33331. }
  33332. m.SetStatus(v)
  33333. return nil
  33334. case usagetotal.FieldType:
  33335. v, ok := value.(int)
  33336. if !ok {
  33337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33338. }
  33339. m.SetType(v)
  33340. return nil
  33341. case usagetotal.FieldBotID:
  33342. v, ok := value.(string)
  33343. if !ok {
  33344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33345. }
  33346. m.SetBotID(v)
  33347. return nil
  33348. case usagetotal.FieldTotalTokens:
  33349. v, ok := value.(uint64)
  33350. if !ok {
  33351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33352. }
  33353. m.SetTotalTokens(v)
  33354. return nil
  33355. case usagetotal.FieldStartIndex:
  33356. v, ok := value.(uint64)
  33357. if !ok {
  33358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33359. }
  33360. m.SetStartIndex(v)
  33361. return nil
  33362. case usagetotal.FieldEndIndex:
  33363. v, ok := value.(uint64)
  33364. if !ok {
  33365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33366. }
  33367. m.SetEndIndex(v)
  33368. return nil
  33369. case usagetotal.FieldOrganizationID:
  33370. v, ok := value.(uint64)
  33371. if !ok {
  33372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33373. }
  33374. m.SetOrganizationID(v)
  33375. return nil
  33376. }
  33377. return fmt.Errorf("unknown UsageTotal field %s", name)
  33378. }
  33379. // AddedFields returns all numeric fields that were incremented/decremented during
  33380. // this mutation.
  33381. func (m *UsageTotalMutation) AddedFields() []string {
  33382. var fields []string
  33383. if m.addstatus != nil {
  33384. fields = append(fields, usagetotal.FieldStatus)
  33385. }
  33386. if m.add_type != nil {
  33387. fields = append(fields, usagetotal.FieldType)
  33388. }
  33389. if m.addtotal_tokens != nil {
  33390. fields = append(fields, usagetotal.FieldTotalTokens)
  33391. }
  33392. if m.addstart_index != nil {
  33393. fields = append(fields, usagetotal.FieldStartIndex)
  33394. }
  33395. if m.addend_index != nil {
  33396. fields = append(fields, usagetotal.FieldEndIndex)
  33397. }
  33398. if m.addorganization_id != nil {
  33399. fields = append(fields, usagetotal.FieldOrganizationID)
  33400. }
  33401. return fields
  33402. }
  33403. // AddedField returns the numeric value that was incremented/decremented on a field
  33404. // with the given name. The second boolean return value indicates that this field
  33405. // was not set, or was not defined in the schema.
  33406. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  33407. switch name {
  33408. case usagetotal.FieldStatus:
  33409. return m.AddedStatus()
  33410. case usagetotal.FieldType:
  33411. return m.AddedType()
  33412. case usagetotal.FieldTotalTokens:
  33413. return m.AddedTotalTokens()
  33414. case usagetotal.FieldStartIndex:
  33415. return m.AddedStartIndex()
  33416. case usagetotal.FieldEndIndex:
  33417. return m.AddedEndIndex()
  33418. case usagetotal.FieldOrganizationID:
  33419. return m.AddedOrganizationID()
  33420. }
  33421. return nil, false
  33422. }
  33423. // AddField adds the value to the field with the given name. It returns an error if
  33424. // the field is not defined in the schema, or if the type mismatched the field
  33425. // type.
  33426. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  33427. switch name {
  33428. case usagetotal.FieldStatus:
  33429. v, ok := value.(int8)
  33430. if !ok {
  33431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33432. }
  33433. m.AddStatus(v)
  33434. return nil
  33435. case usagetotal.FieldType:
  33436. v, ok := value.(int)
  33437. if !ok {
  33438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33439. }
  33440. m.AddType(v)
  33441. return nil
  33442. case usagetotal.FieldTotalTokens:
  33443. v, ok := value.(int64)
  33444. if !ok {
  33445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33446. }
  33447. m.AddTotalTokens(v)
  33448. return nil
  33449. case usagetotal.FieldStartIndex:
  33450. v, ok := value.(int64)
  33451. if !ok {
  33452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33453. }
  33454. m.AddStartIndex(v)
  33455. return nil
  33456. case usagetotal.FieldEndIndex:
  33457. v, ok := value.(int64)
  33458. if !ok {
  33459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33460. }
  33461. m.AddEndIndex(v)
  33462. return nil
  33463. case usagetotal.FieldOrganizationID:
  33464. v, ok := value.(int64)
  33465. if !ok {
  33466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33467. }
  33468. m.AddOrganizationID(v)
  33469. return nil
  33470. }
  33471. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  33472. }
  33473. // ClearedFields returns all nullable fields that were cleared during this
  33474. // mutation.
  33475. func (m *UsageTotalMutation) ClearedFields() []string {
  33476. var fields []string
  33477. if m.FieldCleared(usagetotal.FieldStatus) {
  33478. fields = append(fields, usagetotal.FieldStatus)
  33479. }
  33480. if m.FieldCleared(usagetotal.FieldType) {
  33481. fields = append(fields, usagetotal.FieldType)
  33482. }
  33483. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  33484. fields = append(fields, usagetotal.FieldTotalTokens)
  33485. }
  33486. if m.FieldCleared(usagetotal.FieldStartIndex) {
  33487. fields = append(fields, usagetotal.FieldStartIndex)
  33488. }
  33489. if m.FieldCleared(usagetotal.FieldEndIndex) {
  33490. fields = append(fields, usagetotal.FieldEndIndex)
  33491. }
  33492. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  33493. fields = append(fields, usagetotal.FieldOrganizationID)
  33494. }
  33495. return fields
  33496. }
  33497. // FieldCleared returns a boolean indicating if a field with the given name was
  33498. // cleared in this mutation.
  33499. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  33500. _, ok := m.clearedFields[name]
  33501. return ok
  33502. }
  33503. // ClearField clears the value of the field with the given name. It returns an
  33504. // error if the field is not defined in the schema.
  33505. func (m *UsageTotalMutation) ClearField(name string) error {
  33506. switch name {
  33507. case usagetotal.FieldStatus:
  33508. m.ClearStatus()
  33509. return nil
  33510. case usagetotal.FieldType:
  33511. m.ClearType()
  33512. return nil
  33513. case usagetotal.FieldTotalTokens:
  33514. m.ClearTotalTokens()
  33515. return nil
  33516. case usagetotal.FieldStartIndex:
  33517. m.ClearStartIndex()
  33518. return nil
  33519. case usagetotal.FieldEndIndex:
  33520. m.ClearEndIndex()
  33521. return nil
  33522. case usagetotal.FieldOrganizationID:
  33523. m.ClearOrganizationID()
  33524. return nil
  33525. }
  33526. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  33527. }
  33528. // ResetField resets all changes in the mutation for the field with the given name.
  33529. // It returns an error if the field is not defined in the schema.
  33530. func (m *UsageTotalMutation) ResetField(name string) error {
  33531. switch name {
  33532. case usagetotal.FieldCreatedAt:
  33533. m.ResetCreatedAt()
  33534. return nil
  33535. case usagetotal.FieldUpdatedAt:
  33536. m.ResetUpdatedAt()
  33537. return nil
  33538. case usagetotal.FieldStatus:
  33539. m.ResetStatus()
  33540. return nil
  33541. case usagetotal.FieldType:
  33542. m.ResetType()
  33543. return nil
  33544. case usagetotal.FieldBotID:
  33545. m.ResetBotID()
  33546. return nil
  33547. case usagetotal.FieldTotalTokens:
  33548. m.ResetTotalTokens()
  33549. return nil
  33550. case usagetotal.FieldStartIndex:
  33551. m.ResetStartIndex()
  33552. return nil
  33553. case usagetotal.FieldEndIndex:
  33554. m.ResetEndIndex()
  33555. return nil
  33556. case usagetotal.FieldOrganizationID:
  33557. m.ResetOrganizationID()
  33558. return nil
  33559. }
  33560. return fmt.Errorf("unknown UsageTotal field %s", name)
  33561. }
  33562. // AddedEdges returns all edge names that were set/added in this mutation.
  33563. func (m *UsageTotalMutation) AddedEdges() []string {
  33564. edges := make([]string, 0, 0)
  33565. return edges
  33566. }
  33567. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33568. // name in this mutation.
  33569. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  33570. return nil
  33571. }
  33572. // RemovedEdges returns all edge names that were removed in this mutation.
  33573. func (m *UsageTotalMutation) RemovedEdges() []string {
  33574. edges := make([]string, 0, 0)
  33575. return edges
  33576. }
  33577. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33578. // the given name in this mutation.
  33579. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  33580. return nil
  33581. }
  33582. // ClearedEdges returns all edge names that were cleared in this mutation.
  33583. func (m *UsageTotalMutation) ClearedEdges() []string {
  33584. edges := make([]string, 0, 0)
  33585. return edges
  33586. }
  33587. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33588. // was cleared in this mutation.
  33589. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  33590. return false
  33591. }
  33592. // ClearEdge clears the value of the edge with the given name. It returns an error
  33593. // if that edge is not defined in the schema.
  33594. func (m *UsageTotalMutation) ClearEdge(name string) error {
  33595. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  33596. }
  33597. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33598. // It returns an error if the edge is not defined in the schema.
  33599. func (m *UsageTotalMutation) ResetEdge(name string) error {
  33600. return fmt.Errorf("unknown UsageTotal edge %s", name)
  33601. }
  33602. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  33603. type WhatsappMutation struct {
  33604. config
  33605. op Op
  33606. typ string
  33607. id *uint64
  33608. created_at *time.Time
  33609. updated_at *time.Time
  33610. status *uint8
  33611. addstatus *int8
  33612. deleted_at *time.Time
  33613. ak *string
  33614. sk *string
  33615. callback *string
  33616. account *string
  33617. nickname *string
  33618. phone *string
  33619. organization_id *uint64
  33620. addorganization_id *int64
  33621. agent_id *uint64
  33622. addagent_id *int64
  33623. api_base *string
  33624. api_key *string
  33625. allow_list *[]string
  33626. appendallow_list []string
  33627. group_allow_list *[]string
  33628. appendgroup_allow_list []string
  33629. block_list *[]string
  33630. appendblock_list []string
  33631. group_block_list *[]string
  33632. appendgroup_block_list []string
  33633. clearedFields map[string]struct{}
  33634. done bool
  33635. oldValue func(context.Context) (*Whatsapp, error)
  33636. predicates []predicate.Whatsapp
  33637. }
  33638. var _ ent.Mutation = (*WhatsappMutation)(nil)
  33639. // whatsappOption allows management of the mutation configuration using functional options.
  33640. type whatsappOption func(*WhatsappMutation)
  33641. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  33642. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  33643. m := &WhatsappMutation{
  33644. config: c,
  33645. op: op,
  33646. typ: TypeWhatsapp,
  33647. clearedFields: make(map[string]struct{}),
  33648. }
  33649. for _, opt := range opts {
  33650. opt(m)
  33651. }
  33652. return m
  33653. }
  33654. // withWhatsappID sets the ID field of the mutation.
  33655. func withWhatsappID(id uint64) whatsappOption {
  33656. return func(m *WhatsappMutation) {
  33657. var (
  33658. err error
  33659. once sync.Once
  33660. value *Whatsapp
  33661. )
  33662. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  33663. once.Do(func() {
  33664. if m.done {
  33665. err = errors.New("querying old values post mutation is not allowed")
  33666. } else {
  33667. value, err = m.Client().Whatsapp.Get(ctx, id)
  33668. }
  33669. })
  33670. return value, err
  33671. }
  33672. m.id = &id
  33673. }
  33674. }
  33675. // withWhatsapp sets the old Whatsapp of the mutation.
  33676. func withWhatsapp(node *Whatsapp) whatsappOption {
  33677. return func(m *WhatsappMutation) {
  33678. m.oldValue = func(context.Context) (*Whatsapp, error) {
  33679. return node, nil
  33680. }
  33681. m.id = &node.ID
  33682. }
  33683. }
  33684. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33685. // executed in a transaction (ent.Tx), a transactional client is returned.
  33686. func (m WhatsappMutation) Client() *Client {
  33687. client := &Client{config: m.config}
  33688. client.init()
  33689. return client
  33690. }
  33691. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33692. // it returns an error otherwise.
  33693. func (m WhatsappMutation) Tx() (*Tx, error) {
  33694. if _, ok := m.driver.(*txDriver); !ok {
  33695. return nil, errors.New("ent: mutation is not running in a transaction")
  33696. }
  33697. tx := &Tx{config: m.config}
  33698. tx.init()
  33699. return tx, nil
  33700. }
  33701. // SetID sets the value of the id field. Note that this
  33702. // operation is only accepted on creation of Whatsapp entities.
  33703. func (m *WhatsappMutation) SetID(id uint64) {
  33704. m.id = &id
  33705. }
  33706. // ID returns the ID value in the mutation. Note that the ID is only available
  33707. // if it was provided to the builder or after it was returned from the database.
  33708. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  33709. if m.id == nil {
  33710. return
  33711. }
  33712. return *m.id, true
  33713. }
  33714. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33715. // That means, if the mutation is applied within a transaction with an isolation level such
  33716. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33717. // or updated by the mutation.
  33718. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  33719. switch {
  33720. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33721. id, exists := m.ID()
  33722. if exists {
  33723. return []uint64{id}, nil
  33724. }
  33725. fallthrough
  33726. case m.op.Is(OpUpdate | OpDelete):
  33727. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  33728. default:
  33729. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33730. }
  33731. }
  33732. // SetCreatedAt sets the "created_at" field.
  33733. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  33734. m.created_at = &t
  33735. }
  33736. // CreatedAt returns the value of the "created_at" field in the mutation.
  33737. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  33738. v := m.created_at
  33739. if v == nil {
  33740. return
  33741. }
  33742. return *v, true
  33743. }
  33744. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  33745. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33747. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33748. if !m.op.Is(OpUpdateOne) {
  33749. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33750. }
  33751. if m.id == nil || m.oldValue == nil {
  33752. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33753. }
  33754. oldValue, err := m.oldValue(ctx)
  33755. if err != nil {
  33756. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33757. }
  33758. return oldValue.CreatedAt, nil
  33759. }
  33760. // ResetCreatedAt resets all changes to the "created_at" field.
  33761. func (m *WhatsappMutation) ResetCreatedAt() {
  33762. m.created_at = nil
  33763. }
  33764. // SetUpdatedAt sets the "updated_at" field.
  33765. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  33766. m.updated_at = &t
  33767. }
  33768. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33769. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  33770. v := m.updated_at
  33771. if v == nil {
  33772. return
  33773. }
  33774. return *v, true
  33775. }
  33776. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  33777. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33779. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33780. if !m.op.Is(OpUpdateOne) {
  33781. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33782. }
  33783. if m.id == nil || m.oldValue == nil {
  33784. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33785. }
  33786. oldValue, err := m.oldValue(ctx)
  33787. if err != nil {
  33788. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33789. }
  33790. return oldValue.UpdatedAt, nil
  33791. }
  33792. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33793. func (m *WhatsappMutation) ResetUpdatedAt() {
  33794. m.updated_at = nil
  33795. }
  33796. // SetStatus sets the "status" field.
  33797. func (m *WhatsappMutation) SetStatus(u uint8) {
  33798. m.status = &u
  33799. m.addstatus = nil
  33800. }
  33801. // Status returns the value of the "status" field in the mutation.
  33802. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  33803. v := m.status
  33804. if v == nil {
  33805. return
  33806. }
  33807. return *v, true
  33808. }
  33809. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  33810. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33812. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33813. if !m.op.Is(OpUpdateOne) {
  33814. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33815. }
  33816. if m.id == nil || m.oldValue == nil {
  33817. return v, errors.New("OldStatus requires an ID field in the mutation")
  33818. }
  33819. oldValue, err := m.oldValue(ctx)
  33820. if err != nil {
  33821. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33822. }
  33823. return oldValue.Status, nil
  33824. }
  33825. // AddStatus adds u to the "status" field.
  33826. func (m *WhatsappMutation) AddStatus(u int8) {
  33827. if m.addstatus != nil {
  33828. *m.addstatus += u
  33829. } else {
  33830. m.addstatus = &u
  33831. }
  33832. }
  33833. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33834. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  33835. v := m.addstatus
  33836. if v == nil {
  33837. return
  33838. }
  33839. return *v, true
  33840. }
  33841. // ClearStatus clears the value of the "status" field.
  33842. func (m *WhatsappMutation) ClearStatus() {
  33843. m.status = nil
  33844. m.addstatus = nil
  33845. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  33846. }
  33847. // StatusCleared returns if the "status" field was cleared in this mutation.
  33848. func (m *WhatsappMutation) StatusCleared() bool {
  33849. _, ok := m.clearedFields[whatsapp.FieldStatus]
  33850. return ok
  33851. }
  33852. // ResetStatus resets all changes to the "status" field.
  33853. func (m *WhatsappMutation) ResetStatus() {
  33854. m.status = nil
  33855. m.addstatus = nil
  33856. delete(m.clearedFields, whatsapp.FieldStatus)
  33857. }
  33858. // SetDeletedAt sets the "deleted_at" field.
  33859. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  33860. m.deleted_at = &t
  33861. }
  33862. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33863. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  33864. v := m.deleted_at
  33865. if v == nil {
  33866. return
  33867. }
  33868. return *v, true
  33869. }
  33870. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  33871. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33873. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  33874. if !m.op.Is(OpUpdateOne) {
  33875. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  33876. }
  33877. if m.id == nil || m.oldValue == nil {
  33878. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  33879. }
  33880. oldValue, err := m.oldValue(ctx)
  33881. if err != nil {
  33882. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  33883. }
  33884. return oldValue.DeletedAt, nil
  33885. }
  33886. // ClearDeletedAt clears the value of the "deleted_at" field.
  33887. func (m *WhatsappMutation) ClearDeletedAt() {
  33888. m.deleted_at = nil
  33889. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  33890. }
  33891. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  33892. func (m *WhatsappMutation) DeletedAtCleared() bool {
  33893. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  33894. return ok
  33895. }
  33896. // ResetDeletedAt resets all changes to the "deleted_at" field.
  33897. func (m *WhatsappMutation) ResetDeletedAt() {
  33898. m.deleted_at = nil
  33899. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  33900. }
  33901. // SetAk sets the "ak" field.
  33902. func (m *WhatsappMutation) SetAk(s string) {
  33903. m.ak = &s
  33904. }
  33905. // Ak returns the value of the "ak" field in the mutation.
  33906. func (m *WhatsappMutation) Ak() (r string, exists bool) {
  33907. v := m.ak
  33908. if v == nil {
  33909. return
  33910. }
  33911. return *v, true
  33912. }
  33913. // OldAk returns the old "ak" field's value of the Whatsapp entity.
  33914. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33915. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33916. func (m *WhatsappMutation) OldAk(ctx context.Context) (v string, err error) {
  33917. if !m.op.Is(OpUpdateOne) {
  33918. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  33919. }
  33920. if m.id == nil || m.oldValue == nil {
  33921. return v, errors.New("OldAk requires an ID field in the mutation")
  33922. }
  33923. oldValue, err := m.oldValue(ctx)
  33924. if err != nil {
  33925. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  33926. }
  33927. return oldValue.Ak, nil
  33928. }
  33929. // ClearAk clears the value of the "ak" field.
  33930. func (m *WhatsappMutation) ClearAk() {
  33931. m.ak = nil
  33932. m.clearedFields[whatsapp.FieldAk] = struct{}{}
  33933. }
  33934. // AkCleared returns if the "ak" field was cleared in this mutation.
  33935. func (m *WhatsappMutation) AkCleared() bool {
  33936. _, ok := m.clearedFields[whatsapp.FieldAk]
  33937. return ok
  33938. }
  33939. // ResetAk resets all changes to the "ak" field.
  33940. func (m *WhatsappMutation) ResetAk() {
  33941. m.ak = nil
  33942. delete(m.clearedFields, whatsapp.FieldAk)
  33943. }
  33944. // SetSk sets the "sk" field.
  33945. func (m *WhatsappMutation) SetSk(s string) {
  33946. m.sk = &s
  33947. }
  33948. // Sk returns the value of the "sk" field in the mutation.
  33949. func (m *WhatsappMutation) Sk() (r string, exists bool) {
  33950. v := m.sk
  33951. if v == nil {
  33952. return
  33953. }
  33954. return *v, true
  33955. }
  33956. // OldSk returns the old "sk" field's value of the Whatsapp entity.
  33957. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33958. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33959. func (m *WhatsappMutation) OldSk(ctx context.Context) (v string, err error) {
  33960. if !m.op.Is(OpUpdateOne) {
  33961. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  33962. }
  33963. if m.id == nil || m.oldValue == nil {
  33964. return v, errors.New("OldSk requires an ID field in the mutation")
  33965. }
  33966. oldValue, err := m.oldValue(ctx)
  33967. if err != nil {
  33968. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  33969. }
  33970. return oldValue.Sk, nil
  33971. }
  33972. // ResetSk resets all changes to the "sk" field.
  33973. func (m *WhatsappMutation) ResetSk() {
  33974. m.sk = nil
  33975. }
  33976. // SetCallback sets the "callback" field.
  33977. func (m *WhatsappMutation) SetCallback(s string) {
  33978. m.callback = &s
  33979. }
  33980. // Callback returns the value of the "callback" field in the mutation.
  33981. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  33982. v := m.callback
  33983. if v == nil {
  33984. return
  33985. }
  33986. return *v, true
  33987. }
  33988. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  33989. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33991. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  33992. if !m.op.Is(OpUpdateOne) {
  33993. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  33994. }
  33995. if m.id == nil || m.oldValue == nil {
  33996. return v, errors.New("OldCallback requires an ID field in the mutation")
  33997. }
  33998. oldValue, err := m.oldValue(ctx)
  33999. if err != nil {
  34000. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  34001. }
  34002. return oldValue.Callback, nil
  34003. }
  34004. // ResetCallback resets all changes to the "callback" field.
  34005. func (m *WhatsappMutation) ResetCallback() {
  34006. m.callback = nil
  34007. }
  34008. // SetAccount sets the "account" field.
  34009. func (m *WhatsappMutation) SetAccount(s string) {
  34010. m.account = &s
  34011. }
  34012. // Account returns the value of the "account" field in the mutation.
  34013. func (m *WhatsappMutation) Account() (r string, exists bool) {
  34014. v := m.account
  34015. if v == nil {
  34016. return
  34017. }
  34018. return *v, true
  34019. }
  34020. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  34021. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34023. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  34024. if !m.op.Is(OpUpdateOne) {
  34025. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  34026. }
  34027. if m.id == nil || m.oldValue == nil {
  34028. return v, errors.New("OldAccount requires an ID field in the mutation")
  34029. }
  34030. oldValue, err := m.oldValue(ctx)
  34031. if err != nil {
  34032. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  34033. }
  34034. return oldValue.Account, nil
  34035. }
  34036. // ResetAccount resets all changes to the "account" field.
  34037. func (m *WhatsappMutation) ResetAccount() {
  34038. m.account = nil
  34039. }
  34040. // SetNickname sets the "nickname" field.
  34041. func (m *WhatsappMutation) SetNickname(s string) {
  34042. m.nickname = &s
  34043. }
  34044. // Nickname returns the value of the "nickname" field in the mutation.
  34045. func (m *WhatsappMutation) Nickname() (r string, exists bool) {
  34046. v := m.nickname
  34047. if v == nil {
  34048. return
  34049. }
  34050. return *v, true
  34051. }
  34052. // OldNickname returns the old "nickname" field's value of the Whatsapp entity.
  34053. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34055. func (m *WhatsappMutation) OldNickname(ctx context.Context) (v string, err error) {
  34056. if !m.op.Is(OpUpdateOne) {
  34057. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  34058. }
  34059. if m.id == nil || m.oldValue == nil {
  34060. return v, errors.New("OldNickname requires an ID field in the mutation")
  34061. }
  34062. oldValue, err := m.oldValue(ctx)
  34063. if err != nil {
  34064. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  34065. }
  34066. return oldValue.Nickname, nil
  34067. }
  34068. // ResetNickname resets all changes to the "nickname" field.
  34069. func (m *WhatsappMutation) ResetNickname() {
  34070. m.nickname = nil
  34071. }
  34072. // SetPhone sets the "phone" field.
  34073. func (m *WhatsappMutation) SetPhone(s string) {
  34074. m.phone = &s
  34075. }
  34076. // Phone returns the value of the "phone" field in the mutation.
  34077. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  34078. v := m.phone
  34079. if v == nil {
  34080. return
  34081. }
  34082. return *v, true
  34083. }
  34084. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  34085. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34087. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  34088. if !m.op.Is(OpUpdateOne) {
  34089. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  34090. }
  34091. if m.id == nil || m.oldValue == nil {
  34092. return v, errors.New("OldPhone requires an ID field in the mutation")
  34093. }
  34094. oldValue, err := m.oldValue(ctx)
  34095. if err != nil {
  34096. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  34097. }
  34098. return oldValue.Phone, nil
  34099. }
  34100. // ResetPhone resets all changes to the "phone" field.
  34101. func (m *WhatsappMutation) ResetPhone() {
  34102. m.phone = nil
  34103. }
  34104. // SetOrganizationID sets the "organization_id" field.
  34105. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  34106. m.organization_id = &u
  34107. m.addorganization_id = nil
  34108. }
  34109. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34110. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  34111. v := m.organization_id
  34112. if v == nil {
  34113. return
  34114. }
  34115. return *v, true
  34116. }
  34117. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  34118. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34119. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34120. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34121. if !m.op.Is(OpUpdateOne) {
  34122. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34123. }
  34124. if m.id == nil || m.oldValue == nil {
  34125. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34126. }
  34127. oldValue, err := m.oldValue(ctx)
  34128. if err != nil {
  34129. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34130. }
  34131. return oldValue.OrganizationID, nil
  34132. }
  34133. // AddOrganizationID adds u to the "organization_id" field.
  34134. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  34135. if m.addorganization_id != nil {
  34136. *m.addorganization_id += u
  34137. } else {
  34138. m.addorganization_id = &u
  34139. }
  34140. }
  34141. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34142. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  34143. v := m.addorganization_id
  34144. if v == nil {
  34145. return
  34146. }
  34147. return *v, true
  34148. }
  34149. // ClearOrganizationID clears the value of the "organization_id" field.
  34150. func (m *WhatsappMutation) ClearOrganizationID() {
  34151. m.organization_id = nil
  34152. m.addorganization_id = nil
  34153. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  34154. }
  34155. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34156. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  34157. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  34158. return ok
  34159. }
  34160. // ResetOrganizationID resets all changes to the "organization_id" field.
  34161. func (m *WhatsappMutation) ResetOrganizationID() {
  34162. m.organization_id = nil
  34163. m.addorganization_id = nil
  34164. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  34165. }
  34166. // SetAgentID sets the "agent_id" field.
  34167. func (m *WhatsappMutation) SetAgentID(u uint64) {
  34168. m.agent_id = &u
  34169. m.addagent_id = nil
  34170. }
  34171. // AgentID returns the value of the "agent_id" field in the mutation.
  34172. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  34173. v := m.agent_id
  34174. if v == nil {
  34175. return
  34176. }
  34177. return *v, true
  34178. }
  34179. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  34180. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34182. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  34183. if !m.op.Is(OpUpdateOne) {
  34184. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  34185. }
  34186. if m.id == nil || m.oldValue == nil {
  34187. return v, errors.New("OldAgentID requires an ID field in the mutation")
  34188. }
  34189. oldValue, err := m.oldValue(ctx)
  34190. if err != nil {
  34191. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  34192. }
  34193. return oldValue.AgentID, nil
  34194. }
  34195. // AddAgentID adds u to the "agent_id" field.
  34196. func (m *WhatsappMutation) AddAgentID(u int64) {
  34197. if m.addagent_id != nil {
  34198. *m.addagent_id += u
  34199. } else {
  34200. m.addagent_id = &u
  34201. }
  34202. }
  34203. // AddedAgentID returns the value that was added to the "agent_id" field in this mutation.
  34204. func (m *WhatsappMutation) AddedAgentID() (r int64, exists bool) {
  34205. v := m.addagent_id
  34206. if v == nil {
  34207. return
  34208. }
  34209. return *v, true
  34210. }
  34211. // ResetAgentID resets all changes to the "agent_id" field.
  34212. func (m *WhatsappMutation) ResetAgentID() {
  34213. m.agent_id = nil
  34214. m.addagent_id = nil
  34215. }
  34216. // SetAPIBase sets the "api_base" field.
  34217. func (m *WhatsappMutation) SetAPIBase(s string) {
  34218. m.api_base = &s
  34219. }
  34220. // APIBase returns the value of the "api_base" field in the mutation.
  34221. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  34222. v := m.api_base
  34223. if v == nil {
  34224. return
  34225. }
  34226. return *v, true
  34227. }
  34228. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  34229. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34231. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  34232. if !m.op.Is(OpUpdateOne) {
  34233. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  34234. }
  34235. if m.id == nil || m.oldValue == nil {
  34236. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  34237. }
  34238. oldValue, err := m.oldValue(ctx)
  34239. if err != nil {
  34240. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  34241. }
  34242. return oldValue.APIBase, nil
  34243. }
  34244. // ClearAPIBase clears the value of the "api_base" field.
  34245. func (m *WhatsappMutation) ClearAPIBase() {
  34246. m.api_base = nil
  34247. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  34248. }
  34249. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  34250. func (m *WhatsappMutation) APIBaseCleared() bool {
  34251. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  34252. return ok
  34253. }
  34254. // ResetAPIBase resets all changes to the "api_base" field.
  34255. func (m *WhatsappMutation) ResetAPIBase() {
  34256. m.api_base = nil
  34257. delete(m.clearedFields, whatsapp.FieldAPIBase)
  34258. }
  34259. // SetAPIKey sets the "api_key" field.
  34260. func (m *WhatsappMutation) SetAPIKey(s string) {
  34261. m.api_key = &s
  34262. }
  34263. // APIKey returns the value of the "api_key" field in the mutation.
  34264. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  34265. v := m.api_key
  34266. if v == nil {
  34267. return
  34268. }
  34269. return *v, true
  34270. }
  34271. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  34272. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34274. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  34275. if !m.op.Is(OpUpdateOne) {
  34276. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  34277. }
  34278. if m.id == nil || m.oldValue == nil {
  34279. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  34280. }
  34281. oldValue, err := m.oldValue(ctx)
  34282. if err != nil {
  34283. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  34284. }
  34285. return oldValue.APIKey, nil
  34286. }
  34287. // ClearAPIKey clears the value of the "api_key" field.
  34288. func (m *WhatsappMutation) ClearAPIKey() {
  34289. m.api_key = nil
  34290. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  34291. }
  34292. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  34293. func (m *WhatsappMutation) APIKeyCleared() bool {
  34294. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  34295. return ok
  34296. }
  34297. // ResetAPIKey resets all changes to the "api_key" field.
  34298. func (m *WhatsappMutation) ResetAPIKey() {
  34299. m.api_key = nil
  34300. delete(m.clearedFields, whatsapp.FieldAPIKey)
  34301. }
  34302. // SetAllowList sets the "allow_list" field.
  34303. func (m *WhatsappMutation) SetAllowList(s []string) {
  34304. m.allow_list = &s
  34305. m.appendallow_list = nil
  34306. }
  34307. // AllowList returns the value of the "allow_list" field in the mutation.
  34308. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  34309. v := m.allow_list
  34310. if v == nil {
  34311. return
  34312. }
  34313. return *v, true
  34314. }
  34315. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  34316. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34318. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  34319. if !m.op.Is(OpUpdateOne) {
  34320. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  34321. }
  34322. if m.id == nil || m.oldValue == nil {
  34323. return v, errors.New("OldAllowList requires an ID field in the mutation")
  34324. }
  34325. oldValue, err := m.oldValue(ctx)
  34326. if err != nil {
  34327. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  34328. }
  34329. return oldValue.AllowList, nil
  34330. }
  34331. // AppendAllowList adds s to the "allow_list" field.
  34332. func (m *WhatsappMutation) AppendAllowList(s []string) {
  34333. m.appendallow_list = append(m.appendallow_list, s...)
  34334. }
  34335. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  34336. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  34337. if len(m.appendallow_list) == 0 {
  34338. return nil, false
  34339. }
  34340. return m.appendallow_list, true
  34341. }
  34342. // ResetAllowList resets all changes to the "allow_list" field.
  34343. func (m *WhatsappMutation) ResetAllowList() {
  34344. m.allow_list = nil
  34345. m.appendallow_list = nil
  34346. }
  34347. // SetGroupAllowList sets the "group_allow_list" field.
  34348. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  34349. m.group_allow_list = &s
  34350. m.appendgroup_allow_list = nil
  34351. }
  34352. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  34353. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  34354. v := m.group_allow_list
  34355. if v == nil {
  34356. return
  34357. }
  34358. return *v, true
  34359. }
  34360. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  34361. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34363. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  34364. if !m.op.Is(OpUpdateOne) {
  34365. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  34366. }
  34367. if m.id == nil || m.oldValue == nil {
  34368. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  34369. }
  34370. oldValue, err := m.oldValue(ctx)
  34371. if err != nil {
  34372. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  34373. }
  34374. return oldValue.GroupAllowList, nil
  34375. }
  34376. // AppendGroupAllowList adds s to the "group_allow_list" field.
  34377. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  34378. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  34379. }
  34380. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  34381. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  34382. if len(m.appendgroup_allow_list) == 0 {
  34383. return nil, false
  34384. }
  34385. return m.appendgroup_allow_list, true
  34386. }
  34387. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  34388. func (m *WhatsappMutation) ResetGroupAllowList() {
  34389. m.group_allow_list = nil
  34390. m.appendgroup_allow_list = nil
  34391. }
  34392. // SetBlockList sets the "block_list" field.
  34393. func (m *WhatsappMutation) SetBlockList(s []string) {
  34394. m.block_list = &s
  34395. m.appendblock_list = nil
  34396. }
  34397. // BlockList returns the value of the "block_list" field in the mutation.
  34398. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  34399. v := m.block_list
  34400. if v == nil {
  34401. return
  34402. }
  34403. return *v, true
  34404. }
  34405. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  34406. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34408. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  34409. if !m.op.Is(OpUpdateOne) {
  34410. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  34411. }
  34412. if m.id == nil || m.oldValue == nil {
  34413. return v, errors.New("OldBlockList requires an ID field in the mutation")
  34414. }
  34415. oldValue, err := m.oldValue(ctx)
  34416. if err != nil {
  34417. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  34418. }
  34419. return oldValue.BlockList, nil
  34420. }
  34421. // AppendBlockList adds s to the "block_list" field.
  34422. func (m *WhatsappMutation) AppendBlockList(s []string) {
  34423. m.appendblock_list = append(m.appendblock_list, s...)
  34424. }
  34425. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  34426. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  34427. if len(m.appendblock_list) == 0 {
  34428. return nil, false
  34429. }
  34430. return m.appendblock_list, true
  34431. }
  34432. // ResetBlockList resets all changes to the "block_list" field.
  34433. func (m *WhatsappMutation) ResetBlockList() {
  34434. m.block_list = nil
  34435. m.appendblock_list = nil
  34436. }
  34437. // SetGroupBlockList sets the "group_block_list" field.
  34438. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  34439. m.group_block_list = &s
  34440. m.appendgroup_block_list = nil
  34441. }
  34442. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  34443. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  34444. v := m.group_block_list
  34445. if v == nil {
  34446. return
  34447. }
  34448. return *v, true
  34449. }
  34450. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  34451. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34453. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  34454. if !m.op.Is(OpUpdateOne) {
  34455. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  34456. }
  34457. if m.id == nil || m.oldValue == nil {
  34458. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  34459. }
  34460. oldValue, err := m.oldValue(ctx)
  34461. if err != nil {
  34462. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  34463. }
  34464. return oldValue.GroupBlockList, nil
  34465. }
  34466. // AppendGroupBlockList adds s to the "group_block_list" field.
  34467. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  34468. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  34469. }
  34470. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  34471. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  34472. if len(m.appendgroup_block_list) == 0 {
  34473. return nil, false
  34474. }
  34475. return m.appendgroup_block_list, true
  34476. }
  34477. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  34478. func (m *WhatsappMutation) ResetGroupBlockList() {
  34479. m.group_block_list = nil
  34480. m.appendgroup_block_list = nil
  34481. }
  34482. // Where appends a list predicates to the WhatsappMutation builder.
  34483. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  34484. m.predicates = append(m.predicates, ps...)
  34485. }
  34486. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  34487. // users can use type-assertion to append predicates that do not depend on any generated package.
  34488. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  34489. p := make([]predicate.Whatsapp, len(ps))
  34490. for i := range ps {
  34491. p[i] = ps[i]
  34492. }
  34493. m.Where(p...)
  34494. }
  34495. // Op returns the operation name.
  34496. func (m *WhatsappMutation) Op() Op {
  34497. return m.op
  34498. }
  34499. // SetOp allows setting the mutation operation.
  34500. func (m *WhatsappMutation) SetOp(op Op) {
  34501. m.op = op
  34502. }
  34503. // Type returns the node type of this mutation (Whatsapp).
  34504. func (m *WhatsappMutation) Type() string {
  34505. return m.typ
  34506. }
  34507. // Fields returns all fields that were changed during this mutation. Note that in
  34508. // order to get all numeric fields that were incremented/decremented, call
  34509. // AddedFields().
  34510. func (m *WhatsappMutation) Fields() []string {
  34511. fields := make([]string, 0, 18)
  34512. if m.created_at != nil {
  34513. fields = append(fields, whatsapp.FieldCreatedAt)
  34514. }
  34515. if m.updated_at != nil {
  34516. fields = append(fields, whatsapp.FieldUpdatedAt)
  34517. }
  34518. if m.status != nil {
  34519. fields = append(fields, whatsapp.FieldStatus)
  34520. }
  34521. if m.deleted_at != nil {
  34522. fields = append(fields, whatsapp.FieldDeletedAt)
  34523. }
  34524. if m.ak != nil {
  34525. fields = append(fields, whatsapp.FieldAk)
  34526. }
  34527. if m.sk != nil {
  34528. fields = append(fields, whatsapp.FieldSk)
  34529. }
  34530. if m.callback != nil {
  34531. fields = append(fields, whatsapp.FieldCallback)
  34532. }
  34533. if m.account != nil {
  34534. fields = append(fields, whatsapp.FieldAccount)
  34535. }
  34536. if m.nickname != nil {
  34537. fields = append(fields, whatsapp.FieldNickname)
  34538. }
  34539. if m.phone != nil {
  34540. fields = append(fields, whatsapp.FieldPhone)
  34541. }
  34542. if m.organization_id != nil {
  34543. fields = append(fields, whatsapp.FieldOrganizationID)
  34544. }
  34545. if m.agent_id != nil {
  34546. fields = append(fields, whatsapp.FieldAgentID)
  34547. }
  34548. if m.api_base != nil {
  34549. fields = append(fields, whatsapp.FieldAPIBase)
  34550. }
  34551. if m.api_key != nil {
  34552. fields = append(fields, whatsapp.FieldAPIKey)
  34553. }
  34554. if m.allow_list != nil {
  34555. fields = append(fields, whatsapp.FieldAllowList)
  34556. }
  34557. if m.group_allow_list != nil {
  34558. fields = append(fields, whatsapp.FieldGroupAllowList)
  34559. }
  34560. if m.block_list != nil {
  34561. fields = append(fields, whatsapp.FieldBlockList)
  34562. }
  34563. if m.group_block_list != nil {
  34564. fields = append(fields, whatsapp.FieldGroupBlockList)
  34565. }
  34566. return fields
  34567. }
  34568. // Field returns the value of a field with the given name. The second boolean
  34569. // return value indicates that this field was not set, or was not defined in the
  34570. // schema.
  34571. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  34572. switch name {
  34573. case whatsapp.FieldCreatedAt:
  34574. return m.CreatedAt()
  34575. case whatsapp.FieldUpdatedAt:
  34576. return m.UpdatedAt()
  34577. case whatsapp.FieldStatus:
  34578. return m.Status()
  34579. case whatsapp.FieldDeletedAt:
  34580. return m.DeletedAt()
  34581. case whatsapp.FieldAk:
  34582. return m.Ak()
  34583. case whatsapp.FieldSk:
  34584. return m.Sk()
  34585. case whatsapp.FieldCallback:
  34586. return m.Callback()
  34587. case whatsapp.FieldAccount:
  34588. return m.Account()
  34589. case whatsapp.FieldNickname:
  34590. return m.Nickname()
  34591. case whatsapp.FieldPhone:
  34592. return m.Phone()
  34593. case whatsapp.FieldOrganizationID:
  34594. return m.OrganizationID()
  34595. case whatsapp.FieldAgentID:
  34596. return m.AgentID()
  34597. case whatsapp.FieldAPIBase:
  34598. return m.APIBase()
  34599. case whatsapp.FieldAPIKey:
  34600. return m.APIKey()
  34601. case whatsapp.FieldAllowList:
  34602. return m.AllowList()
  34603. case whatsapp.FieldGroupAllowList:
  34604. return m.GroupAllowList()
  34605. case whatsapp.FieldBlockList:
  34606. return m.BlockList()
  34607. case whatsapp.FieldGroupBlockList:
  34608. return m.GroupBlockList()
  34609. }
  34610. return nil, false
  34611. }
  34612. // OldField returns the old value of the field from the database. An error is
  34613. // returned if the mutation operation is not UpdateOne, or the query to the
  34614. // database failed.
  34615. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34616. switch name {
  34617. case whatsapp.FieldCreatedAt:
  34618. return m.OldCreatedAt(ctx)
  34619. case whatsapp.FieldUpdatedAt:
  34620. return m.OldUpdatedAt(ctx)
  34621. case whatsapp.FieldStatus:
  34622. return m.OldStatus(ctx)
  34623. case whatsapp.FieldDeletedAt:
  34624. return m.OldDeletedAt(ctx)
  34625. case whatsapp.FieldAk:
  34626. return m.OldAk(ctx)
  34627. case whatsapp.FieldSk:
  34628. return m.OldSk(ctx)
  34629. case whatsapp.FieldCallback:
  34630. return m.OldCallback(ctx)
  34631. case whatsapp.FieldAccount:
  34632. return m.OldAccount(ctx)
  34633. case whatsapp.FieldNickname:
  34634. return m.OldNickname(ctx)
  34635. case whatsapp.FieldPhone:
  34636. return m.OldPhone(ctx)
  34637. case whatsapp.FieldOrganizationID:
  34638. return m.OldOrganizationID(ctx)
  34639. case whatsapp.FieldAgentID:
  34640. return m.OldAgentID(ctx)
  34641. case whatsapp.FieldAPIBase:
  34642. return m.OldAPIBase(ctx)
  34643. case whatsapp.FieldAPIKey:
  34644. return m.OldAPIKey(ctx)
  34645. case whatsapp.FieldAllowList:
  34646. return m.OldAllowList(ctx)
  34647. case whatsapp.FieldGroupAllowList:
  34648. return m.OldGroupAllowList(ctx)
  34649. case whatsapp.FieldBlockList:
  34650. return m.OldBlockList(ctx)
  34651. case whatsapp.FieldGroupBlockList:
  34652. return m.OldGroupBlockList(ctx)
  34653. }
  34654. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  34655. }
  34656. // SetField sets the value of a field with the given name. It returns an error if
  34657. // the field is not defined in the schema, or if the type mismatched the field
  34658. // type.
  34659. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  34660. switch name {
  34661. case whatsapp.FieldCreatedAt:
  34662. v, ok := value.(time.Time)
  34663. if !ok {
  34664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34665. }
  34666. m.SetCreatedAt(v)
  34667. return nil
  34668. case whatsapp.FieldUpdatedAt:
  34669. v, ok := value.(time.Time)
  34670. if !ok {
  34671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34672. }
  34673. m.SetUpdatedAt(v)
  34674. return nil
  34675. case whatsapp.FieldStatus:
  34676. v, ok := value.(uint8)
  34677. if !ok {
  34678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34679. }
  34680. m.SetStatus(v)
  34681. return nil
  34682. case whatsapp.FieldDeletedAt:
  34683. v, ok := value.(time.Time)
  34684. if !ok {
  34685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34686. }
  34687. m.SetDeletedAt(v)
  34688. return nil
  34689. case whatsapp.FieldAk:
  34690. v, ok := value.(string)
  34691. if !ok {
  34692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34693. }
  34694. m.SetAk(v)
  34695. return nil
  34696. case whatsapp.FieldSk:
  34697. v, ok := value.(string)
  34698. if !ok {
  34699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34700. }
  34701. m.SetSk(v)
  34702. return nil
  34703. case whatsapp.FieldCallback:
  34704. v, ok := value.(string)
  34705. if !ok {
  34706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34707. }
  34708. m.SetCallback(v)
  34709. return nil
  34710. case whatsapp.FieldAccount:
  34711. v, ok := value.(string)
  34712. if !ok {
  34713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34714. }
  34715. m.SetAccount(v)
  34716. return nil
  34717. case whatsapp.FieldNickname:
  34718. v, ok := value.(string)
  34719. if !ok {
  34720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34721. }
  34722. m.SetNickname(v)
  34723. return nil
  34724. case whatsapp.FieldPhone:
  34725. v, ok := value.(string)
  34726. if !ok {
  34727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34728. }
  34729. m.SetPhone(v)
  34730. return nil
  34731. case whatsapp.FieldOrganizationID:
  34732. v, ok := value.(uint64)
  34733. if !ok {
  34734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34735. }
  34736. m.SetOrganizationID(v)
  34737. return nil
  34738. case whatsapp.FieldAgentID:
  34739. v, ok := value.(uint64)
  34740. if !ok {
  34741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34742. }
  34743. m.SetAgentID(v)
  34744. return nil
  34745. case whatsapp.FieldAPIBase:
  34746. v, ok := value.(string)
  34747. if !ok {
  34748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34749. }
  34750. m.SetAPIBase(v)
  34751. return nil
  34752. case whatsapp.FieldAPIKey:
  34753. v, ok := value.(string)
  34754. if !ok {
  34755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34756. }
  34757. m.SetAPIKey(v)
  34758. return nil
  34759. case whatsapp.FieldAllowList:
  34760. v, ok := value.([]string)
  34761. if !ok {
  34762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34763. }
  34764. m.SetAllowList(v)
  34765. return nil
  34766. case whatsapp.FieldGroupAllowList:
  34767. v, ok := value.([]string)
  34768. if !ok {
  34769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34770. }
  34771. m.SetGroupAllowList(v)
  34772. return nil
  34773. case whatsapp.FieldBlockList:
  34774. v, ok := value.([]string)
  34775. if !ok {
  34776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34777. }
  34778. m.SetBlockList(v)
  34779. return nil
  34780. case whatsapp.FieldGroupBlockList:
  34781. v, ok := value.([]string)
  34782. if !ok {
  34783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34784. }
  34785. m.SetGroupBlockList(v)
  34786. return nil
  34787. }
  34788. return fmt.Errorf("unknown Whatsapp field %s", name)
  34789. }
  34790. // AddedFields returns all numeric fields that were incremented/decremented during
  34791. // this mutation.
  34792. func (m *WhatsappMutation) AddedFields() []string {
  34793. var fields []string
  34794. if m.addstatus != nil {
  34795. fields = append(fields, whatsapp.FieldStatus)
  34796. }
  34797. if m.addorganization_id != nil {
  34798. fields = append(fields, whatsapp.FieldOrganizationID)
  34799. }
  34800. if m.addagent_id != nil {
  34801. fields = append(fields, whatsapp.FieldAgentID)
  34802. }
  34803. return fields
  34804. }
  34805. // AddedField returns the numeric value that was incremented/decremented on a field
  34806. // with the given name. The second boolean return value indicates that this field
  34807. // was not set, or was not defined in the schema.
  34808. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  34809. switch name {
  34810. case whatsapp.FieldStatus:
  34811. return m.AddedStatus()
  34812. case whatsapp.FieldOrganizationID:
  34813. return m.AddedOrganizationID()
  34814. case whatsapp.FieldAgentID:
  34815. return m.AddedAgentID()
  34816. }
  34817. return nil, false
  34818. }
  34819. // AddField adds the value to the field with the given name. It returns an error if
  34820. // the field is not defined in the schema, or if the type mismatched the field
  34821. // type.
  34822. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  34823. switch name {
  34824. case whatsapp.FieldStatus:
  34825. v, ok := value.(int8)
  34826. if !ok {
  34827. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34828. }
  34829. m.AddStatus(v)
  34830. return nil
  34831. case whatsapp.FieldOrganizationID:
  34832. v, ok := value.(int64)
  34833. if !ok {
  34834. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34835. }
  34836. m.AddOrganizationID(v)
  34837. return nil
  34838. case whatsapp.FieldAgentID:
  34839. v, ok := value.(int64)
  34840. if !ok {
  34841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34842. }
  34843. m.AddAgentID(v)
  34844. return nil
  34845. }
  34846. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  34847. }
  34848. // ClearedFields returns all nullable fields that were cleared during this
  34849. // mutation.
  34850. func (m *WhatsappMutation) ClearedFields() []string {
  34851. var fields []string
  34852. if m.FieldCleared(whatsapp.FieldStatus) {
  34853. fields = append(fields, whatsapp.FieldStatus)
  34854. }
  34855. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  34856. fields = append(fields, whatsapp.FieldDeletedAt)
  34857. }
  34858. if m.FieldCleared(whatsapp.FieldAk) {
  34859. fields = append(fields, whatsapp.FieldAk)
  34860. }
  34861. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  34862. fields = append(fields, whatsapp.FieldOrganizationID)
  34863. }
  34864. if m.FieldCleared(whatsapp.FieldAPIBase) {
  34865. fields = append(fields, whatsapp.FieldAPIBase)
  34866. }
  34867. if m.FieldCleared(whatsapp.FieldAPIKey) {
  34868. fields = append(fields, whatsapp.FieldAPIKey)
  34869. }
  34870. return fields
  34871. }
  34872. // FieldCleared returns a boolean indicating if a field with the given name was
  34873. // cleared in this mutation.
  34874. func (m *WhatsappMutation) FieldCleared(name string) bool {
  34875. _, ok := m.clearedFields[name]
  34876. return ok
  34877. }
  34878. // ClearField clears the value of the field with the given name. It returns an
  34879. // error if the field is not defined in the schema.
  34880. func (m *WhatsappMutation) ClearField(name string) error {
  34881. switch name {
  34882. case whatsapp.FieldStatus:
  34883. m.ClearStatus()
  34884. return nil
  34885. case whatsapp.FieldDeletedAt:
  34886. m.ClearDeletedAt()
  34887. return nil
  34888. case whatsapp.FieldAk:
  34889. m.ClearAk()
  34890. return nil
  34891. case whatsapp.FieldOrganizationID:
  34892. m.ClearOrganizationID()
  34893. return nil
  34894. case whatsapp.FieldAPIBase:
  34895. m.ClearAPIBase()
  34896. return nil
  34897. case whatsapp.FieldAPIKey:
  34898. m.ClearAPIKey()
  34899. return nil
  34900. }
  34901. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  34902. }
  34903. // ResetField resets all changes in the mutation for the field with the given name.
  34904. // It returns an error if the field is not defined in the schema.
  34905. func (m *WhatsappMutation) ResetField(name string) error {
  34906. switch name {
  34907. case whatsapp.FieldCreatedAt:
  34908. m.ResetCreatedAt()
  34909. return nil
  34910. case whatsapp.FieldUpdatedAt:
  34911. m.ResetUpdatedAt()
  34912. return nil
  34913. case whatsapp.FieldStatus:
  34914. m.ResetStatus()
  34915. return nil
  34916. case whatsapp.FieldDeletedAt:
  34917. m.ResetDeletedAt()
  34918. return nil
  34919. case whatsapp.FieldAk:
  34920. m.ResetAk()
  34921. return nil
  34922. case whatsapp.FieldSk:
  34923. m.ResetSk()
  34924. return nil
  34925. case whatsapp.FieldCallback:
  34926. m.ResetCallback()
  34927. return nil
  34928. case whatsapp.FieldAccount:
  34929. m.ResetAccount()
  34930. return nil
  34931. case whatsapp.FieldNickname:
  34932. m.ResetNickname()
  34933. return nil
  34934. case whatsapp.FieldPhone:
  34935. m.ResetPhone()
  34936. return nil
  34937. case whatsapp.FieldOrganizationID:
  34938. m.ResetOrganizationID()
  34939. return nil
  34940. case whatsapp.FieldAgentID:
  34941. m.ResetAgentID()
  34942. return nil
  34943. case whatsapp.FieldAPIBase:
  34944. m.ResetAPIBase()
  34945. return nil
  34946. case whatsapp.FieldAPIKey:
  34947. m.ResetAPIKey()
  34948. return nil
  34949. case whatsapp.FieldAllowList:
  34950. m.ResetAllowList()
  34951. return nil
  34952. case whatsapp.FieldGroupAllowList:
  34953. m.ResetGroupAllowList()
  34954. return nil
  34955. case whatsapp.FieldBlockList:
  34956. m.ResetBlockList()
  34957. return nil
  34958. case whatsapp.FieldGroupBlockList:
  34959. m.ResetGroupBlockList()
  34960. return nil
  34961. }
  34962. return fmt.Errorf("unknown Whatsapp field %s", name)
  34963. }
  34964. // AddedEdges returns all edge names that were set/added in this mutation.
  34965. func (m *WhatsappMutation) AddedEdges() []string {
  34966. edges := make([]string, 0, 0)
  34967. return edges
  34968. }
  34969. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  34970. // name in this mutation.
  34971. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  34972. return nil
  34973. }
  34974. // RemovedEdges returns all edge names that were removed in this mutation.
  34975. func (m *WhatsappMutation) RemovedEdges() []string {
  34976. edges := make([]string, 0, 0)
  34977. return edges
  34978. }
  34979. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  34980. // the given name in this mutation.
  34981. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  34982. return nil
  34983. }
  34984. // ClearedEdges returns all edge names that were cleared in this mutation.
  34985. func (m *WhatsappMutation) ClearedEdges() []string {
  34986. edges := make([]string, 0, 0)
  34987. return edges
  34988. }
  34989. // EdgeCleared returns a boolean which indicates if the edge with the given name
  34990. // was cleared in this mutation.
  34991. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  34992. return false
  34993. }
  34994. // ClearEdge clears the value of the edge with the given name. It returns an error
  34995. // if that edge is not defined in the schema.
  34996. func (m *WhatsappMutation) ClearEdge(name string) error {
  34997. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  34998. }
  34999. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35000. // It returns an error if the edge is not defined in the schema.
  35001. func (m *WhatsappMutation) ResetEdge(name string) error {
  35002. return fmt.Errorf("unknown Whatsapp edge %s", name)
  35003. }
  35004. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  35005. type WorkExperienceMutation struct {
  35006. config
  35007. op Op
  35008. typ string
  35009. id *uint64
  35010. created_at *time.Time
  35011. updated_at *time.Time
  35012. deleted_at *time.Time
  35013. start_date *time.Time
  35014. end_date *time.Time
  35015. company *string
  35016. experience *string
  35017. organization_id *uint64
  35018. addorganization_id *int64
  35019. clearedFields map[string]struct{}
  35020. employee *uint64
  35021. clearedemployee bool
  35022. done bool
  35023. oldValue func(context.Context) (*WorkExperience, error)
  35024. predicates []predicate.WorkExperience
  35025. }
  35026. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  35027. // workexperienceOption allows management of the mutation configuration using functional options.
  35028. type workexperienceOption func(*WorkExperienceMutation)
  35029. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  35030. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  35031. m := &WorkExperienceMutation{
  35032. config: c,
  35033. op: op,
  35034. typ: TypeWorkExperience,
  35035. clearedFields: make(map[string]struct{}),
  35036. }
  35037. for _, opt := range opts {
  35038. opt(m)
  35039. }
  35040. return m
  35041. }
  35042. // withWorkExperienceID sets the ID field of the mutation.
  35043. func withWorkExperienceID(id uint64) workexperienceOption {
  35044. return func(m *WorkExperienceMutation) {
  35045. var (
  35046. err error
  35047. once sync.Once
  35048. value *WorkExperience
  35049. )
  35050. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  35051. once.Do(func() {
  35052. if m.done {
  35053. err = errors.New("querying old values post mutation is not allowed")
  35054. } else {
  35055. value, err = m.Client().WorkExperience.Get(ctx, id)
  35056. }
  35057. })
  35058. return value, err
  35059. }
  35060. m.id = &id
  35061. }
  35062. }
  35063. // withWorkExperience sets the old WorkExperience of the mutation.
  35064. func withWorkExperience(node *WorkExperience) workexperienceOption {
  35065. return func(m *WorkExperienceMutation) {
  35066. m.oldValue = func(context.Context) (*WorkExperience, error) {
  35067. return node, nil
  35068. }
  35069. m.id = &node.ID
  35070. }
  35071. }
  35072. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35073. // executed in a transaction (ent.Tx), a transactional client is returned.
  35074. func (m WorkExperienceMutation) Client() *Client {
  35075. client := &Client{config: m.config}
  35076. client.init()
  35077. return client
  35078. }
  35079. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35080. // it returns an error otherwise.
  35081. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  35082. if _, ok := m.driver.(*txDriver); !ok {
  35083. return nil, errors.New("ent: mutation is not running in a transaction")
  35084. }
  35085. tx := &Tx{config: m.config}
  35086. tx.init()
  35087. return tx, nil
  35088. }
  35089. // SetID sets the value of the id field. Note that this
  35090. // operation is only accepted on creation of WorkExperience entities.
  35091. func (m *WorkExperienceMutation) SetID(id uint64) {
  35092. m.id = &id
  35093. }
  35094. // ID returns the ID value in the mutation. Note that the ID is only available
  35095. // if it was provided to the builder or after it was returned from the database.
  35096. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  35097. if m.id == nil {
  35098. return
  35099. }
  35100. return *m.id, true
  35101. }
  35102. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35103. // That means, if the mutation is applied within a transaction with an isolation level such
  35104. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35105. // or updated by the mutation.
  35106. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  35107. switch {
  35108. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35109. id, exists := m.ID()
  35110. if exists {
  35111. return []uint64{id}, nil
  35112. }
  35113. fallthrough
  35114. case m.op.Is(OpUpdate | OpDelete):
  35115. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  35116. default:
  35117. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35118. }
  35119. }
  35120. // SetCreatedAt sets the "created_at" field.
  35121. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  35122. m.created_at = &t
  35123. }
  35124. // CreatedAt returns the value of the "created_at" field in the mutation.
  35125. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  35126. v := m.created_at
  35127. if v == nil {
  35128. return
  35129. }
  35130. return *v, true
  35131. }
  35132. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  35133. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35135. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35136. if !m.op.Is(OpUpdateOne) {
  35137. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35138. }
  35139. if m.id == nil || m.oldValue == nil {
  35140. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35141. }
  35142. oldValue, err := m.oldValue(ctx)
  35143. if err != nil {
  35144. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35145. }
  35146. return oldValue.CreatedAt, nil
  35147. }
  35148. // ResetCreatedAt resets all changes to the "created_at" field.
  35149. func (m *WorkExperienceMutation) ResetCreatedAt() {
  35150. m.created_at = nil
  35151. }
  35152. // SetUpdatedAt sets the "updated_at" field.
  35153. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  35154. m.updated_at = &t
  35155. }
  35156. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35157. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  35158. v := m.updated_at
  35159. if v == nil {
  35160. return
  35161. }
  35162. return *v, true
  35163. }
  35164. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  35165. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35167. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35168. if !m.op.Is(OpUpdateOne) {
  35169. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35170. }
  35171. if m.id == nil || m.oldValue == nil {
  35172. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35173. }
  35174. oldValue, err := m.oldValue(ctx)
  35175. if err != nil {
  35176. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35177. }
  35178. return oldValue.UpdatedAt, nil
  35179. }
  35180. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35181. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  35182. m.updated_at = nil
  35183. }
  35184. // SetDeletedAt sets the "deleted_at" field.
  35185. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  35186. m.deleted_at = &t
  35187. }
  35188. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35189. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  35190. v := m.deleted_at
  35191. if v == nil {
  35192. return
  35193. }
  35194. return *v, true
  35195. }
  35196. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  35197. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35199. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35200. if !m.op.Is(OpUpdateOne) {
  35201. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35202. }
  35203. if m.id == nil || m.oldValue == nil {
  35204. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35205. }
  35206. oldValue, err := m.oldValue(ctx)
  35207. if err != nil {
  35208. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35209. }
  35210. return oldValue.DeletedAt, nil
  35211. }
  35212. // ClearDeletedAt clears the value of the "deleted_at" field.
  35213. func (m *WorkExperienceMutation) ClearDeletedAt() {
  35214. m.deleted_at = nil
  35215. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  35216. }
  35217. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35218. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  35219. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  35220. return ok
  35221. }
  35222. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35223. func (m *WorkExperienceMutation) ResetDeletedAt() {
  35224. m.deleted_at = nil
  35225. delete(m.clearedFields, workexperience.FieldDeletedAt)
  35226. }
  35227. // SetEmployeeID sets the "employee_id" field.
  35228. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  35229. m.employee = &u
  35230. }
  35231. // EmployeeID returns the value of the "employee_id" field in the mutation.
  35232. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  35233. v := m.employee
  35234. if v == nil {
  35235. return
  35236. }
  35237. return *v, true
  35238. }
  35239. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  35240. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35242. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  35243. if !m.op.Is(OpUpdateOne) {
  35244. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  35245. }
  35246. if m.id == nil || m.oldValue == nil {
  35247. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  35248. }
  35249. oldValue, err := m.oldValue(ctx)
  35250. if err != nil {
  35251. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  35252. }
  35253. return oldValue.EmployeeID, nil
  35254. }
  35255. // ResetEmployeeID resets all changes to the "employee_id" field.
  35256. func (m *WorkExperienceMutation) ResetEmployeeID() {
  35257. m.employee = nil
  35258. }
  35259. // SetStartDate sets the "start_date" field.
  35260. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  35261. m.start_date = &t
  35262. }
  35263. // StartDate returns the value of the "start_date" field in the mutation.
  35264. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  35265. v := m.start_date
  35266. if v == nil {
  35267. return
  35268. }
  35269. return *v, true
  35270. }
  35271. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  35272. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35274. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  35275. if !m.op.Is(OpUpdateOne) {
  35276. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  35277. }
  35278. if m.id == nil || m.oldValue == nil {
  35279. return v, errors.New("OldStartDate requires an ID field in the mutation")
  35280. }
  35281. oldValue, err := m.oldValue(ctx)
  35282. if err != nil {
  35283. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  35284. }
  35285. return oldValue.StartDate, nil
  35286. }
  35287. // ResetStartDate resets all changes to the "start_date" field.
  35288. func (m *WorkExperienceMutation) ResetStartDate() {
  35289. m.start_date = nil
  35290. }
  35291. // SetEndDate sets the "end_date" field.
  35292. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  35293. m.end_date = &t
  35294. }
  35295. // EndDate returns the value of the "end_date" field in the mutation.
  35296. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  35297. v := m.end_date
  35298. if v == nil {
  35299. return
  35300. }
  35301. return *v, true
  35302. }
  35303. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  35304. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35306. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  35307. if !m.op.Is(OpUpdateOne) {
  35308. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  35309. }
  35310. if m.id == nil || m.oldValue == nil {
  35311. return v, errors.New("OldEndDate requires an ID field in the mutation")
  35312. }
  35313. oldValue, err := m.oldValue(ctx)
  35314. if err != nil {
  35315. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  35316. }
  35317. return oldValue.EndDate, nil
  35318. }
  35319. // ResetEndDate resets all changes to the "end_date" field.
  35320. func (m *WorkExperienceMutation) ResetEndDate() {
  35321. m.end_date = nil
  35322. }
  35323. // SetCompany sets the "company" field.
  35324. func (m *WorkExperienceMutation) SetCompany(s string) {
  35325. m.company = &s
  35326. }
  35327. // Company returns the value of the "company" field in the mutation.
  35328. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  35329. v := m.company
  35330. if v == nil {
  35331. return
  35332. }
  35333. return *v, true
  35334. }
  35335. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  35336. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35338. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  35339. if !m.op.Is(OpUpdateOne) {
  35340. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  35341. }
  35342. if m.id == nil || m.oldValue == nil {
  35343. return v, errors.New("OldCompany requires an ID field in the mutation")
  35344. }
  35345. oldValue, err := m.oldValue(ctx)
  35346. if err != nil {
  35347. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  35348. }
  35349. return oldValue.Company, nil
  35350. }
  35351. // ResetCompany resets all changes to the "company" field.
  35352. func (m *WorkExperienceMutation) ResetCompany() {
  35353. m.company = nil
  35354. }
  35355. // SetExperience sets the "experience" field.
  35356. func (m *WorkExperienceMutation) SetExperience(s string) {
  35357. m.experience = &s
  35358. }
  35359. // Experience returns the value of the "experience" field in the mutation.
  35360. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  35361. v := m.experience
  35362. if v == nil {
  35363. return
  35364. }
  35365. return *v, true
  35366. }
  35367. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  35368. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35370. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  35371. if !m.op.Is(OpUpdateOne) {
  35372. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  35373. }
  35374. if m.id == nil || m.oldValue == nil {
  35375. return v, errors.New("OldExperience requires an ID field in the mutation")
  35376. }
  35377. oldValue, err := m.oldValue(ctx)
  35378. if err != nil {
  35379. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  35380. }
  35381. return oldValue.Experience, nil
  35382. }
  35383. // ResetExperience resets all changes to the "experience" field.
  35384. func (m *WorkExperienceMutation) ResetExperience() {
  35385. m.experience = nil
  35386. }
  35387. // SetOrganizationID sets the "organization_id" field.
  35388. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  35389. m.organization_id = &u
  35390. m.addorganization_id = nil
  35391. }
  35392. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35393. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  35394. v := m.organization_id
  35395. if v == nil {
  35396. return
  35397. }
  35398. return *v, true
  35399. }
  35400. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  35401. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35402. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35403. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35404. if !m.op.Is(OpUpdateOne) {
  35405. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35406. }
  35407. if m.id == nil || m.oldValue == nil {
  35408. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35409. }
  35410. oldValue, err := m.oldValue(ctx)
  35411. if err != nil {
  35412. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35413. }
  35414. return oldValue.OrganizationID, nil
  35415. }
  35416. // AddOrganizationID adds u to the "organization_id" field.
  35417. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  35418. if m.addorganization_id != nil {
  35419. *m.addorganization_id += u
  35420. } else {
  35421. m.addorganization_id = &u
  35422. }
  35423. }
  35424. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35425. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  35426. v := m.addorganization_id
  35427. if v == nil {
  35428. return
  35429. }
  35430. return *v, true
  35431. }
  35432. // ResetOrganizationID resets all changes to the "organization_id" field.
  35433. func (m *WorkExperienceMutation) ResetOrganizationID() {
  35434. m.organization_id = nil
  35435. m.addorganization_id = nil
  35436. }
  35437. // ClearEmployee clears the "employee" edge to the Employee entity.
  35438. func (m *WorkExperienceMutation) ClearEmployee() {
  35439. m.clearedemployee = true
  35440. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  35441. }
  35442. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  35443. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  35444. return m.clearedemployee
  35445. }
  35446. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  35447. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  35448. // EmployeeID instead. It exists only for internal usage by the builders.
  35449. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  35450. if id := m.employee; id != nil {
  35451. ids = append(ids, *id)
  35452. }
  35453. return
  35454. }
  35455. // ResetEmployee resets all changes to the "employee" edge.
  35456. func (m *WorkExperienceMutation) ResetEmployee() {
  35457. m.employee = nil
  35458. m.clearedemployee = false
  35459. }
  35460. // Where appends a list predicates to the WorkExperienceMutation builder.
  35461. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  35462. m.predicates = append(m.predicates, ps...)
  35463. }
  35464. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  35465. // users can use type-assertion to append predicates that do not depend on any generated package.
  35466. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  35467. p := make([]predicate.WorkExperience, len(ps))
  35468. for i := range ps {
  35469. p[i] = ps[i]
  35470. }
  35471. m.Where(p...)
  35472. }
  35473. // Op returns the operation name.
  35474. func (m *WorkExperienceMutation) Op() Op {
  35475. return m.op
  35476. }
  35477. // SetOp allows setting the mutation operation.
  35478. func (m *WorkExperienceMutation) SetOp(op Op) {
  35479. m.op = op
  35480. }
  35481. // Type returns the node type of this mutation (WorkExperience).
  35482. func (m *WorkExperienceMutation) Type() string {
  35483. return m.typ
  35484. }
  35485. // Fields returns all fields that were changed during this mutation. Note that in
  35486. // order to get all numeric fields that were incremented/decremented, call
  35487. // AddedFields().
  35488. func (m *WorkExperienceMutation) Fields() []string {
  35489. fields := make([]string, 0, 9)
  35490. if m.created_at != nil {
  35491. fields = append(fields, workexperience.FieldCreatedAt)
  35492. }
  35493. if m.updated_at != nil {
  35494. fields = append(fields, workexperience.FieldUpdatedAt)
  35495. }
  35496. if m.deleted_at != nil {
  35497. fields = append(fields, workexperience.FieldDeletedAt)
  35498. }
  35499. if m.employee != nil {
  35500. fields = append(fields, workexperience.FieldEmployeeID)
  35501. }
  35502. if m.start_date != nil {
  35503. fields = append(fields, workexperience.FieldStartDate)
  35504. }
  35505. if m.end_date != nil {
  35506. fields = append(fields, workexperience.FieldEndDate)
  35507. }
  35508. if m.company != nil {
  35509. fields = append(fields, workexperience.FieldCompany)
  35510. }
  35511. if m.experience != nil {
  35512. fields = append(fields, workexperience.FieldExperience)
  35513. }
  35514. if m.organization_id != nil {
  35515. fields = append(fields, workexperience.FieldOrganizationID)
  35516. }
  35517. return fields
  35518. }
  35519. // Field returns the value of a field with the given name. The second boolean
  35520. // return value indicates that this field was not set, or was not defined in the
  35521. // schema.
  35522. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  35523. switch name {
  35524. case workexperience.FieldCreatedAt:
  35525. return m.CreatedAt()
  35526. case workexperience.FieldUpdatedAt:
  35527. return m.UpdatedAt()
  35528. case workexperience.FieldDeletedAt:
  35529. return m.DeletedAt()
  35530. case workexperience.FieldEmployeeID:
  35531. return m.EmployeeID()
  35532. case workexperience.FieldStartDate:
  35533. return m.StartDate()
  35534. case workexperience.FieldEndDate:
  35535. return m.EndDate()
  35536. case workexperience.FieldCompany:
  35537. return m.Company()
  35538. case workexperience.FieldExperience:
  35539. return m.Experience()
  35540. case workexperience.FieldOrganizationID:
  35541. return m.OrganizationID()
  35542. }
  35543. return nil, false
  35544. }
  35545. // OldField returns the old value of the field from the database. An error is
  35546. // returned if the mutation operation is not UpdateOne, or the query to the
  35547. // database failed.
  35548. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35549. switch name {
  35550. case workexperience.FieldCreatedAt:
  35551. return m.OldCreatedAt(ctx)
  35552. case workexperience.FieldUpdatedAt:
  35553. return m.OldUpdatedAt(ctx)
  35554. case workexperience.FieldDeletedAt:
  35555. return m.OldDeletedAt(ctx)
  35556. case workexperience.FieldEmployeeID:
  35557. return m.OldEmployeeID(ctx)
  35558. case workexperience.FieldStartDate:
  35559. return m.OldStartDate(ctx)
  35560. case workexperience.FieldEndDate:
  35561. return m.OldEndDate(ctx)
  35562. case workexperience.FieldCompany:
  35563. return m.OldCompany(ctx)
  35564. case workexperience.FieldExperience:
  35565. return m.OldExperience(ctx)
  35566. case workexperience.FieldOrganizationID:
  35567. return m.OldOrganizationID(ctx)
  35568. }
  35569. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  35570. }
  35571. // SetField sets the value of a field with the given name. It returns an error if
  35572. // the field is not defined in the schema, or if the type mismatched the field
  35573. // type.
  35574. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  35575. switch name {
  35576. case workexperience.FieldCreatedAt:
  35577. v, ok := value.(time.Time)
  35578. if !ok {
  35579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35580. }
  35581. m.SetCreatedAt(v)
  35582. return nil
  35583. case workexperience.FieldUpdatedAt:
  35584. v, ok := value.(time.Time)
  35585. if !ok {
  35586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35587. }
  35588. m.SetUpdatedAt(v)
  35589. return nil
  35590. case workexperience.FieldDeletedAt:
  35591. v, ok := value.(time.Time)
  35592. if !ok {
  35593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35594. }
  35595. m.SetDeletedAt(v)
  35596. return nil
  35597. case workexperience.FieldEmployeeID:
  35598. v, ok := value.(uint64)
  35599. if !ok {
  35600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35601. }
  35602. m.SetEmployeeID(v)
  35603. return nil
  35604. case workexperience.FieldStartDate:
  35605. v, ok := value.(time.Time)
  35606. if !ok {
  35607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35608. }
  35609. m.SetStartDate(v)
  35610. return nil
  35611. case workexperience.FieldEndDate:
  35612. v, ok := value.(time.Time)
  35613. if !ok {
  35614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35615. }
  35616. m.SetEndDate(v)
  35617. return nil
  35618. case workexperience.FieldCompany:
  35619. v, ok := value.(string)
  35620. if !ok {
  35621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35622. }
  35623. m.SetCompany(v)
  35624. return nil
  35625. case workexperience.FieldExperience:
  35626. v, ok := value.(string)
  35627. if !ok {
  35628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35629. }
  35630. m.SetExperience(v)
  35631. return nil
  35632. case workexperience.FieldOrganizationID:
  35633. v, ok := value.(uint64)
  35634. if !ok {
  35635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35636. }
  35637. m.SetOrganizationID(v)
  35638. return nil
  35639. }
  35640. return fmt.Errorf("unknown WorkExperience field %s", name)
  35641. }
  35642. // AddedFields returns all numeric fields that were incremented/decremented during
  35643. // this mutation.
  35644. func (m *WorkExperienceMutation) AddedFields() []string {
  35645. var fields []string
  35646. if m.addorganization_id != nil {
  35647. fields = append(fields, workexperience.FieldOrganizationID)
  35648. }
  35649. return fields
  35650. }
  35651. // AddedField returns the numeric value that was incremented/decremented on a field
  35652. // with the given name. The second boolean return value indicates that this field
  35653. // was not set, or was not defined in the schema.
  35654. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  35655. switch name {
  35656. case workexperience.FieldOrganizationID:
  35657. return m.AddedOrganizationID()
  35658. }
  35659. return nil, false
  35660. }
  35661. // AddField adds the value to the field with the given name. It returns an error if
  35662. // the field is not defined in the schema, or if the type mismatched the field
  35663. // type.
  35664. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  35665. switch name {
  35666. case workexperience.FieldOrganizationID:
  35667. v, ok := value.(int64)
  35668. if !ok {
  35669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35670. }
  35671. m.AddOrganizationID(v)
  35672. return nil
  35673. }
  35674. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  35675. }
  35676. // ClearedFields returns all nullable fields that were cleared during this
  35677. // mutation.
  35678. func (m *WorkExperienceMutation) ClearedFields() []string {
  35679. var fields []string
  35680. if m.FieldCleared(workexperience.FieldDeletedAt) {
  35681. fields = append(fields, workexperience.FieldDeletedAt)
  35682. }
  35683. return fields
  35684. }
  35685. // FieldCleared returns a boolean indicating if a field with the given name was
  35686. // cleared in this mutation.
  35687. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  35688. _, ok := m.clearedFields[name]
  35689. return ok
  35690. }
  35691. // ClearField clears the value of the field with the given name. It returns an
  35692. // error if the field is not defined in the schema.
  35693. func (m *WorkExperienceMutation) ClearField(name string) error {
  35694. switch name {
  35695. case workexperience.FieldDeletedAt:
  35696. m.ClearDeletedAt()
  35697. return nil
  35698. }
  35699. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  35700. }
  35701. // ResetField resets all changes in the mutation for the field with the given name.
  35702. // It returns an error if the field is not defined in the schema.
  35703. func (m *WorkExperienceMutation) ResetField(name string) error {
  35704. switch name {
  35705. case workexperience.FieldCreatedAt:
  35706. m.ResetCreatedAt()
  35707. return nil
  35708. case workexperience.FieldUpdatedAt:
  35709. m.ResetUpdatedAt()
  35710. return nil
  35711. case workexperience.FieldDeletedAt:
  35712. m.ResetDeletedAt()
  35713. return nil
  35714. case workexperience.FieldEmployeeID:
  35715. m.ResetEmployeeID()
  35716. return nil
  35717. case workexperience.FieldStartDate:
  35718. m.ResetStartDate()
  35719. return nil
  35720. case workexperience.FieldEndDate:
  35721. m.ResetEndDate()
  35722. return nil
  35723. case workexperience.FieldCompany:
  35724. m.ResetCompany()
  35725. return nil
  35726. case workexperience.FieldExperience:
  35727. m.ResetExperience()
  35728. return nil
  35729. case workexperience.FieldOrganizationID:
  35730. m.ResetOrganizationID()
  35731. return nil
  35732. }
  35733. return fmt.Errorf("unknown WorkExperience field %s", name)
  35734. }
  35735. // AddedEdges returns all edge names that were set/added in this mutation.
  35736. func (m *WorkExperienceMutation) AddedEdges() []string {
  35737. edges := make([]string, 0, 1)
  35738. if m.employee != nil {
  35739. edges = append(edges, workexperience.EdgeEmployee)
  35740. }
  35741. return edges
  35742. }
  35743. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35744. // name in this mutation.
  35745. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  35746. switch name {
  35747. case workexperience.EdgeEmployee:
  35748. if id := m.employee; id != nil {
  35749. return []ent.Value{*id}
  35750. }
  35751. }
  35752. return nil
  35753. }
  35754. // RemovedEdges returns all edge names that were removed in this mutation.
  35755. func (m *WorkExperienceMutation) RemovedEdges() []string {
  35756. edges := make([]string, 0, 1)
  35757. return edges
  35758. }
  35759. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35760. // the given name in this mutation.
  35761. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  35762. return nil
  35763. }
  35764. // ClearedEdges returns all edge names that were cleared in this mutation.
  35765. func (m *WorkExperienceMutation) ClearedEdges() []string {
  35766. edges := make([]string, 0, 1)
  35767. if m.clearedemployee {
  35768. edges = append(edges, workexperience.EdgeEmployee)
  35769. }
  35770. return edges
  35771. }
  35772. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35773. // was cleared in this mutation.
  35774. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  35775. switch name {
  35776. case workexperience.EdgeEmployee:
  35777. return m.clearedemployee
  35778. }
  35779. return false
  35780. }
  35781. // ClearEdge clears the value of the edge with the given name. It returns an error
  35782. // if that edge is not defined in the schema.
  35783. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  35784. switch name {
  35785. case workexperience.EdgeEmployee:
  35786. m.ClearEmployee()
  35787. return nil
  35788. }
  35789. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  35790. }
  35791. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35792. // It returns an error if the edge is not defined in the schema.
  35793. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  35794. switch name {
  35795. case workexperience.EdgeEmployee:
  35796. m.ResetEmployee()
  35797. return nil
  35798. }
  35799. return fmt.Errorf("unknown WorkExperience edge %s", name)
  35800. }
  35801. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  35802. type WpChatroomMutation struct {
  35803. config
  35804. op Op
  35805. typ string
  35806. id *uint64
  35807. created_at *time.Time
  35808. updated_at *time.Time
  35809. status *uint8
  35810. addstatus *int8
  35811. wx_wxid *string
  35812. chatroom_id *string
  35813. nickname *string
  35814. owner *string
  35815. avatar *string
  35816. member_list *[]string
  35817. appendmember_list []string
  35818. clearedFields map[string]struct{}
  35819. done bool
  35820. oldValue func(context.Context) (*WpChatroom, error)
  35821. predicates []predicate.WpChatroom
  35822. }
  35823. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  35824. // wpchatroomOption allows management of the mutation configuration using functional options.
  35825. type wpchatroomOption func(*WpChatroomMutation)
  35826. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  35827. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  35828. m := &WpChatroomMutation{
  35829. config: c,
  35830. op: op,
  35831. typ: TypeWpChatroom,
  35832. clearedFields: make(map[string]struct{}),
  35833. }
  35834. for _, opt := range opts {
  35835. opt(m)
  35836. }
  35837. return m
  35838. }
  35839. // withWpChatroomID sets the ID field of the mutation.
  35840. func withWpChatroomID(id uint64) wpchatroomOption {
  35841. return func(m *WpChatroomMutation) {
  35842. var (
  35843. err error
  35844. once sync.Once
  35845. value *WpChatroom
  35846. )
  35847. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  35848. once.Do(func() {
  35849. if m.done {
  35850. err = errors.New("querying old values post mutation is not allowed")
  35851. } else {
  35852. value, err = m.Client().WpChatroom.Get(ctx, id)
  35853. }
  35854. })
  35855. return value, err
  35856. }
  35857. m.id = &id
  35858. }
  35859. }
  35860. // withWpChatroom sets the old WpChatroom of the mutation.
  35861. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  35862. return func(m *WpChatroomMutation) {
  35863. m.oldValue = func(context.Context) (*WpChatroom, error) {
  35864. return node, nil
  35865. }
  35866. m.id = &node.ID
  35867. }
  35868. }
  35869. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35870. // executed in a transaction (ent.Tx), a transactional client is returned.
  35871. func (m WpChatroomMutation) Client() *Client {
  35872. client := &Client{config: m.config}
  35873. client.init()
  35874. return client
  35875. }
  35876. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35877. // it returns an error otherwise.
  35878. func (m WpChatroomMutation) Tx() (*Tx, error) {
  35879. if _, ok := m.driver.(*txDriver); !ok {
  35880. return nil, errors.New("ent: mutation is not running in a transaction")
  35881. }
  35882. tx := &Tx{config: m.config}
  35883. tx.init()
  35884. return tx, nil
  35885. }
  35886. // SetID sets the value of the id field. Note that this
  35887. // operation is only accepted on creation of WpChatroom entities.
  35888. func (m *WpChatroomMutation) SetID(id uint64) {
  35889. m.id = &id
  35890. }
  35891. // ID returns the ID value in the mutation. Note that the ID is only available
  35892. // if it was provided to the builder or after it was returned from the database.
  35893. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  35894. if m.id == nil {
  35895. return
  35896. }
  35897. return *m.id, true
  35898. }
  35899. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35900. // That means, if the mutation is applied within a transaction with an isolation level such
  35901. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35902. // or updated by the mutation.
  35903. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  35904. switch {
  35905. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35906. id, exists := m.ID()
  35907. if exists {
  35908. return []uint64{id}, nil
  35909. }
  35910. fallthrough
  35911. case m.op.Is(OpUpdate | OpDelete):
  35912. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  35913. default:
  35914. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35915. }
  35916. }
  35917. // SetCreatedAt sets the "created_at" field.
  35918. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  35919. m.created_at = &t
  35920. }
  35921. // CreatedAt returns the value of the "created_at" field in the mutation.
  35922. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  35923. v := m.created_at
  35924. if v == nil {
  35925. return
  35926. }
  35927. return *v, true
  35928. }
  35929. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  35930. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  35931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35932. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35933. if !m.op.Is(OpUpdateOne) {
  35934. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35935. }
  35936. if m.id == nil || m.oldValue == nil {
  35937. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35938. }
  35939. oldValue, err := m.oldValue(ctx)
  35940. if err != nil {
  35941. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35942. }
  35943. return oldValue.CreatedAt, nil
  35944. }
  35945. // ResetCreatedAt resets all changes to the "created_at" field.
  35946. func (m *WpChatroomMutation) ResetCreatedAt() {
  35947. m.created_at = nil
  35948. }
  35949. // SetUpdatedAt sets the "updated_at" field.
  35950. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  35951. m.updated_at = &t
  35952. }
  35953. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35954. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  35955. v := m.updated_at
  35956. if v == nil {
  35957. return
  35958. }
  35959. return *v, true
  35960. }
  35961. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  35962. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  35963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35964. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35965. if !m.op.Is(OpUpdateOne) {
  35966. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35967. }
  35968. if m.id == nil || m.oldValue == nil {
  35969. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35970. }
  35971. oldValue, err := m.oldValue(ctx)
  35972. if err != nil {
  35973. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35974. }
  35975. return oldValue.UpdatedAt, nil
  35976. }
  35977. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35978. func (m *WpChatroomMutation) ResetUpdatedAt() {
  35979. m.updated_at = nil
  35980. }
  35981. // SetStatus sets the "status" field.
  35982. func (m *WpChatroomMutation) SetStatus(u uint8) {
  35983. m.status = &u
  35984. m.addstatus = nil
  35985. }
  35986. // Status returns the value of the "status" field in the mutation.
  35987. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  35988. v := m.status
  35989. if v == nil {
  35990. return
  35991. }
  35992. return *v, true
  35993. }
  35994. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  35995. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  35996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35997. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  35998. if !m.op.Is(OpUpdateOne) {
  35999. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36000. }
  36001. if m.id == nil || m.oldValue == nil {
  36002. return v, errors.New("OldStatus requires an ID field in the mutation")
  36003. }
  36004. oldValue, err := m.oldValue(ctx)
  36005. if err != nil {
  36006. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36007. }
  36008. return oldValue.Status, nil
  36009. }
  36010. // AddStatus adds u to the "status" field.
  36011. func (m *WpChatroomMutation) AddStatus(u int8) {
  36012. if m.addstatus != nil {
  36013. *m.addstatus += u
  36014. } else {
  36015. m.addstatus = &u
  36016. }
  36017. }
  36018. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36019. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  36020. v := m.addstatus
  36021. if v == nil {
  36022. return
  36023. }
  36024. return *v, true
  36025. }
  36026. // ClearStatus clears the value of the "status" field.
  36027. func (m *WpChatroomMutation) ClearStatus() {
  36028. m.status = nil
  36029. m.addstatus = nil
  36030. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  36031. }
  36032. // StatusCleared returns if the "status" field was cleared in this mutation.
  36033. func (m *WpChatroomMutation) StatusCleared() bool {
  36034. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  36035. return ok
  36036. }
  36037. // ResetStatus resets all changes to the "status" field.
  36038. func (m *WpChatroomMutation) ResetStatus() {
  36039. m.status = nil
  36040. m.addstatus = nil
  36041. delete(m.clearedFields, wpchatroom.FieldStatus)
  36042. }
  36043. // SetWxWxid sets the "wx_wxid" field.
  36044. func (m *WpChatroomMutation) SetWxWxid(s string) {
  36045. m.wx_wxid = &s
  36046. }
  36047. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  36048. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  36049. v := m.wx_wxid
  36050. if v == nil {
  36051. return
  36052. }
  36053. return *v, true
  36054. }
  36055. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  36056. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36057. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36058. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  36059. if !m.op.Is(OpUpdateOne) {
  36060. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  36061. }
  36062. if m.id == nil || m.oldValue == nil {
  36063. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  36064. }
  36065. oldValue, err := m.oldValue(ctx)
  36066. if err != nil {
  36067. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  36068. }
  36069. return oldValue.WxWxid, nil
  36070. }
  36071. // ResetWxWxid resets all changes to the "wx_wxid" field.
  36072. func (m *WpChatroomMutation) ResetWxWxid() {
  36073. m.wx_wxid = nil
  36074. }
  36075. // SetChatroomID sets the "chatroom_id" field.
  36076. func (m *WpChatroomMutation) SetChatroomID(s string) {
  36077. m.chatroom_id = &s
  36078. }
  36079. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  36080. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  36081. v := m.chatroom_id
  36082. if v == nil {
  36083. return
  36084. }
  36085. return *v, true
  36086. }
  36087. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  36088. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36089. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36090. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  36091. if !m.op.Is(OpUpdateOne) {
  36092. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  36093. }
  36094. if m.id == nil || m.oldValue == nil {
  36095. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  36096. }
  36097. oldValue, err := m.oldValue(ctx)
  36098. if err != nil {
  36099. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  36100. }
  36101. return oldValue.ChatroomID, nil
  36102. }
  36103. // ResetChatroomID resets all changes to the "chatroom_id" field.
  36104. func (m *WpChatroomMutation) ResetChatroomID() {
  36105. m.chatroom_id = nil
  36106. }
  36107. // SetNickname sets the "nickname" field.
  36108. func (m *WpChatroomMutation) SetNickname(s string) {
  36109. m.nickname = &s
  36110. }
  36111. // Nickname returns the value of the "nickname" field in the mutation.
  36112. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  36113. v := m.nickname
  36114. if v == nil {
  36115. return
  36116. }
  36117. return *v, true
  36118. }
  36119. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  36120. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36121. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36122. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  36123. if !m.op.Is(OpUpdateOne) {
  36124. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  36125. }
  36126. if m.id == nil || m.oldValue == nil {
  36127. return v, errors.New("OldNickname requires an ID field in the mutation")
  36128. }
  36129. oldValue, err := m.oldValue(ctx)
  36130. if err != nil {
  36131. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  36132. }
  36133. return oldValue.Nickname, nil
  36134. }
  36135. // ResetNickname resets all changes to the "nickname" field.
  36136. func (m *WpChatroomMutation) ResetNickname() {
  36137. m.nickname = nil
  36138. }
  36139. // SetOwner sets the "owner" field.
  36140. func (m *WpChatroomMutation) SetOwner(s string) {
  36141. m.owner = &s
  36142. }
  36143. // Owner returns the value of the "owner" field in the mutation.
  36144. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  36145. v := m.owner
  36146. if v == nil {
  36147. return
  36148. }
  36149. return *v, true
  36150. }
  36151. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  36152. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36154. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  36155. if !m.op.Is(OpUpdateOne) {
  36156. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  36157. }
  36158. if m.id == nil || m.oldValue == nil {
  36159. return v, errors.New("OldOwner requires an ID field in the mutation")
  36160. }
  36161. oldValue, err := m.oldValue(ctx)
  36162. if err != nil {
  36163. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  36164. }
  36165. return oldValue.Owner, nil
  36166. }
  36167. // ResetOwner resets all changes to the "owner" field.
  36168. func (m *WpChatroomMutation) ResetOwner() {
  36169. m.owner = nil
  36170. }
  36171. // SetAvatar sets the "avatar" field.
  36172. func (m *WpChatroomMutation) SetAvatar(s string) {
  36173. m.avatar = &s
  36174. }
  36175. // Avatar returns the value of the "avatar" field in the mutation.
  36176. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  36177. v := m.avatar
  36178. if v == nil {
  36179. return
  36180. }
  36181. return *v, true
  36182. }
  36183. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  36184. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36186. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  36187. if !m.op.Is(OpUpdateOne) {
  36188. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  36189. }
  36190. if m.id == nil || m.oldValue == nil {
  36191. return v, errors.New("OldAvatar requires an ID field in the mutation")
  36192. }
  36193. oldValue, err := m.oldValue(ctx)
  36194. if err != nil {
  36195. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  36196. }
  36197. return oldValue.Avatar, nil
  36198. }
  36199. // ResetAvatar resets all changes to the "avatar" field.
  36200. func (m *WpChatroomMutation) ResetAvatar() {
  36201. m.avatar = nil
  36202. }
  36203. // SetMemberList sets the "member_list" field.
  36204. func (m *WpChatroomMutation) SetMemberList(s []string) {
  36205. m.member_list = &s
  36206. m.appendmember_list = nil
  36207. }
  36208. // MemberList returns the value of the "member_list" field in the mutation.
  36209. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  36210. v := m.member_list
  36211. if v == nil {
  36212. return
  36213. }
  36214. return *v, true
  36215. }
  36216. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  36217. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36218. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36219. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  36220. if !m.op.Is(OpUpdateOne) {
  36221. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  36222. }
  36223. if m.id == nil || m.oldValue == nil {
  36224. return v, errors.New("OldMemberList requires an ID field in the mutation")
  36225. }
  36226. oldValue, err := m.oldValue(ctx)
  36227. if err != nil {
  36228. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  36229. }
  36230. return oldValue.MemberList, nil
  36231. }
  36232. // AppendMemberList adds s to the "member_list" field.
  36233. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  36234. m.appendmember_list = append(m.appendmember_list, s...)
  36235. }
  36236. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  36237. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  36238. if len(m.appendmember_list) == 0 {
  36239. return nil, false
  36240. }
  36241. return m.appendmember_list, true
  36242. }
  36243. // ResetMemberList resets all changes to the "member_list" field.
  36244. func (m *WpChatroomMutation) ResetMemberList() {
  36245. m.member_list = nil
  36246. m.appendmember_list = nil
  36247. }
  36248. // Where appends a list predicates to the WpChatroomMutation builder.
  36249. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  36250. m.predicates = append(m.predicates, ps...)
  36251. }
  36252. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  36253. // users can use type-assertion to append predicates that do not depend on any generated package.
  36254. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  36255. p := make([]predicate.WpChatroom, len(ps))
  36256. for i := range ps {
  36257. p[i] = ps[i]
  36258. }
  36259. m.Where(p...)
  36260. }
  36261. // Op returns the operation name.
  36262. func (m *WpChatroomMutation) Op() Op {
  36263. return m.op
  36264. }
  36265. // SetOp allows setting the mutation operation.
  36266. func (m *WpChatroomMutation) SetOp(op Op) {
  36267. m.op = op
  36268. }
  36269. // Type returns the node type of this mutation (WpChatroom).
  36270. func (m *WpChatroomMutation) Type() string {
  36271. return m.typ
  36272. }
  36273. // Fields returns all fields that were changed during this mutation. Note that in
  36274. // order to get all numeric fields that were incremented/decremented, call
  36275. // AddedFields().
  36276. func (m *WpChatroomMutation) Fields() []string {
  36277. fields := make([]string, 0, 9)
  36278. if m.created_at != nil {
  36279. fields = append(fields, wpchatroom.FieldCreatedAt)
  36280. }
  36281. if m.updated_at != nil {
  36282. fields = append(fields, wpchatroom.FieldUpdatedAt)
  36283. }
  36284. if m.status != nil {
  36285. fields = append(fields, wpchatroom.FieldStatus)
  36286. }
  36287. if m.wx_wxid != nil {
  36288. fields = append(fields, wpchatroom.FieldWxWxid)
  36289. }
  36290. if m.chatroom_id != nil {
  36291. fields = append(fields, wpchatroom.FieldChatroomID)
  36292. }
  36293. if m.nickname != nil {
  36294. fields = append(fields, wpchatroom.FieldNickname)
  36295. }
  36296. if m.owner != nil {
  36297. fields = append(fields, wpchatroom.FieldOwner)
  36298. }
  36299. if m.avatar != nil {
  36300. fields = append(fields, wpchatroom.FieldAvatar)
  36301. }
  36302. if m.member_list != nil {
  36303. fields = append(fields, wpchatroom.FieldMemberList)
  36304. }
  36305. return fields
  36306. }
  36307. // Field returns the value of a field with the given name. The second boolean
  36308. // return value indicates that this field was not set, or was not defined in the
  36309. // schema.
  36310. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  36311. switch name {
  36312. case wpchatroom.FieldCreatedAt:
  36313. return m.CreatedAt()
  36314. case wpchatroom.FieldUpdatedAt:
  36315. return m.UpdatedAt()
  36316. case wpchatroom.FieldStatus:
  36317. return m.Status()
  36318. case wpchatroom.FieldWxWxid:
  36319. return m.WxWxid()
  36320. case wpchatroom.FieldChatroomID:
  36321. return m.ChatroomID()
  36322. case wpchatroom.FieldNickname:
  36323. return m.Nickname()
  36324. case wpchatroom.FieldOwner:
  36325. return m.Owner()
  36326. case wpchatroom.FieldAvatar:
  36327. return m.Avatar()
  36328. case wpchatroom.FieldMemberList:
  36329. return m.MemberList()
  36330. }
  36331. return nil, false
  36332. }
  36333. // OldField returns the old value of the field from the database. An error is
  36334. // returned if the mutation operation is not UpdateOne, or the query to the
  36335. // database failed.
  36336. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36337. switch name {
  36338. case wpchatroom.FieldCreatedAt:
  36339. return m.OldCreatedAt(ctx)
  36340. case wpchatroom.FieldUpdatedAt:
  36341. return m.OldUpdatedAt(ctx)
  36342. case wpchatroom.FieldStatus:
  36343. return m.OldStatus(ctx)
  36344. case wpchatroom.FieldWxWxid:
  36345. return m.OldWxWxid(ctx)
  36346. case wpchatroom.FieldChatroomID:
  36347. return m.OldChatroomID(ctx)
  36348. case wpchatroom.FieldNickname:
  36349. return m.OldNickname(ctx)
  36350. case wpchatroom.FieldOwner:
  36351. return m.OldOwner(ctx)
  36352. case wpchatroom.FieldAvatar:
  36353. return m.OldAvatar(ctx)
  36354. case wpchatroom.FieldMemberList:
  36355. return m.OldMemberList(ctx)
  36356. }
  36357. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  36358. }
  36359. // SetField sets the value of a field with the given name. It returns an error if
  36360. // the field is not defined in the schema, or if the type mismatched the field
  36361. // type.
  36362. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  36363. switch name {
  36364. case wpchatroom.FieldCreatedAt:
  36365. v, ok := value.(time.Time)
  36366. if !ok {
  36367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36368. }
  36369. m.SetCreatedAt(v)
  36370. return nil
  36371. case wpchatroom.FieldUpdatedAt:
  36372. v, ok := value.(time.Time)
  36373. if !ok {
  36374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36375. }
  36376. m.SetUpdatedAt(v)
  36377. return nil
  36378. case wpchatroom.FieldStatus:
  36379. v, ok := value.(uint8)
  36380. if !ok {
  36381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36382. }
  36383. m.SetStatus(v)
  36384. return nil
  36385. case wpchatroom.FieldWxWxid:
  36386. v, ok := value.(string)
  36387. if !ok {
  36388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36389. }
  36390. m.SetWxWxid(v)
  36391. return nil
  36392. case wpchatroom.FieldChatroomID:
  36393. v, ok := value.(string)
  36394. if !ok {
  36395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36396. }
  36397. m.SetChatroomID(v)
  36398. return nil
  36399. case wpchatroom.FieldNickname:
  36400. v, ok := value.(string)
  36401. if !ok {
  36402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36403. }
  36404. m.SetNickname(v)
  36405. return nil
  36406. case wpchatroom.FieldOwner:
  36407. v, ok := value.(string)
  36408. if !ok {
  36409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36410. }
  36411. m.SetOwner(v)
  36412. return nil
  36413. case wpchatroom.FieldAvatar:
  36414. v, ok := value.(string)
  36415. if !ok {
  36416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36417. }
  36418. m.SetAvatar(v)
  36419. return nil
  36420. case wpchatroom.FieldMemberList:
  36421. v, ok := value.([]string)
  36422. if !ok {
  36423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36424. }
  36425. m.SetMemberList(v)
  36426. return nil
  36427. }
  36428. return fmt.Errorf("unknown WpChatroom field %s", name)
  36429. }
  36430. // AddedFields returns all numeric fields that were incremented/decremented during
  36431. // this mutation.
  36432. func (m *WpChatroomMutation) AddedFields() []string {
  36433. var fields []string
  36434. if m.addstatus != nil {
  36435. fields = append(fields, wpchatroom.FieldStatus)
  36436. }
  36437. return fields
  36438. }
  36439. // AddedField returns the numeric value that was incremented/decremented on a field
  36440. // with the given name. The second boolean return value indicates that this field
  36441. // was not set, or was not defined in the schema.
  36442. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  36443. switch name {
  36444. case wpchatroom.FieldStatus:
  36445. return m.AddedStatus()
  36446. }
  36447. return nil, false
  36448. }
  36449. // AddField adds the value to the field with the given name. It returns an error if
  36450. // the field is not defined in the schema, or if the type mismatched the field
  36451. // type.
  36452. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  36453. switch name {
  36454. case wpchatroom.FieldStatus:
  36455. v, ok := value.(int8)
  36456. if !ok {
  36457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36458. }
  36459. m.AddStatus(v)
  36460. return nil
  36461. }
  36462. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  36463. }
  36464. // ClearedFields returns all nullable fields that were cleared during this
  36465. // mutation.
  36466. func (m *WpChatroomMutation) ClearedFields() []string {
  36467. var fields []string
  36468. if m.FieldCleared(wpchatroom.FieldStatus) {
  36469. fields = append(fields, wpchatroom.FieldStatus)
  36470. }
  36471. return fields
  36472. }
  36473. // FieldCleared returns a boolean indicating if a field with the given name was
  36474. // cleared in this mutation.
  36475. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  36476. _, ok := m.clearedFields[name]
  36477. return ok
  36478. }
  36479. // ClearField clears the value of the field with the given name. It returns an
  36480. // error if the field is not defined in the schema.
  36481. func (m *WpChatroomMutation) ClearField(name string) error {
  36482. switch name {
  36483. case wpchatroom.FieldStatus:
  36484. m.ClearStatus()
  36485. return nil
  36486. }
  36487. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  36488. }
  36489. // ResetField resets all changes in the mutation for the field with the given name.
  36490. // It returns an error if the field is not defined in the schema.
  36491. func (m *WpChatroomMutation) ResetField(name string) error {
  36492. switch name {
  36493. case wpchatroom.FieldCreatedAt:
  36494. m.ResetCreatedAt()
  36495. return nil
  36496. case wpchatroom.FieldUpdatedAt:
  36497. m.ResetUpdatedAt()
  36498. return nil
  36499. case wpchatroom.FieldStatus:
  36500. m.ResetStatus()
  36501. return nil
  36502. case wpchatroom.FieldWxWxid:
  36503. m.ResetWxWxid()
  36504. return nil
  36505. case wpchatroom.FieldChatroomID:
  36506. m.ResetChatroomID()
  36507. return nil
  36508. case wpchatroom.FieldNickname:
  36509. m.ResetNickname()
  36510. return nil
  36511. case wpchatroom.FieldOwner:
  36512. m.ResetOwner()
  36513. return nil
  36514. case wpchatroom.FieldAvatar:
  36515. m.ResetAvatar()
  36516. return nil
  36517. case wpchatroom.FieldMemberList:
  36518. m.ResetMemberList()
  36519. return nil
  36520. }
  36521. return fmt.Errorf("unknown WpChatroom field %s", name)
  36522. }
  36523. // AddedEdges returns all edge names that were set/added in this mutation.
  36524. func (m *WpChatroomMutation) AddedEdges() []string {
  36525. edges := make([]string, 0, 0)
  36526. return edges
  36527. }
  36528. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36529. // name in this mutation.
  36530. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  36531. return nil
  36532. }
  36533. // RemovedEdges returns all edge names that were removed in this mutation.
  36534. func (m *WpChatroomMutation) RemovedEdges() []string {
  36535. edges := make([]string, 0, 0)
  36536. return edges
  36537. }
  36538. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36539. // the given name in this mutation.
  36540. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  36541. return nil
  36542. }
  36543. // ClearedEdges returns all edge names that were cleared in this mutation.
  36544. func (m *WpChatroomMutation) ClearedEdges() []string {
  36545. edges := make([]string, 0, 0)
  36546. return edges
  36547. }
  36548. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36549. // was cleared in this mutation.
  36550. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  36551. return false
  36552. }
  36553. // ClearEdge clears the value of the edge with the given name. It returns an error
  36554. // if that edge is not defined in the schema.
  36555. func (m *WpChatroomMutation) ClearEdge(name string) error {
  36556. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  36557. }
  36558. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36559. // It returns an error if the edge is not defined in the schema.
  36560. func (m *WpChatroomMutation) ResetEdge(name string) error {
  36561. return fmt.Errorf("unknown WpChatroom edge %s", name)
  36562. }
  36563. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  36564. type WpChatroomMemberMutation struct {
  36565. config
  36566. op Op
  36567. typ string
  36568. id *uint64
  36569. created_at *time.Time
  36570. updated_at *time.Time
  36571. status *uint8
  36572. addstatus *int8
  36573. wx_wxid *string
  36574. wxid *string
  36575. nickname *string
  36576. avatar *string
  36577. clearedFields map[string]struct{}
  36578. done bool
  36579. oldValue func(context.Context) (*WpChatroomMember, error)
  36580. predicates []predicate.WpChatroomMember
  36581. }
  36582. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  36583. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  36584. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  36585. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  36586. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  36587. m := &WpChatroomMemberMutation{
  36588. config: c,
  36589. op: op,
  36590. typ: TypeWpChatroomMember,
  36591. clearedFields: make(map[string]struct{}),
  36592. }
  36593. for _, opt := range opts {
  36594. opt(m)
  36595. }
  36596. return m
  36597. }
  36598. // withWpChatroomMemberID sets the ID field of the mutation.
  36599. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  36600. return func(m *WpChatroomMemberMutation) {
  36601. var (
  36602. err error
  36603. once sync.Once
  36604. value *WpChatroomMember
  36605. )
  36606. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  36607. once.Do(func() {
  36608. if m.done {
  36609. err = errors.New("querying old values post mutation is not allowed")
  36610. } else {
  36611. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  36612. }
  36613. })
  36614. return value, err
  36615. }
  36616. m.id = &id
  36617. }
  36618. }
  36619. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  36620. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  36621. return func(m *WpChatroomMemberMutation) {
  36622. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  36623. return node, nil
  36624. }
  36625. m.id = &node.ID
  36626. }
  36627. }
  36628. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36629. // executed in a transaction (ent.Tx), a transactional client is returned.
  36630. func (m WpChatroomMemberMutation) Client() *Client {
  36631. client := &Client{config: m.config}
  36632. client.init()
  36633. return client
  36634. }
  36635. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36636. // it returns an error otherwise.
  36637. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  36638. if _, ok := m.driver.(*txDriver); !ok {
  36639. return nil, errors.New("ent: mutation is not running in a transaction")
  36640. }
  36641. tx := &Tx{config: m.config}
  36642. tx.init()
  36643. return tx, nil
  36644. }
  36645. // SetID sets the value of the id field. Note that this
  36646. // operation is only accepted on creation of WpChatroomMember entities.
  36647. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  36648. m.id = &id
  36649. }
  36650. // ID returns the ID value in the mutation. Note that the ID is only available
  36651. // if it was provided to the builder or after it was returned from the database.
  36652. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  36653. if m.id == nil {
  36654. return
  36655. }
  36656. return *m.id, true
  36657. }
  36658. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36659. // That means, if the mutation is applied within a transaction with an isolation level such
  36660. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36661. // or updated by the mutation.
  36662. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  36663. switch {
  36664. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36665. id, exists := m.ID()
  36666. if exists {
  36667. return []uint64{id}, nil
  36668. }
  36669. fallthrough
  36670. case m.op.Is(OpUpdate | OpDelete):
  36671. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  36672. default:
  36673. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36674. }
  36675. }
  36676. // SetCreatedAt sets the "created_at" field.
  36677. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  36678. m.created_at = &t
  36679. }
  36680. // CreatedAt returns the value of the "created_at" field in the mutation.
  36681. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  36682. v := m.created_at
  36683. if v == nil {
  36684. return
  36685. }
  36686. return *v, true
  36687. }
  36688. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  36689. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  36690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36691. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36692. if !m.op.Is(OpUpdateOne) {
  36693. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36694. }
  36695. if m.id == nil || m.oldValue == nil {
  36696. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36697. }
  36698. oldValue, err := m.oldValue(ctx)
  36699. if err != nil {
  36700. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36701. }
  36702. return oldValue.CreatedAt, nil
  36703. }
  36704. // ResetCreatedAt resets all changes to the "created_at" field.
  36705. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  36706. m.created_at = nil
  36707. }
  36708. // SetUpdatedAt sets the "updated_at" field.
  36709. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  36710. m.updated_at = &t
  36711. }
  36712. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36713. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  36714. v := m.updated_at
  36715. if v == nil {
  36716. return
  36717. }
  36718. return *v, true
  36719. }
  36720. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  36721. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  36722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36723. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36724. if !m.op.Is(OpUpdateOne) {
  36725. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36726. }
  36727. if m.id == nil || m.oldValue == nil {
  36728. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36729. }
  36730. oldValue, err := m.oldValue(ctx)
  36731. if err != nil {
  36732. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36733. }
  36734. return oldValue.UpdatedAt, nil
  36735. }
  36736. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36737. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  36738. m.updated_at = nil
  36739. }
  36740. // SetStatus sets the "status" field.
  36741. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  36742. m.status = &u
  36743. m.addstatus = nil
  36744. }
  36745. // Status returns the value of the "status" field in the mutation.
  36746. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  36747. v := m.status
  36748. if v == nil {
  36749. return
  36750. }
  36751. return *v, true
  36752. }
  36753. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  36754. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  36755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36756. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36757. if !m.op.Is(OpUpdateOne) {
  36758. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36759. }
  36760. if m.id == nil || m.oldValue == nil {
  36761. return v, errors.New("OldStatus requires an ID field in the mutation")
  36762. }
  36763. oldValue, err := m.oldValue(ctx)
  36764. if err != nil {
  36765. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36766. }
  36767. return oldValue.Status, nil
  36768. }
  36769. // AddStatus adds u to the "status" field.
  36770. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  36771. if m.addstatus != nil {
  36772. *m.addstatus += u
  36773. } else {
  36774. m.addstatus = &u
  36775. }
  36776. }
  36777. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36778. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  36779. v := m.addstatus
  36780. if v == nil {
  36781. return
  36782. }
  36783. return *v, true
  36784. }
  36785. // ClearStatus clears the value of the "status" field.
  36786. func (m *WpChatroomMemberMutation) ClearStatus() {
  36787. m.status = nil
  36788. m.addstatus = nil
  36789. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  36790. }
  36791. // StatusCleared returns if the "status" field was cleared in this mutation.
  36792. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  36793. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  36794. return ok
  36795. }
  36796. // ResetStatus resets all changes to the "status" field.
  36797. func (m *WpChatroomMemberMutation) ResetStatus() {
  36798. m.status = nil
  36799. m.addstatus = nil
  36800. delete(m.clearedFields, wpchatroommember.FieldStatus)
  36801. }
  36802. // SetWxWxid sets the "wx_wxid" field.
  36803. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  36804. m.wx_wxid = &s
  36805. }
  36806. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  36807. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  36808. v := m.wx_wxid
  36809. if v == nil {
  36810. return
  36811. }
  36812. return *v, true
  36813. }
  36814. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  36815. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  36816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36817. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  36818. if !m.op.Is(OpUpdateOne) {
  36819. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  36820. }
  36821. if m.id == nil || m.oldValue == nil {
  36822. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  36823. }
  36824. oldValue, err := m.oldValue(ctx)
  36825. if err != nil {
  36826. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  36827. }
  36828. return oldValue.WxWxid, nil
  36829. }
  36830. // ResetWxWxid resets all changes to the "wx_wxid" field.
  36831. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  36832. m.wx_wxid = nil
  36833. }
  36834. // SetWxid sets the "wxid" field.
  36835. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  36836. m.wxid = &s
  36837. }
  36838. // Wxid returns the value of the "wxid" field in the mutation.
  36839. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  36840. v := m.wxid
  36841. if v == nil {
  36842. return
  36843. }
  36844. return *v, true
  36845. }
  36846. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  36847. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  36848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36849. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  36850. if !m.op.Is(OpUpdateOne) {
  36851. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  36852. }
  36853. if m.id == nil || m.oldValue == nil {
  36854. return v, errors.New("OldWxid requires an ID field in the mutation")
  36855. }
  36856. oldValue, err := m.oldValue(ctx)
  36857. if err != nil {
  36858. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  36859. }
  36860. return oldValue.Wxid, nil
  36861. }
  36862. // ResetWxid resets all changes to the "wxid" field.
  36863. func (m *WpChatroomMemberMutation) ResetWxid() {
  36864. m.wxid = nil
  36865. }
  36866. // SetNickname sets the "nickname" field.
  36867. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  36868. m.nickname = &s
  36869. }
  36870. // Nickname returns the value of the "nickname" field in the mutation.
  36871. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  36872. v := m.nickname
  36873. if v == nil {
  36874. return
  36875. }
  36876. return *v, true
  36877. }
  36878. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  36879. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  36880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36881. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  36882. if !m.op.Is(OpUpdateOne) {
  36883. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  36884. }
  36885. if m.id == nil || m.oldValue == nil {
  36886. return v, errors.New("OldNickname requires an ID field in the mutation")
  36887. }
  36888. oldValue, err := m.oldValue(ctx)
  36889. if err != nil {
  36890. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  36891. }
  36892. return oldValue.Nickname, nil
  36893. }
  36894. // ResetNickname resets all changes to the "nickname" field.
  36895. func (m *WpChatroomMemberMutation) ResetNickname() {
  36896. m.nickname = nil
  36897. }
  36898. // SetAvatar sets the "avatar" field.
  36899. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  36900. m.avatar = &s
  36901. }
  36902. // Avatar returns the value of the "avatar" field in the mutation.
  36903. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  36904. v := m.avatar
  36905. if v == nil {
  36906. return
  36907. }
  36908. return *v, true
  36909. }
  36910. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  36911. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  36912. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36913. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  36914. if !m.op.Is(OpUpdateOne) {
  36915. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  36916. }
  36917. if m.id == nil || m.oldValue == nil {
  36918. return v, errors.New("OldAvatar requires an ID field in the mutation")
  36919. }
  36920. oldValue, err := m.oldValue(ctx)
  36921. if err != nil {
  36922. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  36923. }
  36924. return oldValue.Avatar, nil
  36925. }
  36926. // ResetAvatar resets all changes to the "avatar" field.
  36927. func (m *WpChatroomMemberMutation) ResetAvatar() {
  36928. m.avatar = nil
  36929. }
  36930. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  36931. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  36932. m.predicates = append(m.predicates, ps...)
  36933. }
  36934. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  36935. // users can use type-assertion to append predicates that do not depend on any generated package.
  36936. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  36937. p := make([]predicate.WpChatroomMember, len(ps))
  36938. for i := range ps {
  36939. p[i] = ps[i]
  36940. }
  36941. m.Where(p...)
  36942. }
  36943. // Op returns the operation name.
  36944. func (m *WpChatroomMemberMutation) Op() Op {
  36945. return m.op
  36946. }
  36947. // SetOp allows setting the mutation operation.
  36948. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  36949. m.op = op
  36950. }
  36951. // Type returns the node type of this mutation (WpChatroomMember).
  36952. func (m *WpChatroomMemberMutation) Type() string {
  36953. return m.typ
  36954. }
  36955. // Fields returns all fields that were changed during this mutation. Note that in
  36956. // order to get all numeric fields that were incremented/decremented, call
  36957. // AddedFields().
  36958. func (m *WpChatroomMemberMutation) Fields() []string {
  36959. fields := make([]string, 0, 7)
  36960. if m.created_at != nil {
  36961. fields = append(fields, wpchatroommember.FieldCreatedAt)
  36962. }
  36963. if m.updated_at != nil {
  36964. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  36965. }
  36966. if m.status != nil {
  36967. fields = append(fields, wpchatroommember.FieldStatus)
  36968. }
  36969. if m.wx_wxid != nil {
  36970. fields = append(fields, wpchatroommember.FieldWxWxid)
  36971. }
  36972. if m.wxid != nil {
  36973. fields = append(fields, wpchatroommember.FieldWxid)
  36974. }
  36975. if m.nickname != nil {
  36976. fields = append(fields, wpchatroommember.FieldNickname)
  36977. }
  36978. if m.avatar != nil {
  36979. fields = append(fields, wpchatroommember.FieldAvatar)
  36980. }
  36981. return fields
  36982. }
  36983. // Field returns the value of a field with the given name. The second boolean
  36984. // return value indicates that this field was not set, or was not defined in the
  36985. // schema.
  36986. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  36987. switch name {
  36988. case wpchatroommember.FieldCreatedAt:
  36989. return m.CreatedAt()
  36990. case wpchatroommember.FieldUpdatedAt:
  36991. return m.UpdatedAt()
  36992. case wpchatroommember.FieldStatus:
  36993. return m.Status()
  36994. case wpchatroommember.FieldWxWxid:
  36995. return m.WxWxid()
  36996. case wpchatroommember.FieldWxid:
  36997. return m.Wxid()
  36998. case wpchatroommember.FieldNickname:
  36999. return m.Nickname()
  37000. case wpchatroommember.FieldAvatar:
  37001. return m.Avatar()
  37002. }
  37003. return nil, false
  37004. }
  37005. // OldField returns the old value of the field from the database. An error is
  37006. // returned if the mutation operation is not UpdateOne, or the query to the
  37007. // database failed.
  37008. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37009. switch name {
  37010. case wpchatroommember.FieldCreatedAt:
  37011. return m.OldCreatedAt(ctx)
  37012. case wpchatroommember.FieldUpdatedAt:
  37013. return m.OldUpdatedAt(ctx)
  37014. case wpchatroommember.FieldStatus:
  37015. return m.OldStatus(ctx)
  37016. case wpchatroommember.FieldWxWxid:
  37017. return m.OldWxWxid(ctx)
  37018. case wpchatroommember.FieldWxid:
  37019. return m.OldWxid(ctx)
  37020. case wpchatroommember.FieldNickname:
  37021. return m.OldNickname(ctx)
  37022. case wpchatroommember.FieldAvatar:
  37023. return m.OldAvatar(ctx)
  37024. }
  37025. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  37026. }
  37027. // SetField sets the value of a field with the given name. It returns an error if
  37028. // the field is not defined in the schema, or if the type mismatched the field
  37029. // type.
  37030. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  37031. switch name {
  37032. case wpchatroommember.FieldCreatedAt:
  37033. v, ok := value.(time.Time)
  37034. if !ok {
  37035. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37036. }
  37037. m.SetCreatedAt(v)
  37038. return nil
  37039. case wpchatroommember.FieldUpdatedAt:
  37040. v, ok := value.(time.Time)
  37041. if !ok {
  37042. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37043. }
  37044. m.SetUpdatedAt(v)
  37045. return nil
  37046. case wpchatroommember.FieldStatus:
  37047. v, ok := value.(uint8)
  37048. if !ok {
  37049. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37050. }
  37051. m.SetStatus(v)
  37052. return nil
  37053. case wpchatroommember.FieldWxWxid:
  37054. v, ok := value.(string)
  37055. if !ok {
  37056. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37057. }
  37058. m.SetWxWxid(v)
  37059. return nil
  37060. case wpchatroommember.FieldWxid:
  37061. v, ok := value.(string)
  37062. if !ok {
  37063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37064. }
  37065. m.SetWxid(v)
  37066. return nil
  37067. case wpchatroommember.FieldNickname:
  37068. v, ok := value.(string)
  37069. if !ok {
  37070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37071. }
  37072. m.SetNickname(v)
  37073. return nil
  37074. case wpchatroommember.FieldAvatar:
  37075. v, ok := value.(string)
  37076. if !ok {
  37077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37078. }
  37079. m.SetAvatar(v)
  37080. return nil
  37081. }
  37082. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  37083. }
  37084. // AddedFields returns all numeric fields that were incremented/decremented during
  37085. // this mutation.
  37086. func (m *WpChatroomMemberMutation) AddedFields() []string {
  37087. var fields []string
  37088. if m.addstatus != nil {
  37089. fields = append(fields, wpchatroommember.FieldStatus)
  37090. }
  37091. return fields
  37092. }
  37093. // AddedField returns the numeric value that was incremented/decremented on a field
  37094. // with the given name. The second boolean return value indicates that this field
  37095. // was not set, or was not defined in the schema.
  37096. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  37097. switch name {
  37098. case wpchatroommember.FieldStatus:
  37099. return m.AddedStatus()
  37100. }
  37101. return nil, false
  37102. }
  37103. // AddField adds the value to the field with the given name. It returns an error if
  37104. // the field is not defined in the schema, or if the type mismatched the field
  37105. // type.
  37106. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  37107. switch name {
  37108. case wpchatroommember.FieldStatus:
  37109. v, ok := value.(int8)
  37110. if !ok {
  37111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37112. }
  37113. m.AddStatus(v)
  37114. return nil
  37115. }
  37116. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  37117. }
  37118. // ClearedFields returns all nullable fields that were cleared during this
  37119. // mutation.
  37120. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  37121. var fields []string
  37122. if m.FieldCleared(wpchatroommember.FieldStatus) {
  37123. fields = append(fields, wpchatroommember.FieldStatus)
  37124. }
  37125. return fields
  37126. }
  37127. // FieldCleared returns a boolean indicating if a field with the given name was
  37128. // cleared in this mutation.
  37129. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  37130. _, ok := m.clearedFields[name]
  37131. return ok
  37132. }
  37133. // ClearField clears the value of the field with the given name. It returns an
  37134. // error if the field is not defined in the schema.
  37135. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  37136. switch name {
  37137. case wpchatroommember.FieldStatus:
  37138. m.ClearStatus()
  37139. return nil
  37140. }
  37141. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  37142. }
  37143. // ResetField resets all changes in the mutation for the field with the given name.
  37144. // It returns an error if the field is not defined in the schema.
  37145. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  37146. switch name {
  37147. case wpchatroommember.FieldCreatedAt:
  37148. m.ResetCreatedAt()
  37149. return nil
  37150. case wpchatroommember.FieldUpdatedAt:
  37151. m.ResetUpdatedAt()
  37152. return nil
  37153. case wpchatroommember.FieldStatus:
  37154. m.ResetStatus()
  37155. return nil
  37156. case wpchatroommember.FieldWxWxid:
  37157. m.ResetWxWxid()
  37158. return nil
  37159. case wpchatroommember.FieldWxid:
  37160. m.ResetWxid()
  37161. return nil
  37162. case wpchatroommember.FieldNickname:
  37163. m.ResetNickname()
  37164. return nil
  37165. case wpchatroommember.FieldAvatar:
  37166. m.ResetAvatar()
  37167. return nil
  37168. }
  37169. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  37170. }
  37171. // AddedEdges returns all edge names that were set/added in this mutation.
  37172. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  37173. edges := make([]string, 0, 0)
  37174. return edges
  37175. }
  37176. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37177. // name in this mutation.
  37178. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  37179. return nil
  37180. }
  37181. // RemovedEdges returns all edge names that were removed in this mutation.
  37182. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  37183. edges := make([]string, 0, 0)
  37184. return edges
  37185. }
  37186. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37187. // the given name in this mutation.
  37188. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  37189. return nil
  37190. }
  37191. // ClearedEdges returns all edge names that were cleared in this mutation.
  37192. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  37193. edges := make([]string, 0, 0)
  37194. return edges
  37195. }
  37196. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37197. // was cleared in this mutation.
  37198. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  37199. return false
  37200. }
  37201. // ClearEdge clears the value of the edge with the given name. It returns an error
  37202. // if that edge is not defined in the schema.
  37203. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  37204. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  37205. }
  37206. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37207. // It returns an error if the edge is not defined in the schema.
  37208. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  37209. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  37210. }
  37211. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  37212. type WxMutation struct {
  37213. config
  37214. op Op
  37215. typ string
  37216. id *uint64
  37217. created_at *time.Time
  37218. updated_at *time.Time
  37219. status *uint8
  37220. addstatus *int8
  37221. deleted_at *time.Time
  37222. port *string
  37223. process_id *string
  37224. callback *string
  37225. wxid *string
  37226. account *string
  37227. nickname *string
  37228. tel *string
  37229. head_big *string
  37230. organization_id *uint64
  37231. addorganization_id *int64
  37232. api_base *string
  37233. api_key *string
  37234. allow_list *[]string
  37235. appendallow_list []string
  37236. group_allow_list *[]string
  37237. appendgroup_allow_list []string
  37238. block_list *[]string
  37239. appendblock_list []string
  37240. group_block_list *[]string
  37241. appendgroup_block_list []string
  37242. clearedFields map[string]struct{}
  37243. server *uint64
  37244. clearedserver bool
  37245. agent *uint64
  37246. clearedagent bool
  37247. done bool
  37248. oldValue func(context.Context) (*Wx, error)
  37249. predicates []predicate.Wx
  37250. }
  37251. var _ ent.Mutation = (*WxMutation)(nil)
  37252. // wxOption allows management of the mutation configuration using functional options.
  37253. type wxOption func(*WxMutation)
  37254. // newWxMutation creates new mutation for the Wx entity.
  37255. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  37256. m := &WxMutation{
  37257. config: c,
  37258. op: op,
  37259. typ: TypeWx,
  37260. clearedFields: make(map[string]struct{}),
  37261. }
  37262. for _, opt := range opts {
  37263. opt(m)
  37264. }
  37265. return m
  37266. }
  37267. // withWxID sets the ID field of the mutation.
  37268. func withWxID(id uint64) wxOption {
  37269. return func(m *WxMutation) {
  37270. var (
  37271. err error
  37272. once sync.Once
  37273. value *Wx
  37274. )
  37275. m.oldValue = func(ctx context.Context) (*Wx, error) {
  37276. once.Do(func() {
  37277. if m.done {
  37278. err = errors.New("querying old values post mutation is not allowed")
  37279. } else {
  37280. value, err = m.Client().Wx.Get(ctx, id)
  37281. }
  37282. })
  37283. return value, err
  37284. }
  37285. m.id = &id
  37286. }
  37287. }
  37288. // withWx sets the old Wx of the mutation.
  37289. func withWx(node *Wx) wxOption {
  37290. return func(m *WxMutation) {
  37291. m.oldValue = func(context.Context) (*Wx, error) {
  37292. return node, nil
  37293. }
  37294. m.id = &node.ID
  37295. }
  37296. }
  37297. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37298. // executed in a transaction (ent.Tx), a transactional client is returned.
  37299. func (m WxMutation) Client() *Client {
  37300. client := &Client{config: m.config}
  37301. client.init()
  37302. return client
  37303. }
  37304. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37305. // it returns an error otherwise.
  37306. func (m WxMutation) Tx() (*Tx, error) {
  37307. if _, ok := m.driver.(*txDriver); !ok {
  37308. return nil, errors.New("ent: mutation is not running in a transaction")
  37309. }
  37310. tx := &Tx{config: m.config}
  37311. tx.init()
  37312. return tx, nil
  37313. }
  37314. // SetID sets the value of the id field. Note that this
  37315. // operation is only accepted on creation of Wx entities.
  37316. func (m *WxMutation) SetID(id uint64) {
  37317. m.id = &id
  37318. }
  37319. // ID returns the ID value in the mutation. Note that the ID is only available
  37320. // if it was provided to the builder or after it was returned from the database.
  37321. func (m *WxMutation) ID() (id uint64, exists bool) {
  37322. if m.id == nil {
  37323. return
  37324. }
  37325. return *m.id, true
  37326. }
  37327. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37328. // That means, if the mutation is applied within a transaction with an isolation level such
  37329. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37330. // or updated by the mutation.
  37331. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  37332. switch {
  37333. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37334. id, exists := m.ID()
  37335. if exists {
  37336. return []uint64{id}, nil
  37337. }
  37338. fallthrough
  37339. case m.op.Is(OpUpdate | OpDelete):
  37340. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  37341. default:
  37342. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37343. }
  37344. }
  37345. // SetCreatedAt sets the "created_at" field.
  37346. func (m *WxMutation) SetCreatedAt(t time.Time) {
  37347. m.created_at = &t
  37348. }
  37349. // CreatedAt returns the value of the "created_at" field in the mutation.
  37350. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  37351. v := m.created_at
  37352. if v == nil {
  37353. return
  37354. }
  37355. return *v, true
  37356. }
  37357. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  37358. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37360. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37361. if !m.op.Is(OpUpdateOne) {
  37362. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37363. }
  37364. if m.id == nil || m.oldValue == nil {
  37365. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37366. }
  37367. oldValue, err := m.oldValue(ctx)
  37368. if err != nil {
  37369. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37370. }
  37371. return oldValue.CreatedAt, nil
  37372. }
  37373. // ResetCreatedAt resets all changes to the "created_at" field.
  37374. func (m *WxMutation) ResetCreatedAt() {
  37375. m.created_at = nil
  37376. }
  37377. // SetUpdatedAt sets the "updated_at" field.
  37378. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  37379. m.updated_at = &t
  37380. }
  37381. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37382. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  37383. v := m.updated_at
  37384. if v == nil {
  37385. return
  37386. }
  37387. return *v, true
  37388. }
  37389. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  37390. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37392. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37393. if !m.op.Is(OpUpdateOne) {
  37394. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37395. }
  37396. if m.id == nil || m.oldValue == nil {
  37397. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37398. }
  37399. oldValue, err := m.oldValue(ctx)
  37400. if err != nil {
  37401. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37402. }
  37403. return oldValue.UpdatedAt, nil
  37404. }
  37405. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37406. func (m *WxMutation) ResetUpdatedAt() {
  37407. m.updated_at = nil
  37408. }
  37409. // SetStatus sets the "status" field.
  37410. func (m *WxMutation) SetStatus(u uint8) {
  37411. m.status = &u
  37412. m.addstatus = nil
  37413. }
  37414. // Status returns the value of the "status" field in the mutation.
  37415. func (m *WxMutation) Status() (r uint8, exists bool) {
  37416. v := m.status
  37417. if v == nil {
  37418. return
  37419. }
  37420. return *v, true
  37421. }
  37422. // OldStatus returns the old "status" field's value of the Wx entity.
  37423. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37425. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37426. if !m.op.Is(OpUpdateOne) {
  37427. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37428. }
  37429. if m.id == nil || m.oldValue == nil {
  37430. return v, errors.New("OldStatus requires an ID field in the mutation")
  37431. }
  37432. oldValue, err := m.oldValue(ctx)
  37433. if err != nil {
  37434. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37435. }
  37436. return oldValue.Status, nil
  37437. }
  37438. // AddStatus adds u to the "status" field.
  37439. func (m *WxMutation) AddStatus(u int8) {
  37440. if m.addstatus != nil {
  37441. *m.addstatus += u
  37442. } else {
  37443. m.addstatus = &u
  37444. }
  37445. }
  37446. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37447. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  37448. v := m.addstatus
  37449. if v == nil {
  37450. return
  37451. }
  37452. return *v, true
  37453. }
  37454. // ClearStatus clears the value of the "status" field.
  37455. func (m *WxMutation) ClearStatus() {
  37456. m.status = nil
  37457. m.addstatus = nil
  37458. m.clearedFields[wx.FieldStatus] = struct{}{}
  37459. }
  37460. // StatusCleared returns if the "status" field was cleared in this mutation.
  37461. func (m *WxMutation) StatusCleared() bool {
  37462. _, ok := m.clearedFields[wx.FieldStatus]
  37463. return ok
  37464. }
  37465. // ResetStatus resets all changes to the "status" field.
  37466. func (m *WxMutation) ResetStatus() {
  37467. m.status = nil
  37468. m.addstatus = nil
  37469. delete(m.clearedFields, wx.FieldStatus)
  37470. }
  37471. // SetDeletedAt sets the "deleted_at" field.
  37472. func (m *WxMutation) SetDeletedAt(t time.Time) {
  37473. m.deleted_at = &t
  37474. }
  37475. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37476. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  37477. v := m.deleted_at
  37478. if v == nil {
  37479. return
  37480. }
  37481. return *v, true
  37482. }
  37483. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  37484. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37486. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37487. if !m.op.Is(OpUpdateOne) {
  37488. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37489. }
  37490. if m.id == nil || m.oldValue == nil {
  37491. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37492. }
  37493. oldValue, err := m.oldValue(ctx)
  37494. if err != nil {
  37495. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37496. }
  37497. return oldValue.DeletedAt, nil
  37498. }
  37499. // ClearDeletedAt clears the value of the "deleted_at" field.
  37500. func (m *WxMutation) ClearDeletedAt() {
  37501. m.deleted_at = nil
  37502. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  37503. }
  37504. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37505. func (m *WxMutation) DeletedAtCleared() bool {
  37506. _, ok := m.clearedFields[wx.FieldDeletedAt]
  37507. return ok
  37508. }
  37509. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37510. func (m *WxMutation) ResetDeletedAt() {
  37511. m.deleted_at = nil
  37512. delete(m.clearedFields, wx.FieldDeletedAt)
  37513. }
  37514. // SetServerID sets the "server_id" field.
  37515. func (m *WxMutation) SetServerID(u uint64) {
  37516. m.server = &u
  37517. }
  37518. // ServerID returns the value of the "server_id" field in the mutation.
  37519. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  37520. v := m.server
  37521. if v == nil {
  37522. return
  37523. }
  37524. return *v, true
  37525. }
  37526. // OldServerID returns the old "server_id" field's value of the Wx entity.
  37527. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37529. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  37530. if !m.op.Is(OpUpdateOne) {
  37531. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  37532. }
  37533. if m.id == nil || m.oldValue == nil {
  37534. return v, errors.New("OldServerID requires an ID field in the mutation")
  37535. }
  37536. oldValue, err := m.oldValue(ctx)
  37537. if err != nil {
  37538. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  37539. }
  37540. return oldValue.ServerID, nil
  37541. }
  37542. // ClearServerID clears the value of the "server_id" field.
  37543. func (m *WxMutation) ClearServerID() {
  37544. m.server = nil
  37545. m.clearedFields[wx.FieldServerID] = struct{}{}
  37546. }
  37547. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  37548. func (m *WxMutation) ServerIDCleared() bool {
  37549. _, ok := m.clearedFields[wx.FieldServerID]
  37550. return ok
  37551. }
  37552. // ResetServerID resets all changes to the "server_id" field.
  37553. func (m *WxMutation) ResetServerID() {
  37554. m.server = nil
  37555. delete(m.clearedFields, wx.FieldServerID)
  37556. }
  37557. // SetPort sets the "port" field.
  37558. func (m *WxMutation) SetPort(s string) {
  37559. m.port = &s
  37560. }
  37561. // Port returns the value of the "port" field in the mutation.
  37562. func (m *WxMutation) Port() (r string, exists bool) {
  37563. v := m.port
  37564. if v == nil {
  37565. return
  37566. }
  37567. return *v, true
  37568. }
  37569. // OldPort returns the old "port" field's value of the Wx entity.
  37570. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37572. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  37573. if !m.op.Is(OpUpdateOne) {
  37574. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  37575. }
  37576. if m.id == nil || m.oldValue == nil {
  37577. return v, errors.New("OldPort requires an ID field in the mutation")
  37578. }
  37579. oldValue, err := m.oldValue(ctx)
  37580. if err != nil {
  37581. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  37582. }
  37583. return oldValue.Port, nil
  37584. }
  37585. // ResetPort resets all changes to the "port" field.
  37586. func (m *WxMutation) ResetPort() {
  37587. m.port = nil
  37588. }
  37589. // SetProcessID sets the "process_id" field.
  37590. func (m *WxMutation) SetProcessID(s string) {
  37591. m.process_id = &s
  37592. }
  37593. // ProcessID returns the value of the "process_id" field in the mutation.
  37594. func (m *WxMutation) ProcessID() (r string, exists bool) {
  37595. v := m.process_id
  37596. if v == nil {
  37597. return
  37598. }
  37599. return *v, true
  37600. }
  37601. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  37602. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37604. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  37605. if !m.op.Is(OpUpdateOne) {
  37606. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  37607. }
  37608. if m.id == nil || m.oldValue == nil {
  37609. return v, errors.New("OldProcessID requires an ID field in the mutation")
  37610. }
  37611. oldValue, err := m.oldValue(ctx)
  37612. if err != nil {
  37613. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  37614. }
  37615. return oldValue.ProcessID, nil
  37616. }
  37617. // ResetProcessID resets all changes to the "process_id" field.
  37618. func (m *WxMutation) ResetProcessID() {
  37619. m.process_id = nil
  37620. }
  37621. // SetCallback sets the "callback" field.
  37622. func (m *WxMutation) SetCallback(s string) {
  37623. m.callback = &s
  37624. }
  37625. // Callback returns the value of the "callback" field in the mutation.
  37626. func (m *WxMutation) Callback() (r string, exists bool) {
  37627. v := m.callback
  37628. if v == nil {
  37629. return
  37630. }
  37631. return *v, true
  37632. }
  37633. // OldCallback returns the old "callback" field's value of the Wx entity.
  37634. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37636. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  37637. if !m.op.Is(OpUpdateOne) {
  37638. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  37639. }
  37640. if m.id == nil || m.oldValue == nil {
  37641. return v, errors.New("OldCallback requires an ID field in the mutation")
  37642. }
  37643. oldValue, err := m.oldValue(ctx)
  37644. if err != nil {
  37645. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  37646. }
  37647. return oldValue.Callback, nil
  37648. }
  37649. // ResetCallback resets all changes to the "callback" field.
  37650. func (m *WxMutation) ResetCallback() {
  37651. m.callback = nil
  37652. }
  37653. // SetWxid sets the "wxid" field.
  37654. func (m *WxMutation) SetWxid(s string) {
  37655. m.wxid = &s
  37656. }
  37657. // Wxid returns the value of the "wxid" field in the mutation.
  37658. func (m *WxMutation) Wxid() (r string, exists bool) {
  37659. v := m.wxid
  37660. if v == nil {
  37661. return
  37662. }
  37663. return *v, true
  37664. }
  37665. // OldWxid returns the old "wxid" field's value of the Wx entity.
  37666. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37668. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  37669. if !m.op.Is(OpUpdateOne) {
  37670. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  37671. }
  37672. if m.id == nil || m.oldValue == nil {
  37673. return v, errors.New("OldWxid requires an ID field in the mutation")
  37674. }
  37675. oldValue, err := m.oldValue(ctx)
  37676. if err != nil {
  37677. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  37678. }
  37679. return oldValue.Wxid, nil
  37680. }
  37681. // ResetWxid resets all changes to the "wxid" field.
  37682. func (m *WxMutation) ResetWxid() {
  37683. m.wxid = nil
  37684. }
  37685. // SetAccount sets the "account" field.
  37686. func (m *WxMutation) SetAccount(s string) {
  37687. m.account = &s
  37688. }
  37689. // Account returns the value of the "account" field in the mutation.
  37690. func (m *WxMutation) Account() (r string, exists bool) {
  37691. v := m.account
  37692. if v == nil {
  37693. return
  37694. }
  37695. return *v, true
  37696. }
  37697. // OldAccount returns the old "account" field's value of the Wx entity.
  37698. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37700. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  37701. if !m.op.Is(OpUpdateOne) {
  37702. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  37703. }
  37704. if m.id == nil || m.oldValue == nil {
  37705. return v, errors.New("OldAccount requires an ID field in the mutation")
  37706. }
  37707. oldValue, err := m.oldValue(ctx)
  37708. if err != nil {
  37709. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  37710. }
  37711. return oldValue.Account, nil
  37712. }
  37713. // ResetAccount resets all changes to the "account" field.
  37714. func (m *WxMutation) ResetAccount() {
  37715. m.account = nil
  37716. }
  37717. // SetNickname sets the "nickname" field.
  37718. func (m *WxMutation) SetNickname(s string) {
  37719. m.nickname = &s
  37720. }
  37721. // Nickname returns the value of the "nickname" field in the mutation.
  37722. func (m *WxMutation) Nickname() (r string, exists bool) {
  37723. v := m.nickname
  37724. if v == nil {
  37725. return
  37726. }
  37727. return *v, true
  37728. }
  37729. // OldNickname returns the old "nickname" field's value of the Wx entity.
  37730. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37732. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  37733. if !m.op.Is(OpUpdateOne) {
  37734. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  37735. }
  37736. if m.id == nil || m.oldValue == nil {
  37737. return v, errors.New("OldNickname requires an ID field in the mutation")
  37738. }
  37739. oldValue, err := m.oldValue(ctx)
  37740. if err != nil {
  37741. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  37742. }
  37743. return oldValue.Nickname, nil
  37744. }
  37745. // ResetNickname resets all changes to the "nickname" field.
  37746. func (m *WxMutation) ResetNickname() {
  37747. m.nickname = nil
  37748. }
  37749. // SetTel sets the "tel" field.
  37750. func (m *WxMutation) SetTel(s string) {
  37751. m.tel = &s
  37752. }
  37753. // Tel returns the value of the "tel" field in the mutation.
  37754. func (m *WxMutation) Tel() (r string, exists bool) {
  37755. v := m.tel
  37756. if v == nil {
  37757. return
  37758. }
  37759. return *v, true
  37760. }
  37761. // OldTel returns the old "tel" field's value of the Wx entity.
  37762. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37764. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  37765. if !m.op.Is(OpUpdateOne) {
  37766. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  37767. }
  37768. if m.id == nil || m.oldValue == nil {
  37769. return v, errors.New("OldTel requires an ID field in the mutation")
  37770. }
  37771. oldValue, err := m.oldValue(ctx)
  37772. if err != nil {
  37773. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  37774. }
  37775. return oldValue.Tel, nil
  37776. }
  37777. // ResetTel resets all changes to the "tel" field.
  37778. func (m *WxMutation) ResetTel() {
  37779. m.tel = nil
  37780. }
  37781. // SetHeadBig sets the "head_big" field.
  37782. func (m *WxMutation) SetHeadBig(s string) {
  37783. m.head_big = &s
  37784. }
  37785. // HeadBig returns the value of the "head_big" field in the mutation.
  37786. func (m *WxMutation) HeadBig() (r string, exists bool) {
  37787. v := m.head_big
  37788. if v == nil {
  37789. return
  37790. }
  37791. return *v, true
  37792. }
  37793. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  37794. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37796. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  37797. if !m.op.Is(OpUpdateOne) {
  37798. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  37799. }
  37800. if m.id == nil || m.oldValue == nil {
  37801. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  37802. }
  37803. oldValue, err := m.oldValue(ctx)
  37804. if err != nil {
  37805. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  37806. }
  37807. return oldValue.HeadBig, nil
  37808. }
  37809. // ResetHeadBig resets all changes to the "head_big" field.
  37810. func (m *WxMutation) ResetHeadBig() {
  37811. m.head_big = nil
  37812. }
  37813. // SetOrganizationID sets the "organization_id" field.
  37814. func (m *WxMutation) SetOrganizationID(u uint64) {
  37815. m.organization_id = &u
  37816. m.addorganization_id = nil
  37817. }
  37818. // OrganizationID returns the value of the "organization_id" field in the mutation.
  37819. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  37820. v := m.organization_id
  37821. if v == nil {
  37822. return
  37823. }
  37824. return *v, true
  37825. }
  37826. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  37827. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37829. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  37830. if !m.op.Is(OpUpdateOne) {
  37831. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  37832. }
  37833. if m.id == nil || m.oldValue == nil {
  37834. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  37835. }
  37836. oldValue, err := m.oldValue(ctx)
  37837. if err != nil {
  37838. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  37839. }
  37840. return oldValue.OrganizationID, nil
  37841. }
  37842. // AddOrganizationID adds u to the "organization_id" field.
  37843. func (m *WxMutation) AddOrganizationID(u int64) {
  37844. if m.addorganization_id != nil {
  37845. *m.addorganization_id += u
  37846. } else {
  37847. m.addorganization_id = &u
  37848. }
  37849. }
  37850. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  37851. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  37852. v := m.addorganization_id
  37853. if v == nil {
  37854. return
  37855. }
  37856. return *v, true
  37857. }
  37858. // ClearOrganizationID clears the value of the "organization_id" field.
  37859. func (m *WxMutation) ClearOrganizationID() {
  37860. m.organization_id = nil
  37861. m.addorganization_id = nil
  37862. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  37863. }
  37864. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  37865. func (m *WxMutation) OrganizationIDCleared() bool {
  37866. _, ok := m.clearedFields[wx.FieldOrganizationID]
  37867. return ok
  37868. }
  37869. // ResetOrganizationID resets all changes to the "organization_id" field.
  37870. func (m *WxMutation) ResetOrganizationID() {
  37871. m.organization_id = nil
  37872. m.addorganization_id = nil
  37873. delete(m.clearedFields, wx.FieldOrganizationID)
  37874. }
  37875. // SetAgentID sets the "agent_id" field.
  37876. func (m *WxMutation) SetAgentID(u uint64) {
  37877. m.agent = &u
  37878. }
  37879. // AgentID returns the value of the "agent_id" field in the mutation.
  37880. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  37881. v := m.agent
  37882. if v == nil {
  37883. return
  37884. }
  37885. return *v, true
  37886. }
  37887. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  37888. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37890. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  37891. if !m.op.Is(OpUpdateOne) {
  37892. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  37893. }
  37894. if m.id == nil || m.oldValue == nil {
  37895. return v, errors.New("OldAgentID requires an ID field in the mutation")
  37896. }
  37897. oldValue, err := m.oldValue(ctx)
  37898. if err != nil {
  37899. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  37900. }
  37901. return oldValue.AgentID, nil
  37902. }
  37903. // ResetAgentID resets all changes to the "agent_id" field.
  37904. func (m *WxMutation) ResetAgentID() {
  37905. m.agent = nil
  37906. }
  37907. // SetAPIBase sets the "api_base" field.
  37908. func (m *WxMutation) SetAPIBase(s string) {
  37909. m.api_base = &s
  37910. }
  37911. // APIBase returns the value of the "api_base" field in the mutation.
  37912. func (m *WxMutation) APIBase() (r string, exists bool) {
  37913. v := m.api_base
  37914. if v == nil {
  37915. return
  37916. }
  37917. return *v, true
  37918. }
  37919. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  37920. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37921. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37922. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  37923. if !m.op.Is(OpUpdateOne) {
  37924. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  37925. }
  37926. if m.id == nil || m.oldValue == nil {
  37927. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  37928. }
  37929. oldValue, err := m.oldValue(ctx)
  37930. if err != nil {
  37931. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  37932. }
  37933. return oldValue.APIBase, nil
  37934. }
  37935. // ClearAPIBase clears the value of the "api_base" field.
  37936. func (m *WxMutation) ClearAPIBase() {
  37937. m.api_base = nil
  37938. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  37939. }
  37940. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  37941. func (m *WxMutation) APIBaseCleared() bool {
  37942. _, ok := m.clearedFields[wx.FieldAPIBase]
  37943. return ok
  37944. }
  37945. // ResetAPIBase resets all changes to the "api_base" field.
  37946. func (m *WxMutation) ResetAPIBase() {
  37947. m.api_base = nil
  37948. delete(m.clearedFields, wx.FieldAPIBase)
  37949. }
  37950. // SetAPIKey sets the "api_key" field.
  37951. func (m *WxMutation) SetAPIKey(s string) {
  37952. m.api_key = &s
  37953. }
  37954. // APIKey returns the value of the "api_key" field in the mutation.
  37955. func (m *WxMutation) APIKey() (r string, exists bool) {
  37956. v := m.api_key
  37957. if v == nil {
  37958. return
  37959. }
  37960. return *v, true
  37961. }
  37962. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  37963. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37964. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37965. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  37966. if !m.op.Is(OpUpdateOne) {
  37967. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  37968. }
  37969. if m.id == nil || m.oldValue == nil {
  37970. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  37971. }
  37972. oldValue, err := m.oldValue(ctx)
  37973. if err != nil {
  37974. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  37975. }
  37976. return oldValue.APIKey, nil
  37977. }
  37978. // ClearAPIKey clears the value of the "api_key" field.
  37979. func (m *WxMutation) ClearAPIKey() {
  37980. m.api_key = nil
  37981. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  37982. }
  37983. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  37984. func (m *WxMutation) APIKeyCleared() bool {
  37985. _, ok := m.clearedFields[wx.FieldAPIKey]
  37986. return ok
  37987. }
  37988. // ResetAPIKey resets all changes to the "api_key" field.
  37989. func (m *WxMutation) ResetAPIKey() {
  37990. m.api_key = nil
  37991. delete(m.clearedFields, wx.FieldAPIKey)
  37992. }
  37993. // SetAllowList sets the "allow_list" field.
  37994. func (m *WxMutation) SetAllowList(s []string) {
  37995. m.allow_list = &s
  37996. m.appendallow_list = nil
  37997. }
  37998. // AllowList returns the value of the "allow_list" field in the mutation.
  37999. func (m *WxMutation) AllowList() (r []string, exists bool) {
  38000. v := m.allow_list
  38001. if v == nil {
  38002. return
  38003. }
  38004. return *v, true
  38005. }
  38006. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  38007. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38009. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  38010. if !m.op.Is(OpUpdateOne) {
  38011. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  38012. }
  38013. if m.id == nil || m.oldValue == nil {
  38014. return v, errors.New("OldAllowList requires an ID field in the mutation")
  38015. }
  38016. oldValue, err := m.oldValue(ctx)
  38017. if err != nil {
  38018. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  38019. }
  38020. return oldValue.AllowList, nil
  38021. }
  38022. // AppendAllowList adds s to the "allow_list" field.
  38023. func (m *WxMutation) AppendAllowList(s []string) {
  38024. m.appendallow_list = append(m.appendallow_list, s...)
  38025. }
  38026. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  38027. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  38028. if len(m.appendallow_list) == 0 {
  38029. return nil, false
  38030. }
  38031. return m.appendallow_list, true
  38032. }
  38033. // ResetAllowList resets all changes to the "allow_list" field.
  38034. func (m *WxMutation) ResetAllowList() {
  38035. m.allow_list = nil
  38036. m.appendallow_list = nil
  38037. }
  38038. // SetGroupAllowList sets the "group_allow_list" field.
  38039. func (m *WxMutation) SetGroupAllowList(s []string) {
  38040. m.group_allow_list = &s
  38041. m.appendgroup_allow_list = nil
  38042. }
  38043. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  38044. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  38045. v := m.group_allow_list
  38046. if v == nil {
  38047. return
  38048. }
  38049. return *v, true
  38050. }
  38051. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  38052. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38054. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  38055. if !m.op.Is(OpUpdateOne) {
  38056. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  38057. }
  38058. if m.id == nil || m.oldValue == nil {
  38059. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  38060. }
  38061. oldValue, err := m.oldValue(ctx)
  38062. if err != nil {
  38063. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  38064. }
  38065. return oldValue.GroupAllowList, nil
  38066. }
  38067. // AppendGroupAllowList adds s to the "group_allow_list" field.
  38068. func (m *WxMutation) AppendGroupAllowList(s []string) {
  38069. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  38070. }
  38071. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  38072. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  38073. if len(m.appendgroup_allow_list) == 0 {
  38074. return nil, false
  38075. }
  38076. return m.appendgroup_allow_list, true
  38077. }
  38078. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  38079. func (m *WxMutation) ResetGroupAllowList() {
  38080. m.group_allow_list = nil
  38081. m.appendgroup_allow_list = nil
  38082. }
  38083. // SetBlockList sets the "block_list" field.
  38084. func (m *WxMutation) SetBlockList(s []string) {
  38085. m.block_list = &s
  38086. m.appendblock_list = nil
  38087. }
  38088. // BlockList returns the value of the "block_list" field in the mutation.
  38089. func (m *WxMutation) BlockList() (r []string, exists bool) {
  38090. v := m.block_list
  38091. if v == nil {
  38092. return
  38093. }
  38094. return *v, true
  38095. }
  38096. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  38097. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38098. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38099. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  38100. if !m.op.Is(OpUpdateOne) {
  38101. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  38102. }
  38103. if m.id == nil || m.oldValue == nil {
  38104. return v, errors.New("OldBlockList requires an ID field in the mutation")
  38105. }
  38106. oldValue, err := m.oldValue(ctx)
  38107. if err != nil {
  38108. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  38109. }
  38110. return oldValue.BlockList, nil
  38111. }
  38112. // AppendBlockList adds s to the "block_list" field.
  38113. func (m *WxMutation) AppendBlockList(s []string) {
  38114. m.appendblock_list = append(m.appendblock_list, s...)
  38115. }
  38116. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  38117. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  38118. if len(m.appendblock_list) == 0 {
  38119. return nil, false
  38120. }
  38121. return m.appendblock_list, true
  38122. }
  38123. // ResetBlockList resets all changes to the "block_list" field.
  38124. func (m *WxMutation) ResetBlockList() {
  38125. m.block_list = nil
  38126. m.appendblock_list = nil
  38127. }
  38128. // SetGroupBlockList sets the "group_block_list" field.
  38129. func (m *WxMutation) SetGroupBlockList(s []string) {
  38130. m.group_block_list = &s
  38131. m.appendgroup_block_list = nil
  38132. }
  38133. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  38134. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  38135. v := m.group_block_list
  38136. if v == nil {
  38137. return
  38138. }
  38139. return *v, true
  38140. }
  38141. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  38142. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38144. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  38145. if !m.op.Is(OpUpdateOne) {
  38146. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  38147. }
  38148. if m.id == nil || m.oldValue == nil {
  38149. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  38150. }
  38151. oldValue, err := m.oldValue(ctx)
  38152. if err != nil {
  38153. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  38154. }
  38155. return oldValue.GroupBlockList, nil
  38156. }
  38157. // AppendGroupBlockList adds s to the "group_block_list" field.
  38158. func (m *WxMutation) AppendGroupBlockList(s []string) {
  38159. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  38160. }
  38161. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  38162. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  38163. if len(m.appendgroup_block_list) == 0 {
  38164. return nil, false
  38165. }
  38166. return m.appendgroup_block_list, true
  38167. }
  38168. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  38169. func (m *WxMutation) ResetGroupBlockList() {
  38170. m.group_block_list = nil
  38171. m.appendgroup_block_list = nil
  38172. }
  38173. // ClearServer clears the "server" edge to the Server entity.
  38174. func (m *WxMutation) ClearServer() {
  38175. m.clearedserver = true
  38176. m.clearedFields[wx.FieldServerID] = struct{}{}
  38177. }
  38178. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  38179. func (m *WxMutation) ServerCleared() bool {
  38180. return m.ServerIDCleared() || m.clearedserver
  38181. }
  38182. // ServerIDs returns the "server" edge IDs in the mutation.
  38183. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  38184. // ServerID instead. It exists only for internal usage by the builders.
  38185. func (m *WxMutation) ServerIDs() (ids []uint64) {
  38186. if id := m.server; id != nil {
  38187. ids = append(ids, *id)
  38188. }
  38189. return
  38190. }
  38191. // ResetServer resets all changes to the "server" edge.
  38192. func (m *WxMutation) ResetServer() {
  38193. m.server = nil
  38194. m.clearedserver = false
  38195. }
  38196. // ClearAgent clears the "agent" edge to the Agent entity.
  38197. func (m *WxMutation) ClearAgent() {
  38198. m.clearedagent = true
  38199. m.clearedFields[wx.FieldAgentID] = struct{}{}
  38200. }
  38201. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  38202. func (m *WxMutation) AgentCleared() bool {
  38203. return m.clearedagent
  38204. }
  38205. // AgentIDs returns the "agent" edge IDs in the mutation.
  38206. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  38207. // AgentID instead. It exists only for internal usage by the builders.
  38208. func (m *WxMutation) AgentIDs() (ids []uint64) {
  38209. if id := m.agent; id != nil {
  38210. ids = append(ids, *id)
  38211. }
  38212. return
  38213. }
  38214. // ResetAgent resets all changes to the "agent" edge.
  38215. func (m *WxMutation) ResetAgent() {
  38216. m.agent = nil
  38217. m.clearedagent = false
  38218. }
  38219. // Where appends a list predicates to the WxMutation builder.
  38220. func (m *WxMutation) Where(ps ...predicate.Wx) {
  38221. m.predicates = append(m.predicates, ps...)
  38222. }
  38223. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  38224. // users can use type-assertion to append predicates that do not depend on any generated package.
  38225. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  38226. p := make([]predicate.Wx, len(ps))
  38227. for i := range ps {
  38228. p[i] = ps[i]
  38229. }
  38230. m.Where(p...)
  38231. }
  38232. // Op returns the operation name.
  38233. func (m *WxMutation) Op() Op {
  38234. return m.op
  38235. }
  38236. // SetOp allows setting the mutation operation.
  38237. func (m *WxMutation) SetOp(op Op) {
  38238. m.op = op
  38239. }
  38240. // Type returns the node type of this mutation (Wx).
  38241. func (m *WxMutation) Type() string {
  38242. return m.typ
  38243. }
  38244. // Fields returns all fields that were changed during this mutation. Note that in
  38245. // order to get all numeric fields that were incremented/decremented, call
  38246. // AddedFields().
  38247. func (m *WxMutation) Fields() []string {
  38248. fields := make([]string, 0, 21)
  38249. if m.created_at != nil {
  38250. fields = append(fields, wx.FieldCreatedAt)
  38251. }
  38252. if m.updated_at != nil {
  38253. fields = append(fields, wx.FieldUpdatedAt)
  38254. }
  38255. if m.status != nil {
  38256. fields = append(fields, wx.FieldStatus)
  38257. }
  38258. if m.deleted_at != nil {
  38259. fields = append(fields, wx.FieldDeletedAt)
  38260. }
  38261. if m.server != nil {
  38262. fields = append(fields, wx.FieldServerID)
  38263. }
  38264. if m.port != nil {
  38265. fields = append(fields, wx.FieldPort)
  38266. }
  38267. if m.process_id != nil {
  38268. fields = append(fields, wx.FieldProcessID)
  38269. }
  38270. if m.callback != nil {
  38271. fields = append(fields, wx.FieldCallback)
  38272. }
  38273. if m.wxid != nil {
  38274. fields = append(fields, wx.FieldWxid)
  38275. }
  38276. if m.account != nil {
  38277. fields = append(fields, wx.FieldAccount)
  38278. }
  38279. if m.nickname != nil {
  38280. fields = append(fields, wx.FieldNickname)
  38281. }
  38282. if m.tel != nil {
  38283. fields = append(fields, wx.FieldTel)
  38284. }
  38285. if m.head_big != nil {
  38286. fields = append(fields, wx.FieldHeadBig)
  38287. }
  38288. if m.organization_id != nil {
  38289. fields = append(fields, wx.FieldOrganizationID)
  38290. }
  38291. if m.agent != nil {
  38292. fields = append(fields, wx.FieldAgentID)
  38293. }
  38294. if m.api_base != nil {
  38295. fields = append(fields, wx.FieldAPIBase)
  38296. }
  38297. if m.api_key != nil {
  38298. fields = append(fields, wx.FieldAPIKey)
  38299. }
  38300. if m.allow_list != nil {
  38301. fields = append(fields, wx.FieldAllowList)
  38302. }
  38303. if m.group_allow_list != nil {
  38304. fields = append(fields, wx.FieldGroupAllowList)
  38305. }
  38306. if m.block_list != nil {
  38307. fields = append(fields, wx.FieldBlockList)
  38308. }
  38309. if m.group_block_list != nil {
  38310. fields = append(fields, wx.FieldGroupBlockList)
  38311. }
  38312. return fields
  38313. }
  38314. // Field returns the value of a field with the given name. The second boolean
  38315. // return value indicates that this field was not set, or was not defined in the
  38316. // schema.
  38317. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  38318. switch name {
  38319. case wx.FieldCreatedAt:
  38320. return m.CreatedAt()
  38321. case wx.FieldUpdatedAt:
  38322. return m.UpdatedAt()
  38323. case wx.FieldStatus:
  38324. return m.Status()
  38325. case wx.FieldDeletedAt:
  38326. return m.DeletedAt()
  38327. case wx.FieldServerID:
  38328. return m.ServerID()
  38329. case wx.FieldPort:
  38330. return m.Port()
  38331. case wx.FieldProcessID:
  38332. return m.ProcessID()
  38333. case wx.FieldCallback:
  38334. return m.Callback()
  38335. case wx.FieldWxid:
  38336. return m.Wxid()
  38337. case wx.FieldAccount:
  38338. return m.Account()
  38339. case wx.FieldNickname:
  38340. return m.Nickname()
  38341. case wx.FieldTel:
  38342. return m.Tel()
  38343. case wx.FieldHeadBig:
  38344. return m.HeadBig()
  38345. case wx.FieldOrganizationID:
  38346. return m.OrganizationID()
  38347. case wx.FieldAgentID:
  38348. return m.AgentID()
  38349. case wx.FieldAPIBase:
  38350. return m.APIBase()
  38351. case wx.FieldAPIKey:
  38352. return m.APIKey()
  38353. case wx.FieldAllowList:
  38354. return m.AllowList()
  38355. case wx.FieldGroupAllowList:
  38356. return m.GroupAllowList()
  38357. case wx.FieldBlockList:
  38358. return m.BlockList()
  38359. case wx.FieldGroupBlockList:
  38360. return m.GroupBlockList()
  38361. }
  38362. return nil, false
  38363. }
  38364. // OldField returns the old value of the field from the database. An error is
  38365. // returned if the mutation operation is not UpdateOne, or the query to the
  38366. // database failed.
  38367. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38368. switch name {
  38369. case wx.FieldCreatedAt:
  38370. return m.OldCreatedAt(ctx)
  38371. case wx.FieldUpdatedAt:
  38372. return m.OldUpdatedAt(ctx)
  38373. case wx.FieldStatus:
  38374. return m.OldStatus(ctx)
  38375. case wx.FieldDeletedAt:
  38376. return m.OldDeletedAt(ctx)
  38377. case wx.FieldServerID:
  38378. return m.OldServerID(ctx)
  38379. case wx.FieldPort:
  38380. return m.OldPort(ctx)
  38381. case wx.FieldProcessID:
  38382. return m.OldProcessID(ctx)
  38383. case wx.FieldCallback:
  38384. return m.OldCallback(ctx)
  38385. case wx.FieldWxid:
  38386. return m.OldWxid(ctx)
  38387. case wx.FieldAccount:
  38388. return m.OldAccount(ctx)
  38389. case wx.FieldNickname:
  38390. return m.OldNickname(ctx)
  38391. case wx.FieldTel:
  38392. return m.OldTel(ctx)
  38393. case wx.FieldHeadBig:
  38394. return m.OldHeadBig(ctx)
  38395. case wx.FieldOrganizationID:
  38396. return m.OldOrganizationID(ctx)
  38397. case wx.FieldAgentID:
  38398. return m.OldAgentID(ctx)
  38399. case wx.FieldAPIBase:
  38400. return m.OldAPIBase(ctx)
  38401. case wx.FieldAPIKey:
  38402. return m.OldAPIKey(ctx)
  38403. case wx.FieldAllowList:
  38404. return m.OldAllowList(ctx)
  38405. case wx.FieldGroupAllowList:
  38406. return m.OldGroupAllowList(ctx)
  38407. case wx.FieldBlockList:
  38408. return m.OldBlockList(ctx)
  38409. case wx.FieldGroupBlockList:
  38410. return m.OldGroupBlockList(ctx)
  38411. }
  38412. return nil, fmt.Errorf("unknown Wx field %s", name)
  38413. }
  38414. // SetField sets the value of a field with the given name. It returns an error if
  38415. // the field is not defined in the schema, or if the type mismatched the field
  38416. // type.
  38417. func (m *WxMutation) SetField(name string, value ent.Value) error {
  38418. switch name {
  38419. case wx.FieldCreatedAt:
  38420. v, ok := value.(time.Time)
  38421. if !ok {
  38422. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38423. }
  38424. m.SetCreatedAt(v)
  38425. return nil
  38426. case wx.FieldUpdatedAt:
  38427. v, ok := value.(time.Time)
  38428. if !ok {
  38429. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38430. }
  38431. m.SetUpdatedAt(v)
  38432. return nil
  38433. case wx.FieldStatus:
  38434. v, ok := value.(uint8)
  38435. if !ok {
  38436. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38437. }
  38438. m.SetStatus(v)
  38439. return nil
  38440. case wx.FieldDeletedAt:
  38441. v, ok := value.(time.Time)
  38442. if !ok {
  38443. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38444. }
  38445. m.SetDeletedAt(v)
  38446. return nil
  38447. case wx.FieldServerID:
  38448. v, ok := value.(uint64)
  38449. if !ok {
  38450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38451. }
  38452. m.SetServerID(v)
  38453. return nil
  38454. case wx.FieldPort:
  38455. v, ok := value.(string)
  38456. if !ok {
  38457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38458. }
  38459. m.SetPort(v)
  38460. return nil
  38461. case wx.FieldProcessID:
  38462. v, ok := value.(string)
  38463. if !ok {
  38464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38465. }
  38466. m.SetProcessID(v)
  38467. return nil
  38468. case wx.FieldCallback:
  38469. v, ok := value.(string)
  38470. if !ok {
  38471. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38472. }
  38473. m.SetCallback(v)
  38474. return nil
  38475. case wx.FieldWxid:
  38476. v, ok := value.(string)
  38477. if !ok {
  38478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38479. }
  38480. m.SetWxid(v)
  38481. return nil
  38482. case wx.FieldAccount:
  38483. v, ok := value.(string)
  38484. if !ok {
  38485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38486. }
  38487. m.SetAccount(v)
  38488. return nil
  38489. case wx.FieldNickname:
  38490. v, ok := value.(string)
  38491. if !ok {
  38492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38493. }
  38494. m.SetNickname(v)
  38495. return nil
  38496. case wx.FieldTel:
  38497. v, ok := value.(string)
  38498. if !ok {
  38499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38500. }
  38501. m.SetTel(v)
  38502. return nil
  38503. case wx.FieldHeadBig:
  38504. v, ok := value.(string)
  38505. if !ok {
  38506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38507. }
  38508. m.SetHeadBig(v)
  38509. return nil
  38510. case wx.FieldOrganizationID:
  38511. v, ok := value.(uint64)
  38512. if !ok {
  38513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38514. }
  38515. m.SetOrganizationID(v)
  38516. return nil
  38517. case wx.FieldAgentID:
  38518. v, ok := value.(uint64)
  38519. if !ok {
  38520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38521. }
  38522. m.SetAgentID(v)
  38523. return nil
  38524. case wx.FieldAPIBase:
  38525. v, ok := value.(string)
  38526. if !ok {
  38527. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38528. }
  38529. m.SetAPIBase(v)
  38530. return nil
  38531. case wx.FieldAPIKey:
  38532. v, ok := value.(string)
  38533. if !ok {
  38534. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38535. }
  38536. m.SetAPIKey(v)
  38537. return nil
  38538. case wx.FieldAllowList:
  38539. v, ok := value.([]string)
  38540. if !ok {
  38541. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38542. }
  38543. m.SetAllowList(v)
  38544. return nil
  38545. case wx.FieldGroupAllowList:
  38546. v, ok := value.([]string)
  38547. if !ok {
  38548. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38549. }
  38550. m.SetGroupAllowList(v)
  38551. return nil
  38552. case wx.FieldBlockList:
  38553. v, ok := value.([]string)
  38554. if !ok {
  38555. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38556. }
  38557. m.SetBlockList(v)
  38558. return nil
  38559. case wx.FieldGroupBlockList:
  38560. v, ok := value.([]string)
  38561. if !ok {
  38562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38563. }
  38564. m.SetGroupBlockList(v)
  38565. return nil
  38566. }
  38567. return fmt.Errorf("unknown Wx field %s", name)
  38568. }
  38569. // AddedFields returns all numeric fields that were incremented/decremented during
  38570. // this mutation.
  38571. func (m *WxMutation) AddedFields() []string {
  38572. var fields []string
  38573. if m.addstatus != nil {
  38574. fields = append(fields, wx.FieldStatus)
  38575. }
  38576. if m.addorganization_id != nil {
  38577. fields = append(fields, wx.FieldOrganizationID)
  38578. }
  38579. return fields
  38580. }
  38581. // AddedField returns the numeric value that was incremented/decremented on a field
  38582. // with the given name. The second boolean return value indicates that this field
  38583. // was not set, or was not defined in the schema.
  38584. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  38585. switch name {
  38586. case wx.FieldStatus:
  38587. return m.AddedStatus()
  38588. case wx.FieldOrganizationID:
  38589. return m.AddedOrganizationID()
  38590. }
  38591. return nil, false
  38592. }
  38593. // AddField adds the value to the field with the given name. It returns an error if
  38594. // the field is not defined in the schema, or if the type mismatched the field
  38595. // type.
  38596. func (m *WxMutation) AddField(name string, value ent.Value) error {
  38597. switch name {
  38598. case wx.FieldStatus:
  38599. v, ok := value.(int8)
  38600. if !ok {
  38601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38602. }
  38603. m.AddStatus(v)
  38604. return nil
  38605. case wx.FieldOrganizationID:
  38606. v, ok := value.(int64)
  38607. if !ok {
  38608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38609. }
  38610. m.AddOrganizationID(v)
  38611. return nil
  38612. }
  38613. return fmt.Errorf("unknown Wx numeric field %s", name)
  38614. }
  38615. // ClearedFields returns all nullable fields that were cleared during this
  38616. // mutation.
  38617. func (m *WxMutation) ClearedFields() []string {
  38618. var fields []string
  38619. if m.FieldCleared(wx.FieldStatus) {
  38620. fields = append(fields, wx.FieldStatus)
  38621. }
  38622. if m.FieldCleared(wx.FieldDeletedAt) {
  38623. fields = append(fields, wx.FieldDeletedAt)
  38624. }
  38625. if m.FieldCleared(wx.FieldServerID) {
  38626. fields = append(fields, wx.FieldServerID)
  38627. }
  38628. if m.FieldCleared(wx.FieldOrganizationID) {
  38629. fields = append(fields, wx.FieldOrganizationID)
  38630. }
  38631. if m.FieldCleared(wx.FieldAPIBase) {
  38632. fields = append(fields, wx.FieldAPIBase)
  38633. }
  38634. if m.FieldCleared(wx.FieldAPIKey) {
  38635. fields = append(fields, wx.FieldAPIKey)
  38636. }
  38637. return fields
  38638. }
  38639. // FieldCleared returns a boolean indicating if a field with the given name was
  38640. // cleared in this mutation.
  38641. func (m *WxMutation) FieldCleared(name string) bool {
  38642. _, ok := m.clearedFields[name]
  38643. return ok
  38644. }
  38645. // ClearField clears the value of the field with the given name. It returns an
  38646. // error if the field is not defined in the schema.
  38647. func (m *WxMutation) ClearField(name string) error {
  38648. switch name {
  38649. case wx.FieldStatus:
  38650. m.ClearStatus()
  38651. return nil
  38652. case wx.FieldDeletedAt:
  38653. m.ClearDeletedAt()
  38654. return nil
  38655. case wx.FieldServerID:
  38656. m.ClearServerID()
  38657. return nil
  38658. case wx.FieldOrganizationID:
  38659. m.ClearOrganizationID()
  38660. return nil
  38661. case wx.FieldAPIBase:
  38662. m.ClearAPIBase()
  38663. return nil
  38664. case wx.FieldAPIKey:
  38665. m.ClearAPIKey()
  38666. return nil
  38667. }
  38668. return fmt.Errorf("unknown Wx nullable field %s", name)
  38669. }
  38670. // ResetField resets all changes in the mutation for the field with the given name.
  38671. // It returns an error if the field is not defined in the schema.
  38672. func (m *WxMutation) ResetField(name string) error {
  38673. switch name {
  38674. case wx.FieldCreatedAt:
  38675. m.ResetCreatedAt()
  38676. return nil
  38677. case wx.FieldUpdatedAt:
  38678. m.ResetUpdatedAt()
  38679. return nil
  38680. case wx.FieldStatus:
  38681. m.ResetStatus()
  38682. return nil
  38683. case wx.FieldDeletedAt:
  38684. m.ResetDeletedAt()
  38685. return nil
  38686. case wx.FieldServerID:
  38687. m.ResetServerID()
  38688. return nil
  38689. case wx.FieldPort:
  38690. m.ResetPort()
  38691. return nil
  38692. case wx.FieldProcessID:
  38693. m.ResetProcessID()
  38694. return nil
  38695. case wx.FieldCallback:
  38696. m.ResetCallback()
  38697. return nil
  38698. case wx.FieldWxid:
  38699. m.ResetWxid()
  38700. return nil
  38701. case wx.FieldAccount:
  38702. m.ResetAccount()
  38703. return nil
  38704. case wx.FieldNickname:
  38705. m.ResetNickname()
  38706. return nil
  38707. case wx.FieldTel:
  38708. m.ResetTel()
  38709. return nil
  38710. case wx.FieldHeadBig:
  38711. m.ResetHeadBig()
  38712. return nil
  38713. case wx.FieldOrganizationID:
  38714. m.ResetOrganizationID()
  38715. return nil
  38716. case wx.FieldAgentID:
  38717. m.ResetAgentID()
  38718. return nil
  38719. case wx.FieldAPIBase:
  38720. m.ResetAPIBase()
  38721. return nil
  38722. case wx.FieldAPIKey:
  38723. m.ResetAPIKey()
  38724. return nil
  38725. case wx.FieldAllowList:
  38726. m.ResetAllowList()
  38727. return nil
  38728. case wx.FieldGroupAllowList:
  38729. m.ResetGroupAllowList()
  38730. return nil
  38731. case wx.FieldBlockList:
  38732. m.ResetBlockList()
  38733. return nil
  38734. case wx.FieldGroupBlockList:
  38735. m.ResetGroupBlockList()
  38736. return nil
  38737. }
  38738. return fmt.Errorf("unknown Wx field %s", name)
  38739. }
  38740. // AddedEdges returns all edge names that were set/added in this mutation.
  38741. func (m *WxMutation) AddedEdges() []string {
  38742. edges := make([]string, 0, 2)
  38743. if m.server != nil {
  38744. edges = append(edges, wx.EdgeServer)
  38745. }
  38746. if m.agent != nil {
  38747. edges = append(edges, wx.EdgeAgent)
  38748. }
  38749. return edges
  38750. }
  38751. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38752. // name in this mutation.
  38753. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  38754. switch name {
  38755. case wx.EdgeServer:
  38756. if id := m.server; id != nil {
  38757. return []ent.Value{*id}
  38758. }
  38759. case wx.EdgeAgent:
  38760. if id := m.agent; id != nil {
  38761. return []ent.Value{*id}
  38762. }
  38763. }
  38764. return nil
  38765. }
  38766. // RemovedEdges returns all edge names that were removed in this mutation.
  38767. func (m *WxMutation) RemovedEdges() []string {
  38768. edges := make([]string, 0, 2)
  38769. return edges
  38770. }
  38771. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38772. // the given name in this mutation.
  38773. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  38774. return nil
  38775. }
  38776. // ClearedEdges returns all edge names that were cleared in this mutation.
  38777. func (m *WxMutation) ClearedEdges() []string {
  38778. edges := make([]string, 0, 2)
  38779. if m.clearedserver {
  38780. edges = append(edges, wx.EdgeServer)
  38781. }
  38782. if m.clearedagent {
  38783. edges = append(edges, wx.EdgeAgent)
  38784. }
  38785. return edges
  38786. }
  38787. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38788. // was cleared in this mutation.
  38789. func (m *WxMutation) EdgeCleared(name string) bool {
  38790. switch name {
  38791. case wx.EdgeServer:
  38792. return m.clearedserver
  38793. case wx.EdgeAgent:
  38794. return m.clearedagent
  38795. }
  38796. return false
  38797. }
  38798. // ClearEdge clears the value of the edge with the given name. It returns an error
  38799. // if that edge is not defined in the schema.
  38800. func (m *WxMutation) ClearEdge(name string) error {
  38801. switch name {
  38802. case wx.EdgeServer:
  38803. m.ClearServer()
  38804. return nil
  38805. case wx.EdgeAgent:
  38806. m.ClearAgent()
  38807. return nil
  38808. }
  38809. return fmt.Errorf("unknown Wx unique edge %s", name)
  38810. }
  38811. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38812. // It returns an error if the edge is not defined in the schema.
  38813. func (m *WxMutation) ResetEdge(name string) error {
  38814. switch name {
  38815. case wx.EdgeServer:
  38816. m.ResetServer()
  38817. return nil
  38818. case wx.EdgeAgent:
  38819. m.ResetAgent()
  38820. return nil
  38821. }
  38822. return fmt.Errorf("unknown Wx edge %s", name)
  38823. }
  38824. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  38825. type WxCardMutation struct {
  38826. config
  38827. op Op
  38828. typ string
  38829. id *uint64
  38830. created_at *time.Time
  38831. updated_at *time.Time
  38832. deleted_at *time.Time
  38833. user_id *uint64
  38834. adduser_id *int64
  38835. wx_user_id *uint64
  38836. addwx_user_id *int64
  38837. avatar *string
  38838. logo *string
  38839. name *string
  38840. company *string
  38841. address *string
  38842. phone *string
  38843. official_account *string
  38844. wechat_account *string
  38845. email *string
  38846. api_base *string
  38847. api_key *string
  38848. ai_info *string
  38849. intro *string
  38850. clearedFields map[string]struct{}
  38851. done bool
  38852. oldValue func(context.Context) (*WxCard, error)
  38853. predicates []predicate.WxCard
  38854. }
  38855. var _ ent.Mutation = (*WxCardMutation)(nil)
  38856. // wxcardOption allows management of the mutation configuration using functional options.
  38857. type wxcardOption func(*WxCardMutation)
  38858. // newWxCardMutation creates new mutation for the WxCard entity.
  38859. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  38860. m := &WxCardMutation{
  38861. config: c,
  38862. op: op,
  38863. typ: TypeWxCard,
  38864. clearedFields: make(map[string]struct{}),
  38865. }
  38866. for _, opt := range opts {
  38867. opt(m)
  38868. }
  38869. return m
  38870. }
  38871. // withWxCardID sets the ID field of the mutation.
  38872. func withWxCardID(id uint64) wxcardOption {
  38873. return func(m *WxCardMutation) {
  38874. var (
  38875. err error
  38876. once sync.Once
  38877. value *WxCard
  38878. )
  38879. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  38880. once.Do(func() {
  38881. if m.done {
  38882. err = errors.New("querying old values post mutation is not allowed")
  38883. } else {
  38884. value, err = m.Client().WxCard.Get(ctx, id)
  38885. }
  38886. })
  38887. return value, err
  38888. }
  38889. m.id = &id
  38890. }
  38891. }
  38892. // withWxCard sets the old WxCard of the mutation.
  38893. func withWxCard(node *WxCard) wxcardOption {
  38894. return func(m *WxCardMutation) {
  38895. m.oldValue = func(context.Context) (*WxCard, error) {
  38896. return node, nil
  38897. }
  38898. m.id = &node.ID
  38899. }
  38900. }
  38901. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38902. // executed in a transaction (ent.Tx), a transactional client is returned.
  38903. func (m WxCardMutation) Client() *Client {
  38904. client := &Client{config: m.config}
  38905. client.init()
  38906. return client
  38907. }
  38908. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38909. // it returns an error otherwise.
  38910. func (m WxCardMutation) Tx() (*Tx, error) {
  38911. if _, ok := m.driver.(*txDriver); !ok {
  38912. return nil, errors.New("ent: mutation is not running in a transaction")
  38913. }
  38914. tx := &Tx{config: m.config}
  38915. tx.init()
  38916. return tx, nil
  38917. }
  38918. // SetID sets the value of the id field. Note that this
  38919. // operation is only accepted on creation of WxCard entities.
  38920. func (m *WxCardMutation) SetID(id uint64) {
  38921. m.id = &id
  38922. }
  38923. // ID returns the ID value in the mutation. Note that the ID is only available
  38924. // if it was provided to the builder or after it was returned from the database.
  38925. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  38926. if m.id == nil {
  38927. return
  38928. }
  38929. return *m.id, true
  38930. }
  38931. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  38932. // That means, if the mutation is applied within a transaction with an isolation level such
  38933. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  38934. // or updated by the mutation.
  38935. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  38936. switch {
  38937. case m.op.Is(OpUpdateOne | OpDeleteOne):
  38938. id, exists := m.ID()
  38939. if exists {
  38940. return []uint64{id}, nil
  38941. }
  38942. fallthrough
  38943. case m.op.Is(OpUpdate | OpDelete):
  38944. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  38945. default:
  38946. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  38947. }
  38948. }
  38949. // SetCreatedAt sets the "created_at" field.
  38950. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  38951. m.created_at = &t
  38952. }
  38953. // CreatedAt returns the value of the "created_at" field in the mutation.
  38954. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  38955. v := m.created_at
  38956. if v == nil {
  38957. return
  38958. }
  38959. return *v, true
  38960. }
  38961. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  38962. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  38963. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38964. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  38965. if !m.op.Is(OpUpdateOne) {
  38966. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  38967. }
  38968. if m.id == nil || m.oldValue == nil {
  38969. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  38970. }
  38971. oldValue, err := m.oldValue(ctx)
  38972. if err != nil {
  38973. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  38974. }
  38975. return oldValue.CreatedAt, nil
  38976. }
  38977. // ResetCreatedAt resets all changes to the "created_at" field.
  38978. func (m *WxCardMutation) ResetCreatedAt() {
  38979. m.created_at = nil
  38980. }
  38981. // SetUpdatedAt sets the "updated_at" field.
  38982. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  38983. m.updated_at = &t
  38984. }
  38985. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  38986. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  38987. v := m.updated_at
  38988. if v == nil {
  38989. return
  38990. }
  38991. return *v, true
  38992. }
  38993. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  38994. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  38995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38996. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  38997. if !m.op.Is(OpUpdateOne) {
  38998. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  38999. }
  39000. if m.id == nil || m.oldValue == nil {
  39001. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39002. }
  39003. oldValue, err := m.oldValue(ctx)
  39004. if err != nil {
  39005. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39006. }
  39007. return oldValue.UpdatedAt, nil
  39008. }
  39009. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39010. func (m *WxCardMutation) ResetUpdatedAt() {
  39011. m.updated_at = nil
  39012. }
  39013. // SetDeletedAt sets the "deleted_at" field.
  39014. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  39015. m.deleted_at = &t
  39016. }
  39017. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39018. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  39019. v := m.deleted_at
  39020. if v == nil {
  39021. return
  39022. }
  39023. return *v, true
  39024. }
  39025. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  39026. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39027. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39028. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39029. if !m.op.Is(OpUpdateOne) {
  39030. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39031. }
  39032. if m.id == nil || m.oldValue == nil {
  39033. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39034. }
  39035. oldValue, err := m.oldValue(ctx)
  39036. if err != nil {
  39037. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39038. }
  39039. return oldValue.DeletedAt, nil
  39040. }
  39041. // ClearDeletedAt clears the value of the "deleted_at" field.
  39042. func (m *WxCardMutation) ClearDeletedAt() {
  39043. m.deleted_at = nil
  39044. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  39045. }
  39046. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39047. func (m *WxCardMutation) DeletedAtCleared() bool {
  39048. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  39049. return ok
  39050. }
  39051. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39052. func (m *WxCardMutation) ResetDeletedAt() {
  39053. m.deleted_at = nil
  39054. delete(m.clearedFields, wxcard.FieldDeletedAt)
  39055. }
  39056. // SetUserID sets the "user_id" field.
  39057. func (m *WxCardMutation) SetUserID(u uint64) {
  39058. m.user_id = &u
  39059. m.adduser_id = nil
  39060. }
  39061. // UserID returns the value of the "user_id" field in the mutation.
  39062. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  39063. v := m.user_id
  39064. if v == nil {
  39065. return
  39066. }
  39067. return *v, true
  39068. }
  39069. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  39070. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39072. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  39073. if !m.op.Is(OpUpdateOne) {
  39074. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  39075. }
  39076. if m.id == nil || m.oldValue == nil {
  39077. return v, errors.New("OldUserID requires an ID field in the mutation")
  39078. }
  39079. oldValue, err := m.oldValue(ctx)
  39080. if err != nil {
  39081. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  39082. }
  39083. return oldValue.UserID, nil
  39084. }
  39085. // AddUserID adds u to the "user_id" field.
  39086. func (m *WxCardMutation) AddUserID(u int64) {
  39087. if m.adduser_id != nil {
  39088. *m.adduser_id += u
  39089. } else {
  39090. m.adduser_id = &u
  39091. }
  39092. }
  39093. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  39094. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  39095. v := m.adduser_id
  39096. if v == nil {
  39097. return
  39098. }
  39099. return *v, true
  39100. }
  39101. // ClearUserID clears the value of the "user_id" field.
  39102. func (m *WxCardMutation) ClearUserID() {
  39103. m.user_id = nil
  39104. m.adduser_id = nil
  39105. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  39106. }
  39107. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  39108. func (m *WxCardMutation) UserIDCleared() bool {
  39109. _, ok := m.clearedFields[wxcard.FieldUserID]
  39110. return ok
  39111. }
  39112. // ResetUserID resets all changes to the "user_id" field.
  39113. func (m *WxCardMutation) ResetUserID() {
  39114. m.user_id = nil
  39115. m.adduser_id = nil
  39116. delete(m.clearedFields, wxcard.FieldUserID)
  39117. }
  39118. // SetWxUserID sets the "wx_user_id" field.
  39119. func (m *WxCardMutation) SetWxUserID(u uint64) {
  39120. m.wx_user_id = &u
  39121. m.addwx_user_id = nil
  39122. }
  39123. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  39124. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  39125. v := m.wx_user_id
  39126. if v == nil {
  39127. return
  39128. }
  39129. return *v, true
  39130. }
  39131. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  39132. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39134. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  39135. if !m.op.Is(OpUpdateOne) {
  39136. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  39137. }
  39138. if m.id == nil || m.oldValue == nil {
  39139. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  39140. }
  39141. oldValue, err := m.oldValue(ctx)
  39142. if err != nil {
  39143. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  39144. }
  39145. return oldValue.WxUserID, nil
  39146. }
  39147. // AddWxUserID adds u to the "wx_user_id" field.
  39148. func (m *WxCardMutation) AddWxUserID(u int64) {
  39149. if m.addwx_user_id != nil {
  39150. *m.addwx_user_id += u
  39151. } else {
  39152. m.addwx_user_id = &u
  39153. }
  39154. }
  39155. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  39156. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  39157. v := m.addwx_user_id
  39158. if v == nil {
  39159. return
  39160. }
  39161. return *v, true
  39162. }
  39163. // ClearWxUserID clears the value of the "wx_user_id" field.
  39164. func (m *WxCardMutation) ClearWxUserID() {
  39165. m.wx_user_id = nil
  39166. m.addwx_user_id = nil
  39167. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  39168. }
  39169. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  39170. func (m *WxCardMutation) WxUserIDCleared() bool {
  39171. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  39172. return ok
  39173. }
  39174. // ResetWxUserID resets all changes to the "wx_user_id" field.
  39175. func (m *WxCardMutation) ResetWxUserID() {
  39176. m.wx_user_id = nil
  39177. m.addwx_user_id = nil
  39178. delete(m.clearedFields, wxcard.FieldWxUserID)
  39179. }
  39180. // SetAvatar sets the "avatar" field.
  39181. func (m *WxCardMutation) SetAvatar(s string) {
  39182. m.avatar = &s
  39183. }
  39184. // Avatar returns the value of the "avatar" field in the mutation.
  39185. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  39186. v := m.avatar
  39187. if v == nil {
  39188. return
  39189. }
  39190. return *v, true
  39191. }
  39192. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  39193. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39194. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39195. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  39196. if !m.op.Is(OpUpdateOne) {
  39197. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  39198. }
  39199. if m.id == nil || m.oldValue == nil {
  39200. return v, errors.New("OldAvatar requires an ID field in the mutation")
  39201. }
  39202. oldValue, err := m.oldValue(ctx)
  39203. if err != nil {
  39204. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  39205. }
  39206. return oldValue.Avatar, nil
  39207. }
  39208. // ResetAvatar resets all changes to the "avatar" field.
  39209. func (m *WxCardMutation) ResetAvatar() {
  39210. m.avatar = nil
  39211. }
  39212. // SetLogo sets the "logo" field.
  39213. func (m *WxCardMutation) SetLogo(s string) {
  39214. m.logo = &s
  39215. }
  39216. // Logo returns the value of the "logo" field in the mutation.
  39217. func (m *WxCardMutation) Logo() (r string, exists bool) {
  39218. v := m.logo
  39219. if v == nil {
  39220. return
  39221. }
  39222. return *v, true
  39223. }
  39224. // OldLogo returns the old "logo" field's value of the WxCard entity.
  39225. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39227. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  39228. if !m.op.Is(OpUpdateOne) {
  39229. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  39230. }
  39231. if m.id == nil || m.oldValue == nil {
  39232. return v, errors.New("OldLogo requires an ID field in the mutation")
  39233. }
  39234. oldValue, err := m.oldValue(ctx)
  39235. if err != nil {
  39236. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  39237. }
  39238. return oldValue.Logo, nil
  39239. }
  39240. // ResetLogo resets all changes to the "logo" field.
  39241. func (m *WxCardMutation) ResetLogo() {
  39242. m.logo = nil
  39243. }
  39244. // SetName sets the "name" field.
  39245. func (m *WxCardMutation) SetName(s string) {
  39246. m.name = &s
  39247. }
  39248. // Name returns the value of the "name" field in the mutation.
  39249. func (m *WxCardMutation) Name() (r string, exists bool) {
  39250. v := m.name
  39251. if v == nil {
  39252. return
  39253. }
  39254. return *v, true
  39255. }
  39256. // OldName returns the old "name" field's value of the WxCard entity.
  39257. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39259. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  39260. if !m.op.Is(OpUpdateOne) {
  39261. return v, errors.New("OldName is only allowed on UpdateOne operations")
  39262. }
  39263. if m.id == nil || m.oldValue == nil {
  39264. return v, errors.New("OldName requires an ID field in the mutation")
  39265. }
  39266. oldValue, err := m.oldValue(ctx)
  39267. if err != nil {
  39268. return v, fmt.Errorf("querying old value for OldName: %w", err)
  39269. }
  39270. return oldValue.Name, nil
  39271. }
  39272. // ResetName resets all changes to the "name" field.
  39273. func (m *WxCardMutation) ResetName() {
  39274. m.name = nil
  39275. }
  39276. // SetCompany sets the "company" field.
  39277. func (m *WxCardMutation) SetCompany(s string) {
  39278. m.company = &s
  39279. }
  39280. // Company returns the value of the "company" field in the mutation.
  39281. func (m *WxCardMutation) Company() (r string, exists bool) {
  39282. v := m.company
  39283. if v == nil {
  39284. return
  39285. }
  39286. return *v, true
  39287. }
  39288. // OldCompany returns the old "company" field's value of the WxCard entity.
  39289. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39291. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  39292. if !m.op.Is(OpUpdateOne) {
  39293. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  39294. }
  39295. if m.id == nil || m.oldValue == nil {
  39296. return v, errors.New("OldCompany requires an ID field in the mutation")
  39297. }
  39298. oldValue, err := m.oldValue(ctx)
  39299. if err != nil {
  39300. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  39301. }
  39302. return oldValue.Company, nil
  39303. }
  39304. // ResetCompany resets all changes to the "company" field.
  39305. func (m *WxCardMutation) ResetCompany() {
  39306. m.company = nil
  39307. }
  39308. // SetAddress sets the "address" field.
  39309. func (m *WxCardMutation) SetAddress(s string) {
  39310. m.address = &s
  39311. }
  39312. // Address returns the value of the "address" field in the mutation.
  39313. func (m *WxCardMutation) Address() (r string, exists bool) {
  39314. v := m.address
  39315. if v == nil {
  39316. return
  39317. }
  39318. return *v, true
  39319. }
  39320. // OldAddress returns the old "address" field's value of the WxCard entity.
  39321. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39322. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39323. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  39324. if !m.op.Is(OpUpdateOne) {
  39325. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  39326. }
  39327. if m.id == nil || m.oldValue == nil {
  39328. return v, errors.New("OldAddress requires an ID field in the mutation")
  39329. }
  39330. oldValue, err := m.oldValue(ctx)
  39331. if err != nil {
  39332. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  39333. }
  39334. return oldValue.Address, nil
  39335. }
  39336. // ResetAddress resets all changes to the "address" field.
  39337. func (m *WxCardMutation) ResetAddress() {
  39338. m.address = nil
  39339. }
  39340. // SetPhone sets the "phone" field.
  39341. func (m *WxCardMutation) SetPhone(s string) {
  39342. m.phone = &s
  39343. }
  39344. // Phone returns the value of the "phone" field in the mutation.
  39345. func (m *WxCardMutation) Phone() (r string, exists bool) {
  39346. v := m.phone
  39347. if v == nil {
  39348. return
  39349. }
  39350. return *v, true
  39351. }
  39352. // OldPhone returns the old "phone" field's value of the WxCard entity.
  39353. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39355. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  39356. if !m.op.Is(OpUpdateOne) {
  39357. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  39358. }
  39359. if m.id == nil || m.oldValue == nil {
  39360. return v, errors.New("OldPhone requires an ID field in the mutation")
  39361. }
  39362. oldValue, err := m.oldValue(ctx)
  39363. if err != nil {
  39364. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  39365. }
  39366. return oldValue.Phone, nil
  39367. }
  39368. // ResetPhone resets all changes to the "phone" field.
  39369. func (m *WxCardMutation) ResetPhone() {
  39370. m.phone = nil
  39371. }
  39372. // SetOfficialAccount sets the "official_account" field.
  39373. func (m *WxCardMutation) SetOfficialAccount(s string) {
  39374. m.official_account = &s
  39375. }
  39376. // OfficialAccount returns the value of the "official_account" field in the mutation.
  39377. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  39378. v := m.official_account
  39379. if v == nil {
  39380. return
  39381. }
  39382. return *v, true
  39383. }
  39384. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  39385. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39386. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39387. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  39388. if !m.op.Is(OpUpdateOne) {
  39389. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  39390. }
  39391. if m.id == nil || m.oldValue == nil {
  39392. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  39393. }
  39394. oldValue, err := m.oldValue(ctx)
  39395. if err != nil {
  39396. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  39397. }
  39398. return oldValue.OfficialAccount, nil
  39399. }
  39400. // ResetOfficialAccount resets all changes to the "official_account" field.
  39401. func (m *WxCardMutation) ResetOfficialAccount() {
  39402. m.official_account = nil
  39403. }
  39404. // SetWechatAccount sets the "wechat_account" field.
  39405. func (m *WxCardMutation) SetWechatAccount(s string) {
  39406. m.wechat_account = &s
  39407. }
  39408. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  39409. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  39410. v := m.wechat_account
  39411. if v == nil {
  39412. return
  39413. }
  39414. return *v, true
  39415. }
  39416. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  39417. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39419. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  39420. if !m.op.Is(OpUpdateOne) {
  39421. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  39422. }
  39423. if m.id == nil || m.oldValue == nil {
  39424. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  39425. }
  39426. oldValue, err := m.oldValue(ctx)
  39427. if err != nil {
  39428. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  39429. }
  39430. return oldValue.WechatAccount, nil
  39431. }
  39432. // ResetWechatAccount resets all changes to the "wechat_account" field.
  39433. func (m *WxCardMutation) ResetWechatAccount() {
  39434. m.wechat_account = nil
  39435. }
  39436. // SetEmail sets the "email" field.
  39437. func (m *WxCardMutation) SetEmail(s string) {
  39438. m.email = &s
  39439. }
  39440. // Email returns the value of the "email" field in the mutation.
  39441. func (m *WxCardMutation) Email() (r string, exists bool) {
  39442. v := m.email
  39443. if v == nil {
  39444. return
  39445. }
  39446. return *v, true
  39447. }
  39448. // OldEmail returns the old "email" field's value of the WxCard entity.
  39449. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39450. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39451. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  39452. if !m.op.Is(OpUpdateOne) {
  39453. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  39454. }
  39455. if m.id == nil || m.oldValue == nil {
  39456. return v, errors.New("OldEmail requires an ID field in the mutation")
  39457. }
  39458. oldValue, err := m.oldValue(ctx)
  39459. if err != nil {
  39460. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  39461. }
  39462. return oldValue.Email, nil
  39463. }
  39464. // ClearEmail clears the value of the "email" field.
  39465. func (m *WxCardMutation) ClearEmail() {
  39466. m.email = nil
  39467. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  39468. }
  39469. // EmailCleared returns if the "email" field was cleared in this mutation.
  39470. func (m *WxCardMutation) EmailCleared() bool {
  39471. _, ok := m.clearedFields[wxcard.FieldEmail]
  39472. return ok
  39473. }
  39474. // ResetEmail resets all changes to the "email" field.
  39475. func (m *WxCardMutation) ResetEmail() {
  39476. m.email = nil
  39477. delete(m.clearedFields, wxcard.FieldEmail)
  39478. }
  39479. // SetAPIBase sets the "api_base" field.
  39480. func (m *WxCardMutation) SetAPIBase(s string) {
  39481. m.api_base = &s
  39482. }
  39483. // APIBase returns the value of the "api_base" field in the mutation.
  39484. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  39485. v := m.api_base
  39486. if v == nil {
  39487. return
  39488. }
  39489. return *v, true
  39490. }
  39491. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  39492. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39494. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  39495. if !m.op.Is(OpUpdateOne) {
  39496. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  39497. }
  39498. if m.id == nil || m.oldValue == nil {
  39499. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  39500. }
  39501. oldValue, err := m.oldValue(ctx)
  39502. if err != nil {
  39503. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  39504. }
  39505. return oldValue.APIBase, nil
  39506. }
  39507. // ClearAPIBase clears the value of the "api_base" field.
  39508. func (m *WxCardMutation) ClearAPIBase() {
  39509. m.api_base = nil
  39510. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  39511. }
  39512. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  39513. func (m *WxCardMutation) APIBaseCleared() bool {
  39514. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  39515. return ok
  39516. }
  39517. // ResetAPIBase resets all changes to the "api_base" field.
  39518. func (m *WxCardMutation) ResetAPIBase() {
  39519. m.api_base = nil
  39520. delete(m.clearedFields, wxcard.FieldAPIBase)
  39521. }
  39522. // SetAPIKey sets the "api_key" field.
  39523. func (m *WxCardMutation) SetAPIKey(s string) {
  39524. m.api_key = &s
  39525. }
  39526. // APIKey returns the value of the "api_key" field in the mutation.
  39527. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  39528. v := m.api_key
  39529. if v == nil {
  39530. return
  39531. }
  39532. return *v, true
  39533. }
  39534. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  39535. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39537. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  39538. if !m.op.Is(OpUpdateOne) {
  39539. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  39540. }
  39541. if m.id == nil || m.oldValue == nil {
  39542. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  39543. }
  39544. oldValue, err := m.oldValue(ctx)
  39545. if err != nil {
  39546. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  39547. }
  39548. return oldValue.APIKey, nil
  39549. }
  39550. // ClearAPIKey clears the value of the "api_key" field.
  39551. func (m *WxCardMutation) ClearAPIKey() {
  39552. m.api_key = nil
  39553. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  39554. }
  39555. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  39556. func (m *WxCardMutation) APIKeyCleared() bool {
  39557. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  39558. return ok
  39559. }
  39560. // ResetAPIKey resets all changes to the "api_key" field.
  39561. func (m *WxCardMutation) ResetAPIKey() {
  39562. m.api_key = nil
  39563. delete(m.clearedFields, wxcard.FieldAPIKey)
  39564. }
  39565. // SetAiInfo sets the "ai_info" field.
  39566. func (m *WxCardMutation) SetAiInfo(s string) {
  39567. m.ai_info = &s
  39568. }
  39569. // AiInfo returns the value of the "ai_info" field in the mutation.
  39570. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  39571. v := m.ai_info
  39572. if v == nil {
  39573. return
  39574. }
  39575. return *v, true
  39576. }
  39577. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  39578. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39579. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39580. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  39581. if !m.op.Is(OpUpdateOne) {
  39582. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  39583. }
  39584. if m.id == nil || m.oldValue == nil {
  39585. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  39586. }
  39587. oldValue, err := m.oldValue(ctx)
  39588. if err != nil {
  39589. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  39590. }
  39591. return oldValue.AiInfo, nil
  39592. }
  39593. // ClearAiInfo clears the value of the "ai_info" field.
  39594. func (m *WxCardMutation) ClearAiInfo() {
  39595. m.ai_info = nil
  39596. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  39597. }
  39598. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  39599. func (m *WxCardMutation) AiInfoCleared() bool {
  39600. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  39601. return ok
  39602. }
  39603. // ResetAiInfo resets all changes to the "ai_info" field.
  39604. func (m *WxCardMutation) ResetAiInfo() {
  39605. m.ai_info = nil
  39606. delete(m.clearedFields, wxcard.FieldAiInfo)
  39607. }
  39608. // SetIntro sets the "intro" field.
  39609. func (m *WxCardMutation) SetIntro(s string) {
  39610. m.intro = &s
  39611. }
  39612. // Intro returns the value of the "intro" field in the mutation.
  39613. func (m *WxCardMutation) Intro() (r string, exists bool) {
  39614. v := m.intro
  39615. if v == nil {
  39616. return
  39617. }
  39618. return *v, true
  39619. }
  39620. // OldIntro returns the old "intro" field's value of the WxCard entity.
  39621. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39622. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39623. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  39624. if !m.op.Is(OpUpdateOne) {
  39625. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  39626. }
  39627. if m.id == nil || m.oldValue == nil {
  39628. return v, errors.New("OldIntro requires an ID field in the mutation")
  39629. }
  39630. oldValue, err := m.oldValue(ctx)
  39631. if err != nil {
  39632. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  39633. }
  39634. return oldValue.Intro, nil
  39635. }
  39636. // ClearIntro clears the value of the "intro" field.
  39637. func (m *WxCardMutation) ClearIntro() {
  39638. m.intro = nil
  39639. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  39640. }
  39641. // IntroCleared returns if the "intro" field was cleared in this mutation.
  39642. func (m *WxCardMutation) IntroCleared() bool {
  39643. _, ok := m.clearedFields[wxcard.FieldIntro]
  39644. return ok
  39645. }
  39646. // ResetIntro resets all changes to the "intro" field.
  39647. func (m *WxCardMutation) ResetIntro() {
  39648. m.intro = nil
  39649. delete(m.clearedFields, wxcard.FieldIntro)
  39650. }
  39651. // Where appends a list predicates to the WxCardMutation builder.
  39652. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  39653. m.predicates = append(m.predicates, ps...)
  39654. }
  39655. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  39656. // users can use type-assertion to append predicates that do not depend on any generated package.
  39657. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  39658. p := make([]predicate.WxCard, len(ps))
  39659. for i := range ps {
  39660. p[i] = ps[i]
  39661. }
  39662. m.Where(p...)
  39663. }
  39664. // Op returns the operation name.
  39665. func (m *WxCardMutation) Op() Op {
  39666. return m.op
  39667. }
  39668. // SetOp allows setting the mutation operation.
  39669. func (m *WxCardMutation) SetOp(op Op) {
  39670. m.op = op
  39671. }
  39672. // Type returns the node type of this mutation (WxCard).
  39673. func (m *WxCardMutation) Type() string {
  39674. return m.typ
  39675. }
  39676. // Fields returns all fields that were changed during this mutation. Note that in
  39677. // order to get all numeric fields that were incremented/decremented, call
  39678. // AddedFields().
  39679. func (m *WxCardMutation) Fields() []string {
  39680. fields := make([]string, 0, 18)
  39681. if m.created_at != nil {
  39682. fields = append(fields, wxcard.FieldCreatedAt)
  39683. }
  39684. if m.updated_at != nil {
  39685. fields = append(fields, wxcard.FieldUpdatedAt)
  39686. }
  39687. if m.deleted_at != nil {
  39688. fields = append(fields, wxcard.FieldDeletedAt)
  39689. }
  39690. if m.user_id != nil {
  39691. fields = append(fields, wxcard.FieldUserID)
  39692. }
  39693. if m.wx_user_id != nil {
  39694. fields = append(fields, wxcard.FieldWxUserID)
  39695. }
  39696. if m.avatar != nil {
  39697. fields = append(fields, wxcard.FieldAvatar)
  39698. }
  39699. if m.logo != nil {
  39700. fields = append(fields, wxcard.FieldLogo)
  39701. }
  39702. if m.name != nil {
  39703. fields = append(fields, wxcard.FieldName)
  39704. }
  39705. if m.company != nil {
  39706. fields = append(fields, wxcard.FieldCompany)
  39707. }
  39708. if m.address != nil {
  39709. fields = append(fields, wxcard.FieldAddress)
  39710. }
  39711. if m.phone != nil {
  39712. fields = append(fields, wxcard.FieldPhone)
  39713. }
  39714. if m.official_account != nil {
  39715. fields = append(fields, wxcard.FieldOfficialAccount)
  39716. }
  39717. if m.wechat_account != nil {
  39718. fields = append(fields, wxcard.FieldWechatAccount)
  39719. }
  39720. if m.email != nil {
  39721. fields = append(fields, wxcard.FieldEmail)
  39722. }
  39723. if m.api_base != nil {
  39724. fields = append(fields, wxcard.FieldAPIBase)
  39725. }
  39726. if m.api_key != nil {
  39727. fields = append(fields, wxcard.FieldAPIKey)
  39728. }
  39729. if m.ai_info != nil {
  39730. fields = append(fields, wxcard.FieldAiInfo)
  39731. }
  39732. if m.intro != nil {
  39733. fields = append(fields, wxcard.FieldIntro)
  39734. }
  39735. return fields
  39736. }
  39737. // Field returns the value of a field with the given name. The second boolean
  39738. // return value indicates that this field was not set, or was not defined in the
  39739. // schema.
  39740. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  39741. switch name {
  39742. case wxcard.FieldCreatedAt:
  39743. return m.CreatedAt()
  39744. case wxcard.FieldUpdatedAt:
  39745. return m.UpdatedAt()
  39746. case wxcard.FieldDeletedAt:
  39747. return m.DeletedAt()
  39748. case wxcard.FieldUserID:
  39749. return m.UserID()
  39750. case wxcard.FieldWxUserID:
  39751. return m.WxUserID()
  39752. case wxcard.FieldAvatar:
  39753. return m.Avatar()
  39754. case wxcard.FieldLogo:
  39755. return m.Logo()
  39756. case wxcard.FieldName:
  39757. return m.Name()
  39758. case wxcard.FieldCompany:
  39759. return m.Company()
  39760. case wxcard.FieldAddress:
  39761. return m.Address()
  39762. case wxcard.FieldPhone:
  39763. return m.Phone()
  39764. case wxcard.FieldOfficialAccount:
  39765. return m.OfficialAccount()
  39766. case wxcard.FieldWechatAccount:
  39767. return m.WechatAccount()
  39768. case wxcard.FieldEmail:
  39769. return m.Email()
  39770. case wxcard.FieldAPIBase:
  39771. return m.APIBase()
  39772. case wxcard.FieldAPIKey:
  39773. return m.APIKey()
  39774. case wxcard.FieldAiInfo:
  39775. return m.AiInfo()
  39776. case wxcard.FieldIntro:
  39777. return m.Intro()
  39778. }
  39779. return nil, false
  39780. }
  39781. // OldField returns the old value of the field from the database. An error is
  39782. // returned if the mutation operation is not UpdateOne, or the query to the
  39783. // database failed.
  39784. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39785. switch name {
  39786. case wxcard.FieldCreatedAt:
  39787. return m.OldCreatedAt(ctx)
  39788. case wxcard.FieldUpdatedAt:
  39789. return m.OldUpdatedAt(ctx)
  39790. case wxcard.FieldDeletedAt:
  39791. return m.OldDeletedAt(ctx)
  39792. case wxcard.FieldUserID:
  39793. return m.OldUserID(ctx)
  39794. case wxcard.FieldWxUserID:
  39795. return m.OldWxUserID(ctx)
  39796. case wxcard.FieldAvatar:
  39797. return m.OldAvatar(ctx)
  39798. case wxcard.FieldLogo:
  39799. return m.OldLogo(ctx)
  39800. case wxcard.FieldName:
  39801. return m.OldName(ctx)
  39802. case wxcard.FieldCompany:
  39803. return m.OldCompany(ctx)
  39804. case wxcard.FieldAddress:
  39805. return m.OldAddress(ctx)
  39806. case wxcard.FieldPhone:
  39807. return m.OldPhone(ctx)
  39808. case wxcard.FieldOfficialAccount:
  39809. return m.OldOfficialAccount(ctx)
  39810. case wxcard.FieldWechatAccount:
  39811. return m.OldWechatAccount(ctx)
  39812. case wxcard.FieldEmail:
  39813. return m.OldEmail(ctx)
  39814. case wxcard.FieldAPIBase:
  39815. return m.OldAPIBase(ctx)
  39816. case wxcard.FieldAPIKey:
  39817. return m.OldAPIKey(ctx)
  39818. case wxcard.FieldAiInfo:
  39819. return m.OldAiInfo(ctx)
  39820. case wxcard.FieldIntro:
  39821. return m.OldIntro(ctx)
  39822. }
  39823. return nil, fmt.Errorf("unknown WxCard field %s", name)
  39824. }
  39825. // SetField sets the value of a field with the given name. It returns an error if
  39826. // the field is not defined in the schema, or if the type mismatched the field
  39827. // type.
  39828. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  39829. switch name {
  39830. case wxcard.FieldCreatedAt:
  39831. v, ok := value.(time.Time)
  39832. if !ok {
  39833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39834. }
  39835. m.SetCreatedAt(v)
  39836. return nil
  39837. case wxcard.FieldUpdatedAt:
  39838. v, ok := value.(time.Time)
  39839. if !ok {
  39840. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39841. }
  39842. m.SetUpdatedAt(v)
  39843. return nil
  39844. case wxcard.FieldDeletedAt:
  39845. v, ok := value.(time.Time)
  39846. if !ok {
  39847. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39848. }
  39849. m.SetDeletedAt(v)
  39850. return nil
  39851. case wxcard.FieldUserID:
  39852. v, ok := value.(uint64)
  39853. if !ok {
  39854. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39855. }
  39856. m.SetUserID(v)
  39857. return nil
  39858. case wxcard.FieldWxUserID:
  39859. v, ok := value.(uint64)
  39860. if !ok {
  39861. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39862. }
  39863. m.SetWxUserID(v)
  39864. return nil
  39865. case wxcard.FieldAvatar:
  39866. v, ok := value.(string)
  39867. if !ok {
  39868. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39869. }
  39870. m.SetAvatar(v)
  39871. return nil
  39872. case wxcard.FieldLogo:
  39873. v, ok := value.(string)
  39874. if !ok {
  39875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39876. }
  39877. m.SetLogo(v)
  39878. return nil
  39879. case wxcard.FieldName:
  39880. v, ok := value.(string)
  39881. if !ok {
  39882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39883. }
  39884. m.SetName(v)
  39885. return nil
  39886. case wxcard.FieldCompany:
  39887. v, ok := value.(string)
  39888. if !ok {
  39889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39890. }
  39891. m.SetCompany(v)
  39892. return nil
  39893. case wxcard.FieldAddress:
  39894. v, ok := value.(string)
  39895. if !ok {
  39896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39897. }
  39898. m.SetAddress(v)
  39899. return nil
  39900. case wxcard.FieldPhone:
  39901. v, ok := value.(string)
  39902. if !ok {
  39903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39904. }
  39905. m.SetPhone(v)
  39906. return nil
  39907. case wxcard.FieldOfficialAccount:
  39908. v, ok := value.(string)
  39909. if !ok {
  39910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39911. }
  39912. m.SetOfficialAccount(v)
  39913. return nil
  39914. case wxcard.FieldWechatAccount:
  39915. v, ok := value.(string)
  39916. if !ok {
  39917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39918. }
  39919. m.SetWechatAccount(v)
  39920. return nil
  39921. case wxcard.FieldEmail:
  39922. v, ok := value.(string)
  39923. if !ok {
  39924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39925. }
  39926. m.SetEmail(v)
  39927. return nil
  39928. case wxcard.FieldAPIBase:
  39929. v, ok := value.(string)
  39930. if !ok {
  39931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39932. }
  39933. m.SetAPIBase(v)
  39934. return nil
  39935. case wxcard.FieldAPIKey:
  39936. v, ok := value.(string)
  39937. if !ok {
  39938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39939. }
  39940. m.SetAPIKey(v)
  39941. return nil
  39942. case wxcard.FieldAiInfo:
  39943. v, ok := value.(string)
  39944. if !ok {
  39945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39946. }
  39947. m.SetAiInfo(v)
  39948. return nil
  39949. case wxcard.FieldIntro:
  39950. v, ok := value.(string)
  39951. if !ok {
  39952. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39953. }
  39954. m.SetIntro(v)
  39955. return nil
  39956. }
  39957. return fmt.Errorf("unknown WxCard field %s", name)
  39958. }
  39959. // AddedFields returns all numeric fields that were incremented/decremented during
  39960. // this mutation.
  39961. func (m *WxCardMutation) AddedFields() []string {
  39962. var fields []string
  39963. if m.adduser_id != nil {
  39964. fields = append(fields, wxcard.FieldUserID)
  39965. }
  39966. if m.addwx_user_id != nil {
  39967. fields = append(fields, wxcard.FieldWxUserID)
  39968. }
  39969. return fields
  39970. }
  39971. // AddedField returns the numeric value that was incremented/decremented on a field
  39972. // with the given name. The second boolean return value indicates that this field
  39973. // was not set, or was not defined in the schema.
  39974. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  39975. switch name {
  39976. case wxcard.FieldUserID:
  39977. return m.AddedUserID()
  39978. case wxcard.FieldWxUserID:
  39979. return m.AddedWxUserID()
  39980. }
  39981. return nil, false
  39982. }
  39983. // AddField adds the value to the field with the given name. It returns an error if
  39984. // the field is not defined in the schema, or if the type mismatched the field
  39985. // type.
  39986. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  39987. switch name {
  39988. case wxcard.FieldUserID:
  39989. v, ok := value.(int64)
  39990. if !ok {
  39991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39992. }
  39993. m.AddUserID(v)
  39994. return nil
  39995. case wxcard.FieldWxUserID:
  39996. v, ok := value.(int64)
  39997. if !ok {
  39998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39999. }
  40000. m.AddWxUserID(v)
  40001. return nil
  40002. }
  40003. return fmt.Errorf("unknown WxCard numeric field %s", name)
  40004. }
  40005. // ClearedFields returns all nullable fields that were cleared during this
  40006. // mutation.
  40007. func (m *WxCardMutation) ClearedFields() []string {
  40008. var fields []string
  40009. if m.FieldCleared(wxcard.FieldDeletedAt) {
  40010. fields = append(fields, wxcard.FieldDeletedAt)
  40011. }
  40012. if m.FieldCleared(wxcard.FieldUserID) {
  40013. fields = append(fields, wxcard.FieldUserID)
  40014. }
  40015. if m.FieldCleared(wxcard.FieldWxUserID) {
  40016. fields = append(fields, wxcard.FieldWxUserID)
  40017. }
  40018. if m.FieldCleared(wxcard.FieldEmail) {
  40019. fields = append(fields, wxcard.FieldEmail)
  40020. }
  40021. if m.FieldCleared(wxcard.FieldAPIBase) {
  40022. fields = append(fields, wxcard.FieldAPIBase)
  40023. }
  40024. if m.FieldCleared(wxcard.FieldAPIKey) {
  40025. fields = append(fields, wxcard.FieldAPIKey)
  40026. }
  40027. if m.FieldCleared(wxcard.FieldAiInfo) {
  40028. fields = append(fields, wxcard.FieldAiInfo)
  40029. }
  40030. if m.FieldCleared(wxcard.FieldIntro) {
  40031. fields = append(fields, wxcard.FieldIntro)
  40032. }
  40033. return fields
  40034. }
  40035. // FieldCleared returns a boolean indicating if a field with the given name was
  40036. // cleared in this mutation.
  40037. func (m *WxCardMutation) FieldCleared(name string) bool {
  40038. _, ok := m.clearedFields[name]
  40039. return ok
  40040. }
  40041. // ClearField clears the value of the field with the given name. It returns an
  40042. // error if the field is not defined in the schema.
  40043. func (m *WxCardMutation) ClearField(name string) error {
  40044. switch name {
  40045. case wxcard.FieldDeletedAt:
  40046. m.ClearDeletedAt()
  40047. return nil
  40048. case wxcard.FieldUserID:
  40049. m.ClearUserID()
  40050. return nil
  40051. case wxcard.FieldWxUserID:
  40052. m.ClearWxUserID()
  40053. return nil
  40054. case wxcard.FieldEmail:
  40055. m.ClearEmail()
  40056. return nil
  40057. case wxcard.FieldAPIBase:
  40058. m.ClearAPIBase()
  40059. return nil
  40060. case wxcard.FieldAPIKey:
  40061. m.ClearAPIKey()
  40062. return nil
  40063. case wxcard.FieldAiInfo:
  40064. m.ClearAiInfo()
  40065. return nil
  40066. case wxcard.FieldIntro:
  40067. m.ClearIntro()
  40068. return nil
  40069. }
  40070. return fmt.Errorf("unknown WxCard nullable field %s", name)
  40071. }
  40072. // ResetField resets all changes in the mutation for the field with the given name.
  40073. // It returns an error if the field is not defined in the schema.
  40074. func (m *WxCardMutation) ResetField(name string) error {
  40075. switch name {
  40076. case wxcard.FieldCreatedAt:
  40077. m.ResetCreatedAt()
  40078. return nil
  40079. case wxcard.FieldUpdatedAt:
  40080. m.ResetUpdatedAt()
  40081. return nil
  40082. case wxcard.FieldDeletedAt:
  40083. m.ResetDeletedAt()
  40084. return nil
  40085. case wxcard.FieldUserID:
  40086. m.ResetUserID()
  40087. return nil
  40088. case wxcard.FieldWxUserID:
  40089. m.ResetWxUserID()
  40090. return nil
  40091. case wxcard.FieldAvatar:
  40092. m.ResetAvatar()
  40093. return nil
  40094. case wxcard.FieldLogo:
  40095. m.ResetLogo()
  40096. return nil
  40097. case wxcard.FieldName:
  40098. m.ResetName()
  40099. return nil
  40100. case wxcard.FieldCompany:
  40101. m.ResetCompany()
  40102. return nil
  40103. case wxcard.FieldAddress:
  40104. m.ResetAddress()
  40105. return nil
  40106. case wxcard.FieldPhone:
  40107. m.ResetPhone()
  40108. return nil
  40109. case wxcard.FieldOfficialAccount:
  40110. m.ResetOfficialAccount()
  40111. return nil
  40112. case wxcard.FieldWechatAccount:
  40113. m.ResetWechatAccount()
  40114. return nil
  40115. case wxcard.FieldEmail:
  40116. m.ResetEmail()
  40117. return nil
  40118. case wxcard.FieldAPIBase:
  40119. m.ResetAPIBase()
  40120. return nil
  40121. case wxcard.FieldAPIKey:
  40122. m.ResetAPIKey()
  40123. return nil
  40124. case wxcard.FieldAiInfo:
  40125. m.ResetAiInfo()
  40126. return nil
  40127. case wxcard.FieldIntro:
  40128. m.ResetIntro()
  40129. return nil
  40130. }
  40131. return fmt.Errorf("unknown WxCard field %s", name)
  40132. }
  40133. // AddedEdges returns all edge names that were set/added in this mutation.
  40134. func (m *WxCardMutation) AddedEdges() []string {
  40135. edges := make([]string, 0, 0)
  40136. return edges
  40137. }
  40138. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40139. // name in this mutation.
  40140. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  40141. return nil
  40142. }
  40143. // RemovedEdges returns all edge names that were removed in this mutation.
  40144. func (m *WxCardMutation) RemovedEdges() []string {
  40145. edges := make([]string, 0, 0)
  40146. return edges
  40147. }
  40148. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40149. // the given name in this mutation.
  40150. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  40151. return nil
  40152. }
  40153. // ClearedEdges returns all edge names that were cleared in this mutation.
  40154. func (m *WxCardMutation) ClearedEdges() []string {
  40155. edges := make([]string, 0, 0)
  40156. return edges
  40157. }
  40158. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40159. // was cleared in this mutation.
  40160. func (m *WxCardMutation) EdgeCleared(name string) bool {
  40161. return false
  40162. }
  40163. // ClearEdge clears the value of the edge with the given name. It returns an error
  40164. // if that edge is not defined in the schema.
  40165. func (m *WxCardMutation) ClearEdge(name string) error {
  40166. return fmt.Errorf("unknown WxCard unique edge %s", name)
  40167. }
  40168. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40169. // It returns an error if the edge is not defined in the schema.
  40170. func (m *WxCardMutation) ResetEdge(name string) error {
  40171. return fmt.Errorf("unknown WxCard edge %s", name)
  40172. }
  40173. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  40174. type WxCardUserMutation struct {
  40175. config
  40176. op Op
  40177. typ string
  40178. id *uint64
  40179. created_at *time.Time
  40180. updated_at *time.Time
  40181. deleted_at *time.Time
  40182. wxid *string
  40183. account *string
  40184. avatar *string
  40185. nickname *string
  40186. remark *string
  40187. phone *string
  40188. open_id *string
  40189. union_id *string
  40190. session_key *string
  40191. is_vip *int
  40192. addis_vip *int
  40193. clearedFields map[string]struct{}
  40194. done bool
  40195. oldValue func(context.Context) (*WxCardUser, error)
  40196. predicates []predicate.WxCardUser
  40197. }
  40198. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  40199. // wxcarduserOption allows management of the mutation configuration using functional options.
  40200. type wxcarduserOption func(*WxCardUserMutation)
  40201. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  40202. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  40203. m := &WxCardUserMutation{
  40204. config: c,
  40205. op: op,
  40206. typ: TypeWxCardUser,
  40207. clearedFields: make(map[string]struct{}),
  40208. }
  40209. for _, opt := range opts {
  40210. opt(m)
  40211. }
  40212. return m
  40213. }
  40214. // withWxCardUserID sets the ID field of the mutation.
  40215. func withWxCardUserID(id uint64) wxcarduserOption {
  40216. return func(m *WxCardUserMutation) {
  40217. var (
  40218. err error
  40219. once sync.Once
  40220. value *WxCardUser
  40221. )
  40222. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  40223. once.Do(func() {
  40224. if m.done {
  40225. err = errors.New("querying old values post mutation is not allowed")
  40226. } else {
  40227. value, err = m.Client().WxCardUser.Get(ctx, id)
  40228. }
  40229. })
  40230. return value, err
  40231. }
  40232. m.id = &id
  40233. }
  40234. }
  40235. // withWxCardUser sets the old WxCardUser of the mutation.
  40236. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  40237. return func(m *WxCardUserMutation) {
  40238. m.oldValue = func(context.Context) (*WxCardUser, error) {
  40239. return node, nil
  40240. }
  40241. m.id = &node.ID
  40242. }
  40243. }
  40244. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40245. // executed in a transaction (ent.Tx), a transactional client is returned.
  40246. func (m WxCardUserMutation) Client() *Client {
  40247. client := &Client{config: m.config}
  40248. client.init()
  40249. return client
  40250. }
  40251. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40252. // it returns an error otherwise.
  40253. func (m WxCardUserMutation) Tx() (*Tx, error) {
  40254. if _, ok := m.driver.(*txDriver); !ok {
  40255. return nil, errors.New("ent: mutation is not running in a transaction")
  40256. }
  40257. tx := &Tx{config: m.config}
  40258. tx.init()
  40259. return tx, nil
  40260. }
  40261. // SetID sets the value of the id field. Note that this
  40262. // operation is only accepted on creation of WxCardUser entities.
  40263. func (m *WxCardUserMutation) SetID(id uint64) {
  40264. m.id = &id
  40265. }
  40266. // ID returns the ID value in the mutation. Note that the ID is only available
  40267. // if it was provided to the builder or after it was returned from the database.
  40268. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  40269. if m.id == nil {
  40270. return
  40271. }
  40272. return *m.id, true
  40273. }
  40274. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40275. // That means, if the mutation is applied within a transaction with an isolation level such
  40276. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40277. // or updated by the mutation.
  40278. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  40279. switch {
  40280. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40281. id, exists := m.ID()
  40282. if exists {
  40283. return []uint64{id}, nil
  40284. }
  40285. fallthrough
  40286. case m.op.Is(OpUpdate | OpDelete):
  40287. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  40288. default:
  40289. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40290. }
  40291. }
  40292. // SetCreatedAt sets the "created_at" field.
  40293. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  40294. m.created_at = &t
  40295. }
  40296. // CreatedAt returns the value of the "created_at" field in the mutation.
  40297. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  40298. v := m.created_at
  40299. if v == nil {
  40300. return
  40301. }
  40302. return *v, true
  40303. }
  40304. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  40305. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40307. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40308. if !m.op.Is(OpUpdateOne) {
  40309. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40310. }
  40311. if m.id == nil || m.oldValue == nil {
  40312. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40313. }
  40314. oldValue, err := m.oldValue(ctx)
  40315. if err != nil {
  40316. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40317. }
  40318. return oldValue.CreatedAt, nil
  40319. }
  40320. // ResetCreatedAt resets all changes to the "created_at" field.
  40321. func (m *WxCardUserMutation) ResetCreatedAt() {
  40322. m.created_at = nil
  40323. }
  40324. // SetUpdatedAt sets the "updated_at" field.
  40325. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  40326. m.updated_at = &t
  40327. }
  40328. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40329. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  40330. v := m.updated_at
  40331. if v == nil {
  40332. return
  40333. }
  40334. return *v, true
  40335. }
  40336. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  40337. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40338. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40339. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40340. if !m.op.Is(OpUpdateOne) {
  40341. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40342. }
  40343. if m.id == nil || m.oldValue == nil {
  40344. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40345. }
  40346. oldValue, err := m.oldValue(ctx)
  40347. if err != nil {
  40348. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40349. }
  40350. return oldValue.UpdatedAt, nil
  40351. }
  40352. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40353. func (m *WxCardUserMutation) ResetUpdatedAt() {
  40354. m.updated_at = nil
  40355. }
  40356. // SetDeletedAt sets the "deleted_at" field.
  40357. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  40358. m.deleted_at = &t
  40359. }
  40360. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  40361. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  40362. v := m.deleted_at
  40363. if v == nil {
  40364. return
  40365. }
  40366. return *v, true
  40367. }
  40368. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  40369. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40371. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  40372. if !m.op.Is(OpUpdateOne) {
  40373. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  40374. }
  40375. if m.id == nil || m.oldValue == nil {
  40376. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  40377. }
  40378. oldValue, err := m.oldValue(ctx)
  40379. if err != nil {
  40380. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  40381. }
  40382. return oldValue.DeletedAt, nil
  40383. }
  40384. // ClearDeletedAt clears the value of the "deleted_at" field.
  40385. func (m *WxCardUserMutation) ClearDeletedAt() {
  40386. m.deleted_at = nil
  40387. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  40388. }
  40389. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  40390. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  40391. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  40392. return ok
  40393. }
  40394. // ResetDeletedAt resets all changes to the "deleted_at" field.
  40395. func (m *WxCardUserMutation) ResetDeletedAt() {
  40396. m.deleted_at = nil
  40397. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  40398. }
  40399. // SetWxid sets the "wxid" field.
  40400. func (m *WxCardUserMutation) SetWxid(s string) {
  40401. m.wxid = &s
  40402. }
  40403. // Wxid returns the value of the "wxid" field in the mutation.
  40404. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  40405. v := m.wxid
  40406. if v == nil {
  40407. return
  40408. }
  40409. return *v, true
  40410. }
  40411. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  40412. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40414. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  40415. if !m.op.Is(OpUpdateOne) {
  40416. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  40417. }
  40418. if m.id == nil || m.oldValue == nil {
  40419. return v, errors.New("OldWxid requires an ID field in the mutation")
  40420. }
  40421. oldValue, err := m.oldValue(ctx)
  40422. if err != nil {
  40423. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  40424. }
  40425. return oldValue.Wxid, nil
  40426. }
  40427. // ResetWxid resets all changes to the "wxid" field.
  40428. func (m *WxCardUserMutation) ResetWxid() {
  40429. m.wxid = nil
  40430. }
  40431. // SetAccount sets the "account" field.
  40432. func (m *WxCardUserMutation) SetAccount(s string) {
  40433. m.account = &s
  40434. }
  40435. // Account returns the value of the "account" field in the mutation.
  40436. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  40437. v := m.account
  40438. if v == nil {
  40439. return
  40440. }
  40441. return *v, true
  40442. }
  40443. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  40444. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40446. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  40447. if !m.op.Is(OpUpdateOne) {
  40448. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  40449. }
  40450. if m.id == nil || m.oldValue == nil {
  40451. return v, errors.New("OldAccount requires an ID field in the mutation")
  40452. }
  40453. oldValue, err := m.oldValue(ctx)
  40454. if err != nil {
  40455. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  40456. }
  40457. return oldValue.Account, nil
  40458. }
  40459. // ResetAccount resets all changes to the "account" field.
  40460. func (m *WxCardUserMutation) ResetAccount() {
  40461. m.account = nil
  40462. }
  40463. // SetAvatar sets the "avatar" field.
  40464. func (m *WxCardUserMutation) SetAvatar(s string) {
  40465. m.avatar = &s
  40466. }
  40467. // Avatar returns the value of the "avatar" field in the mutation.
  40468. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  40469. v := m.avatar
  40470. if v == nil {
  40471. return
  40472. }
  40473. return *v, true
  40474. }
  40475. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  40476. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40478. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  40479. if !m.op.Is(OpUpdateOne) {
  40480. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  40481. }
  40482. if m.id == nil || m.oldValue == nil {
  40483. return v, errors.New("OldAvatar requires an ID field in the mutation")
  40484. }
  40485. oldValue, err := m.oldValue(ctx)
  40486. if err != nil {
  40487. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  40488. }
  40489. return oldValue.Avatar, nil
  40490. }
  40491. // ResetAvatar resets all changes to the "avatar" field.
  40492. func (m *WxCardUserMutation) ResetAvatar() {
  40493. m.avatar = nil
  40494. }
  40495. // SetNickname sets the "nickname" field.
  40496. func (m *WxCardUserMutation) SetNickname(s string) {
  40497. m.nickname = &s
  40498. }
  40499. // Nickname returns the value of the "nickname" field in the mutation.
  40500. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  40501. v := m.nickname
  40502. if v == nil {
  40503. return
  40504. }
  40505. return *v, true
  40506. }
  40507. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  40508. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40510. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  40511. if !m.op.Is(OpUpdateOne) {
  40512. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  40513. }
  40514. if m.id == nil || m.oldValue == nil {
  40515. return v, errors.New("OldNickname requires an ID field in the mutation")
  40516. }
  40517. oldValue, err := m.oldValue(ctx)
  40518. if err != nil {
  40519. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  40520. }
  40521. return oldValue.Nickname, nil
  40522. }
  40523. // ResetNickname resets all changes to the "nickname" field.
  40524. func (m *WxCardUserMutation) ResetNickname() {
  40525. m.nickname = nil
  40526. }
  40527. // SetRemark sets the "remark" field.
  40528. func (m *WxCardUserMutation) SetRemark(s string) {
  40529. m.remark = &s
  40530. }
  40531. // Remark returns the value of the "remark" field in the mutation.
  40532. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  40533. v := m.remark
  40534. if v == nil {
  40535. return
  40536. }
  40537. return *v, true
  40538. }
  40539. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  40540. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40542. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  40543. if !m.op.Is(OpUpdateOne) {
  40544. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  40545. }
  40546. if m.id == nil || m.oldValue == nil {
  40547. return v, errors.New("OldRemark requires an ID field in the mutation")
  40548. }
  40549. oldValue, err := m.oldValue(ctx)
  40550. if err != nil {
  40551. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  40552. }
  40553. return oldValue.Remark, nil
  40554. }
  40555. // ResetRemark resets all changes to the "remark" field.
  40556. func (m *WxCardUserMutation) ResetRemark() {
  40557. m.remark = nil
  40558. }
  40559. // SetPhone sets the "phone" field.
  40560. func (m *WxCardUserMutation) SetPhone(s string) {
  40561. m.phone = &s
  40562. }
  40563. // Phone returns the value of the "phone" field in the mutation.
  40564. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  40565. v := m.phone
  40566. if v == nil {
  40567. return
  40568. }
  40569. return *v, true
  40570. }
  40571. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  40572. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40574. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  40575. if !m.op.Is(OpUpdateOne) {
  40576. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  40577. }
  40578. if m.id == nil || m.oldValue == nil {
  40579. return v, errors.New("OldPhone requires an ID field in the mutation")
  40580. }
  40581. oldValue, err := m.oldValue(ctx)
  40582. if err != nil {
  40583. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  40584. }
  40585. return oldValue.Phone, nil
  40586. }
  40587. // ResetPhone resets all changes to the "phone" field.
  40588. func (m *WxCardUserMutation) ResetPhone() {
  40589. m.phone = nil
  40590. }
  40591. // SetOpenID sets the "open_id" field.
  40592. func (m *WxCardUserMutation) SetOpenID(s string) {
  40593. m.open_id = &s
  40594. }
  40595. // OpenID returns the value of the "open_id" field in the mutation.
  40596. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  40597. v := m.open_id
  40598. if v == nil {
  40599. return
  40600. }
  40601. return *v, true
  40602. }
  40603. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  40604. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40606. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  40607. if !m.op.Is(OpUpdateOne) {
  40608. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  40609. }
  40610. if m.id == nil || m.oldValue == nil {
  40611. return v, errors.New("OldOpenID requires an ID field in the mutation")
  40612. }
  40613. oldValue, err := m.oldValue(ctx)
  40614. if err != nil {
  40615. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  40616. }
  40617. return oldValue.OpenID, nil
  40618. }
  40619. // ResetOpenID resets all changes to the "open_id" field.
  40620. func (m *WxCardUserMutation) ResetOpenID() {
  40621. m.open_id = nil
  40622. }
  40623. // SetUnionID sets the "union_id" field.
  40624. func (m *WxCardUserMutation) SetUnionID(s string) {
  40625. m.union_id = &s
  40626. }
  40627. // UnionID returns the value of the "union_id" field in the mutation.
  40628. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  40629. v := m.union_id
  40630. if v == nil {
  40631. return
  40632. }
  40633. return *v, true
  40634. }
  40635. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  40636. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40637. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40638. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  40639. if !m.op.Is(OpUpdateOne) {
  40640. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  40641. }
  40642. if m.id == nil || m.oldValue == nil {
  40643. return v, errors.New("OldUnionID requires an ID field in the mutation")
  40644. }
  40645. oldValue, err := m.oldValue(ctx)
  40646. if err != nil {
  40647. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  40648. }
  40649. return oldValue.UnionID, nil
  40650. }
  40651. // ResetUnionID resets all changes to the "union_id" field.
  40652. func (m *WxCardUserMutation) ResetUnionID() {
  40653. m.union_id = nil
  40654. }
  40655. // SetSessionKey sets the "session_key" field.
  40656. func (m *WxCardUserMutation) SetSessionKey(s string) {
  40657. m.session_key = &s
  40658. }
  40659. // SessionKey returns the value of the "session_key" field in the mutation.
  40660. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  40661. v := m.session_key
  40662. if v == nil {
  40663. return
  40664. }
  40665. return *v, true
  40666. }
  40667. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  40668. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40670. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  40671. if !m.op.Is(OpUpdateOne) {
  40672. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  40673. }
  40674. if m.id == nil || m.oldValue == nil {
  40675. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  40676. }
  40677. oldValue, err := m.oldValue(ctx)
  40678. if err != nil {
  40679. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  40680. }
  40681. return oldValue.SessionKey, nil
  40682. }
  40683. // ResetSessionKey resets all changes to the "session_key" field.
  40684. func (m *WxCardUserMutation) ResetSessionKey() {
  40685. m.session_key = nil
  40686. }
  40687. // SetIsVip sets the "is_vip" field.
  40688. func (m *WxCardUserMutation) SetIsVip(i int) {
  40689. m.is_vip = &i
  40690. m.addis_vip = nil
  40691. }
  40692. // IsVip returns the value of the "is_vip" field in the mutation.
  40693. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  40694. v := m.is_vip
  40695. if v == nil {
  40696. return
  40697. }
  40698. return *v, true
  40699. }
  40700. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  40701. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40702. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40703. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  40704. if !m.op.Is(OpUpdateOne) {
  40705. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  40706. }
  40707. if m.id == nil || m.oldValue == nil {
  40708. return v, errors.New("OldIsVip requires an ID field in the mutation")
  40709. }
  40710. oldValue, err := m.oldValue(ctx)
  40711. if err != nil {
  40712. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  40713. }
  40714. return oldValue.IsVip, nil
  40715. }
  40716. // AddIsVip adds i to the "is_vip" field.
  40717. func (m *WxCardUserMutation) AddIsVip(i int) {
  40718. if m.addis_vip != nil {
  40719. *m.addis_vip += i
  40720. } else {
  40721. m.addis_vip = &i
  40722. }
  40723. }
  40724. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  40725. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  40726. v := m.addis_vip
  40727. if v == nil {
  40728. return
  40729. }
  40730. return *v, true
  40731. }
  40732. // ResetIsVip resets all changes to the "is_vip" field.
  40733. func (m *WxCardUserMutation) ResetIsVip() {
  40734. m.is_vip = nil
  40735. m.addis_vip = nil
  40736. }
  40737. // Where appends a list predicates to the WxCardUserMutation builder.
  40738. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  40739. m.predicates = append(m.predicates, ps...)
  40740. }
  40741. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  40742. // users can use type-assertion to append predicates that do not depend on any generated package.
  40743. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  40744. p := make([]predicate.WxCardUser, len(ps))
  40745. for i := range ps {
  40746. p[i] = ps[i]
  40747. }
  40748. m.Where(p...)
  40749. }
  40750. // Op returns the operation name.
  40751. func (m *WxCardUserMutation) Op() Op {
  40752. return m.op
  40753. }
  40754. // SetOp allows setting the mutation operation.
  40755. func (m *WxCardUserMutation) SetOp(op Op) {
  40756. m.op = op
  40757. }
  40758. // Type returns the node type of this mutation (WxCardUser).
  40759. func (m *WxCardUserMutation) Type() string {
  40760. return m.typ
  40761. }
  40762. // Fields returns all fields that were changed during this mutation. Note that in
  40763. // order to get all numeric fields that were incremented/decremented, call
  40764. // AddedFields().
  40765. func (m *WxCardUserMutation) Fields() []string {
  40766. fields := make([]string, 0, 13)
  40767. if m.created_at != nil {
  40768. fields = append(fields, wxcarduser.FieldCreatedAt)
  40769. }
  40770. if m.updated_at != nil {
  40771. fields = append(fields, wxcarduser.FieldUpdatedAt)
  40772. }
  40773. if m.deleted_at != nil {
  40774. fields = append(fields, wxcarduser.FieldDeletedAt)
  40775. }
  40776. if m.wxid != nil {
  40777. fields = append(fields, wxcarduser.FieldWxid)
  40778. }
  40779. if m.account != nil {
  40780. fields = append(fields, wxcarduser.FieldAccount)
  40781. }
  40782. if m.avatar != nil {
  40783. fields = append(fields, wxcarduser.FieldAvatar)
  40784. }
  40785. if m.nickname != nil {
  40786. fields = append(fields, wxcarduser.FieldNickname)
  40787. }
  40788. if m.remark != nil {
  40789. fields = append(fields, wxcarduser.FieldRemark)
  40790. }
  40791. if m.phone != nil {
  40792. fields = append(fields, wxcarduser.FieldPhone)
  40793. }
  40794. if m.open_id != nil {
  40795. fields = append(fields, wxcarduser.FieldOpenID)
  40796. }
  40797. if m.union_id != nil {
  40798. fields = append(fields, wxcarduser.FieldUnionID)
  40799. }
  40800. if m.session_key != nil {
  40801. fields = append(fields, wxcarduser.FieldSessionKey)
  40802. }
  40803. if m.is_vip != nil {
  40804. fields = append(fields, wxcarduser.FieldIsVip)
  40805. }
  40806. return fields
  40807. }
  40808. // Field returns the value of a field with the given name. The second boolean
  40809. // return value indicates that this field was not set, or was not defined in the
  40810. // schema.
  40811. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  40812. switch name {
  40813. case wxcarduser.FieldCreatedAt:
  40814. return m.CreatedAt()
  40815. case wxcarduser.FieldUpdatedAt:
  40816. return m.UpdatedAt()
  40817. case wxcarduser.FieldDeletedAt:
  40818. return m.DeletedAt()
  40819. case wxcarduser.FieldWxid:
  40820. return m.Wxid()
  40821. case wxcarduser.FieldAccount:
  40822. return m.Account()
  40823. case wxcarduser.FieldAvatar:
  40824. return m.Avatar()
  40825. case wxcarduser.FieldNickname:
  40826. return m.Nickname()
  40827. case wxcarduser.FieldRemark:
  40828. return m.Remark()
  40829. case wxcarduser.FieldPhone:
  40830. return m.Phone()
  40831. case wxcarduser.FieldOpenID:
  40832. return m.OpenID()
  40833. case wxcarduser.FieldUnionID:
  40834. return m.UnionID()
  40835. case wxcarduser.FieldSessionKey:
  40836. return m.SessionKey()
  40837. case wxcarduser.FieldIsVip:
  40838. return m.IsVip()
  40839. }
  40840. return nil, false
  40841. }
  40842. // OldField returns the old value of the field from the database. An error is
  40843. // returned if the mutation operation is not UpdateOne, or the query to the
  40844. // database failed.
  40845. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40846. switch name {
  40847. case wxcarduser.FieldCreatedAt:
  40848. return m.OldCreatedAt(ctx)
  40849. case wxcarduser.FieldUpdatedAt:
  40850. return m.OldUpdatedAt(ctx)
  40851. case wxcarduser.FieldDeletedAt:
  40852. return m.OldDeletedAt(ctx)
  40853. case wxcarduser.FieldWxid:
  40854. return m.OldWxid(ctx)
  40855. case wxcarduser.FieldAccount:
  40856. return m.OldAccount(ctx)
  40857. case wxcarduser.FieldAvatar:
  40858. return m.OldAvatar(ctx)
  40859. case wxcarduser.FieldNickname:
  40860. return m.OldNickname(ctx)
  40861. case wxcarduser.FieldRemark:
  40862. return m.OldRemark(ctx)
  40863. case wxcarduser.FieldPhone:
  40864. return m.OldPhone(ctx)
  40865. case wxcarduser.FieldOpenID:
  40866. return m.OldOpenID(ctx)
  40867. case wxcarduser.FieldUnionID:
  40868. return m.OldUnionID(ctx)
  40869. case wxcarduser.FieldSessionKey:
  40870. return m.OldSessionKey(ctx)
  40871. case wxcarduser.FieldIsVip:
  40872. return m.OldIsVip(ctx)
  40873. }
  40874. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  40875. }
  40876. // SetField sets the value of a field with the given name. It returns an error if
  40877. // the field is not defined in the schema, or if the type mismatched the field
  40878. // type.
  40879. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  40880. switch name {
  40881. case wxcarduser.FieldCreatedAt:
  40882. v, ok := value.(time.Time)
  40883. if !ok {
  40884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40885. }
  40886. m.SetCreatedAt(v)
  40887. return nil
  40888. case wxcarduser.FieldUpdatedAt:
  40889. v, ok := value.(time.Time)
  40890. if !ok {
  40891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40892. }
  40893. m.SetUpdatedAt(v)
  40894. return nil
  40895. case wxcarduser.FieldDeletedAt:
  40896. v, ok := value.(time.Time)
  40897. if !ok {
  40898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40899. }
  40900. m.SetDeletedAt(v)
  40901. return nil
  40902. case wxcarduser.FieldWxid:
  40903. v, ok := value.(string)
  40904. if !ok {
  40905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40906. }
  40907. m.SetWxid(v)
  40908. return nil
  40909. case wxcarduser.FieldAccount:
  40910. v, ok := value.(string)
  40911. if !ok {
  40912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40913. }
  40914. m.SetAccount(v)
  40915. return nil
  40916. case wxcarduser.FieldAvatar:
  40917. v, ok := value.(string)
  40918. if !ok {
  40919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40920. }
  40921. m.SetAvatar(v)
  40922. return nil
  40923. case wxcarduser.FieldNickname:
  40924. v, ok := value.(string)
  40925. if !ok {
  40926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40927. }
  40928. m.SetNickname(v)
  40929. return nil
  40930. case wxcarduser.FieldRemark:
  40931. v, ok := value.(string)
  40932. if !ok {
  40933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40934. }
  40935. m.SetRemark(v)
  40936. return nil
  40937. case wxcarduser.FieldPhone:
  40938. v, ok := value.(string)
  40939. if !ok {
  40940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40941. }
  40942. m.SetPhone(v)
  40943. return nil
  40944. case wxcarduser.FieldOpenID:
  40945. v, ok := value.(string)
  40946. if !ok {
  40947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40948. }
  40949. m.SetOpenID(v)
  40950. return nil
  40951. case wxcarduser.FieldUnionID:
  40952. v, ok := value.(string)
  40953. if !ok {
  40954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40955. }
  40956. m.SetUnionID(v)
  40957. return nil
  40958. case wxcarduser.FieldSessionKey:
  40959. v, ok := value.(string)
  40960. if !ok {
  40961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40962. }
  40963. m.SetSessionKey(v)
  40964. return nil
  40965. case wxcarduser.FieldIsVip:
  40966. v, ok := value.(int)
  40967. if !ok {
  40968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40969. }
  40970. m.SetIsVip(v)
  40971. return nil
  40972. }
  40973. return fmt.Errorf("unknown WxCardUser field %s", name)
  40974. }
  40975. // AddedFields returns all numeric fields that were incremented/decremented during
  40976. // this mutation.
  40977. func (m *WxCardUserMutation) AddedFields() []string {
  40978. var fields []string
  40979. if m.addis_vip != nil {
  40980. fields = append(fields, wxcarduser.FieldIsVip)
  40981. }
  40982. return fields
  40983. }
  40984. // AddedField returns the numeric value that was incremented/decremented on a field
  40985. // with the given name. The second boolean return value indicates that this field
  40986. // was not set, or was not defined in the schema.
  40987. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  40988. switch name {
  40989. case wxcarduser.FieldIsVip:
  40990. return m.AddedIsVip()
  40991. }
  40992. return nil, false
  40993. }
  40994. // AddField adds the value to the field with the given name. It returns an error if
  40995. // the field is not defined in the schema, or if the type mismatched the field
  40996. // type.
  40997. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  40998. switch name {
  40999. case wxcarduser.FieldIsVip:
  41000. v, ok := value.(int)
  41001. if !ok {
  41002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41003. }
  41004. m.AddIsVip(v)
  41005. return nil
  41006. }
  41007. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  41008. }
  41009. // ClearedFields returns all nullable fields that were cleared during this
  41010. // mutation.
  41011. func (m *WxCardUserMutation) ClearedFields() []string {
  41012. var fields []string
  41013. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  41014. fields = append(fields, wxcarduser.FieldDeletedAt)
  41015. }
  41016. return fields
  41017. }
  41018. // FieldCleared returns a boolean indicating if a field with the given name was
  41019. // cleared in this mutation.
  41020. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  41021. _, ok := m.clearedFields[name]
  41022. return ok
  41023. }
  41024. // ClearField clears the value of the field with the given name. It returns an
  41025. // error if the field is not defined in the schema.
  41026. func (m *WxCardUserMutation) ClearField(name string) error {
  41027. switch name {
  41028. case wxcarduser.FieldDeletedAt:
  41029. m.ClearDeletedAt()
  41030. return nil
  41031. }
  41032. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  41033. }
  41034. // ResetField resets all changes in the mutation for the field with the given name.
  41035. // It returns an error if the field is not defined in the schema.
  41036. func (m *WxCardUserMutation) ResetField(name string) error {
  41037. switch name {
  41038. case wxcarduser.FieldCreatedAt:
  41039. m.ResetCreatedAt()
  41040. return nil
  41041. case wxcarduser.FieldUpdatedAt:
  41042. m.ResetUpdatedAt()
  41043. return nil
  41044. case wxcarduser.FieldDeletedAt:
  41045. m.ResetDeletedAt()
  41046. return nil
  41047. case wxcarduser.FieldWxid:
  41048. m.ResetWxid()
  41049. return nil
  41050. case wxcarduser.FieldAccount:
  41051. m.ResetAccount()
  41052. return nil
  41053. case wxcarduser.FieldAvatar:
  41054. m.ResetAvatar()
  41055. return nil
  41056. case wxcarduser.FieldNickname:
  41057. m.ResetNickname()
  41058. return nil
  41059. case wxcarduser.FieldRemark:
  41060. m.ResetRemark()
  41061. return nil
  41062. case wxcarduser.FieldPhone:
  41063. m.ResetPhone()
  41064. return nil
  41065. case wxcarduser.FieldOpenID:
  41066. m.ResetOpenID()
  41067. return nil
  41068. case wxcarduser.FieldUnionID:
  41069. m.ResetUnionID()
  41070. return nil
  41071. case wxcarduser.FieldSessionKey:
  41072. m.ResetSessionKey()
  41073. return nil
  41074. case wxcarduser.FieldIsVip:
  41075. m.ResetIsVip()
  41076. return nil
  41077. }
  41078. return fmt.Errorf("unknown WxCardUser field %s", name)
  41079. }
  41080. // AddedEdges returns all edge names that were set/added in this mutation.
  41081. func (m *WxCardUserMutation) AddedEdges() []string {
  41082. edges := make([]string, 0, 0)
  41083. return edges
  41084. }
  41085. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41086. // name in this mutation.
  41087. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  41088. return nil
  41089. }
  41090. // RemovedEdges returns all edge names that were removed in this mutation.
  41091. func (m *WxCardUserMutation) RemovedEdges() []string {
  41092. edges := make([]string, 0, 0)
  41093. return edges
  41094. }
  41095. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41096. // the given name in this mutation.
  41097. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  41098. return nil
  41099. }
  41100. // ClearedEdges returns all edge names that were cleared in this mutation.
  41101. func (m *WxCardUserMutation) ClearedEdges() []string {
  41102. edges := make([]string, 0, 0)
  41103. return edges
  41104. }
  41105. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41106. // was cleared in this mutation.
  41107. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  41108. return false
  41109. }
  41110. // ClearEdge clears the value of the edge with the given name. It returns an error
  41111. // if that edge is not defined in the schema.
  41112. func (m *WxCardUserMutation) ClearEdge(name string) error {
  41113. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  41114. }
  41115. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41116. // It returns an error if the edge is not defined in the schema.
  41117. func (m *WxCardUserMutation) ResetEdge(name string) error {
  41118. return fmt.Errorf("unknown WxCardUser edge %s", name)
  41119. }
  41120. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  41121. type WxCardVisitMutation struct {
  41122. config
  41123. op Op
  41124. typ string
  41125. id *uint64
  41126. created_at *time.Time
  41127. updated_at *time.Time
  41128. deleted_at *time.Time
  41129. user_id *uint64
  41130. adduser_id *int64
  41131. bot_id *uint64
  41132. addbot_id *int64
  41133. bot_type *uint8
  41134. addbot_type *int8
  41135. clearedFields map[string]struct{}
  41136. done bool
  41137. oldValue func(context.Context) (*WxCardVisit, error)
  41138. predicates []predicate.WxCardVisit
  41139. }
  41140. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  41141. // wxcardvisitOption allows management of the mutation configuration using functional options.
  41142. type wxcardvisitOption func(*WxCardVisitMutation)
  41143. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  41144. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  41145. m := &WxCardVisitMutation{
  41146. config: c,
  41147. op: op,
  41148. typ: TypeWxCardVisit,
  41149. clearedFields: make(map[string]struct{}),
  41150. }
  41151. for _, opt := range opts {
  41152. opt(m)
  41153. }
  41154. return m
  41155. }
  41156. // withWxCardVisitID sets the ID field of the mutation.
  41157. func withWxCardVisitID(id uint64) wxcardvisitOption {
  41158. return func(m *WxCardVisitMutation) {
  41159. var (
  41160. err error
  41161. once sync.Once
  41162. value *WxCardVisit
  41163. )
  41164. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  41165. once.Do(func() {
  41166. if m.done {
  41167. err = errors.New("querying old values post mutation is not allowed")
  41168. } else {
  41169. value, err = m.Client().WxCardVisit.Get(ctx, id)
  41170. }
  41171. })
  41172. return value, err
  41173. }
  41174. m.id = &id
  41175. }
  41176. }
  41177. // withWxCardVisit sets the old WxCardVisit of the mutation.
  41178. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  41179. return func(m *WxCardVisitMutation) {
  41180. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  41181. return node, nil
  41182. }
  41183. m.id = &node.ID
  41184. }
  41185. }
  41186. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41187. // executed in a transaction (ent.Tx), a transactional client is returned.
  41188. func (m WxCardVisitMutation) Client() *Client {
  41189. client := &Client{config: m.config}
  41190. client.init()
  41191. return client
  41192. }
  41193. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41194. // it returns an error otherwise.
  41195. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  41196. if _, ok := m.driver.(*txDriver); !ok {
  41197. return nil, errors.New("ent: mutation is not running in a transaction")
  41198. }
  41199. tx := &Tx{config: m.config}
  41200. tx.init()
  41201. return tx, nil
  41202. }
  41203. // SetID sets the value of the id field. Note that this
  41204. // operation is only accepted on creation of WxCardVisit entities.
  41205. func (m *WxCardVisitMutation) SetID(id uint64) {
  41206. m.id = &id
  41207. }
  41208. // ID returns the ID value in the mutation. Note that the ID is only available
  41209. // if it was provided to the builder or after it was returned from the database.
  41210. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  41211. if m.id == nil {
  41212. return
  41213. }
  41214. return *m.id, true
  41215. }
  41216. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41217. // That means, if the mutation is applied within a transaction with an isolation level such
  41218. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41219. // or updated by the mutation.
  41220. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  41221. switch {
  41222. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41223. id, exists := m.ID()
  41224. if exists {
  41225. return []uint64{id}, nil
  41226. }
  41227. fallthrough
  41228. case m.op.Is(OpUpdate | OpDelete):
  41229. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  41230. default:
  41231. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41232. }
  41233. }
  41234. // SetCreatedAt sets the "created_at" field.
  41235. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  41236. m.created_at = &t
  41237. }
  41238. // CreatedAt returns the value of the "created_at" field in the mutation.
  41239. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  41240. v := m.created_at
  41241. if v == nil {
  41242. return
  41243. }
  41244. return *v, true
  41245. }
  41246. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  41247. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41248. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41249. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41250. if !m.op.Is(OpUpdateOne) {
  41251. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41252. }
  41253. if m.id == nil || m.oldValue == nil {
  41254. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41255. }
  41256. oldValue, err := m.oldValue(ctx)
  41257. if err != nil {
  41258. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41259. }
  41260. return oldValue.CreatedAt, nil
  41261. }
  41262. // ResetCreatedAt resets all changes to the "created_at" field.
  41263. func (m *WxCardVisitMutation) ResetCreatedAt() {
  41264. m.created_at = nil
  41265. }
  41266. // SetUpdatedAt sets the "updated_at" field.
  41267. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  41268. m.updated_at = &t
  41269. }
  41270. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41271. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  41272. v := m.updated_at
  41273. if v == nil {
  41274. return
  41275. }
  41276. return *v, true
  41277. }
  41278. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  41279. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41281. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41282. if !m.op.Is(OpUpdateOne) {
  41283. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41284. }
  41285. if m.id == nil || m.oldValue == nil {
  41286. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41287. }
  41288. oldValue, err := m.oldValue(ctx)
  41289. if err != nil {
  41290. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41291. }
  41292. return oldValue.UpdatedAt, nil
  41293. }
  41294. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41295. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  41296. m.updated_at = nil
  41297. }
  41298. // SetDeletedAt sets the "deleted_at" field.
  41299. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  41300. m.deleted_at = &t
  41301. }
  41302. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41303. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  41304. v := m.deleted_at
  41305. if v == nil {
  41306. return
  41307. }
  41308. return *v, true
  41309. }
  41310. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  41311. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41313. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41314. if !m.op.Is(OpUpdateOne) {
  41315. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41316. }
  41317. if m.id == nil || m.oldValue == nil {
  41318. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41319. }
  41320. oldValue, err := m.oldValue(ctx)
  41321. if err != nil {
  41322. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41323. }
  41324. return oldValue.DeletedAt, nil
  41325. }
  41326. // ClearDeletedAt clears the value of the "deleted_at" field.
  41327. func (m *WxCardVisitMutation) ClearDeletedAt() {
  41328. m.deleted_at = nil
  41329. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  41330. }
  41331. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41332. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  41333. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  41334. return ok
  41335. }
  41336. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41337. func (m *WxCardVisitMutation) ResetDeletedAt() {
  41338. m.deleted_at = nil
  41339. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  41340. }
  41341. // SetUserID sets the "user_id" field.
  41342. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  41343. m.user_id = &u
  41344. m.adduser_id = nil
  41345. }
  41346. // UserID returns the value of the "user_id" field in the mutation.
  41347. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  41348. v := m.user_id
  41349. if v == nil {
  41350. return
  41351. }
  41352. return *v, true
  41353. }
  41354. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  41355. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41357. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  41358. if !m.op.Is(OpUpdateOne) {
  41359. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  41360. }
  41361. if m.id == nil || m.oldValue == nil {
  41362. return v, errors.New("OldUserID requires an ID field in the mutation")
  41363. }
  41364. oldValue, err := m.oldValue(ctx)
  41365. if err != nil {
  41366. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  41367. }
  41368. return oldValue.UserID, nil
  41369. }
  41370. // AddUserID adds u to the "user_id" field.
  41371. func (m *WxCardVisitMutation) AddUserID(u int64) {
  41372. if m.adduser_id != nil {
  41373. *m.adduser_id += u
  41374. } else {
  41375. m.adduser_id = &u
  41376. }
  41377. }
  41378. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  41379. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  41380. v := m.adduser_id
  41381. if v == nil {
  41382. return
  41383. }
  41384. return *v, true
  41385. }
  41386. // ClearUserID clears the value of the "user_id" field.
  41387. func (m *WxCardVisitMutation) ClearUserID() {
  41388. m.user_id = nil
  41389. m.adduser_id = nil
  41390. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  41391. }
  41392. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  41393. func (m *WxCardVisitMutation) UserIDCleared() bool {
  41394. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  41395. return ok
  41396. }
  41397. // ResetUserID resets all changes to the "user_id" field.
  41398. func (m *WxCardVisitMutation) ResetUserID() {
  41399. m.user_id = nil
  41400. m.adduser_id = nil
  41401. delete(m.clearedFields, wxcardvisit.FieldUserID)
  41402. }
  41403. // SetBotID sets the "bot_id" field.
  41404. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  41405. m.bot_id = &u
  41406. m.addbot_id = nil
  41407. }
  41408. // BotID returns the value of the "bot_id" field in the mutation.
  41409. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  41410. v := m.bot_id
  41411. if v == nil {
  41412. return
  41413. }
  41414. return *v, true
  41415. }
  41416. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  41417. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41418. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41419. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  41420. if !m.op.Is(OpUpdateOne) {
  41421. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  41422. }
  41423. if m.id == nil || m.oldValue == nil {
  41424. return v, errors.New("OldBotID requires an ID field in the mutation")
  41425. }
  41426. oldValue, err := m.oldValue(ctx)
  41427. if err != nil {
  41428. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  41429. }
  41430. return oldValue.BotID, nil
  41431. }
  41432. // AddBotID adds u to the "bot_id" field.
  41433. func (m *WxCardVisitMutation) AddBotID(u int64) {
  41434. if m.addbot_id != nil {
  41435. *m.addbot_id += u
  41436. } else {
  41437. m.addbot_id = &u
  41438. }
  41439. }
  41440. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  41441. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  41442. v := m.addbot_id
  41443. if v == nil {
  41444. return
  41445. }
  41446. return *v, true
  41447. }
  41448. // ResetBotID resets all changes to the "bot_id" field.
  41449. func (m *WxCardVisitMutation) ResetBotID() {
  41450. m.bot_id = nil
  41451. m.addbot_id = nil
  41452. }
  41453. // SetBotType sets the "bot_type" field.
  41454. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  41455. m.bot_type = &u
  41456. m.addbot_type = nil
  41457. }
  41458. // BotType returns the value of the "bot_type" field in the mutation.
  41459. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  41460. v := m.bot_type
  41461. if v == nil {
  41462. return
  41463. }
  41464. return *v, true
  41465. }
  41466. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  41467. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41469. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  41470. if !m.op.Is(OpUpdateOne) {
  41471. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  41472. }
  41473. if m.id == nil || m.oldValue == nil {
  41474. return v, errors.New("OldBotType requires an ID field in the mutation")
  41475. }
  41476. oldValue, err := m.oldValue(ctx)
  41477. if err != nil {
  41478. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  41479. }
  41480. return oldValue.BotType, nil
  41481. }
  41482. // AddBotType adds u to the "bot_type" field.
  41483. func (m *WxCardVisitMutation) AddBotType(u int8) {
  41484. if m.addbot_type != nil {
  41485. *m.addbot_type += u
  41486. } else {
  41487. m.addbot_type = &u
  41488. }
  41489. }
  41490. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  41491. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  41492. v := m.addbot_type
  41493. if v == nil {
  41494. return
  41495. }
  41496. return *v, true
  41497. }
  41498. // ResetBotType resets all changes to the "bot_type" field.
  41499. func (m *WxCardVisitMutation) ResetBotType() {
  41500. m.bot_type = nil
  41501. m.addbot_type = nil
  41502. }
  41503. // Where appends a list predicates to the WxCardVisitMutation builder.
  41504. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  41505. m.predicates = append(m.predicates, ps...)
  41506. }
  41507. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  41508. // users can use type-assertion to append predicates that do not depend on any generated package.
  41509. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  41510. p := make([]predicate.WxCardVisit, len(ps))
  41511. for i := range ps {
  41512. p[i] = ps[i]
  41513. }
  41514. m.Where(p...)
  41515. }
  41516. // Op returns the operation name.
  41517. func (m *WxCardVisitMutation) Op() Op {
  41518. return m.op
  41519. }
  41520. // SetOp allows setting the mutation operation.
  41521. func (m *WxCardVisitMutation) SetOp(op Op) {
  41522. m.op = op
  41523. }
  41524. // Type returns the node type of this mutation (WxCardVisit).
  41525. func (m *WxCardVisitMutation) Type() string {
  41526. return m.typ
  41527. }
  41528. // Fields returns all fields that were changed during this mutation. Note that in
  41529. // order to get all numeric fields that were incremented/decremented, call
  41530. // AddedFields().
  41531. func (m *WxCardVisitMutation) Fields() []string {
  41532. fields := make([]string, 0, 6)
  41533. if m.created_at != nil {
  41534. fields = append(fields, wxcardvisit.FieldCreatedAt)
  41535. }
  41536. if m.updated_at != nil {
  41537. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  41538. }
  41539. if m.deleted_at != nil {
  41540. fields = append(fields, wxcardvisit.FieldDeletedAt)
  41541. }
  41542. if m.user_id != nil {
  41543. fields = append(fields, wxcardvisit.FieldUserID)
  41544. }
  41545. if m.bot_id != nil {
  41546. fields = append(fields, wxcardvisit.FieldBotID)
  41547. }
  41548. if m.bot_type != nil {
  41549. fields = append(fields, wxcardvisit.FieldBotType)
  41550. }
  41551. return fields
  41552. }
  41553. // Field returns the value of a field with the given name. The second boolean
  41554. // return value indicates that this field was not set, or was not defined in the
  41555. // schema.
  41556. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  41557. switch name {
  41558. case wxcardvisit.FieldCreatedAt:
  41559. return m.CreatedAt()
  41560. case wxcardvisit.FieldUpdatedAt:
  41561. return m.UpdatedAt()
  41562. case wxcardvisit.FieldDeletedAt:
  41563. return m.DeletedAt()
  41564. case wxcardvisit.FieldUserID:
  41565. return m.UserID()
  41566. case wxcardvisit.FieldBotID:
  41567. return m.BotID()
  41568. case wxcardvisit.FieldBotType:
  41569. return m.BotType()
  41570. }
  41571. return nil, false
  41572. }
  41573. // OldField returns the old value of the field from the database. An error is
  41574. // returned if the mutation operation is not UpdateOne, or the query to the
  41575. // database failed.
  41576. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41577. switch name {
  41578. case wxcardvisit.FieldCreatedAt:
  41579. return m.OldCreatedAt(ctx)
  41580. case wxcardvisit.FieldUpdatedAt:
  41581. return m.OldUpdatedAt(ctx)
  41582. case wxcardvisit.FieldDeletedAt:
  41583. return m.OldDeletedAt(ctx)
  41584. case wxcardvisit.FieldUserID:
  41585. return m.OldUserID(ctx)
  41586. case wxcardvisit.FieldBotID:
  41587. return m.OldBotID(ctx)
  41588. case wxcardvisit.FieldBotType:
  41589. return m.OldBotType(ctx)
  41590. }
  41591. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  41592. }
  41593. // SetField sets the value of a field with the given name. It returns an error if
  41594. // the field is not defined in the schema, or if the type mismatched the field
  41595. // type.
  41596. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  41597. switch name {
  41598. case wxcardvisit.FieldCreatedAt:
  41599. v, ok := value.(time.Time)
  41600. if !ok {
  41601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41602. }
  41603. m.SetCreatedAt(v)
  41604. return nil
  41605. case wxcardvisit.FieldUpdatedAt:
  41606. v, ok := value.(time.Time)
  41607. if !ok {
  41608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41609. }
  41610. m.SetUpdatedAt(v)
  41611. return nil
  41612. case wxcardvisit.FieldDeletedAt:
  41613. v, ok := value.(time.Time)
  41614. if !ok {
  41615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41616. }
  41617. m.SetDeletedAt(v)
  41618. return nil
  41619. case wxcardvisit.FieldUserID:
  41620. v, ok := value.(uint64)
  41621. if !ok {
  41622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41623. }
  41624. m.SetUserID(v)
  41625. return nil
  41626. case wxcardvisit.FieldBotID:
  41627. v, ok := value.(uint64)
  41628. if !ok {
  41629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41630. }
  41631. m.SetBotID(v)
  41632. return nil
  41633. case wxcardvisit.FieldBotType:
  41634. v, ok := value.(uint8)
  41635. if !ok {
  41636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41637. }
  41638. m.SetBotType(v)
  41639. return nil
  41640. }
  41641. return fmt.Errorf("unknown WxCardVisit field %s", name)
  41642. }
  41643. // AddedFields returns all numeric fields that were incremented/decremented during
  41644. // this mutation.
  41645. func (m *WxCardVisitMutation) AddedFields() []string {
  41646. var fields []string
  41647. if m.adduser_id != nil {
  41648. fields = append(fields, wxcardvisit.FieldUserID)
  41649. }
  41650. if m.addbot_id != nil {
  41651. fields = append(fields, wxcardvisit.FieldBotID)
  41652. }
  41653. if m.addbot_type != nil {
  41654. fields = append(fields, wxcardvisit.FieldBotType)
  41655. }
  41656. return fields
  41657. }
  41658. // AddedField returns the numeric value that was incremented/decremented on a field
  41659. // with the given name. The second boolean return value indicates that this field
  41660. // was not set, or was not defined in the schema.
  41661. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  41662. switch name {
  41663. case wxcardvisit.FieldUserID:
  41664. return m.AddedUserID()
  41665. case wxcardvisit.FieldBotID:
  41666. return m.AddedBotID()
  41667. case wxcardvisit.FieldBotType:
  41668. return m.AddedBotType()
  41669. }
  41670. return nil, false
  41671. }
  41672. // AddField adds the value to the field with the given name. It returns an error if
  41673. // the field is not defined in the schema, or if the type mismatched the field
  41674. // type.
  41675. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  41676. switch name {
  41677. case wxcardvisit.FieldUserID:
  41678. v, ok := value.(int64)
  41679. if !ok {
  41680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41681. }
  41682. m.AddUserID(v)
  41683. return nil
  41684. case wxcardvisit.FieldBotID:
  41685. v, ok := value.(int64)
  41686. if !ok {
  41687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41688. }
  41689. m.AddBotID(v)
  41690. return nil
  41691. case wxcardvisit.FieldBotType:
  41692. v, ok := value.(int8)
  41693. if !ok {
  41694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41695. }
  41696. m.AddBotType(v)
  41697. return nil
  41698. }
  41699. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  41700. }
  41701. // ClearedFields returns all nullable fields that were cleared during this
  41702. // mutation.
  41703. func (m *WxCardVisitMutation) ClearedFields() []string {
  41704. var fields []string
  41705. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  41706. fields = append(fields, wxcardvisit.FieldDeletedAt)
  41707. }
  41708. if m.FieldCleared(wxcardvisit.FieldUserID) {
  41709. fields = append(fields, wxcardvisit.FieldUserID)
  41710. }
  41711. return fields
  41712. }
  41713. // FieldCleared returns a boolean indicating if a field with the given name was
  41714. // cleared in this mutation.
  41715. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  41716. _, ok := m.clearedFields[name]
  41717. return ok
  41718. }
  41719. // ClearField clears the value of the field with the given name. It returns an
  41720. // error if the field is not defined in the schema.
  41721. func (m *WxCardVisitMutation) ClearField(name string) error {
  41722. switch name {
  41723. case wxcardvisit.FieldDeletedAt:
  41724. m.ClearDeletedAt()
  41725. return nil
  41726. case wxcardvisit.FieldUserID:
  41727. m.ClearUserID()
  41728. return nil
  41729. }
  41730. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  41731. }
  41732. // ResetField resets all changes in the mutation for the field with the given name.
  41733. // It returns an error if the field is not defined in the schema.
  41734. func (m *WxCardVisitMutation) ResetField(name string) error {
  41735. switch name {
  41736. case wxcardvisit.FieldCreatedAt:
  41737. m.ResetCreatedAt()
  41738. return nil
  41739. case wxcardvisit.FieldUpdatedAt:
  41740. m.ResetUpdatedAt()
  41741. return nil
  41742. case wxcardvisit.FieldDeletedAt:
  41743. m.ResetDeletedAt()
  41744. return nil
  41745. case wxcardvisit.FieldUserID:
  41746. m.ResetUserID()
  41747. return nil
  41748. case wxcardvisit.FieldBotID:
  41749. m.ResetBotID()
  41750. return nil
  41751. case wxcardvisit.FieldBotType:
  41752. m.ResetBotType()
  41753. return nil
  41754. }
  41755. return fmt.Errorf("unknown WxCardVisit field %s", name)
  41756. }
  41757. // AddedEdges returns all edge names that were set/added in this mutation.
  41758. func (m *WxCardVisitMutation) AddedEdges() []string {
  41759. edges := make([]string, 0, 0)
  41760. return edges
  41761. }
  41762. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41763. // name in this mutation.
  41764. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  41765. return nil
  41766. }
  41767. // RemovedEdges returns all edge names that were removed in this mutation.
  41768. func (m *WxCardVisitMutation) RemovedEdges() []string {
  41769. edges := make([]string, 0, 0)
  41770. return edges
  41771. }
  41772. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41773. // the given name in this mutation.
  41774. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  41775. return nil
  41776. }
  41777. // ClearedEdges returns all edge names that were cleared in this mutation.
  41778. func (m *WxCardVisitMutation) ClearedEdges() []string {
  41779. edges := make([]string, 0, 0)
  41780. return edges
  41781. }
  41782. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41783. // was cleared in this mutation.
  41784. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  41785. return false
  41786. }
  41787. // ClearEdge clears the value of the edge with the given name. It returns an error
  41788. // if that edge is not defined in the schema.
  41789. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  41790. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  41791. }
  41792. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41793. // It returns an error if the edge is not defined in the schema.
  41794. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  41795. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  41796. }