mutation.go 1.2 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457
  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/batchmsg"
  13. "wechat-api/ent/category"
  14. "wechat-api/ent/chatrecords"
  15. "wechat-api/ent/chatsession"
  16. "wechat-api/ent/contact"
  17. "wechat-api/ent/custom_types"
  18. "wechat-api/ent/employee"
  19. "wechat-api/ent/employeeconfig"
  20. "wechat-api/ent/label"
  21. "wechat-api/ent/labelrelationship"
  22. "wechat-api/ent/labeltagging"
  23. "wechat-api/ent/message"
  24. "wechat-api/ent/messagerecords"
  25. "wechat-api/ent/msg"
  26. "wechat-api/ent/predicate"
  27. "wechat-api/ent/server"
  28. "wechat-api/ent/sopnode"
  29. "wechat-api/ent/sopstage"
  30. "wechat-api/ent/soptask"
  31. "wechat-api/ent/token"
  32. "wechat-api/ent/tutorial"
  33. "wechat-api/ent/usagedetail"
  34. "wechat-api/ent/usagestatisticday"
  35. "wechat-api/ent/usagestatistichour"
  36. "wechat-api/ent/usagestatisticmonth"
  37. "wechat-api/ent/usagetotal"
  38. "wechat-api/ent/workexperience"
  39. "wechat-api/ent/wpchatroom"
  40. "wechat-api/ent/wpchatroommember"
  41. "wechat-api/ent/wx"
  42. "wechat-api/ent/wxcard"
  43. "wechat-api/ent/wxcarduser"
  44. "wechat-api/ent/wxcardvisit"
  45. "entgo.io/ent"
  46. "entgo.io/ent/dialect/sql"
  47. )
  48. const (
  49. // Operation types.
  50. OpCreate = ent.OpCreate
  51. OpDelete = ent.OpDelete
  52. OpDeleteOne = ent.OpDeleteOne
  53. OpUpdate = ent.OpUpdate
  54. OpUpdateOne = ent.OpUpdateOne
  55. // Node types.
  56. TypeAgent = "Agent"
  57. TypeAgentBase = "AgentBase"
  58. TypeAliyunAvatar = "AliyunAvatar"
  59. TypeBatchMsg = "BatchMsg"
  60. TypeCategory = "Category"
  61. TypeChatRecords = "ChatRecords"
  62. TypeChatSession = "ChatSession"
  63. TypeContact = "Contact"
  64. TypeEmployee = "Employee"
  65. TypeEmployeeConfig = "EmployeeConfig"
  66. TypeLabel = "Label"
  67. TypeLabelRelationship = "LabelRelationship"
  68. TypeLabelTagging = "LabelTagging"
  69. TypeMessage = "Message"
  70. TypeMessageRecords = "MessageRecords"
  71. TypeMsg = "Msg"
  72. TypeServer = "Server"
  73. TypeSopNode = "SopNode"
  74. TypeSopStage = "SopStage"
  75. TypeSopTask = "SopTask"
  76. TypeToken = "Token"
  77. TypeTutorial = "Tutorial"
  78. TypeUsageDetail = "UsageDetail"
  79. TypeUsageStatisticDay = "UsageStatisticDay"
  80. TypeUsageStatisticHour = "UsageStatisticHour"
  81. TypeUsageStatisticMonth = "UsageStatisticMonth"
  82. TypeUsageTotal = "UsageTotal"
  83. TypeWorkExperience = "WorkExperience"
  84. TypeWpChatroom = "WpChatroom"
  85. TypeWpChatroomMember = "WpChatroomMember"
  86. TypeWx = "Wx"
  87. TypeWxCard = "WxCard"
  88. TypeWxCardUser = "WxCardUser"
  89. TypeWxCardVisit = "WxCardVisit"
  90. )
  91. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  92. type AgentMutation struct {
  93. config
  94. op Op
  95. typ string
  96. id *uint64
  97. created_at *time.Time
  98. updated_at *time.Time
  99. deleted_at *time.Time
  100. name *string
  101. role *string
  102. status *int
  103. addstatus *int
  104. background *string
  105. examples *string
  106. organization_id *uint64
  107. addorganization_id *int64
  108. dataset_id *string
  109. collection_id *string
  110. clearedFields map[string]struct{}
  111. wx_agent map[uint64]struct{}
  112. removedwx_agent map[uint64]struct{}
  113. clearedwx_agent bool
  114. token_agent map[uint64]struct{}
  115. removedtoken_agent map[uint64]struct{}
  116. clearedtoken_agent bool
  117. done bool
  118. oldValue func(context.Context) (*Agent, error)
  119. predicates []predicate.Agent
  120. }
  121. var _ ent.Mutation = (*AgentMutation)(nil)
  122. // agentOption allows management of the mutation configuration using functional options.
  123. type agentOption func(*AgentMutation)
  124. // newAgentMutation creates new mutation for the Agent entity.
  125. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  126. m := &AgentMutation{
  127. config: c,
  128. op: op,
  129. typ: TypeAgent,
  130. clearedFields: make(map[string]struct{}),
  131. }
  132. for _, opt := range opts {
  133. opt(m)
  134. }
  135. return m
  136. }
  137. // withAgentID sets the ID field of the mutation.
  138. func withAgentID(id uint64) agentOption {
  139. return func(m *AgentMutation) {
  140. var (
  141. err error
  142. once sync.Once
  143. value *Agent
  144. )
  145. m.oldValue = func(ctx context.Context) (*Agent, error) {
  146. once.Do(func() {
  147. if m.done {
  148. err = errors.New("querying old values post mutation is not allowed")
  149. } else {
  150. value, err = m.Client().Agent.Get(ctx, id)
  151. }
  152. })
  153. return value, err
  154. }
  155. m.id = &id
  156. }
  157. }
  158. // withAgent sets the old Agent of the mutation.
  159. func withAgent(node *Agent) agentOption {
  160. return func(m *AgentMutation) {
  161. m.oldValue = func(context.Context) (*Agent, error) {
  162. return node, nil
  163. }
  164. m.id = &node.ID
  165. }
  166. }
  167. // Client returns a new `ent.Client` from the mutation. If the mutation was
  168. // executed in a transaction (ent.Tx), a transactional client is returned.
  169. func (m AgentMutation) Client() *Client {
  170. client := &Client{config: m.config}
  171. client.init()
  172. return client
  173. }
  174. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  175. // it returns an error otherwise.
  176. func (m AgentMutation) Tx() (*Tx, error) {
  177. if _, ok := m.driver.(*txDriver); !ok {
  178. return nil, errors.New("ent: mutation is not running in a transaction")
  179. }
  180. tx := &Tx{config: m.config}
  181. tx.init()
  182. return tx, nil
  183. }
  184. // SetID sets the value of the id field. Note that this
  185. // operation is only accepted on creation of Agent entities.
  186. func (m *AgentMutation) SetID(id uint64) {
  187. m.id = &id
  188. }
  189. // ID returns the ID value in the mutation. Note that the ID is only available
  190. // if it was provided to the builder or after it was returned from the database.
  191. func (m *AgentMutation) ID() (id uint64, exists bool) {
  192. if m.id == nil {
  193. return
  194. }
  195. return *m.id, true
  196. }
  197. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  198. // That means, if the mutation is applied within a transaction with an isolation level such
  199. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  200. // or updated by the mutation.
  201. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  202. switch {
  203. case m.op.Is(OpUpdateOne | OpDeleteOne):
  204. id, exists := m.ID()
  205. if exists {
  206. return []uint64{id}, nil
  207. }
  208. fallthrough
  209. case m.op.Is(OpUpdate | OpDelete):
  210. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  211. default:
  212. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  213. }
  214. }
  215. // SetCreatedAt sets the "created_at" field.
  216. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  217. m.created_at = &t
  218. }
  219. // CreatedAt returns the value of the "created_at" field in the mutation.
  220. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  221. v := m.created_at
  222. if v == nil {
  223. return
  224. }
  225. return *v, true
  226. }
  227. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  228. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  230. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  231. if !m.op.Is(OpUpdateOne) {
  232. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  233. }
  234. if m.id == nil || m.oldValue == nil {
  235. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  236. }
  237. oldValue, err := m.oldValue(ctx)
  238. if err != nil {
  239. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  240. }
  241. return oldValue.CreatedAt, nil
  242. }
  243. // ResetCreatedAt resets all changes to the "created_at" field.
  244. func (m *AgentMutation) ResetCreatedAt() {
  245. m.created_at = nil
  246. }
  247. // SetUpdatedAt sets the "updated_at" field.
  248. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  249. m.updated_at = &t
  250. }
  251. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  252. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  253. v := m.updated_at
  254. if v == nil {
  255. return
  256. }
  257. return *v, true
  258. }
  259. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  260. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  262. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  263. if !m.op.Is(OpUpdateOne) {
  264. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  265. }
  266. if m.id == nil || m.oldValue == nil {
  267. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  268. }
  269. oldValue, err := m.oldValue(ctx)
  270. if err != nil {
  271. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  272. }
  273. return oldValue.UpdatedAt, nil
  274. }
  275. // ResetUpdatedAt resets all changes to the "updated_at" field.
  276. func (m *AgentMutation) ResetUpdatedAt() {
  277. m.updated_at = nil
  278. }
  279. // SetDeletedAt sets the "deleted_at" field.
  280. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  281. m.deleted_at = &t
  282. }
  283. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  284. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  285. v := m.deleted_at
  286. if v == nil {
  287. return
  288. }
  289. return *v, true
  290. }
  291. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  292. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  294. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  295. if !m.op.Is(OpUpdateOne) {
  296. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  297. }
  298. if m.id == nil || m.oldValue == nil {
  299. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  300. }
  301. oldValue, err := m.oldValue(ctx)
  302. if err != nil {
  303. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  304. }
  305. return oldValue.DeletedAt, nil
  306. }
  307. // ClearDeletedAt clears the value of the "deleted_at" field.
  308. func (m *AgentMutation) ClearDeletedAt() {
  309. m.deleted_at = nil
  310. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  311. }
  312. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  313. func (m *AgentMutation) DeletedAtCleared() bool {
  314. _, ok := m.clearedFields[agent.FieldDeletedAt]
  315. return ok
  316. }
  317. // ResetDeletedAt resets all changes to the "deleted_at" field.
  318. func (m *AgentMutation) ResetDeletedAt() {
  319. m.deleted_at = nil
  320. delete(m.clearedFields, agent.FieldDeletedAt)
  321. }
  322. // SetName sets the "name" field.
  323. func (m *AgentMutation) SetName(s string) {
  324. m.name = &s
  325. }
  326. // Name returns the value of the "name" field in the mutation.
  327. func (m *AgentMutation) Name() (r string, exists bool) {
  328. v := m.name
  329. if v == nil {
  330. return
  331. }
  332. return *v, true
  333. }
  334. // OldName returns the old "name" field's value of the Agent entity.
  335. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  337. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  338. if !m.op.Is(OpUpdateOne) {
  339. return v, errors.New("OldName is only allowed on UpdateOne operations")
  340. }
  341. if m.id == nil || m.oldValue == nil {
  342. return v, errors.New("OldName requires an ID field in the mutation")
  343. }
  344. oldValue, err := m.oldValue(ctx)
  345. if err != nil {
  346. return v, fmt.Errorf("querying old value for OldName: %w", err)
  347. }
  348. return oldValue.Name, nil
  349. }
  350. // ResetName resets all changes to the "name" field.
  351. func (m *AgentMutation) ResetName() {
  352. m.name = nil
  353. }
  354. // SetRole sets the "role" field.
  355. func (m *AgentMutation) SetRole(s string) {
  356. m.role = &s
  357. }
  358. // Role returns the value of the "role" field in the mutation.
  359. func (m *AgentMutation) Role() (r string, exists bool) {
  360. v := m.role
  361. if v == nil {
  362. return
  363. }
  364. return *v, true
  365. }
  366. // OldRole returns the old "role" field's value of the Agent entity.
  367. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  368. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  369. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  370. if !m.op.Is(OpUpdateOne) {
  371. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  372. }
  373. if m.id == nil || m.oldValue == nil {
  374. return v, errors.New("OldRole requires an ID field in the mutation")
  375. }
  376. oldValue, err := m.oldValue(ctx)
  377. if err != nil {
  378. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  379. }
  380. return oldValue.Role, nil
  381. }
  382. // ResetRole resets all changes to the "role" field.
  383. func (m *AgentMutation) ResetRole() {
  384. m.role = nil
  385. }
  386. // SetStatus sets the "status" field.
  387. func (m *AgentMutation) SetStatus(i int) {
  388. m.status = &i
  389. m.addstatus = nil
  390. }
  391. // Status returns the value of the "status" field in the mutation.
  392. func (m *AgentMutation) Status() (r int, exists bool) {
  393. v := m.status
  394. if v == nil {
  395. return
  396. }
  397. return *v, true
  398. }
  399. // OldStatus returns the old "status" field's value of the Agent entity.
  400. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  402. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  403. if !m.op.Is(OpUpdateOne) {
  404. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  405. }
  406. if m.id == nil || m.oldValue == nil {
  407. return v, errors.New("OldStatus requires an ID field in the mutation")
  408. }
  409. oldValue, err := m.oldValue(ctx)
  410. if err != nil {
  411. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  412. }
  413. return oldValue.Status, nil
  414. }
  415. // AddStatus adds i to the "status" field.
  416. func (m *AgentMutation) AddStatus(i int) {
  417. if m.addstatus != nil {
  418. *m.addstatus += i
  419. } else {
  420. m.addstatus = &i
  421. }
  422. }
  423. // AddedStatus returns the value that was added to the "status" field in this mutation.
  424. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  425. v := m.addstatus
  426. if v == nil {
  427. return
  428. }
  429. return *v, true
  430. }
  431. // ClearStatus clears the value of the "status" field.
  432. func (m *AgentMutation) ClearStatus() {
  433. m.status = nil
  434. m.addstatus = nil
  435. m.clearedFields[agent.FieldStatus] = struct{}{}
  436. }
  437. // StatusCleared returns if the "status" field was cleared in this mutation.
  438. func (m *AgentMutation) StatusCleared() bool {
  439. _, ok := m.clearedFields[agent.FieldStatus]
  440. return ok
  441. }
  442. // ResetStatus resets all changes to the "status" field.
  443. func (m *AgentMutation) ResetStatus() {
  444. m.status = nil
  445. m.addstatus = nil
  446. delete(m.clearedFields, agent.FieldStatus)
  447. }
  448. // SetBackground sets the "background" field.
  449. func (m *AgentMutation) SetBackground(s string) {
  450. m.background = &s
  451. }
  452. // Background returns the value of the "background" field in the mutation.
  453. func (m *AgentMutation) Background() (r string, exists bool) {
  454. v := m.background
  455. if v == nil {
  456. return
  457. }
  458. return *v, true
  459. }
  460. // OldBackground returns the old "background" field's value of the Agent entity.
  461. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  463. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  464. if !m.op.Is(OpUpdateOne) {
  465. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  466. }
  467. if m.id == nil || m.oldValue == nil {
  468. return v, errors.New("OldBackground requires an ID field in the mutation")
  469. }
  470. oldValue, err := m.oldValue(ctx)
  471. if err != nil {
  472. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  473. }
  474. return oldValue.Background, nil
  475. }
  476. // ClearBackground clears the value of the "background" field.
  477. func (m *AgentMutation) ClearBackground() {
  478. m.background = nil
  479. m.clearedFields[agent.FieldBackground] = struct{}{}
  480. }
  481. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  482. func (m *AgentMutation) BackgroundCleared() bool {
  483. _, ok := m.clearedFields[agent.FieldBackground]
  484. return ok
  485. }
  486. // ResetBackground resets all changes to the "background" field.
  487. func (m *AgentMutation) ResetBackground() {
  488. m.background = nil
  489. delete(m.clearedFields, agent.FieldBackground)
  490. }
  491. // SetExamples sets the "examples" field.
  492. func (m *AgentMutation) SetExamples(s string) {
  493. m.examples = &s
  494. }
  495. // Examples returns the value of the "examples" field in the mutation.
  496. func (m *AgentMutation) Examples() (r string, exists bool) {
  497. v := m.examples
  498. if v == nil {
  499. return
  500. }
  501. return *v, true
  502. }
  503. // OldExamples returns the old "examples" field's value of the Agent entity.
  504. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  505. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  506. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  507. if !m.op.Is(OpUpdateOne) {
  508. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  509. }
  510. if m.id == nil || m.oldValue == nil {
  511. return v, errors.New("OldExamples requires an ID field in the mutation")
  512. }
  513. oldValue, err := m.oldValue(ctx)
  514. if err != nil {
  515. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  516. }
  517. return oldValue.Examples, nil
  518. }
  519. // ClearExamples clears the value of the "examples" field.
  520. func (m *AgentMutation) ClearExamples() {
  521. m.examples = nil
  522. m.clearedFields[agent.FieldExamples] = struct{}{}
  523. }
  524. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  525. func (m *AgentMutation) ExamplesCleared() bool {
  526. _, ok := m.clearedFields[agent.FieldExamples]
  527. return ok
  528. }
  529. // ResetExamples resets all changes to the "examples" field.
  530. func (m *AgentMutation) ResetExamples() {
  531. m.examples = nil
  532. delete(m.clearedFields, agent.FieldExamples)
  533. }
  534. // SetOrganizationID sets the "organization_id" field.
  535. func (m *AgentMutation) SetOrganizationID(u uint64) {
  536. m.organization_id = &u
  537. m.addorganization_id = nil
  538. }
  539. // OrganizationID returns the value of the "organization_id" field in the mutation.
  540. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  541. v := m.organization_id
  542. if v == nil {
  543. return
  544. }
  545. return *v, true
  546. }
  547. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  548. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  550. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  551. if !m.op.Is(OpUpdateOne) {
  552. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  553. }
  554. if m.id == nil || m.oldValue == nil {
  555. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  556. }
  557. oldValue, err := m.oldValue(ctx)
  558. if err != nil {
  559. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  560. }
  561. return oldValue.OrganizationID, nil
  562. }
  563. // AddOrganizationID adds u to the "organization_id" field.
  564. func (m *AgentMutation) AddOrganizationID(u int64) {
  565. if m.addorganization_id != nil {
  566. *m.addorganization_id += u
  567. } else {
  568. m.addorganization_id = &u
  569. }
  570. }
  571. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  572. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  573. v := m.addorganization_id
  574. if v == nil {
  575. return
  576. }
  577. return *v, true
  578. }
  579. // ResetOrganizationID resets all changes to the "organization_id" field.
  580. func (m *AgentMutation) ResetOrganizationID() {
  581. m.organization_id = nil
  582. m.addorganization_id = nil
  583. }
  584. // SetDatasetID sets the "dataset_id" field.
  585. func (m *AgentMutation) SetDatasetID(s string) {
  586. m.dataset_id = &s
  587. }
  588. // DatasetID returns the value of the "dataset_id" field in the mutation.
  589. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  590. v := m.dataset_id
  591. if v == nil {
  592. return
  593. }
  594. return *v, true
  595. }
  596. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  597. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  599. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  600. if !m.op.Is(OpUpdateOne) {
  601. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  602. }
  603. if m.id == nil || m.oldValue == nil {
  604. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  605. }
  606. oldValue, err := m.oldValue(ctx)
  607. if err != nil {
  608. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  609. }
  610. return oldValue.DatasetID, nil
  611. }
  612. // ResetDatasetID resets all changes to the "dataset_id" field.
  613. func (m *AgentMutation) ResetDatasetID() {
  614. m.dataset_id = nil
  615. }
  616. // SetCollectionID sets the "collection_id" field.
  617. func (m *AgentMutation) SetCollectionID(s string) {
  618. m.collection_id = &s
  619. }
  620. // CollectionID returns the value of the "collection_id" field in the mutation.
  621. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  622. v := m.collection_id
  623. if v == nil {
  624. return
  625. }
  626. return *v, true
  627. }
  628. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  629. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  631. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  632. if !m.op.Is(OpUpdateOne) {
  633. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  634. }
  635. if m.id == nil || m.oldValue == nil {
  636. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  637. }
  638. oldValue, err := m.oldValue(ctx)
  639. if err != nil {
  640. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  641. }
  642. return oldValue.CollectionID, nil
  643. }
  644. // ResetCollectionID resets all changes to the "collection_id" field.
  645. func (m *AgentMutation) ResetCollectionID() {
  646. m.collection_id = nil
  647. }
  648. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  649. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  650. if m.wx_agent == nil {
  651. m.wx_agent = make(map[uint64]struct{})
  652. }
  653. for i := range ids {
  654. m.wx_agent[ids[i]] = struct{}{}
  655. }
  656. }
  657. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  658. func (m *AgentMutation) ClearWxAgent() {
  659. m.clearedwx_agent = true
  660. }
  661. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  662. func (m *AgentMutation) WxAgentCleared() bool {
  663. return m.clearedwx_agent
  664. }
  665. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  666. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  667. if m.removedwx_agent == nil {
  668. m.removedwx_agent = make(map[uint64]struct{})
  669. }
  670. for i := range ids {
  671. delete(m.wx_agent, ids[i])
  672. m.removedwx_agent[ids[i]] = struct{}{}
  673. }
  674. }
  675. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  676. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  677. for id := range m.removedwx_agent {
  678. ids = append(ids, id)
  679. }
  680. return
  681. }
  682. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  683. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  684. for id := range m.wx_agent {
  685. ids = append(ids, id)
  686. }
  687. return
  688. }
  689. // ResetWxAgent resets all changes to the "wx_agent" edge.
  690. func (m *AgentMutation) ResetWxAgent() {
  691. m.wx_agent = nil
  692. m.clearedwx_agent = false
  693. m.removedwx_agent = nil
  694. }
  695. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  696. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  697. if m.token_agent == nil {
  698. m.token_agent = make(map[uint64]struct{})
  699. }
  700. for i := range ids {
  701. m.token_agent[ids[i]] = struct{}{}
  702. }
  703. }
  704. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  705. func (m *AgentMutation) ClearTokenAgent() {
  706. m.clearedtoken_agent = true
  707. }
  708. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  709. func (m *AgentMutation) TokenAgentCleared() bool {
  710. return m.clearedtoken_agent
  711. }
  712. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  713. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  714. if m.removedtoken_agent == nil {
  715. m.removedtoken_agent = make(map[uint64]struct{})
  716. }
  717. for i := range ids {
  718. delete(m.token_agent, ids[i])
  719. m.removedtoken_agent[ids[i]] = struct{}{}
  720. }
  721. }
  722. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  723. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  724. for id := range m.removedtoken_agent {
  725. ids = append(ids, id)
  726. }
  727. return
  728. }
  729. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  730. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  731. for id := range m.token_agent {
  732. ids = append(ids, id)
  733. }
  734. return
  735. }
  736. // ResetTokenAgent resets all changes to the "token_agent" edge.
  737. func (m *AgentMutation) ResetTokenAgent() {
  738. m.token_agent = nil
  739. m.clearedtoken_agent = false
  740. m.removedtoken_agent = nil
  741. }
  742. // Where appends a list predicates to the AgentMutation builder.
  743. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  744. m.predicates = append(m.predicates, ps...)
  745. }
  746. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  747. // users can use type-assertion to append predicates that do not depend on any generated package.
  748. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  749. p := make([]predicate.Agent, len(ps))
  750. for i := range ps {
  751. p[i] = ps[i]
  752. }
  753. m.Where(p...)
  754. }
  755. // Op returns the operation name.
  756. func (m *AgentMutation) Op() Op {
  757. return m.op
  758. }
  759. // SetOp allows setting the mutation operation.
  760. func (m *AgentMutation) SetOp(op Op) {
  761. m.op = op
  762. }
  763. // Type returns the node type of this mutation (Agent).
  764. func (m *AgentMutation) Type() string {
  765. return m.typ
  766. }
  767. // Fields returns all fields that were changed during this mutation. Note that in
  768. // order to get all numeric fields that were incremented/decremented, call
  769. // AddedFields().
  770. func (m *AgentMutation) Fields() []string {
  771. fields := make([]string, 0, 11)
  772. if m.created_at != nil {
  773. fields = append(fields, agent.FieldCreatedAt)
  774. }
  775. if m.updated_at != nil {
  776. fields = append(fields, agent.FieldUpdatedAt)
  777. }
  778. if m.deleted_at != nil {
  779. fields = append(fields, agent.FieldDeletedAt)
  780. }
  781. if m.name != nil {
  782. fields = append(fields, agent.FieldName)
  783. }
  784. if m.role != nil {
  785. fields = append(fields, agent.FieldRole)
  786. }
  787. if m.status != nil {
  788. fields = append(fields, agent.FieldStatus)
  789. }
  790. if m.background != nil {
  791. fields = append(fields, agent.FieldBackground)
  792. }
  793. if m.examples != nil {
  794. fields = append(fields, agent.FieldExamples)
  795. }
  796. if m.organization_id != nil {
  797. fields = append(fields, agent.FieldOrganizationID)
  798. }
  799. if m.dataset_id != nil {
  800. fields = append(fields, agent.FieldDatasetID)
  801. }
  802. if m.collection_id != nil {
  803. fields = append(fields, agent.FieldCollectionID)
  804. }
  805. return fields
  806. }
  807. // Field returns the value of a field with the given name. The second boolean
  808. // return value indicates that this field was not set, or was not defined in the
  809. // schema.
  810. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  811. switch name {
  812. case agent.FieldCreatedAt:
  813. return m.CreatedAt()
  814. case agent.FieldUpdatedAt:
  815. return m.UpdatedAt()
  816. case agent.FieldDeletedAt:
  817. return m.DeletedAt()
  818. case agent.FieldName:
  819. return m.Name()
  820. case agent.FieldRole:
  821. return m.Role()
  822. case agent.FieldStatus:
  823. return m.Status()
  824. case agent.FieldBackground:
  825. return m.Background()
  826. case agent.FieldExamples:
  827. return m.Examples()
  828. case agent.FieldOrganizationID:
  829. return m.OrganizationID()
  830. case agent.FieldDatasetID:
  831. return m.DatasetID()
  832. case agent.FieldCollectionID:
  833. return m.CollectionID()
  834. }
  835. return nil, false
  836. }
  837. // OldField returns the old value of the field from the database. An error is
  838. // returned if the mutation operation is not UpdateOne, or the query to the
  839. // database failed.
  840. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  841. switch name {
  842. case agent.FieldCreatedAt:
  843. return m.OldCreatedAt(ctx)
  844. case agent.FieldUpdatedAt:
  845. return m.OldUpdatedAt(ctx)
  846. case agent.FieldDeletedAt:
  847. return m.OldDeletedAt(ctx)
  848. case agent.FieldName:
  849. return m.OldName(ctx)
  850. case agent.FieldRole:
  851. return m.OldRole(ctx)
  852. case agent.FieldStatus:
  853. return m.OldStatus(ctx)
  854. case agent.FieldBackground:
  855. return m.OldBackground(ctx)
  856. case agent.FieldExamples:
  857. return m.OldExamples(ctx)
  858. case agent.FieldOrganizationID:
  859. return m.OldOrganizationID(ctx)
  860. case agent.FieldDatasetID:
  861. return m.OldDatasetID(ctx)
  862. case agent.FieldCollectionID:
  863. return m.OldCollectionID(ctx)
  864. }
  865. return nil, fmt.Errorf("unknown Agent field %s", name)
  866. }
  867. // SetField sets the value of a field with the given name. It returns an error if
  868. // the field is not defined in the schema, or if the type mismatched the field
  869. // type.
  870. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  871. switch name {
  872. case agent.FieldCreatedAt:
  873. v, ok := value.(time.Time)
  874. if !ok {
  875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  876. }
  877. m.SetCreatedAt(v)
  878. return nil
  879. case agent.FieldUpdatedAt:
  880. v, ok := value.(time.Time)
  881. if !ok {
  882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  883. }
  884. m.SetUpdatedAt(v)
  885. return nil
  886. case agent.FieldDeletedAt:
  887. v, ok := value.(time.Time)
  888. if !ok {
  889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  890. }
  891. m.SetDeletedAt(v)
  892. return nil
  893. case agent.FieldName:
  894. v, ok := value.(string)
  895. if !ok {
  896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  897. }
  898. m.SetName(v)
  899. return nil
  900. case agent.FieldRole:
  901. v, ok := value.(string)
  902. if !ok {
  903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  904. }
  905. m.SetRole(v)
  906. return nil
  907. case agent.FieldStatus:
  908. v, ok := value.(int)
  909. if !ok {
  910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  911. }
  912. m.SetStatus(v)
  913. return nil
  914. case agent.FieldBackground:
  915. v, ok := value.(string)
  916. if !ok {
  917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  918. }
  919. m.SetBackground(v)
  920. return nil
  921. case agent.FieldExamples:
  922. v, ok := value.(string)
  923. if !ok {
  924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  925. }
  926. m.SetExamples(v)
  927. return nil
  928. case agent.FieldOrganizationID:
  929. v, ok := value.(uint64)
  930. if !ok {
  931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  932. }
  933. m.SetOrganizationID(v)
  934. return nil
  935. case agent.FieldDatasetID:
  936. v, ok := value.(string)
  937. if !ok {
  938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  939. }
  940. m.SetDatasetID(v)
  941. return nil
  942. case agent.FieldCollectionID:
  943. v, ok := value.(string)
  944. if !ok {
  945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  946. }
  947. m.SetCollectionID(v)
  948. return nil
  949. }
  950. return fmt.Errorf("unknown Agent field %s", name)
  951. }
  952. // AddedFields returns all numeric fields that were incremented/decremented during
  953. // this mutation.
  954. func (m *AgentMutation) AddedFields() []string {
  955. var fields []string
  956. if m.addstatus != nil {
  957. fields = append(fields, agent.FieldStatus)
  958. }
  959. if m.addorganization_id != nil {
  960. fields = append(fields, agent.FieldOrganizationID)
  961. }
  962. return fields
  963. }
  964. // AddedField returns the numeric value that was incremented/decremented on a field
  965. // with the given name. The second boolean return value indicates that this field
  966. // was not set, or was not defined in the schema.
  967. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  968. switch name {
  969. case agent.FieldStatus:
  970. return m.AddedStatus()
  971. case agent.FieldOrganizationID:
  972. return m.AddedOrganizationID()
  973. }
  974. return nil, false
  975. }
  976. // AddField adds the value to the field with the given name. It returns an error if
  977. // the field is not defined in the schema, or if the type mismatched the field
  978. // type.
  979. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  980. switch name {
  981. case agent.FieldStatus:
  982. v, ok := value.(int)
  983. if !ok {
  984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  985. }
  986. m.AddStatus(v)
  987. return nil
  988. case agent.FieldOrganizationID:
  989. v, ok := value.(int64)
  990. if !ok {
  991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  992. }
  993. m.AddOrganizationID(v)
  994. return nil
  995. }
  996. return fmt.Errorf("unknown Agent numeric field %s", name)
  997. }
  998. // ClearedFields returns all nullable fields that were cleared during this
  999. // mutation.
  1000. func (m *AgentMutation) ClearedFields() []string {
  1001. var fields []string
  1002. if m.FieldCleared(agent.FieldDeletedAt) {
  1003. fields = append(fields, agent.FieldDeletedAt)
  1004. }
  1005. if m.FieldCleared(agent.FieldStatus) {
  1006. fields = append(fields, agent.FieldStatus)
  1007. }
  1008. if m.FieldCleared(agent.FieldBackground) {
  1009. fields = append(fields, agent.FieldBackground)
  1010. }
  1011. if m.FieldCleared(agent.FieldExamples) {
  1012. fields = append(fields, agent.FieldExamples)
  1013. }
  1014. return fields
  1015. }
  1016. // FieldCleared returns a boolean indicating if a field with the given name was
  1017. // cleared in this mutation.
  1018. func (m *AgentMutation) FieldCleared(name string) bool {
  1019. _, ok := m.clearedFields[name]
  1020. return ok
  1021. }
  1022. // ClearField clears the value of the field with the given name. It returns an
  1023. // error if the field is not defined in the schema.
  1024. func (m *AgentMutation) ClearField(name string) error {
  1025. switch name {
  1026. case agent.FieldDeletedAt:
  1027. m.ClearDeletedAt()
  1028. return nil
  1029. case agent.FieldStatus:
  1030. m.ClearStatus()
  1031. return nil
  1032. case agent.FieldBackground:
  1033. m.ClearBackground()
  1034. return nil
  1035. case agent.FieldExamples:
  1036. m.ClearExamples()
  1037. return nil
  1038. }
  1039. return fmt.Errorf("unknown Agent nullable field %s", name)
  1040. }
  1041. // ResetField resets all changes in the mutation for the field with the given name.
  1042. // It returns an error if the field is not defined in the schema.
  1043. func (m *AgentMutation) ResetField(name string) error {
  1044. switch name {
  1045. case agent.FieldCreatedAt:
  1046. m.ResetCreatedAt()
  1047. return nil
  1048. case agent.FieldUpdatedAt:
  1049. m.ResetUpdatedAt()
  1050. return nil
  1051. case agent.FieldDeletedAt:
  1052. m.ResetDeletedAt()
  1053. return nil
  1054. case agent.FieldName:
  1055. m.ResetName()
  1056. return nil
  1057. case agent.FieldRole:
  1058. m.ResetRole()
  1059. return nil
  1060. case agent.FieldStatus:
  1061. m.ResetStatus()
  1062. return nil
  1063. case agent.FieldBackground:
  1064. m.ResetBackground()
  1065. return nil
  1066. case agent.FieldExamples:
  1067. m.ResetExamples()
  1068. return nil
  1069. case agent.FieldOrganizationID:
  1070. m.ResetOrganizationID()
  1071. return nil
  1072. case agent.FieldDatasetID:
  1073. m.ResetDatasetID()
  1074. return nil
  1075. case agent.FieldCollectionID:
  1076. m.ResetCollectionID()
  1077. return nil
  1078. }
  1079. return fmt.Errorf("unknown Agent field %s", name)
  1080. }
  1081. // AddedEdges returns all edge names that were set/added in this mutation.
  1082. func (m *AgentMutation) AddedEdges() []string {
  1083. edges := make([]string, 0, 2)
  1084. if m.wx_agent != nil {
  1085. edges = append(edges, agent.EdgeWxAgent)
  1086. }
  1087. if m.token_agent != nil {
  1088. edges = append(edges, agent.EdgeTokenAgent)
  1089. }
  1090. return edges
  1091. }
  1092. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1093. // name in this mutation.
  1094. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1095. switch name {
  1096. case agent.EdgeWxAgent:
  1097. ids := make([]ent.Value, 0, len(m.wx_agent))
  1098. for id := range m.wx_agent {
  1099. ids = append(ids, id)
  1100. }
  1101. return ids
  1102. case agent.EdgeTokenAgent:
  1103. ids := make([]ent.Value, 0, len(m.token_agent))
  1104. for id := range m.token_agent {
  1105. ids = append(ids, id)
  1106. }
  1107. return ids
  1108. }
  1109. return nil
  1110. }
  1111. // RemovedEdges returns all edge names that were removed in this mutation.
  1112. func (m *AgentMutation) RemovedEdges() []string {
  1113. edges := make([]string, 0, 2)
  1114. if m.removedwx_agent != nil {
  1115. edges = append(edges, agent.EdgeWxAgent)
  1116. }
  1117. if m.removedtoken_agent != nil {
  1118. edges = append(edges, agent.EdgeTokenAgent)
  1119. }
  1120. return edges
  1121. }
  1122. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1123. // the given name in this mutation.
  1124. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1125. switch name {
  1126. case agent.EdgeWxAgent:
  1127. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1128. for id := range m.removedwx_agent {
  1129. ids = append(ids, id)
  1130. }
  1131. return ids
  1132. case agent.EdgeTokenAgent:
  1133. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1134. for id := range m.removedtoken_agent {
  1135. ids = append(ids, id)
  1136. }
  1137. return ids
  1138. }
  1139. return nil
  1140. }
  1141. // ClearedEdges returns all edge names that were cleared in this mutation.
  1142. func (m *AgentMutation) ClearedEdges() []string {
  1143. edges := make([]string, 0, 2)
  1144. if m.clearedwx_agent {
  1145. edges = append(edges, agent.EdgeWxAgent)
  1146. }
  1147. if m.clearedtoken_agent {
  1148. edges = append(edges, agent.EdgeTokenAgent)
  1149. }
  1150. return edges
  1151. }
  1152. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1153. // was cleared in this mutation.
  1154. func (m *AgentMutation) EdgeCleared(name string) bool {
  1155. switch name {
  1156. case agent.EdgeWxAgent:
  1157. return m.clearedwx_agent
  1158. case agent.EdgeTokenAgent:
  1159. return m.clearedtoken_agent
  1160. }
  1161. return false
  1162. }
  1163. // ClearEdge clears the value of the edge with the given name. It returns an error
  1164. // if that edge is not defined in the schema.
  1165. func (m *AgentMutation) ClearEdge(name string) error {
  1166. switch name {
  1167. }
  1168. return fmt.Errorf("unknown Agent unique edge %s", name)
  1169. }
  1170. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1171. // It returns an error if the edge is not defined in the schema.
  1172. func (m *AgentMutation) ResetEdge(name string) error {
  1173. switch name {
  1174. case agent.EdgeWxAgent:
  1175. m.ResetWxAgent()
  1176. return nil
  1177. case agent.EdgeTokenAgent:
  1178. m.ResetTokenAgent()
  1179. return nil
  1180. }
  1181. return fmt.Errorf("unknown Agent edge %s", name)
  1182. }
  1183. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1184. type AgentBaseMutation struct {
  1185. config
  1186. op Op
  1187. typ string
  1188. id *string
  1189. q *string
  1190. a *string
  1191. chunk_index *uint64
  1192. addchunk_index *int64
  1193. indexes *[]string
  1194. appendindexes []string
  1195. dataset_id *string
  1196. collection_id *string
  1197. source_name *string
  1198. can_write *[]bool
  1199. appendcan_write []bool
  1200. is_owner *[]bool
  1201. appendis_owner []bool
  1202. clearedFields map[string]struct{}
  1203. wx_agent map[uint64]struct{}
  1204. removedwx_agent map[uint64]struct{}
  1205. clearedwx_agent bool
  1206. done bool
  1207. oldValue func(context.Context) (*AgentBase, error)
  1208. predicates []predicate.AgentBase
  1209. }
  1210. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1211. // agentbaseOption allows management of the mutation configuration using functional options.
  1212. type agentbaseOption func(*AgentBaseMutation)
  1213. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1214. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1215. m := &AgentBaseMutation{
  1216. config: c,
  1217. op: op,
  1218. typ: TypeAgentBase,
  1219. clearedFields: make(map[string]struct{}),
  1220. }
  1221. for _, opt := range opts {
  1222. opt(m)
  1223. }
  1224. return m
  1225. }
  1226. // withAgentBaseID sets the ID field of the mutation.
  1227. func withAgentBaseID(id string) agentbaseOption {
  1228. return func(m *AgentBaseMutation) {
  1229. var (
  1230. err error
  1231. once sync.Once
  1232. value *AgentBase
  1233. )
  1234. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1235. once.Do(func() {
  1236. if m.done {
  1237. err = errors.New("querying old values post mutation is not allowed")
  1238. } else {
  1239. value, err = m.Client().AgentBase.Get(ctx, id)
  1240. }
  1241. })
  1242. return value, err
  1243. }
  1244. m.id = &id
  1245. }
  1246. }
  1247. // withAgentBase sets the old AgentBase of the mutation.
  1248. func withAgentBase(node *AgentBase) agentbaseOption {
  1249. return func(m *AgentBaseMutation) {
  1250. m.oldValue = func(context.Context) (*AgentBase, error) {
  1251. return node, nil
  1252. }
  1253. m.id = &node.ID
  1254. }
  1255. }
  1256. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1257. // executed in a transaction (ent.Tx), a transactional client is returned.
  1258. func (m AgentBaseMutation) Client() *Client {
  1259. client := &Client{config: m.config}
  1260. client.init()
  1261. return client
  1262. }
  1263. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1264. // it returns an error otherwise.
  1265. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1266. if _, ok := m.driver.(*txDriver); !ok {
  1267. return nil, errors.New("ent: mutation is not running in a transaction")
  1268. }
  1269. tx := &Tx{config: m.config}
  1270. tx.init()
  1271. return tx, nil
  1272. }
  1273. // SetID sets the value of the id field. Note that this
  1274. // operation is only accepted on creation of AgentBase entities.
  1275. func (m *AgentBaseMutation) SetID(id string) {
  1276. m.id = &id
  1277. }
  1278. // ID returns the ID value in the mutation. Note that the ID is only available
  1279. // if it was provided to the builder or after it was returned from the database.
  1280. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1281. if m.id == nil {
  1282. return
  1283. }
  1284. return *m.id, true
  1285. }
  1286. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1287. // That means, if the mutation is applied within a transaction with an isolation level such
  1288. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1289. // or updated by the mutation.
  1290. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1291. switch {
  1292. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1293. id, exists := m.ID()
  1294. if exists {
  1295. return []string{id}, nil
  1296. }
  1297. fallthrough
  1298. case m.op.Is(OpUpdate | OpDelete):
  1299. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1300. default:
  1301. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1302. }
  1303. }
  1304. // SetQ sets the "q" field.
  1305. func (m *AgentBaseMutation) SetQ(s string) {
  1306. m.q = &s
  1307. }
  1308. // Q returns the value of the "q" field in the mutation.
  1309. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1310. v := m.q
  1311. if v == nil {
  1312. return
  1313. }
  1314. return *v, true
  1315. }
  1316. // OldQ returns the old "q" field's value of the AgentBase entity.
  1317. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1318. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1319. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1320. if !m.op.Is(OpUpdateOne) {
  1321. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1322. }
  1323. if m.id == nil || m.oldValue == nil {
  1324. return v, errors.New("OldQ requires an ID field in the mutation")
  1325. }
  1326. oldValue, err := m.oldValue(ctx)
  1327. if err != nil {
  1328. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1329. }
  1330. return oldValue.Q, nil
  1331. }
  1332. // ClearQ clears the value of the "q" field.
  1333. func (m *AgentBaseMutation) ClearQ() {
  1334. m.q = nil
  1335. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1336. }
  1337. // QCleared returns if the "q" field was cleared in this mutation.
  1338. func (m *AgentBaseMutation) QCleared() bool {
  1339. _, ok := m.clearedFields[agentbase.FieldQ]
  1340. return ok
  1341. }
  1342. // ResetQ resets all changes to the "q" field.
  1343. func (m *AgentBaseMutation) ResetQ() {
  1344. m.q = nil
  1345. delete(m.clearedFields, agentbase.FieldQ)
  1346. }
  1347. // SetA sets the "a" field.
  1348. func (m *AgentBaseMutation) SetA(s string) {
  1349. m.a = &s
  1350. }
  1351. // A returns the value of the "a" field in the mutation.
  1352. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1353. v := m.a
  1354. if v == nil {
  1355. return
  1356. }
  1357. return *v, true
  1358. }
  1359. // OldA returns the old "a" field's value of the AgentBase entity.
  1360. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1362. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1363. if !m.op.Is(OpUpdateOne) {
  1364. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1365. }
  1366. if m.id == nil || m.oldValue == nil {
  1367. return v, errors.New("OldA requires an ID field in the mutation")
  1368. }
  1369. oldValue, err := m.oldValue(ctx)
  1370. if err != nil {
  1371. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1372. }
  1373. return oldValue.A, nil
  1374. }
  1375. // ClearA clears the value of the "a" field.
  1376. func (m *AgentBaseMutation) ClearA() {
  1377. m.a = nil
  1378. m.clearedFields[agentbase.FieldA] = struct{}{}
  1379. }
  1380. // ACleared returns if the "a" field was cleared in this mutation.
  1381. func (m *AgentBaseMutation) ACleared() bool {
  1382. _, ok := m.clearedFields[agentbase.FieldA]
  1383. return ok
  1384. }
  1385. // ResetA resets all changes to the "a" field.
  1386. func (m *AgentBaseMutation) ResetA() {
  1387. m.a = nil
  1388. delete(m.clearedFields, agentbase.FieldA)
  1389. }
  1390. // SetChunkIndex sets the "chunk_index" field.
  1391. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1392. m.chunk_index = &u
  1393. m.addchunk_index = nil
  1394. }
  1395. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1396. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1397. v := m.chunk_index
  1398. if v == nil {
  1399. return
  1400. }
  1401. return *v, true
  1402. }
  1403. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1404. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1406. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1407. if !m.op.Is(OpUpdateOne) {
  1408. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1409. }
  1410. if m.id == nil || m.oldValue == nil {
  1411. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1412. }
  1413. oldValue, err := m.oldValue(ctx)
  1414. if err != nil {
  1415. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1416. }
  1417. return oldValue.ChunkIndex, nil
  1418. }
  1419. // AddChunkIndex adds u to the "chunk_index" field.
  1420. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1421. if m.addchunk_index != nil {
  1422. *m.addchunk_index += u
  1423. } else {
  1424. m.addchunk_index = &u
  1425. }
  1426. }
  1427. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1428. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1429. v := m.addchunk_index
  1430. if v == nil {
  1431. return
  1432. }
  1433. return *v, true
  1434. }
  1435. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1436. func (m *AgentBaseMutation) ResetChunkIndex() {
  1437. m.chunk_index = nil
  1438. m.addchunk_index = nil
  1439. }
  1440. // SetIndexes sets the "indexes" field.
  1441. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1442. m.indexes = &s
  1443. m.appendindexes = nil
  1444. }
  1445. // Indexes returns the value of the "indexes" field in the mutation.
  1446. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1447. v := m.indexes
  1448. if v == nil {
  1449. return
  1450. }
  1451. return *v, true
  1452. }
  1453. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1454. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1456. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1457. if !m.op.Is(OpUpdateOne) {
  1458. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1459. }
  1460. if m.id == nil || m.oldValue == nil {
  1461. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1462. }
  1463. oldValue, err := m.oldValue(ctx)
  1464. if err != nil {
  1465. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1466. }
  1467. return oldValue.Indexes, nil
  1468. }
  1469. // AppendIndexes adds s to the "indexes" field.
  1470. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1471. m.appendindexes = append(m.appendindexes, s...)
  1472. }
  1473. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1474. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1475. if len(m.appendindexes) == 0 {
  1476. return nil, false
  1477. }
  1478. return m.appendindexes, true
  1479. }
  1480. // ClearIndexes clears the value of the "indexes" field.
  1481. func (m *AgentBaseMutation) ClearIndexes() {
  1482. m.indexes = nil
  1483. m.appendindexes = nil
  1484. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1485. }
  1486. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1487. func (m *AgentBaseMutation) IndexesCleared() bool {
  1488. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1489. return ok
  1490. }
  1491. // ResetIndexes resets all changes to the "indexes" field.
  1492. func (m *AgentBaseMutation) ResetIndexes() {
  1493. m.indexes = nil
  1494. m.appendindexes = nil
  1495. delete(m.clearedFields, agentbase.FieldIndexes)
  1496. }
  1497. // SetDatasetID sets the "dataset_id" field.
  1498. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1499. m.dataset_id = &s
  1500. }
  1501. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1502. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1503. v := m.dataset_id
  1504. if v == nil {
  1505. return
  1506. }
  1507. return *v, true
  1508. }
  1509. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1510. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1511. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1512. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1513. if !m.op.Is(OpUpdateOne) {
  1514. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1515. }
  1516. if m.id == nil || m.oldValue == nil {
  1517. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1518. }
  1519. oldValue, err := m.oldValue(ctx)
  1520. if err != nil {
  1521. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1522. }
  1523. return oldValue.DatasetID, nil
  1524. }
  1525. // ClearDatasetID clears the value of the "dataset_id" field.
  1526. func (m *AgentBaseMutation) ClearDatasetID() {
  1527. m.dataset_id = nil
  1528. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1529. }
  1530. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1531. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1532. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1533. return ok
  1534. }
  1535. // ResetDatasetID resets all changes to the "dataset_id" field.
  1536. func (m *AgentBaseMutation) ResetDatasetID() {
  1537. m.dataset_id = nil
  1538. delete(m.clearedFields, agentbase.FieldDatasetID)
  1539. }
  1540. // SetCollectionID sets the "collection_id" field.
  1541. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1542. m.collection_id = &s
  1543. }
  1544. // CollectionID returns the value of the "collection_id" field in the mutation.
  1545. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1546. v := m.collection_id
  1547. if v == nil {
  1548. return
  1549. }
  1550. return *v, true
  1551. }
  1552. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1553. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1555. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1556. if !m.op.Is(OpUpdateOne) {
  1557. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1558. }
  1559. if m.id == nil || m.oldValue == nil {
  1560. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1561. }
  1562. oldValue, err := m.oldValue(ctx)
  1563. if err != nil {
  1564. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1565. }
  1566. return oldValue.CollectionID, nil
  1567. }
  1568. // ClearCollectionID clears the value of the "collection_id" field.
  1569. func (m *AgentBaseMutation) ClearCollectionID() {
  1570. m.collection_id = nil
  1571. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1572. }
  1573. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1574. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1575. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1576. return ok
  1577. }
  1578. // ResetCollectionID resets all changes to the "collection_id" field.
  1579. func (m *AgentBaseMutation) ResetCollectionID() {
  1580. m.collection_id = nil
  1581. delete(m.clearedFields, agentbase.FieldCollectionID)
  1582. }
  1583. // SetSourceName sets the "source_name" field.
  1584. func (m *AgentBaseMutation) SetSourceName(s string) {
  1585. m.source_name = &s
  1586. }
  1587. // SourceName returns the value of the "source_name" field in the mutation.
  1588. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1589. v := m.source_name
  1590. if v == nil {
  1591. return
  1592. }
  1593. return *v, true
  1594. }
  1595. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1596. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1598. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1599. if !m.op.Is(OpUpdateOne) {
  1600. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1601. }
  1602. if m.id == nil || m.oldValue == nil {
  1603. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1604. }
  1605. oldValue, err := m.oldValue(ctx)
  1606. if err != nil {
  1607. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1608. }
  1609. return oldValue.SourceName, nil
  1610. }
  1611. // ClearSourceName clears the value of the "source_name" field.
  1612. func (m *AgentBaseMutation) ClearSourceName() {
  1613. m.source_name = nil
  1614. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1615. }
  1616. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1617. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1618. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1619. return ok
  1620. }
  1621. // ResetSourceName resets all changes to the "source_name" field.
  1622. func (m *AgentBaseMutation) ResetSourceName() {
  1623. m.source_name = nil
  1624. delete(m.clearedFields, agentbase.FieldSourceName)
  1625. }
  1626. // SetCanWrite sets the "can_write" field.
  1627. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1628. m.can_write = &b
  1629. m.appendcan_write = nil
  1630. }
  1631. // CanWrite returns the value of the "can_write" field in the mutation.
  1632. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1633. v := m.can_write
  1634. if v == nil {
  1635. return
  1636. }
  1637. return *v, true
  1638. }
  1639. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1640. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1642. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1643. if !m.op.Is(OpUpdateOne) {
  1644. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1645. }
  1646. if m.id == nil || m.oldValue == nil {
  1647. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1648. }
  1649. oldValue, err := m.oldValue(ctx)
  1650. if err != nil {
  1651. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1652. }
  1653. return oldValue.CanWrite, nil
  1654. }
  1655. // AppendCanWrite adds b to the "can_write" field.
  1656. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1657. m.appendcan_write = append(m.appendcan_write, b...)
  1658. }
  1659. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1660. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1661. if len(m.appendcan_write) == 0 {
  1662. return nil, false
  1663. }
  1664. return m.appendcan_write, true
  1665. }
  1666. // ClearCanWrite clears the value of the "can_write" field.
  1667. func (m *AgentBaseMutation) ClearCanWrite() {
  1668. m.can_write = nil
  1669. m.appendcan_write = nil
  1670. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1671. }
  1672. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1673. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1674. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1675. return ok
  1676. }
  1677. // ResetCanWrite resets all changes to the "can_write" field.
  1678. func (m *AgentBaseMutation) ResetCanWrite() {
  1679. m.can_write = nil
  1680. m.appendcan_write = nil
  1681. delete(m.clearedFields, agentbase.FieldCanWrite)
  1682. }
  1683. // SetIsOwner sets the "is_owner" field.
  1684. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1685. m.is_owner = &b
  1686. m.appendis_owner = nil
  1687. }
  1688. // IsOwner returns the value of the "is_owner" field in the mutation.
  1689. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1690. v := m.is_owner
  1691. if v == nil {
  1692. return
  1693. }
  1694. return *v, true
  1695. }
  1696. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1697. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1698. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1699. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1700. if !m.op.Is(OpUpdateOne) {
  1701. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1702. }
  1703. if m.id == nil || m.oldValue == nil {
  1704. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1705. }
  1706. oldValue, err := m.oldValue(ctx)
  1707. if err != nil {
  1708. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1709. }
  1710. return oldValue.IsOwner, nil
  1711. }
  1712. // AppendIsOwner adds b to the "is_owner" field.
  1713. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1714. m.appendis_owner = append(m.appendis_owner, b...)
  1715. }
  1716. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1717. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1718. if len(m.appendis_owner) == 0 {
  1719. return nil, false
  1720. }
  1721. return m.appendis_owner, true
  1722. }
  1723. // ClearIsOwner clears the value of the "is_owner" field.
  1724. func (m *AgentBaseMutation) ClearIsOwner() {
  1725. m.is_owner = nil
  1726. m.appendis_owner = nil
  1727. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1728. }
  1729. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1730. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1731. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1732. return ok
  1733. }
  1734. // ResetIsOwner resets all changes to the "is_owner" field.
  1735. func (m *AgentBaseMutation) ResetIsOwner() {
  1736. m.is_owner = nil
  1737. m.appendis_owner = nil
  1738. delete(m.clearedFields, agentbase.FieldIsOwner)
  1739. }
  1740. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1741. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1742. if m.wx_agent == nil {
  1743. m.wx_agent = make(map[uint64]struct{})
  1744. }
  1745. for i := range ids {
  1746. m.wx_agent[ids[i]] = struct{}{}
  1747. }
  1748. }
  1749. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1750. func (m *AgentBaseMutation) ClearWxAgent() {
  1751. m.clearedwx_agent = true
  1752. }
  1753. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1754. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1755. return m.clearedwx_agent
  1756. }
  1757. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1758. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1759. if m.removedwx_agent == nil {
  1760. m.removedwx_agent = make(map[uint64]struct{})
  1761. }
  1762. for i := range ids {
  1763. delete(m.wx_agent, ids[i])
  1764. m.removedwx_agent[ids[i]] = struct{}{}
  1765. }
  1766. }
  1767. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1768. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1769. for id := range m.removedwx_agent {
  1770. ids = append(ids, id)
  1771. }
  1772. return
  1773. }
  1774. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1775. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1776. for id := range m.wx_agent {
  1777. ids = append(ids, id)
  1778. }
  1779. return
  1780. }
  1781. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1782. func (m *AgentBaseMutation) ResetWxAgent() {
  1783. m.wx_agent = nil
  1784. m.clearedwx_agent = false
  1785. m.removedwx_agent = nil
  1786. }
  1787. // Where appends a list predicates to the AgentBaseMutation builder.
  1788. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1789. m.predicates = append(m.predicates, ps...)
  1790. }
  1791. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1792. // users can use type-assertion to append predicates that do not depend on any generated package.
  1793. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1794. p := make([]predicate.AgentBase, len(ps))
  1795. for i := range ps {
  1796. p[i] = ps[i]
  1797. }
  1798. m.Where(p...)
  1799. }
  1800. // Op returns the operation name.
  1801. func (m *AgentBaseMutation) Op() Op {
  1802. return m.op
  1803. }
  1804. // SetOp allows setting the mutation operation.
  1805. func (m *AgentBaseMutation) SetOp(op Op) {
  1806. m.op = op
  1807. }
  1808. // Type returns the node type of this mutation (AgentBase).
  1809. func (m *AgentBaseMutation) Type() string {
  1810. return m.typ
  1811. }
  1812. // Fields returns all fields that were changed during this mutation. Note that in
  1813. // order to get all numeric fields that were incremented/decremented, call
  1814. // AddedFields().
  1815. func (m *AgentBaseMutation) Fields() []string {
  1816. fields := make([]string, 0, 9)
  1817. if m.q != nil {
  1818. fields = append(fields, agentbase.FieldQ)
  1819. }
  1820. if m.a != nil {
  1821. fields = append(fields, agentbase.FieldA)
  1822. }
  1823. if m.chunk_index != nil {
  1824. fields = append(fields, agentbase.FieldChunkIndex)
  1825. }
  1826. if m.indexes != nil {
  1827. fields = append(fields, agentbase.FieldIndexes)
  1828. }
  1829. if m.dataset_id != nil {
  1830. fields = append(fields, agentbase.FieldDatasetID)
  1831. }
  1832. if m.collection_id != nil {
  1833. fields = append(fields, agentbase.FieldCollectionID)
  1834. }
  1835. if m.source_name != nil {
  1836. fields = append(fields, agentbase.FieldSourceName)
  1837. }
  1838. if m.can_write != nil {
  1839. fields = append(fields, agentbase.FieldCanWrite)
  1840. }
  1841. if m.is_owner != nil {
  1842. fields = append(fields, agentbase.FieldIsOwner)
  1843. }
  1844. return fields
  1845. }
  1846. // Field returns the value of a field with the given name. The second boolean
  1847. // return value indicates that this field was not set, or was not defined in the
  1848. // schema.
  1849. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1850. switch name {
  1851. case agentbase.FieldQ:
  1852. return m.Q()
  1853. case agentbase.FieldA:
  1854. return m.A()
  1855. case agentbase.FieldChunkIndex:
  1856. return m.ChunkIndex()
  1857. case agentbase.FieldIndexes:
  1858. return m.Indexes()
  1859. case agentbase.FieldDatasetID:
  1860. return m.DatasetID()
  1861. case agentbase.FieldCollectionID:
  1862. return m.CollectionID()
  1863. case agentbase.FieldSourceName:
  1864. return m.SourceName()
  1865. case agentbase.FieldCanWrite:
  1866. return m.CanWrite()
  1867. case agentbase.FieldIsOwner:
  1868. return m.IsOwner()
  1869. }
  1870. return nil, false
  1871. }
  1872. // OldField returns the old value of the field from the database. An error is
  1873. // returned if the mutation operation is not UpdateOne, or the query to the
  1874. // database failed.
  1875. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1876. switch name {
  1877. case agentbase.FieldQ:
  1878. return m.OldQ(ctx)
  1879. case agentbase.FieldA:
  1880. return m.OldA(ctx)
  1881. case agentbase.FieldChunkIndex:
  1882. return m.OldChunkIndex(ctx)
  1883. case agentbase.FieldIndexes:
  1884. return m.OldIndexes(ctx)
  1885. case agentbase.FieldDatasetID:
  1886. return m.OldDatasetID(ctx)
  1887. case agentbase.FieldCollectionID:
  1888. return m.OldCollectionID(ctx)
  1889. case agentbase.FieldSourceName:
  1890. return m.OldSourceName(ctx)
  1891. case agentbase.FieldCanWrite:
  1892. return m.OldCanWrite(ctx)
  1893. case agentbase.FieldIsOwner:
  1894. return m.OldIsOwner(ctx)
  1895. }
  1896. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1897. }
  1898. // SetField sets the value of a field with the given name. It returns an error if
  1899. // the field is not defined in the schema, or if the type mismatched the field
  1900. // type.
  1901. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1902. switch name {
  1903. case agentbase.FieldQ:
  1904. v, ok := value.(string)
  1905. if !ok {
  1906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1907. }
  1908. m.SetQ(v)
  1909. return nil
  1910. case agentbase.FieldA:
  1911. v, ok := value.(string)
  1912. if !ok {
  1913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1914. }
  1915. m.SetA(v)
  1916. return nil
  1917. case agentbase.FieldChunkIndex:
  1918. v, ok := value.(uint64)
  1919. if !ok {
  1920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1921. }
  1922. m.SetChunkIndex(v)
  1923. return nil
  1924. case agentbase.FieldIndexes:
  1925. v, ok := value.([]string)
  1926. if !ok {
  1927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1928. }
  1929. m.SetIndexes(v)
  1930. return nil
  1931. case agentbase.FieldDatasetID:
  1932. v, ok := value.(string)
  1933. if !ok {
  1934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1935. }
  1936. m.SetDatasetID(v)
  1937. return nil
  1938. case agentbase.FieldCollectionID:
  1939. v, ok := value.(string)
  1940. if !ok {
  1941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1942. }
  1943. m.SetCollectionID(v)
  1944. return nil
  1945. case agentbase.FieldSourceName:
  1946. v, ok := value.(string)
  1947. if !ok {
  1948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1949. }
  1950. m.SetSourceName(v)
  1951. return nil
  1952. case agentbase.FieldCanWrite:
  1953. v, ok := value.([]bool)
  1954. if !ok {
  1955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1956. }
  1957. m.SetCanWrite(v)
  1958. return nil
  1959. case agentbase.FieldIsOwner:
  1960. v, ok := value.([]bool)
  1961. if !ok {
  1962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1963. }
  1964. m.SetIsOwner(v)
  1965. return nil
  1966. }
  1967. return fmt.Errorf("unknown AgentBase field %s", name)
  1968. }
  1969. // AddedFields returns all numeric fields that were incremented/decremented during
  1970. // this mutation.
  1971. func (m *AgentBaseMutation) AddedFields() []string {
  1972. var fields []string
  1973. if m.addchunk_index != nil {
  1974. fields = append(fields, agentbase.FieldChunkIndex)
  1975. }
  1976. return fields
  1977. }
  1978. // AddedField returns the numeric value that was incremented/decremented on a field
  1979. // with the given name. The second boolean return value indicates that this field
  1980. // was not set, or was not defined in the schema.
  1981. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  1982. switch name {
  1983. case agentbase.FieldChunkIndex:
  1984. return m.AddedChunkIndex()
  1985. }
  1986. return nil, false
  1987. }
  1988. // AddField adds the value to the field with the given name. It returns an error if
  1989. // the field is not defined in the schema, or if the type mismatched the field
  1990. // type.
  1991. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  1992. switch name {
  1993. case agentbase.FieldChunkIndex:
  1994. v, ok := value.(int64)
  1995. if !ok {
  1996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1997. }
  1998. m.AddChunkIndex(v)
  1999. return nil
  2000. }
  2001. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2002. }
  2003. // ClearedFields returns all nullable fields that were cleared during this
  2004. // mutation.
  2005. func (m *AgentBaseMutation) ClearedFields() []string {
  2006. var fields []string
  2007. if m.FieldCleared(agentbase.FieldQ) {
  2008. fields = append(fields, agentbase.FieldQ)
  2009. }
  2010. if m.FieldCleared(agentbase.FieldA) {
  2011. fields = append(fields, agentbase.FieldA)
  2012. }
  2013. if m.FieldCleared(agentbase.FieldIndexes) {
  2014. fields = append(fields, agentbase.FieldIndexes)
  2015. }
  2016. if m.FieldCleared(agentbase.FieldDatasetID) {
  2017. fields = append(fields, agentbase.FieldDatasetID)
  2018. }
  2019. if m.FieldCleared(agentbase.FieldCollectionID) {
  2020. fields = append(fields, agentbase.FieldCollectionID)
  2021. }
  2022. if m.FieldCleared(agentbase.FieldSourceName) {
  2023. fields = append(fields, agentbase.FieldSourceName)
  2024. }
  2025. if m.FieldCleared(agentbase.FieldCanWrite) {
  2026. fields = append(fields, agentbase.FieldCanWrite)
  2027. }
  2028. if m.FieldCleared(agentbase.FieldIsOwner) {
  2029. fields = append(fields, agentbase.FieldIsOwner)
  2030. }
  2031. return fields
  2032. }
  2033. // FieldCleared returns a boolean indicating if a field with the given name was
  2034. // cleared in this mutation.
  2035. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2036. _, ok := m.clearedFields[name]
  2037. return ok
  2038. }
  2039. // ClearField clears the value of the field with the given name. It returns an
  2040. // error if the field is not defined in the schema.
  2041. func (m *AgentBaseMutation) ClearField(name string) error {
  2042. switch name {
  2043. case agentbase.FieldQ:
  2044. m.ClearQ()
  2045. return nil
  2046. case agentbase.FieldA:
  2047. m.ClearA()
  2048. return nil
  2049. case agentbase.FieldIndexes:
  2050. m.ClearIndexes()
  2051. return nil
  2052. case agentbase.FieldDatasetID:
  2053. m.ClearDatasetID()
  2054. return nil
  2055. case agentbase.FieldCollectionID:
  2056. m.ClearCollectionID()
  2057. return nil
  2058. case agentbase.FieldSourceName:
  2059. m.ClearSourceName()
  2060. return nil
  2061. case agentbase.FieldCanWrite:
  2062. m.ClearCanWrite()
  2063. return nil
  2064. case agentbase.FieldIsOwner:
  2065. m.ClearIsOwner()
  2066. return nil
  2067. }
  2068. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2069. }
  2070. // ResetField resets all changes in the mutation for the field with the given name.
  2071. // It returns an error if the field is not defined in the schema.
  2072. func (m *AgentBaseMutation) ResetField(name string) error {
  2073. switch name {
  2074. case agentbase.FieldQ:
  2075. m.ResetQ()
  2076. return nil
  2077. case agentbase.FieldA:
  2078. m.ResetA()
  2079. return nil
  2080. case agentbase.FieldChunkIndex:
  2081. m.ResetChunkIndex()
  2082. return nil
  2083. case agentbase.FieldIndexes:
  2084. m.ResetIndexes()
  2085. return nil
  2086. case agentbase.FieldDatasetID:
  2087. m.ResetDatasetID()
  2088. return nil
  2089. case agentbase.FieldCollectionID:
  2090. m.ResetCollectionID()
  2091. return nil
  2092. case agentbase.FieldSourceName:
  2093. m.ResetSourceName()
  2094. return nil
  2095. case agentbase.FieldCanWrite:
  2096. m.ResetCanWrite()
  2097. return nil
  2098. case agentbase.FieldIsOwner:
  2099. m.ResetIsOwner()
  2100. return nil
  2101. }
  2102. return fmt.Errorf("unknown AgentBase field %s", name)
  2103. }
  2104. // AddedEdges returns all edge names that were set/added in this mutation.
  2105. func (m *AgentBaseMutation) AddedEdges() []string {
  2106. edges := make([]string, 0, 1)
  2107. if m.wx_agent != nil {
  2108. edges = append(edges, agentbase.EdgeWxAgent)
  2109. }
  2110. return edges
  2111. }
  2112. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2113. // name in this mutation.
  2114. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2115. switch name {
  2116. case agentbase.EdgeWxAgent:
  2117. ids := make([]ent.Value, 0, len(m.wx_agent))
  2118. for id := range m.wx_agent {
  2119. ids = append(ids, id)
  2120. }
  2121. return ids
  2122. }
  2123. return nil
  2124. }
  2125. // RemovedEdges returns all edge names that were removed in this mutation.
  2126. func (m *AgentBaseMutation) RemovedEdges() []string {
  2127. edges := make([]string, 0, 1)
  2128. if m.removedwx_agent != nil {
  2129. edges = append(edges, agentbase.EdgeWxAgent)
  2130. }
  2131. return edges
  2132. }
  2133. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2134. // the given name in this mutation.
  2135. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2136. switch name {
  2137. case agentbase.EdgeWxAgent:
  2138. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2139. for id := range m.removedwx_agent {
  2140. ids = append(ids, id)
  2141. }
  2142. return ids
  2143. }
  2144. return nil
  2145. }
  2146. // ClearedEdges returns all edge names that were cleared in this mutation.
  2147. func (m *AgentBaseMutation) ClearedEdges() []string {
  2148. edges := make([]string, 0, 1)
  2149. if m.clearedwx_agent {
  2150. edges = append(edges, agentbase.EdgeWxAgent)
  2151. }
  2152. return edges
  2153. }
  2154. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2155. // was cleared in this mutation.
  2156. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2157. switch name {
  2158. case agentbase.EdgeWxAgent:
  2159. return m.clearedwx_agent
  2160. }
  2161. return false
  2162. }
  2163. // ClearEdge clears the value of the edge with the given name. It returns an error
  2164. // if that edge is not defined in the schema.
  2165. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2166. switch name {
  2167. }
  2168. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2169. }
  2170. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2171. // It returns an error if the edge is not defined in the schema.
  2172. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2173. switch name {
  2174. case agentbase.EdgeWxAgent:
  2175. m.ResetWxAgent()
  2176. return nil
  2177. }
  2178. return fmt.Errorf("unknown AgentBase edge %s", name)
  2179. }
  2180. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2181. type AliyunAvatarMutation struct {
  2182. config
  2183. op Op
  2184. typ string
  2185. id *uint64
  2186. created_at *time.Time
  2187. updated_at *time.Time
  2188. deleted_at *time.Time
  2189. user_id *uint64
  2190. adduser_id *int64
  2191. biz_id *string
  2192. access_key_id *string
  2193. access_key_secret *string
  2194. app_id *string
  2195. tenant_id *uint64
  2196. addtenant_id *int64
  2197. response *string
  2198. token *string
  2199. session_id *string
  2200. clearedFields map[string]struct{}
  2201. done bool
  2202. oldValue func(context.Context) (*AliyunAvatar, error)
  2203. predicates []predicate.AliyunAvatar
  2204. }
  2205. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2206. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2207. type aliyunavatarOption func(*AliyunAvatarMutation)
  2208. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2209. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2210. m := &AliyunAvatarMutation{
  2211. config: c,
  2212. op: op,
  2213. typ: TypeAliyunAvatar,
  2214. clearedFields: make(map[string]struct{}),
  2215. }
  2216. for _, opt := range opts {
  2217. opt(m)
  2218. }
  2219. return m
  2220. }
  2221. // withAliyunAvatarID sets the ID field of the mutation.
  2222. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2223. return func(m *AliyunAvatarMutation) {
  2224. var (
  2225. err error
  2226. once sync.Once
  2227. value *AliyunAvatar
  2228. )
  2229. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2230. once.Do(func() {
  2231. if m.done {
  2232. err = errors.New("querying old values post mutation is not allowed")
  2233. } else {
  2234. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2235. }
  2236. })
  2237. return value, err
  2238. }
  2239. m.id = &id
  2240. }
  2241. }
  2242. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2243. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2244. return func(m *AliyunAvatarMutation) {
  2245. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2246. return node, nil
  2247. }
  2248. m.id = &node.ID
  2249. }
  2250. }
  2251. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2252. // executed in a transaction (ent.Tx), a transactional client is returned.
  2253. func (m AliyunAvatarMutation) Client() *Client {
  2254. client := &Client{config: m.config}
  2255. client.init()
  2256. return client
  2257. }
  2258. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2259. // it returns an error otherwise.
  2260. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2261. if _, ok := m.driver.(*txDriver); !ok {
  2262. return nil, errors.New("ent: mutation is not running in a transaction")
  2263. }
  2264. tx := &Tx{config: m.config}
  2265. tx.init()
  2266. return tx, nil
  2267. }
  2268. // SetID sets the value of the id field. Note that this
  2269. // operation is only accepted on creation of AliyunAvatar entities.
  2270. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2271. m.id = &id
  2272. }
  2273. // ID returns the ID value in the mutation. Note that the ID is only available
  2274. // if it was provided to the builder or after it was returned from the database.
  2275. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2276. if m.id == nil {
  2277. return
  2278. }
  2279. return *m.id, true
  2280. }
  2281. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2282. // That means, if the mutation is applied within a transaction with an isolation level such
  2283. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2284. // or updated by the mutation.
  2285. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2286. switch {
  2287. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2288. id, exists := m.ID()
  2289. if exists {
  2290. return []uint64{id}, nil
  2291. }
  2292. fallthrough
  2293. case m.op.Is(OpUpdate | OpDelete):
  2294. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2295. default:
  2296. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2297. }
  2298. }
  2299. // SetCreatedAt sets the "created_at" field.
  2300. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2301. m.created_at = &t
  2302. }
  2303. // CreatedAt returns the value of the "created_at" field in the mutation.
  2304. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2305. v := m.created_at
  2306. if v == nil {
  2307. return
  2308. }
  2309. return *v, true
  2310. }
  2311. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2312. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2314. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2315. if !m.op.Is(OpUpdateOne) {
  2316. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2317. }
  2318. if m.id == nil || m.oldValue == nil {
  2319. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2320. }
  2321. oldValue, err := m.oldValue(ctx)
  2322. if err != nil {
  2323. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2324. }
  2325. return oldValue.CreatedAt, nil
  2326. }
  2327. // ResetCreatedAt resets all changes to the "created_at" field.
  2328. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2329. m.created_at = nil
  2330. }
  2331. // SetUpdatedAt sets the "updated_at" field.
  2332. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2333. m.updated_at = &t
  2334. }
  2335. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2336. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2337. v := m.updated_at
  2338. if v == nil {
  2339. return
  2340. }
  2341. return *v, true
  2342. }
  2343. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2344. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2346. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2347. if !m.op.Is(OpUpdateOne) {
  2348. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2349. }
  2350. if m.id == nil || m.oldValue == nil {
  2351. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2352. }
  2353. oldValue, err := m.oldValue(ctx)
  2354. if err != nil {
  2355. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2356. }
  2357. return oldValue.UpdatedAt, nil
  2358. }
  2359. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2360. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2361. m.updated_at = nil
  2362. }
  2363. // SetDeletedAt sets the "deleted_at" field.
  2364. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2365. m.deleted_at = &t
  2366. }
  2367. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2368. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2369. v := m.deleted_at
  2370. if v == nil {
  2371. return
  2372. }
  2373. return *v, true
  2374. }
  2375. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2376. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2378. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2379. if !m.op.Is(OpUpdateOne) {
  2380. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2381. }
  2382. if m.id == nil || m.oldValue == nil {
  2383. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2384. }
  2385. oldValue, err := m.oldValue(ctx)
  2386. if err != nil {
  2387. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2388. }
  2389. return oldValue.DeletedAt, nil
  2390. }
  2391. // ClearDeletedAt clears the value of the "deleted_at" field.
  2392. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2393. m.deleted_at = nil
  2394. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2395. }
  2396. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2397. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2398. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2399. return ok
  2400. }
  2401. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2402. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2403. m.deleted_at = nil
  2404. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2405. }
  2406. // SetUserID sets the "user_id" field.
  2407. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2408. m.user_id = &u
  2409. m.adduser_id = nil
  2410. }
  2411. // UserID returns the value of the "user_id" field in the mutation.
  2412. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2413. v := m.user_id
  2414. if v == nil {
  2415. return
  2416. }
  2417. return *v, true
  2418. }
  2419. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2420. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2422. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2423. if !m.op.Is(OpUpdateOne) {
  2424. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2425. }
  2426. if m.id == nil || m.oldValue == nil {
  2427. return v, errors.New("OldUserID requires an ID field in the mutation")
  2428. }
  2429. oldValue, err := m.oldValue(ctx)
  2430. if err != nil {
  2431. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2432. }
  2433. return oldValue.UserID, nil
  2434. }
  2435. // AddUserID adds u to the "user_id" field.
  2436. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2437. if m.adduser_id != nil {
  2438. *m.adduser_id += u
  2439. } else {
  2440. m.adduser_id = &u
  2441. }
  2442. }
  2443. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2444. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2445. v := m.adduser_id
  2446. if v == nil {
  2447. return
  2448. }
  2449. return *v, true
  2450. }
  2451. // ResetUserID resets all changes to the "user_id" field.
  2452. func (m *AliyunAvatarMutation) ResetUserID() {
  2453. m.user_id = nil
  2454. m.adduser_id = nil
  2455. }
  2456. // SetBizID sets the "biz_id" field.
  2457. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2458. m.biz_id = &s
  2459. }
  2460. // BizID returns the value of the "biz_id" field in the mutation.
  2461. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2462. v := m.biz_id
  2463. if v == nil {
  2464. return
  2465. }
  2466. return *v, true
  2467. }
  2468. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2469. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2470. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2471. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2472. if !m.op.Is(OpUpdateOne) {
  2473. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2474. }
  2475. if m.id == nil || m.oldValue == nil {
  2476. return v, errors.New("OldBizID requires an ID field in the mutation")
  2477. }
  2478. oldValue, err := m.oldValue(ctx)
  2479. if err != nil {
  2480. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2481. }
  2482. return oldValue.BizID, nil
  2483. }
  2484. // ResetBizID resets all changes to the "biz_id" field.
  2485. func (m *AliyunAvatarMutation) ResetBizID() {
  2486. m.biz_id = nil
  2487. }
  2488. // SetAccessKeyID sets the "access_key_id" field.
  2489. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2490. m.access_key_id = &s
  2491. }
  2492. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2493. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2494. v := m.access_key_id
  2495. if v == nil {
  2496. return
  2497. }
  2498. return *v, true
  2499. }
  2500. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2501. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2502. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2503. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2504. if !m.op.Is(OpUpdateOne) {
  2505. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2506. }
  2507. if m.id == nil || m.oldValue == nil {
  2508. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2509. }
  2510. oldValue, err := m.oldValue(ctx)
  2511. if err != nil {
  2512. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2513. }
  2514. return oldValue.AccessKeyID, nil
  2515. }
  2516. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2517. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2518. m.access_key_id = nil
  2519. }
  2520. // SetAccessKeySecret sets the "access_key_secret" field.
  2521. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2522. m.access_key_secret = &s
  2523. }
  2524. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2525. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2526. v := m.access_key_secret
  2527. if v == nil {
  2528. return
  2529. }
  2530. return *v, true
  2531. }
  2532. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2533. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2534. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2535. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2536. if !m.op.Is(OpUpdateOne) {
  2537. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2538. }
  2539. if m.id == nil || m.oldValue == nil {
  2540. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2541. }
  2542. oldValue, err := m.oldValue(ctx)
  2543. if err != nil {
  2544. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2545. }
  2546. return oldValue.AccessKeySecret, nil
  2547. }
  2548. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2549. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2550. m.access_key_secret = nil
  2551. }
  2552. // SetAppID sets the "app_id" field.
  2553. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2554. m.app_id = &s
  2555. }
  2556. // AppID returns the value of the "app_id" field in the mutation.
  2557. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2558. v := m.app_id
  2559. if v == nil {
  2560. return
  2561. }
  2562. return *v, true
  2563. }
  2564. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2565. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2567. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2568. if !m.op.Is(OpUpdateOne) {
  2569. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2570. }
  2571. if m.id == nil || m.oldValue == nil {
  2572. return v, errors.New("OldAppID requires an ID field in the mutation")
  2573. }
  2574. oldValue, err := m.oldValue(ctx)
  2575. if err != nil {
  2576. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2577. }
  2578. return oldValue.AppID, nil
  2579. }
  2580. // ClearAppID clears the value of the "app_id" field.
  2581. func (m *AliyunAvatarMutation) ClearAppID() {
  2582. m.app_id = nil
  2583. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2584. }
  2585. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2586. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2587. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2588. return ok
  2589. }
  2590. // ResetAppID resets all changes to the "app_id" field.
  2591. func (m *AliyunAvatarMutation) ResetAppID() {
  2592. m.app_id = nil
  2593. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2594. }
  2595. // SetTenantID sets the "tenant_id" field.
  2596. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2597. m.tenant_id = &u
  2598. m.addtenant_id = nil
  2599. }
  2600. // TenantID returns the value of the "tenant_id" field in the mutation.
  2601. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2602. v := m.tenant_id
  2603. if v == nil {
  2604. return
  2605. }
  2606. return *v, true
  2607. }
  2608. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2609. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2610. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2611. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2612. if !m.op.Is(OpUpdateOne) {
  2613. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2614. }
  2615. if m.id == nil || m.oldValue == nil {
  2616. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2617. }
  2618. oldValue, err := m.oldValue(ctx)
  2619. if err != nil {
  2620. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2621. }
  2622. return oldValue.TenantID, nil
  2623. }
  2624. // AddTenantID adds u to the "tenant_id" field.
  2625. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2626. if m.addtenant_id != nil {
  2627. *m.addtenant_id += u
  2628. } else {
  2629. m.addtenant_id = &u
  2630. }
  2631. }
  2632. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2633. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2634. v := m.addtenant_id
  2635. if v == nil {
  2636. return
  2637. }
  2638. return *v, true
  2639. }
  2640. // ResetTenantID resets all changes to the "tenant_id" field.
  2641. func (m *AliyunAvatarMutation) ResetTenantID() {
  2642. m.tenant_id = nil
  2643. m.addtenant_id = nil
  2644. }
  2645. // SetResponse sets the "response" field.
  2646. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2647. m.response = &s
  2648. }
  2649. // Response returns the value of the "response" field in the mutation.
  2650. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2651. v := m.response
  2652. if v == nil {
  2653. return
  2654. }
  2655. return *v, true
  2656. }
  2657. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2658. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2660. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2661. if !m.op.Is(OpUpdateOne) {
  2662. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2663. }
  2664. if m.id == nil || m.oldValue == nil {
  2665. return v, errors.New("OldResponse requires an ID field in the mutation")
  2666. }
  2667. oldValue, err := m.oldValue(ctx)
  2668. if err != nil {
  2669. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2670. }
  2671. return oldValue.Response, nil
  2672. }
  2673. // ResetResponse resets all changes to the "response" field.
  2674. func (m *AliyunAvatarMutation) ResetResponse() {
  2675. m.response = nil
  2676. }
  2677. // SetToken sets the "token" field.
  2678. func (m *AliyunAvatarMutation) SetToken(s string) {
  2679. m.token = &s
  2680. }
  2681. // Token returns the value of the "token" field in the mutation.
  2682. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2683. v := m.token
  2684. if v == nil {
  2685. return
  2686. }
  2687. return *v, true
  2688. }
  2689. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2690. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2691. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2692. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2693. if !m.op.Is(OpUpdateOne) {
  2694. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2695. }
  2696. if m.id == nil || m.oldValue == nil {
  2697. return v, errors.New("OldToken requires an ID field in the mutation")
  2698. }
  2699. oldValue, err := m.oldValue(ctx)
  2700. if err != nil {
  2701. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2702. }
  2703. return oldValue.Token, nil
  2704. }
  2705. // ResetToken resets all changes to the "token" field.
  2706. func (m *AliyunAvatarMutation) ResetToken() {
  2707. m.token = nil
  2708. }
  2709. // SetSessionID sets the "session_id" field.
  2710. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2711. m.session_id = &s
  2712. }
  2713. // SessionID returns the value of the "session_id" field in the mutation.
  2714. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2715. v := m.session_id
  2716. if v == nil {
  2717. return
  2718. }
  2719. return *v, true
  2720. }
  2721. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2722. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2724. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2725. if !m.op.Is(OpUpdateOne) {
  2726. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2727. }
  2728. if m.id == nil || m.oldValue == nil {
  2729. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2730. }
  2731. oldValue, err := m.oldValue(ctx)
  2732. if err != nil {
  2733. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2734. }
  2735. return oldValue.SessionID, nil
  2736. }
  2737. // ResetSessionID resets all changes to the "session_id" field.
  2738. func (m *AliyunAvatarMutation) ResetSessionID() {
  2739. m.session_id = nil
  2740. }
  2741. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2742. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2743. m.predicates = append(m.predicates, ps...)
  2744. }
  2745. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2746. // users can use type-assertion to append predicates that do not depend on any generated package.
  2747. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2748. p := make([]predicate.AliyunAvatar, len(ps))
  2749. for i := range ps {
  2750. p[i] = ps[i]
  2751. }
  2752. m.Where(p...)
  2753. }
  2754. // Op returns the operation name.
  2755. func (m *AliyunAvatarMutation) Op() Op {
  2756. return m.op
  2757. }
  2758. // SetOp allows setting the mutation operation.
  2759. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2760. m.op = op
  2761. }
  2762. // Type returns the node type of this mutation (AliyunAvatar).
  2763. func (m *AliyunAvatarMutation) Type() string {
  2764. return m.typ
  2765. }
  2766. // Fields returns all fields that were changed during this mutation. Note that in
  2767. // order to get all numeric fields that were incremented/decremented, call
  2768. // AddedFields().
  2769. func (m *AliyunAvatarMutation) Fields() []string {
  2770. fields := make([]string, 0, 12)
  2771. if m.created_at != nil {
  2772. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2773. }
  2774. if m.updated_at != nil {
  2775. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2776. }
  2777. if m.deleted_at != nil {
  2778. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2779. }
  2780. if m.user_id != nil {
  2781. fields = append(fields, aliyunavatar.FieldUserID)
  2782. }
  2783. if m.biz_id != nil {
  2784. fields = append(fields, aliyunavatar.FieldBizID)
  2785. }
  2786. if m.access_key_id != nil {
  2787. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2788. }
  2789. if m.access_key_secret != nil {
  2790. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2791. }
  2792. if m.app_id != nil {
  2793. fields = append(fields, aliyunavatar.FieldAppID)
  2794. }
  2795. if m.tenant_id != nil {
  2796. fields = append(fields, aliyunavatar.FieldTenantID)
  2797. }
  2798. if m.response != nil {
  2799. fields = append(fields, aliyunavatar.FieldResponse)
  2800. }
  2801. if m.token != nil {
  2802. fields = append(fields, aliyunavatar.FieldToken)
  2803. }
  2804. if m.session_id != nil {
  2805. fields = append(fields, aliyunavatar.FieldSessionID)
  2806. }
  2807. return fields
  2808. }
  2809. // Field returns the value of a field with the given name. The second boolean
  2810. // return value indicates that this field was not set, or was not defined in the
  2811. // schema.
  2812. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2813. switch name {
  2814. case aliyunavatar.FieldCreatedAt:
  2815. return m.CreatedAt()
  2816. case aliyunavatar.FieldUpdatedAt:
  2817. return m.UpdatedAt()
  2818. case aliyunavatar.FieldDeletedAt:
  2819. return m.DeletedAt()
  2820. case aliyunavatar.FieldUserID:
  2821. return m.UserID()
  2822. case aliyunavatar.FieldBizID:
  2823. return m.BizID()
  2824. case aliyunavatar.FieldAccessKeyID:
  2825. return m.AccessKeyID()
  2826. case aliyunavatar.FieldAccessKeySecret:
  2827. return m.AccessKeySecret()
  2828. case aliyunavatar.FieldAppID:
  2829. return m.AppID()
  2830. case aliyunavatar.FieldTenantID:
  2831. return m.TenantID()
  2832. case aliyunavatar.FieldResponse:
  2833. return m.Response()
  2834. case aliyunavatar.FieldToken:
  2835. return m.Token()
  2836. case aliyunavatar.FieldSessionID:
  2837. return m.SessionID()
  2838. }
  2839. return nil, false
  2840. }
  2841. // OldField returns the old value of the field from the database. An error is
  2842. // returned if the mutation operation is not UpdateOne, or the query to the
  2843. // database failed.
  2844. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2845. switch name {
  2846. case aliyunavatar.FieldCreatedAt:
  2847. return m.OldCreatedAt(ctx)
  2848. case aliyunavatar.FieldUpdatedAt:
  2849. return m.OldUpdatedAt(ctx)
  2850. case aliyunavatar.FieldDeletedAt:
  2851. return m.OldDeletedAt(ctx)
  2852. case aliyunavatar.FieldUserID:
  2853. return m.OldUserID(ctx)
  2854. case aliyunavatar.FieldBizID:
  2855. return m.OldBizID(ctx)
  2856. case aliyunavatar.FieldAccessKeyID:
  2857. return m.OldAccessKeyID(ctx)
  2858. case aliyunavatar.FieldAccessKeySecret:
  2859. return m.OldAccessKeySecret(ctx)
  2860. case aliyunavatar.FieldAppID:
  2861. return m.OldAppID(ctx)
  2862. case aliyunavatar.FieldTenantID:
  2863. return m.OldTenantID(ctx)
  2864. case aliyunavatar.FieldResponse:
  2865. return m.OldResponse(ctx)
  2866. case aliyunavatar.FieldToken:
  2867. return m.OldToken(ctx)
  2868. case aliyunavatar.FieldSessionID:
  2869. return m.OldSessionID(ctx)
  2870. }
  2871. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2872. }
  2873. // SetField sets the value of a field with the given name. It returns an error if
  2874. // the field is not defined in the schema, or if the type mismatched the field
  2875. // type.
  2876. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2877. switch name {
  2878. case aliyunavatar.FieldCreatedAt:
  2879. v, ok := value.(time.Time)
  2880. if !ok {
  2881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2882. }
  2883. m.SetCreatedAt(v)
  2884. return nil
  2885. case aliyunavatar.FieldUpdatedAt:
  2886. v, ok := value.(time.Time)
  2887. if !ok {
  2888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2889. }
  2890. m.SetUpdatedAt(v)
  2891. return nil
  2892. case aliyunavatar.FieldDeletedAt:
  2893. v, ok := value.(time.Time)
  2894. if !ok {
  2895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2896. }
  2897. m.SetDeletedAt(v)
  2898. return nil
  2899. case aliyunavatar.FieldUserID:
  2900. v, ok := value.(uint64)
  2901. if !ok {
  2902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2903. }
  2904. m.SetUserID(v)
  2905. return nil
  2906. case aliyunavatar.FieldBizID:
  2907. v, ok := value.(string)
  2908. if !ok {
  2909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2910. }
  2911. m.SetBizID(v)
  2912. return nil
  2913. case aliyunavatar.FieldAccessKeyID:
  2914. v, ok := value.(string)
  2915. if !ok {
  2916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2917. }
  2918. m.SetAccessKeyID(v)
  2919. return nil
  2920. case aliyunavatar.FieldAccessKeySecret:
  2921. v, ok := value.(string)
  2922. if !ok {
  2923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2924. }
  2925. m.SetAccessKeySecret(v)
  2926. return nil
  2927. case aliyunavatar.FieldAppID:
  2928. v, ok := value.(string)
  2929. if !ok {
  2930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2931. }
  2932. m.SetAppID(v)
  2933. return nil
  2934. case aliyunavatar.FieldTenantID:
  2935. v, ok := value.(uint64)
  2936. if !ok {
  2937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2938. }
  2939. m.SetTenantID(v)
  2940. return nil
  2941. case aliyunavatar.FieldResponse:
  2942. v, ok := value.(string)
  2943. if !ok {
  2944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2945. }
  2946. m.SetResponse(v)
  2947. return nil
  2948. case aliyunavatar.FieldToken:
  2949. v, ok := value.(string)
  2950. if !ok {
  2951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2952. }
  2953. m.SetToken(v)
  2954. return nil
  2955. case aliyunavatar.FieldSessionID:
  2956. v, ok := value.(string)
  2957. if !ok {
  2958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2959. }
  2960. m.SetSessionID(v)
  2961. return nil
  2962. }
  2963. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  2964. }
  2965. // AddedFields returns all numeric fields that were incremented/decremented during
  2966. // this mutation.
  2967. func (m *AliyunAvatarMutation) AddedFields() []string {
  2968. var fields []string
  2969. if m.adduser_id != nil {
  2970. fields = append(fields, aliyunavatar.FieldUserID)
  2971. }
  2972. if m.addtenant_id != nil {
  2973. fields = append(fields, aliyunavatar.FieldTenantID)
  2974. }
  2975. return fields
  2976. }
  2977. // AddedField returns the numeric value that was incremented/decremented on a field
  2978. // with the given name. The second boolean return value indicates that this field
  2979. // was not set, or was not defined in the schema.
  2980. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  2981. switch name {
  2982. case aliyunavatar.FieldUserID:
  2983. return m.AddedUserID()
  2984. case aliyunavatar.FieldTenantID:
  2985. return m.AddedTenantID()
  2986. }
  2987. return nil, false
  2988. }
  2989. // AddField adds the value to the field with the given name. It returns an error if
  2990. // the field is not defined in the schema, or if the type mismatched the field
  2991. // type.
  2992. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  2993. switch name {
  2994. case aliyunavatar.FieldUserID:
  2995. v, ok := value.(int64)
  2996. if !ok {
  2997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2998. }
  2999. m.AddUserID(v)
  3000. return nil
  3001. case aliyunavatar.FieldTenantID:
  3002. v, ok := value.(int64)
  3003. if !ok {
  3004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3005. }
  3006. m.AddTenantID(v)
  3007. return nil
  3008. }
  3009. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3010. }
  3011. // ClearedFields returns all nullable fields that were cleared during this
  3012. // mutation.
  3013. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3014. var fields []string
  3015. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3016. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3017. }
  3018. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3019. fields = append(fields, aliyunavatar.FieldAppID)
  3020. }
  3021. return fields
  3022. }
  3023. // FieldCleared returns a boolean indicating if a field with the given name was
  3024. // cleared in this mutation.
  3025. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3026. _, ok := m.clearedFields[name]
  3027. return ok
  3028. }
  3029. // ClearField clears the value of the field with the given name. It returns an
  3030. // error if the field is not defined in the schema.
  3031. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3032. switch name {
  3033. case aliyunavatar.FieldDeletedAt:
  3034. m.ClearDeletedAt()
  3035. return nil
  3036. case aliyunavatar.FieldAppID:
  3037. m.ClearAppID()
  3038. return nil
  3039. }
  3040. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3041. }
  3042. // ResetField resets all changes in the mutation for the field with the given name.
  3043. // It returns an error if the field is not defined in the schema.
  3044. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3045. switch name {
  3046. case aliyunavatar.FieldCreatedAt:
  3047. m.ResetCreatedAt()
  3048. return nil
  3049. case aliyunavatar.FieldUpdatedAt:
  3050. m.ResetUpdatedAt()
  3051. return nil
  3052. case aliyunavatar.FieldDeletedAt:
  3053. m.ResetDeletedAt()
  3054. return nil
  3055. case aliyunavatar.FieldUserID:
  3056. m.ResetUserID()
  3057. return nil
  3058. case aliyunavatar.FieldBizID:
  3059. m.ResetBizID()
  3060. return nil
  3061. case aliyunavatar.FieldAccessKeyID:
  3062. m.ResetAccessKeyID()
  3063. return nil
  3064. case aliyunavatar.FieldAccessKeySecret:
  3065. m.ResetAccessKeySecret()
  3066. return nil
  3067. case aliyunavatar.FieldAppID:
  3068. m.ResetAppID()
  3069. return nil
  3070. case aliyunavatar.FieldTenantID:
  3071. m.ResetTenantID()
  3072. return nil
  3073. case aliyunavatar.FieldResponse:
  3074. m.ResetResponse()
  3075. return nil
  3076. case aliyunavatar.FieldToken:
  3077. m.ResetToken()
  3078. return nil
  3079. case aliyunavatar.FieldSessionID:
  3080. m.ResetSessionID()
  3081. return nil
  3082. }
  3083. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3084. }
  3085. // AddedEdges returns all edge names that were set/added in this mutation.
  3086. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3087. edges := make([]string, 0, 0)
  3088. return edges
  3089. }
  3090. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3091. // name in this mutation.
  3092. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3093. return nil
  3094. }
  3095. // RemovedEdges returns all edge names that were removed in this mutation.
  3096. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3097. edges := make([]string, 0, 0)
  3098. return edges
  3099. }
  3100. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3101. // the given name in this mutation.
  3102. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3103. return nil
  3104. }
  3105. // ClearedEdges returns all edge names that were cleared in this mutation.
  3106. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3107. edges := make([]string, 0, 0)
  3108. return edges
  3109. }
  3110. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3111. // was cleared in this mutation.
  3112. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3113. return false
  3114. }
  3115. // ClearEdge clears the value of the edge with the given name. It returns an error
  3116. // if that edge is not defined in the schema.
  3117. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3118. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3119. }
  3120. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3121. // It returns an error if the edge is not defined in the schema.
  3122. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3123. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3124. }
  3125. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3126. type BatchMsgMutation struct {
  3127. config
  3128. op Op
  3129. typ string
  3130. id *uint64
  3131. created_at *time.Time
  3132. updated_at *time.Time
  3133. deleted_at *time.Time
  3134. status *uint8
  3135. addstatus *int8
  3136. batch_no *string
  3137. task_name *string
  3138. fromwxid *string
  3139. msg *string
  3140. tag *string
  3141. tagids *string
  3142. total *int32
  3143. addtotal *int32
  3144. success *int32
  3145. addsuccess *int32
  3146. fail *int32
  3147. addfail *int32
  3148. start_time *time.Time
  3149. stop_time *time.Time
  3150. send_time *time.Time
  3151. _type *int32
  3152. add_type *int32
  3153. organization_id *uint64
  3154. addorganization_id *int64
  3155. clearedFields map[string]struct{}
  3156. done bool
  3157. oldValue func(context.Context) (*BatchMsg, error)
  3158. predicates []predicate.BatchMsg
  3159. }
  3160. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  3161. // batchmsgOption allows management of the mutation configuration using functional options.
  3162. type batchmsgOption func(*BatchMsgMutation)
  3163. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  3164. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  3165. m := &BatchMsgMutation{
  3166. config: c,
  3167. op: op,
  3168. typ: TypeBatchMsg,
  3169. clearedFields: make(map[string]struct{}),
  3170. }
  3171. for _, opt := range opts {
  3172. opt(m)
  3173. }
  3174. return m
  3175. }
  3176. // withBatchMsgID sets the ID field of the mutation.
  3177. func withBatchMsgID(id uint64) batchmsgOption {
  3178. return func(m *BatchMsgMutation) {
  3179. var (
  3180. err error
  3181. once sync.Once
  3182. value *BatchMsg
  3183. )
  3184. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  3185. once.Do(func() {
  3186. if m.done {
  3187. err = errors.New("querying old values post mutation is not allowed")
  3188. } else {
  3189. value, err = m.Client().BatchMsg.Get(ctx, id)
  3190. }
  3191. })
  3192. return value, err
  3193. }
  3194. m.id = &id
  3195. }
  3196. }
  3197. // withBatchMsg sets the old BatchMsg of the mutation.
  3198. func withBatchMsg(node *BatchMsg) batchmsgOption {
  3199. return func(m *BatchMsgMutation) {
  3200. m.oldValue = func(context.Context) (*BatchMsg, error) {
  3201. return node, nil
  3202. }
  3203. m.id = &node.ID
  3204. }
  3205. }
  3206. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3207. // executed in a transaction (ent.Tx), a transactional client is returned.
  3208. func (m BatchMsgMutation) Client() *Client {
  3209. client := &Client{config: m.config}
  3210. client.init()
  3211. return client
  3212. }
  3213. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3214. // it returns an error otherwise.
  3215. func (m BatchMsgMutation) Tx() (*Tx, error) {
  3216. if _, ok := m.driver.(*txDriver); !ok {
  3217. return nil, errors.New("ent: mutation is not running in a transaction")
  3218. }
  3219. tx := &Tx{config: m.config}
  3220. tx.init()
  3221. return tx, nil
  3222. }
  3223. // SetID sets the value of the id field. Note that this
  3224. // operation is only accepted on creation of BatchMsg entities.
  3225. func (m *BatchMsgMutation) SetID(id uint64) {
  3226. m.id = &id
  3227. }
  3228. // ID returns the ID value in the mutation. Note that the ID is only available
  3229. // if it was provided to the builder or after it was returned from the database.
  3230. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  3231. if m.id == nil {
  3232. return
  3233. }
  3234. return *m.id, true
  3235. }
  3236. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3237. // That means, if the mutation is applied within a transaction with an isolation level such
  3238. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3239. // or updated by the mutation.
  3240. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  3241. switch {
  3242. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3243. id, exists := m.ID()
  3244. if exists {
  3245. return []uint64{id}, nil
  3246. }
  3247. fallthrough
  3248. case m.op.Is(OpUpdate | OpDelete):
  3249. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  3250. default:
  3251. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3252. }
  3253. }
  3254. // SetCreatedAt sets the "created_at" field.
  3255. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  3256. m.created_at = &t
  3257. }
  3258. // CreatedAt returns the value of the "created_at" field in the mutation.
  3259. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  3260. v := m.created_at
  3261. if v == nil {
  3262. return
  3263. }
  3264. return *v, true
  3265. }
  3266. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  3267. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3269. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3270. if !m.op.Is(OpUpdateOne) {
  3271. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3272. }
  3273. if m.id == nil || m.oldValue == nil {
  3274. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3275. }
  3276. oldValue, err := m.oldValue(ctx)
  3277. if err != nil {
  3278. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3279. }
  3280. return oldValue.CreatedAt, nil
  3281. }
  3282. // ResetCreatedAt resets all changes to the "created_at" field.
  3283. func (m *BatchMsgMutation) ResetCreatedAt() {
  3284. m.created_at = nil
  3285. }
  3286. // SetUpdatedAt sets the "updated_at" field.
  3287. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  3288. m.updated_at = &t
  3289. }
  3290. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3291. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  3292. v := m.updated_at
  3293. if v == nil {
  3294. return
  3295. }
  3296. return *v, true
  3297. }
  3298. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  3299. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3301. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3302. if !m.op.Is(OpUpdateOne) {
  3303. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3304. }
  3305. if m.id == nil || m.oldValue == nil {
  3306. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3307. }
  3308. oldValue, err := m.oldValue(ctx)
  3309. if err != nil {
  3310. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3311. }
  3312. return oldValue.UpdatedAt, nil
  3313. }
  3314. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3315. func (m *BatchMsgMutation) ResetUpdatedAt() {
  3316. m.updated_at = nil
  3317. }
  3318. // SetDeletedAt sets the "deleted_at" field.
  3319. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  3320. m.deleted_at = &t
  3321. }
  3322. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3323. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  3324. v := m.deleted_at
  3325. if v == nil {
  3326. return
  3327. }
  3328. return *v, true
  3329. }
  3330. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  3331. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3333. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3334. if !m.op.Is(OpUpdateOne) {
  3335. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3336. }
  3337. if m.id == nil || m.oldValue == nil {
  3338. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3339. }
  3340. oldValue, err := m.oldValue(ctx)
  3341. if err != nil {
  3342. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3343. }
  3344. return oldValue.DeletedAt, nil
  3345. }
  3346. // ClearDeletedAt clears the value of the "deleted_at" field.
  3347. func (m *BatchMsgMutation) ClearDeletedAt() {
  3348. m.deleted_at = nil
  3349. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  3350. }
  3351. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3352. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  3353. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  3354. return ok
  3355. }
  3356. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3357. func (m *BatchMsgMutation) ResetDeletedAt() {
  3358. m.deleted_at = nil
  3359. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  3360. }
  3361. // SetStatus sets the "status" field.
  3362. func (m *BatchMsgMutation) SetStatus(u uint8) {
  3363. m.status = &u
  3364. m.addstatus = nil
  3365. }
  3366. // Status returns the value of the "status" field in the mutation.
  3367. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  3368. v := m.status
  3369. if v == nil {
  3370. return
  3371. }
  3372. return *v, true
  3373. }
  3374. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  3375. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3376. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3377. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  3378. if !m.op.Is(OpUpdateOne) {
  3379. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3380. }
  3381. if m.id == nil || m.oldValue == nil {
  3382. return v, errors.New("OldStatus requires an ID field in the mutation")
  3383. }
  3384. oldValue, err := m.oldValue(ctx)
  3385. if err != nil {
  3386. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3387. }
  3388. return oldValue.Status, nil
  3389. }
  3390. // AddStatus adds u to the "status" field.
  3391. func (m *BatchMsgMutation) AddStatus(u int8) {
  3392. if m.addstatus != nil {
  3393. *m.addstatus += u
  3394. } else {
  3395. m.addstatus = &u
  3396. }
  3397. }
  3398. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3399. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  3400. v := m.addstatus
  3401. if v == nil {
  3402. return
  3403. }
  3404. return *v, true
  3405. }
  3406. // ClearStatus clears the value of the "status" field.
  3407. func (m *BatchMsgMutation) ClearStatus() {
  3408. m.status = nil
  3409. m.addstatus = nil
  3410. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  3411. }
  3412. // StatusCleared returns if the "status" field was cleared in this mutation.
  3413. func (m *BatchMsgMutation) StatusCleared() bool {
  3414. _, ok := m.clearedFields[batchmsg.FieldStatus]
  3415. return ok
  3416. }
  3417. // ResetStatus resets all changes to the "status" field.
  3418. func (m *BatchMsgMutation) ResetStatus() {
  3419. m.status = nil
  3420. m.addstatus = nil
  3421. delete(m.clearedFields, batchmsg.FieldStatus)
  3422. }
  3423. // SetBatchNo sets the "batch_no" field.
  3424. func (m *BatchMsgMutation) SetBatchNo(s string) {
  3425. m.batch_no = &s
  3426. }
  3427. // BatchNo returns the value of the "batch_no" field in the mutation.
  3428. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  3429. v := m.batch_no
  3430. if v == nil {
  3431. return
  3432. }
  3433. return *v, true
  3434. }
  3435. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  3436. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3438. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  3439. if !m.op.Is(OpUpdateOne) {
  3440. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  3441. }
  3442. if m.id == nil || m.oldValue == nil {
  3443. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  3444. }
  3445. oldValue, err := m.oldValue(ctx)
  3446. if err != nil {
  3447. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  3448. }
  3449. return oldValue.BatchNo, nil
  3450. }
  3451. // ClearBatchNo clears the value of the "batch_no" field.
  3452. func (m *BatchMsgMutation) ClearBatchNo() {
  3453. m.batch_no = nil
  3454. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  3455. }
  3456. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  3457. func (m *BatchMsgMutation) BatchNoCleared() bool {
  3458. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  3459. return ok
  3460. }
  3461. // ResetBatchNo resets all changes to the "batch_no" field.
  3462. func (m *BatchMsgMutation) ResetBatchNo() {
  3463. m.batch_no = nil
  3464. delete(m.clearedFields, batchmsg.FieldBatchNo)
  3465. }
  3466. // SetTaskName sets the "task_name" field.
  3467. func (m *BatchMsgMutation) SetTaskName(s string) {
  3468. m.task_name = &s
  3469. }
  3470. // TaskName returns the value of the "task_name" field in the mutation.
  3471. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  3472. v := m.task_name
  3473. if v == nil {
  3474. return
  3475. }
  3476. return *v, true
  3477. }
  3478. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  3479. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3481. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  3482. if !m.op.Is(OpUpdateOne) {
  3483. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  3484. }
  3485. if m.id == nil || m.oldValue == nil {
  3486. return v, errors.New("OldTaskName requires an ID field in the mutation")
  3487. }
  3488. oldValue, err := m.oldValue(ctx)
  3489. if err != nil {
  3490. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  3491. }
  3492. return oldValue.TaskName, nil
  3493. }
  3494. // ClearTaskName clears the value of the "task_name" field.
  3495. func (m *BatchMsgMutation) ClearTaskName() {
  3496. m.task_name = nil
  3497. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  3498. }
  3499. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  3500. func (m *BatchMsgMutation) TaskNameCleared() bool {
  3501. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  3502. return ok
  3503. }
  3504. // ResetTaskName resets all changes to the "task_name" field.
  3505. func (m *BatchMsgMutation) ResetTaskName() {
  3506. m.task_name = nil
  3507. delete(m.clearedFields, batchmsg.FieldTaskName)
  3508. }
  3509. // SetFromwxid sets the "fromwxid" field.
  3510. func (m *BatchMsgMutation) SetFromwxid(s string) {
  3511. m.fromwxid = &s
  3512. }
  3513. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  3514. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  3515. v := m.fromwxid
  3516. if v == nil {
  3517. return
  3518. }
  3519. return *v, true
  3520. }
  3521. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  3522. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3524. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  3525. if !m.op.Is(OpUpdateOne) {
  3526. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  3527. }
  3528. if m.id == nil || m.oldValue == nil {
  3529. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  3530. }
  3531. oldValue, err := m.oldValue(ctx)
  3532. if err != nil {
  3533. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  3534. }
  3535. return oldValue.Fromwxid, nil
  3536. }
  3537. // ClearFromwxid clears the value of the "fromwxid" field.
  3538. func (m *BatchMsgMutation) ClearFromwxid() {
  3539. m.fromwxid = nil
  3540. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  3541. }
  3542. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  3543. func (m *BatchMsgMutation) FromwxidCleared() bool {
  3544. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  3545. return ok
  3546. }
  3547. // ResetFromwxid resets all changes to the "fromwxid" field.
  3548. func (m *BatchMsgMutation) ResetFromwxid() {
  3549. m.fromwxid = nil
  3550. delete(m.clearedFields, batchmsg.FieldFromwxid)
  3551. }
  3552. // SetMsg sets the "msg" field.
  3553. func (m *BatchMsgMutation) SetMsg(s string) {
  3554. m.msg = &s
  3555. }
  3556. // Msg returns the value of the "msg" field in the mutation.
  3557. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  3558. v := m.msg
  3559. if v == nil {
  3560. return
  3561. }
  3562. return *v, true
  3563. }
  3564. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  3565. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3567. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  3568. if !m.op.Is(OpUpdateOne) {
  3569. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  3570. }
  3571. if m.id == nil || m.oldValue == nil {
  3572. return v, errors.New("OldMsg requires an ID field in the mutation")
  3573. }
  3574. oldValue, err := m.oldValue(ctx)
  3575. if err != nil {
  3576. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  3577. }
  3578. return oldValue.Msg, nil
  3579. }
  3580. // ClearMsg clears the value of the "msg" field.
  3581. func (m *BatchMsgMutation) ClearMsg() {
  3582. m.msg = nil
  3583. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  3584. }
  3585. // MsgCleared returns if the "msg" field was cleared in this mutation.
  3586. func (m *BatchMsgMutation) MsgCleared() bool {
  3587. _, ok := m.clearedFields[batchmsg.FieldMsg]
  3588. return ok
  3589. }
  3590. // ResetMsg resets all changes to the "msg" field.
  3591. func (m *BatchMsgMutation) ResetMsg() {
  3592. m.msg = nil
  3593. delete(m.clearedFields, batchmsg.FieldMsg)
  3594. }
  3595. // SetTag sets the "tag" field.
  3596. func (m *BatchMsgMutation) SetTag(s string) {
  3597. m.tag = &s
  3598. }
  3599. // Tag returns the value of the "tag" field in the mutation.
  3600. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  3601. v := m.tag
  3602. if v == nil {
  3603. return
  3604. }
  3605. return *v, true
  3606. }
  3607. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  3608. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3610. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  3611. if !m.op.Is(OpUpdateOne) {
  3612. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  3613. }
  3614. if m.id == nil || m.oldValue == nil {
  3615. return v, errors.New("OldTag requires an ID field in the mutation")
  3616. }
  3617. oldValue, err := m.oldValue(ctx)
  3618. if err != nil {
  3619. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  3620. }
  3621. return oldValue.Tag, nil
  3622. }
  3623. // ClearTag clears the value of the "tag" field.
  3624. func (m *BatchMsgMutation) ClearTag() {
  3625. m.tag = nil
  3626. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  3627. }
  3628. // TagCleared returns if the "tag" field was cleared in this mutation.
  3629. func (m *BatchMsgMutation) TagCleared() bool {
  3630. _, ok := m.clearedFields[batchmsg.FieldTag]
  3631. return ok
  3632. }
  3633. // ResetTag resets all changes to the "tag" field.
  3634. func (m *BatchMsgMutation) ResetTag() {
  3635. m.tag = nil
  3636. delete(m.clearedFields, batchmsg.FieldTag)
  3637. }
  3638. // SetTagids sets the "tagids" field.
  3639. func (m *BatchMsgMutation) SetTagids(s string) {
  3640. m.tagids = &s
  3641. }
  3642. // Tagids returns the value of the "tagids" field in the mutation.
  3643. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  3644. v := m.tagids
  3645. if v == nil {
  3646. return
  3647. }
  3648. return *v, true
  3649. }
  3650. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  3651. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3653. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  3654. if !m.op.Is(OpUpdateOne) {
  3655. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  3656. }
  3657. if m.id == nil || m.oldValue == nil {
  3658. return v, errors.New("OldTagids requires an ID field in the mutation")
  3659. }
  3660. oldValue, err := m.oldValue(ctx)
  3661. if err != nil {
  3662. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  3663. }
  3664. return oldValue.Tagids, nil
  3665. }
  3666. // ClearTagids clears the value of the "tagids" field.
  3667. func (m *BatchMsgMutation) ClearTagids() {
  3668. m.tagids = nil
  3669. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  3670. }
  3671. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  3672. func (m *BatchMsgMutation) TagidsCleared() bool {
  3673. _, ok := m.clearedFields[batchmsg.FieldTagids]
  3674. return ok
  3675. }
  3676. // ResetTagids resets all changes to the "tagids" field.
  3677. func (m *BatchMsgMutation) ResetTagids() {
  3678. m.tagids = nil
  3679. delete(m.clearedFields, batchmsg.FieldTagids)
  3680. }
  3681. // SetTotal sets the "total" field.
  3682. func (m *BatchMsgMutation) SetTotal(i int32) {
  3683. m.total = &i
  3684. m.addtotal = nil
  3685. }
  3686. // Total returns the value of the "total" field in the mutation.
  3687. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  3688. v := m.total
  3689. if v == nil {
  3690. return
  3691. }
  3692. return *v, true
  3693. }
  3694. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  3695. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3697. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  3698. if !m.op.Is(OpUpdateOne) {
  3699. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  3700. }
  3701. if m.id == nil || m.oldValue == nil {
  3702. return v, errors.New("OldTotal requires an ID field in the mutation")
  3703. }
  3704. oldValue, err := m.oldValue(ctx)
  3705. if err != nil {
  3706. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  3707. }
  3708. return oldValue.Total, nil
  3709. }
  3710. // AddTotal adds i to the "total" field.
  3711. func (m *BatchMsgMutation) AddTotal(i int32) {
  3712. if m.addtotal != nil {
  3713. *m.addtotal += i
  3714. } else {
  3715. m.addtotal = &i
  3716. }
  3717. }
  3718. // AddedTotal returns the value that was added to the "total" field in this mutation.
  3719. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  3720. v := m.addtotal
  3721. if v == nil {
  3722. return
  3723. }
  3724. return *v, true
  3725. }
  3726. // ClearTotal clears the value of the "total" field.
  3727. func (m *BatchMsgMutation) ClearTotal() {
  3728. m.total = nil
  3729. m.addtotal = nil
  3730. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  3731. }
  3732. // TotalCleared returns if the "total" field was cleared in this mutation.
  3733. func (m *BatchMsgMutation) TotalCleared() bool {
  3734. _, ok := m.clearedFields[batchmsg.FieldTotal]
  3735. return ok
  3736. }
  3737. // ResetTotal resets all changes to the "total" field.
  3738. func (m *BatchMsgMutation) ResetTotal() {
  3739. m.total = nil
  3740. m.addtotal = nil
  3741. delete(m.clearedFields, batchmsg.FieldTotal)
  3742. }
  3743. // SetSuccess sets the "success" field.
  3744. func (m *BatchMsgMutation) SetSuccess(i int32) {
  3745. m.success = &i
  3746. m.addsuccess = nil
  3747. }
  3748. // Success returns the value of the "success" field in the mutation.
  3749. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  3750. v := m.success
  3751. if v == nil {
  3752. return
  3753. }
  3754. return *v, true
  3755. }
  3756. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  3757. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3758. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3759. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  3760. if !m.op.Is(OpUpdateOne) {
  3761. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  3762. }
  3763. if m.id == nil || m.oldValue == nil {
  3764. return v, errors.New("OldSuccess requires an ID field in the mutation")
  3765. }
  3766. oldValue, err := m.oldValue(ctx)
  3767. if err != nil {
  3768. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  3769. }
  3770. return oldValue.Success, nil
  3771. }
  3772. // AddSuccess adds i to the "success" field.
  3773. func (m *BatchMsgMutation) AddSuccess(i int32) {
  3774. if m.addsuccess != nil {
  3775. *m.addsuccess += i
  3776. } else {
  3777. m.addsuccess = &i
  3778. }
  3779. }
  3780. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  3781. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  3782. v := m.addsuccess
  3783. if v == nil {
  3784. return
  3785. }
  3786. return *v, true
  3787. }
  3788. // ClearSuccess clears the value of the "success" field.
  3789. func (m *BatchMsgMutation) ClearSuccess() {
  3790. m.success = nil
  3791. m.addsuccess = nil
  3792. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  3793. }
  3794. // SuccessCleared returns if the "success" field was cleared in this mutation.
  3795. func (m *BatchMsgMutation) SuccessCleared() bool {
  3796. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  3797. return ok
  3798. }
  3799. // ResetSuccess resets all changes to the "success" field.
  3800. func (m *BatchMsgMutation) ResetSuccess() {
  3801. m.success = nil
  3802. m.addsuccess = nil
  3803. delete(m.clearedFields, batchmsg.FieldSuccess)
  3804. }
  3805. // SetFail sets the "fail" field.
  3806. func (m *BatchMsgMutation) SetFail(i int32) {
  3807. m.fail = &i
  3808. m.addfail = nil
  3809. }
  3810. // Fail returns the value of the "fail" field in the mutation.
  3811. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  3812. v := m.fail
  3813. if v == nil {
  3814. return
  3815. }
  3816. return *v, true
  3817. }
  3818. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  3819. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3820. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3821. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  3822. if !m.op.Is(OpUpdateOne) {
  3823. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  3824. }
  3825. if m.id == nil || m.oldValue == nil {
  3826. return v, errors.New("OldFail requires an ID field in the mutation")
  3827. }
  3828. oldValue, err := m.oldValue(ctx)
  3829. if err != nil {
  3830. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  3831. }
  3832. return oldValue.Fail, nil
  3833. }
  3834. // AddFail adds i to the "fail" field.
  3835. func (m *BatchMsgMutation) AddFail(i int32) {
  3836. if m.addfail != nil {
  3837. *m.addfail += i
  3838. } else {
  3839. m.addfail = &i
  3840. }
  3841. }
  3842. // AddedFail returns the value that was added to the "fail" field in this mutation.
  3843. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  3844. v := m.addfail
  3845. if v == nil {
  3846. return
  3847. }
  3848. return *v, true
  3849. }
  3850. // ClearFail clears the value of the "fail" field.
  3851. func (m *BatchMsgMutation) ClearFail() {
  3852. m.fail = nil
  3853. m.addfail = nil
  3854. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  3855. }
  3856. // FailCleared returns if the "fail" field was cleared in this mutation.
  3857. func (m *BatchMsgMutation) FailCleared() bool {
  3858. _, ok := m.clearedFields[batchmsg.FieldFail]
  3859. return ok
  3860. }
  3861. // ResetFail resets all changes to the "fail" field.
  3862. func (m *BatchMsgMutation) ResetFail() {
  3863. m.fail = nil
  3864. m.addfail = nil
  3865. delete(m.clearedFields, batchmsg.FieldFail)
  3866. }
  3867. // SetStartTime sets the "start_time" field.
  3868. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  3869. m.start_time = &t
  3870. }
  3871. // StartTime returns the value of the "start_time" field in the mutation.
  3872. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  3873. v := m.start_time
  3874. if v == nil {
  3875. return
  3876. }
  3877. return *v, true
  3878. }
  3879. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  3880. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3881. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3882. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  3883. if !m.op.Is(OpUpdateOne) {
  3884. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  3885. }
  3886. if m.id == nil || m.oldValue == nil {
  3887. return v, errors.New("OldStartTime requires an ID field in the mutation")
  3888. }
  3889. oldValue, err := m.oldValue(ctx)
  3890. if err != nil {
  3891. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  3892. }
  3893. return oldValue.StartTime, nil
  3894. }
  3895. // ClearStartTime clears the value of the "start_time" field.
  3896. func (m *BatchMsgMutation) ClearStartTime() {
  3897. m.start_time = nil
  3898. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  3899. }
  3900. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  3901. func (m *BatchMsgMutation) StartTimeCleared() bool {
  3902. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  3903. return ok
  3904. }
  3905. // ResetStartTime resets all changes to the "start_time" field.
  3906. func (m *BatchMsgMutation) ResetStartTime() {
  3907. m.start_time = nil
  3908. delete(m.clearedFields, batchmsg.FieldStartTime)
  3909. }
  3910. // SetStopTime sets the "stop_time" field.
  3911. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  3912. m.stop_time = &t
  3913. }
  3914. // StopTime returns the value of the "stop_time" field in the mutation.
  3915. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  3916. v := m.stop_time
  3917. if v == nil {
  3918. return
  3919. }
  3920. return *v, true
  3921. }
  3922. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  3923. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3924. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3925. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  3926. if !m.op.Is(OpUpdateOne) {
  3927. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  3928. }
  3929. if m.id == nil || m.oldValue == nil {
  3930. return v, errors.New("OldStopTime requires an ID field in the mutation")
  3931. }
  3932. oldValue, err := m.oldValue(ctx)
  3933. if err != nil {
  3934. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  3935. }
  3936. return oldValue.StopTime, nil
  3937. }
  3938. // ClearStopTime clears the value of the "stop_time" field.
  3939. func (m *BatchMsgMutation) ClearStopTime() {
  3940. m.stop_time = nil
  3941. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  3942. }
  3943. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  3944. func (m *BatchMsgMutation) StopTimeCleared() bool {
  3945. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  3946. return ok
  3947. }
  3948. // ResetStopTime resets all changes to the "stop_time" field.
  3949. func (m *BatchMsgMutation) ResetStopTime() {
  3950. m.stop_time = nil
  3951. delete(m.clearedFields, batchmsg.FieldStopTime)
  3952. }
  3953. // SetSendTime sets the "send_time" field.
  3954. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  3955. m.send_time = &t
  3956. }
  3957. // SendTime returns the value of the "send_time" field in the mutation.
  3958. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  3959. v := m.send_time
  3960. if v == nil {
  3961. return
  3962. }
  3963. return *v, true
  3964. }
  3965. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  3966. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  3967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3968. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  3969. if !m.op.Is(OpUpdateOne) {
  3970. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  3971. }
  3972. if m.id == nil || m.oldValue == nil {
  3973. return v, errors.New("OldSendTime requires an ID field in the mutation")
  3974. }
  3975. oldValue, err := m.oldValue(ctx)
  3976. if err != nil {
  3977. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  3978. }
  3979. return oldValue.SendTime, nil
  3980. }
  3981. // ClearSendTime clears the value of the "send_time" field.
  3982. func (m *BatchMsgMutation) ClearSendTime() {
  3983. m.send_time = nil
  3984. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  3985. }
  3986. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  3987. func (m *BatchMsgMutation) SendTimeCleared() bool {
  3988. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  3989. return ok
  3990. }
  3991. // ResetSendTime resets all changes to the "send_time" field.
  3992. func (m *BatchMsgMutation) ResetSendTime() {
  3993. m.send_time = nil
  3994. delete(m.clearedFields, batchmsg.FieldSendTime)
  3995. }
  3996. // SetType sets the "type" field.
  3997. func (m *BatchMsgMutation) SetType(i int32) {
  3998. m._type = &i
  3999. m.add_type = nil
  4000. }
  4001. // GetType returns the value of the "type" field in the mutation.
  4002. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  4003. v := m._type
  4004. if v == nil {
  4005. return
  4006. }
  4007. return *v, true
  4008. }
  4009. // OldType returns the old "type" field's value of the BatchMsg entity.
  4010. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4012. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  4013. if !m.op.Is(OpUpdateOne) {
  4014. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4015. }
  4016. if m.id == nil || m.oldValue == nil {
  4017. return v, errors.New("OldType requires an ID field in the mutation")
  4018. }
  4019. oldValue, err := m.oldValue(ctx)
  4020. if err != nil {
  4021. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4022. }
  4023. return oldValue.Type, nil
  4024. }
  4025. // AddType adds i to the "type" field.
  4026. func (m *BatchMsgMutation) AddType(i int32) {
  4027. if m.add_type != nil {
  4028. *m.add_type += i
  4029. } else {
  4030. m.add_type = &i
  4031. }
  4032. }
  4033. // AddedType returns the value that was added to the "type" field in this mutation.
  4034. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4035. v := m.add_type
  4036. if v == nil {
  4037. return
  4038. }
  4039. return *v, true
  4040. }
  4041. // ClearType clears the value of the "type" field.
  4042. func (m *BatchMsgMutation) ClearType() {
  4043. m._type = nil
  4044. m.add_type = nil
  4045. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4046. }
  4047. // TypeCleared returns if the "type" field was cleared in this mutation.
  4048. func (m *BatchMsgMutation) TypeCleared() bool {
  4049. _, ok := m.clearedFields[batchmsg.FieldType]
  4050. return ok
  4051. }
  4052. // ResetType resets all changes to the "type" field.
  4053. func (m *BatchMsgMutation) ResetType() {
  4054. m._type = nil
  4055. m.add_type = nil
  4056. delete(m.clearedFields, batchmsg.FieldType)
  4057. }
  4058. // SetOrganizationID sets the "organization_id" field.
  4059. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4060. m.organization_id = &u
  4061. m.addorganization_id = nil
  4062. }
  4063. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4064. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4065. v := m.organization_id
  4066. if v == nil {
  4067. return
  4068. }
  4069. return *v, true
  4070. }
  4071. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4072. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4074. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4075. if !m.op.Is(OpUpdateOne) {
  4076. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4077. }
  4078. if m.id == nil || m.oldValue == nil {
  4079. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4080. }
  4081. oldValue, err := m.oldValue(ctx)
  4082. if err != nil {
  4083. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4084. }
  4085. return oldValue.OrganizationID, nil
  4086. }
  4087. // AddOrganizationID adds u to the "organization_id" field.
  4088. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4089. if m.addorganization_id != nil {
  4090. *m.addorganization_id += u
  4091. } else {
  4092. m.addorganization_id = &u
  4093. }
  4094. }
  4095. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4096. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4097. v := m.addorganization_id
  4098. if v == nil {
  4099. return
  4100. }
  4101. return *v, true
  4102. }
  4103. // ResetOrganizationID resets all changes to the "organization_id" field.
  4104. func (m *BatchMsgMutation) ResetOrganizationID() {
  4105. m.organization_id = nil
  4106. m.addorganization_id = nil
  4107. }
  4108. // Where appends a list predicates to the BatchMsgMutation builder.
  4109. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  4110. m.predicates = append(m.predicates, ps...)
  4111. }
  4112. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  4113. // users can use type-assertion to append predicates that do not depend on any generated package.
  4114. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  4115. p := make([]predicate.BatchMsg, len(ps))
  4116. for i := range ps {
  4117. p[i] = ps[i]
  4118. }
  4119. m.Where(p...)
  4120. }
  4121. // Op returns the operation name.
  4122. func (m *BatchMsgMutation) Op() Op {
  4123. return m.op
  4124. }
  4125. // SetOp allows setting the mutation operation.
  4126. func (m *BatchMsgMutation) SetOp(op Op) {
  4127. m.op = op
  4128. }
  4129. // Type returns the node type of this mutation (BatchMsg).
  4130. func (m *BatchMsgMutation) Type() string {
  4131. return m.typ
  4132. }
  4133. // Fields returns all fields that were changed during this mutation. Note that in
  4134. // order to get all numeric fields that were incremented/decremented, call
  4135. // AddedFields().
  4136. func (m *BatchMsgMutation) Fields() []string {
  4137. fields := make([]string, 0, 18)
  4138. if m.created_at != nil {
  4139. fields = append(fields, batchmsg.FieldCreatedAt)
  4140. }
  4141. if m.updated_at != nil {
  4142. fields = append(fields, batchmsg.FieldUpdatedAt)
  4143. }
  4144. if m.deleted_at != nil {
  4145. fields = append(fields, batchmsg.FieldDeletedAt)
  4146. }
  4147. if m.status != nil {
  4148. fields = append(fields, batchmsg.FieldStatus)
  4149. }
  4150. if m.batch_no != nil {
  4151. fields = append(fields, batchmsg.FieldBatchNo)
  4152. }
  4153. if m.task_name != nil {
  4154. fields = append(fields, batchmsg.FieldTaskName)
  4155. }
  4156. if m.fromwxid != nil {
  4157. fields = append(fields, batchmsg.FieldFromwxid)
  4158. }
  4159. if m.msg != nil {
  4160. fields = append(fields, batchmsg.FieldMsg)
  4161. }
  4162. if m.tag != nil {
  4163. fields = append(fields, batchmsg.FieldTag)
  4164. }
  4165. if m.tagids != nil {
  4166. fields = append(fields, batchmsg.FieldTagids)
  4167. }
  4168. if m.total != nil {
  4169. fields = append(fields, batchmsg.FieldTotal)
  4170. }
  4171. if m.success != nil {
  4172. fields = append(fields, batchmsg.FieldSuccess)
  4173. }
  4174. if m.fail != nil {
  4175. fields = append(fields, batchmsg.FieldFail)
  4176. }
  4177. if m.start_time != nil {
  4178. fields = append(fields, batchmsg.FieldStartTime)
  4179. }
  4180. if m.stop_time != nil {
  4181. fields = append(fields, batchmsg.FieldStopTime)
  4182. }
  4183. if m.send_time != nil {
  4184. fields = append(fields, batchmsg.FieldSendTime)
  4185. }
  4186. if m._type != nil {
  4187. fields = append(fields, batchmsg.FieldType)
  4188. }
  4189. if m.organization_id != nil {
  4190. fields = append(fields, batchmsg.FieldOrganizationID)
  4191. }
  4192. return fields
  4193. }
  4194. // Field returns the value of a field with the given name. The second boolean
  4195. // return value indicates that this field was not set, or was not defined in the
  4196. // schema.
  4197. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  4198. switch name {
  4199. case batchmsg.FieldCreatedAt:
  4200. return m.CreatedAt()
  4201. case batchmsg.FieldUpdatedAt:
  4202. return m.UpdatedAt()
  4203. case batchmsg.FieldDeletedAt:
  4204. return m.DeletedAt()
  4205. case batchmsg.FieldStatus:
  4206. return m.Status()
  4207. case batchmsg.FieldBatchNo:
  4208. return m.BatchNo()
  4209. case batchmsg.FieldTaskName:
  4210. return m.TaskName()
  4211. case batchmsg.FieldFromwxid:
  4212. return m.Fromwxid()
  4213. case batchmsg.FieldMsg:
  4214. return m.Msg()
  4215. case batchmsg.FieldTag:
  4216. return m.Tag()
  4217. case batchmsg.FieldTagids:
  4218. return m.Tagids()
  4219. case batchmsg.FieldTotal:
  4220. return m.Total()
  4221. case batchmsg.FieldSuccess:
  4222. return m.Success()
  4223. case batchmsg.FieldFail:
  4224. return m.Fail()
  4225. case batchmsg.FieldStartTime:
  4226. return m.StartTime()
  4227. case batchmsg.FieldStopTime:
  4228. return m.StopTime()
  4229. case batchmsg.FieldSendTime:
  4230. return m.SendTime()
  4231. case batchmsg.FieldType:
  4232. return m.GetType()
  4233. case batchmsg.FieldOrganizationID:
  4234. return m.OrganizationID()
  4235. }
  4236. return nil, false
  4237. }
  4238. // OldField returns the old value of the field from the database. An error is
  4239. // returned if the mutation operation is not UpdateOne, or the query to the
  4240. // database failed.
  4241. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4242. switch name {
  4243. case batchmsg.FieldCreatedAt:
  4244. return m.OldCreatedAt(ctx)
  4245. case batchmsg.FieldUpdatedAt:
  4246. return m.OldUpdatedAt(ctx)
  4247. case batchmsg.FieldDeletedAt:
  4248. return m.OldDeletedAt(ctx)
  4249. case batchmsg.FieldStatus:
  4250. return m.OldStatus(ctx)
  4251. case batchmsg.FieldBatchNo:
  4252. return m.OldBatchNo(ctx)
  4253. case batchmsg.FieldTaskName:
  4254. return m.OldTaskName(ctx)
  4255. case batchmsg.FieldFromwxid:
  4256. return m.OldFromwxid(ctx)
  4257. case batchmsg.FieldMsg:
  4258. return m.OldMsg(ctx)
  4259. case batchmsg.FieldTag:
  4260. return m.OldTag(ctx)
  4261. case batchmsg.FieldTagids:
  4262. return m.OldTagids(ctx)
  4263. case batchmsg.FieldTotal:
  4264. return m.OldTotal(ctx)
  4265. case batchmsg.FieldSuccess:
  4266. return m.OldSuccess(ctx)
  4267. case batchmsg.FieldFail:
  4268. return m.OldFail(ctx)
  4269. case batchmsg.FieldStartTime:
  4270. return m.OldStartTime(ctx)
  4271. case batchmsg.FieldStopTime:
  4272. return m.OldStopTime(ctx)
  4273. case batchmsg.FieldSendTime:
  4274. return m.OldSendTime(ctx)
  4275. case batchmsg.FieldType:
  4276. return m.OldType(ctx)
  4277. case batchmsg.FieldOrganizationID:
  4278. return m.OldOrganizationID(ctx)
  4279. }
  4280. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  4281. }
  4282. // SetField sets the value of a field with the given name. It returns an error if
  4283. // the field is not defined in the schema, or if the type mismatched the field
  4284. // type.
  4285. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  4286. switch name {
  4287. case batchmsg.FieldCreatedAt:
  4288. v, ok := value.(time.Time)
  4289. if !ok {
  4290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4291. }
  4292. m.SetCreatedAt(v)
  4293. return nil
  4294. case batchmsg.FieldUpdatedAt:
  4295. v, ok := value.(time.Time)
  4296. if !ok {
  4297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4298. }
  4299. m.SetUpdatedAt(v)
  4300. return nil
  4301. case batchmsg.FieldDeletedAt:
  4302. v, ok := value.(time.Time)
  4303. if !ok {
  4304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4305. }
  4306. m.SetDeletedAt(v)
  4307. return nil
  4308. case batchmsg.FieldStatus:
  4309. v, ok := value.(uint8)
  4310. if !ok {
  4311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4312. }
  4313. m.SetStatus(v)
  4314. return nil
  4315. case batchmsg.FieldBatchNo:
  4316. v, ok := value.(string)
  4317. if !ok {
  4318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4319. }
  4320. m.SetBatchNo(v)
  4321. return nil
  4322. case batchmsg.FieldTaskName:
  4323. v, ok := value.(string)
  4324. if !ok {
  4325. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4326. }
  4327. m.SetTaskName(v)
  4328. return nil
  4329. case batchmsg.FieldFromwxid:
  4330. v, ok := value.(string)
  4331. if !ok {
  4332. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4333. }
  4334. m.SetFromwxid(v)
  4335. return nil
  4336. case batchmsg.FieldMsg:
  4337. v, ok := value.(string)
  4338. if !ok {
  4339. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4340. }
  4341. m.SetMsg(v)
  4342. return nil
  4343. case batchmsg.FieldTag:
  4344. v, ok := value.(string)
  4345. if !ok {
  4346. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4347. }
  4348. m.SetTag(v)
  4349. return nil
  4350. case batchmsg.FieldTagids:
  4351. v, ok := value.(string)
  4352. if !ok {
  4353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4354. }
  4355. m.SetTagids(v)
  4356. return nil
  4357. case batchmsg.FieldTotal:
  4358. v, ok := value.(int32)
  4359. if !ok {
  4360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4361. }
  4362. m.SetTotal(v)
  4363. return nil
  4364. case batchmsg.FieldSuccess:
  4365. v, ok := value.(int32)
  4366. if !ok {
  4367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4368. }
  4369. m.SetSuccess(v)
  4370. return nil
  4371. case batchmsg.FieldFail:
  4372. v, ok := value.(int32)
  4373. if !ok {
  4374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4375. }
  4376. m.SetFail(v)
  4377. return nil
  4378. case batchmsg.FieldStartTime:
  4379. v, ok := value.(time.Time)
  4380. if !ok {
  4381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4382. }
  4383. m.SetStartTime(v)
  4384. return nil
  4385. case batchmsg.FieldStopTime:
  4386. v, ok := value.(time.Time)
  4387. if !ok {
  4388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4389. }
  4390. m.SetStopTime(v)
  4391. return nil
  4392. case batchmsg.FieldSendTime:
  4393. v, ok := value.(time.Time)
  4394. if !ok {
  4395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4396. }
  4397. m.SetSendTime(v)
  4398. return nil
  4399. case batchmsg.FieldType:
  4400. v, ok := value.(int32)
  4401. if !ok {
  4402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4403. }
  4404. m.SetType(v)
  4405. return nil
  4406. case batchmsg.FieldOrganizationID:
  4407. v, ok := value.(uint64)
  4408. if !ok {
  4409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4410. }
  4411. m.SetOrganizationID(v)
  4412. return nil
  4413. }
  4414. return fmt.Errorf("unknown BatchMsg field %s", name)
  4415. }
  4416. // AddedFields returns all numeric fields that were incremented/decremented during
  4417. // this mutation.
  4418. func (m *BatchMsgMutation) AddedFields() []string {
  4419. var fields []string
  4420. if m.addstatus != nil {
  4421. fields = append(fields, batchmsg.FieldStatus)
  4422. }
  4423. if m.addtotal != nil {
  4424. fields = append(fields, batchmsg.FieldTotal)
  4425. }
  4426. if m.addsuccess != nil {
  4427. fields = append(fields, batchmsg.FieldSuccess)
  4428. }
  4429. if m.addfail != nil {
  4430. fields = append(fields, batchmsg.FieldFail)
  4431. }
  4432. if m.add_type != nil {
  4433. fields = append(fields, batchmsg.FieldType)
  4434. }
  4435. if m.addorganization_id != nil {
  4436. fields = append(fields, batchmsg.FieldOrganizationID)
  4437. }
  4438. return fields
  4439. }
  4440. // AddedField returns the numeric value that was incremented/decremented on a field
  4441. // with the given name. The second boolean return value indicates that this field
  4442. // was not set, or was not defined in the schema.
  4443. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  4444. switch name {
  4445. case batchmsg.FieldStatus:
  4446. return m.AddedStatus()
  4447. case batchmsg.FieldTotal:
  4448. return m.AddedTotal()
  4449. case batchmsg.FieldSuccess:
  4450. return m.AddedSuccess()
  4451. case batchmsg.FieldFail:
  4452. return m.AddedFail()
  4453. case batchmsg.FieldType:
  4454. return m.AddedType()
  4455. case batchmsg.FieldOrganizationID:
  4456. return m.AddedOrganizationID()
  4457. }
  4458. return nil, false
  4459. }
  4460. // AddField adds the value to the field with the given name. It returns an error if
  4461. // the field is not defined in the schema, or if the type mismatched the field
  4462. // type.
  4463. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  4464. switch name {
  4465. case batchmsg.FieldStatus:
  4466. v, ok := value.(int8)
  4467. if !ok {
  4468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4469. }
  4470. m.AddStatus(v)
  4471. return nil
  4472. case batchmsg.FieldTotal:
  4473. v, ok := value.(int32)
  4474. if !ok {
  4475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4476. }
  4477. m.AddTotal(v)
  4478. return nil
  4479. case batchmsg.FieldSuccess:
  4480. v, ok := value.(int32)
  4481. if !ok {
  4482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4483. }
  4484. m.AddSuccess(v)
  4485. return nil
  4486. case batchmsg.FieldFail:
  4487. v, ok := value.(int32)
  4488. if !ok {
  4489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4490. }
  4491. m.AddFail(v)
  4492. return nil
  4493. case batchmsg.FieldType:
  4494. v, ok := value.(int32)
  4495. if !ok {
  4496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4497. }
  4498. m.AddType(v)
  4499. return nil
  4500. case batchmsg.FieldOrganizationID:
  4501. v, ok := value.(int64)
  4502. if !ok {
  4503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  4504. }
  4505. m.AddOrganizationID(v)
  4506. return nil
  4507. }
  4508. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  4509. }
  4510. // ClearedFields returns all nullable fields that were cleared during this
  4511. // mutation.
  4512. func (m *BatchMsgMutation) ClearedFields() []string {
  4513. var fields []string
  4514. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  4515. fields = append(fields, batchmsg.FieldDeletedAt)
  4516. }
  4517. if m.FieldCleared(batchmsg.FieldStatus) {
  4518. fields = append(fields, batchmsg.FieldStatus)
  4519. }
  4520. if m.FieldCleared(batchmsg.FieldBatchNo) {
  4521. fields = append(fields, batchmsg.FieldBatchNo)
  4522. }
  4523. if m.FieldCleared(batchmsg.FieldTaskName) {
  4524. fields = append(fields, batchmsg.FieldTaskName)
  4525. }
  4526. if m.FieldCleared(batchmsg.FieldFromwxid) {
  4527. fields = append(fields, batchmsg.FieldFromwxid)
  4528. }
  4529. if m.FieldCleared(batchmsg.FieldMsg) {
  4530. fields = append(fields, batchmsg.FieldMsg)
  4531. }
  4532. if m.FieldCleared(batchmsg.FieldTag) {
  4533. fields = append(fields, batchmsg.FieldTag)
  4534. }
  4535. if m.FieldCleared(batchmsg.FieldTagids) {
  4536. fields = append(fields, batchmsg.FieldTagids)
  4537. }
  4538. if m.FieldCleared(batchmsg.FieldTotal) {
  4539. fields = append(fields, batchmsg.FieldTotal)
  4540. }
  4541. if m.FieldCleared(batchmsg.FieldSuccess) {
  4542. fields = append(fields, batchmsg.FieldSuccess)
  4543. }
  4544. if m.FieldCleared(batchmsg.FieldFail) {
  4545. fields = append(fields, batchmsg.FieldFail)
  4546. }
  4547. if m.FieldCleared(batchmsg.FieldStartTime) {
  4548. fields = append(fields, batchmsg.FieldStartTime)
  4549. }
  4550. if m.FieldCleared(batchmsg.FieldStopTime) {
  4551. fields = append(fields, batchmsg.FieldStopTime)
  4552. }
  4553. if m.FieldCleared(batchmsg.FieldSendTime) {
  4554. fields = append(fields, batchmsg.FieldSendTime)
  4555. }
  4556. if m.FieldCleared(batchmsg.FieldType) {
  4557. fields = append(fields, batchmsg.FieldType)
  4558. }
  4559. return fields
  4560. }
  4561. // FieldCleared returns a boolean indicating if a field with the given name was
  4562. // cleared in this mutation.
  4563. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  4564. _, ok := m.clearedFields[name]
  4565. return ok
  4566. }
  4567. // ClearField clears the value of the field with the given name. It returns an
  4568. // error if the field is not defined in the schema.
  4569. func (m *BatchMsgMutation) ClearField(name string) error {
  4570. switch name {
  4571. case batchmsg.FieldDeletedAt:
  4572. m.ClearDeletedAt()
  4573. return nil
  4574. case batchmsg.FieldStatus:
  4575. m.ClearStatus()
  4576. return nil
  4577. case batchmsg.FieldBatchNo:
  4578. m.ClearBatchNo()
  4579. return nil
  4580. case batchmsg.FieldTaskName:
  4581. m.ClearTaskName()
  4582. return nil
  4583. case batchmsg.FieldFromwxid:
  4584. m.ClearFromwxid()
  4585. return nil
  4586. case batchmsg.FieldMsg:
  4587. m.ClearMsg()
  4588. return nil
  4589. case batchmsg.FieldTag:
  4590. m.ClearTag()
  4591. return nil
  4592. case batchmsg.FieldTagids:
  4593. m.ClearTagids()
  4594. return nil
  4595. case batchmsg.FieldTotal:
  4596. m.ClearTotal()
  4597. return nil
  4598. case batchmsg.FieldSuccess:
  4599. m.ClearSuccess()
  4600. return nil
  4601. case batchmsg.FieldFail:
  4602. m.ClearFail()
  4603. return nil
  4604. case batchmsg.FieldStartTime:
  4605. m.ClearStartTime()
  4606. return nil
  4607. case batchmsg.FieldStopTime:
  4608. m.ClearStopTime()
  4609. return nil
  4610. case batchmsg.FieldSendTime:
  4611. m.ClearSendTime()
  4612. return nil
  4613. case batchmsg.FieldType:
  4614. m.ClearType()
  4615. return nil
  4616. }
  4617. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  4618. }
  4619. // ResetField resets all changes in the mutation for the field with the given name.
  4620. // It returns an error if the field is not defined in the schema.
  4621. func (m *BatchMsgMutation) ResetField(name string) error {
  4622. switch name {
  4623. case batchmsg.FieldCreatedAt:
  4624. m.ResetCreatedAt()
  4625. return nil
  4626. case batchmsg.FieldUpdatedAt:
  4627. m.ResetUpdatedAt()
  4628. return nil
  4629. case batchmsg.FieldDeletedAt:
  4630. m.ResetDeletedAt()
  4631. return nil
  4632. case batchmsg.FieldStatus:
  4633. m.ResetStatus()
  4634. return nil
  4635. case batchmsg.FieldBatchNo:
  4636. m.ResetBatchNo()
  4637. return nil
  4638. case batchmsg.FieldTaskName:
  4639. m.ResetTaskName()
  4640. return nil
  4641. case batchmsg.FieldFromwxid:
  4642. m.ResetFromwxid()
  4643. return nil
  4644. case batchmsg.FieldMsg:
  4645. m.ResetMsg()
  4646. return nil
  4647. case batchmsg.FieldTag:
  4648. m.ResetTag()
  4649. return nil
  4650. case batchmsg.FieldTagids:
  4651. m.ResetTagids()
  4652. return nil
  4653. case batchmsg.FieldTotal:
  4654. m.ResetTotal()
  4655. return nil
  4656. case batchmsg.FieldSuccess:
  4657. m.ResetSuccess()
  4658. return nil
  4659. case batchmsg.FieldFail:
  4660. m.ResetFail()
  4661. return nil
  4662. case batchmsg.FieldStartTime:
  4663. m.ResetStartTime()
  4664. return nil
  4665. case batchmsg.FieldStopTime:
  4666. m.ResetStopTime()
  4667. return nil
  4668. case batchmsg.FieldSendTime:
  4669. m.ResetSendTime()
  4670. return nil
  4671. case batchmsg.FieldType:
  4672. m.ResetType()
  4673. return nil
  4674. case batchmsg.FieldOrganizationID:
  4675. m.ResetOrganizationID()
  4676. return nil
  4677. }
  4678. return fmt.Errorf("unknown BatchMsg field %s", name)
  4679. }
  4680. // AddedEdges returns all edge names that were set/added in this mutation.
  4681. func (m *BatchMsgMutation) AddedEdges() []string {
  4682. edges := make([]string, 0, 0)
  4683. return edges
  4684. }
  4685. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  4686. // name in this mutation.
  4687. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  4688. return nil
  4689. }
  4690. // RemovedEdges returns all edge names that were removed in this mutation.
  4691. func (m *BatchMsgMutation) RemovedEdges() []string {
  4692. edges := make([]string, 0, 0)
  4693. return edges
  4694. }
  4695. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  4696. // the given name in this mutation.
  4697. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  4698. return nil
  4699. }
  4700. // ClearedEdges returns all edge names that were cleared in this mutation.
  4701. func (m *BatchMsgMutation) ClearedEdges() []string {
  4702. edges := make([]string, 0, 0)
  4703. return edges
  4704. }
  4705. // EdgeCleared returns a boolean which indicates if the edge with the given name
  4706. // was cleared in this mutation.
  4707. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  4708. return false
  4709. }
  4710. // ClearEdge clears the value of the edge with the given name. It returns an error
  4711. // if that edge is not defined in the schema.
  4712. func (m *BatchMsgMutation) ClearEdge(name string) error {
  4713. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  4714. }
  4715. // ResetEdge resets all changes to the edge with the given name in this mutation.
  4716. // It returns an error if the edge is not defined in the schema.
  4717. func (m *BatchMsgMutation) ResetEdge(name string) error {
  4718. return fmt.Errorf("unknown BatchMsg edge %s", name)
  4719. }
  4720. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  4721. type CategoryMutation struct {
  4722. config
  4723. op Op
  4724. typ string
  4725. id *uint64
  4726. created_at *time.Time
  4727. updated_at *time.Time
  4728. deleted_at *time.Time
  4729. name *string
  4730. organization_id *uint64
  4731. addorganization_id *int64
  4732. clearedFields map[string]struct{}
  4733. done bool
  4734. oldValue func(context.Context) (*Category, error)
  4735. predicates []predicate.Category
  4736. }
  4737. var _ ent.Mutation = (*CategoryMutation)(nil)
  4738. // categoryOption allows management of the mutation configuration using functional options.
  4739. type categoryOption func(*CategoryMutation)
  4740. // newCategoryMutation creates new mutation for the Category entity.
  4741. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  4742. m := &CategoryMutation{
  4743. config: c,
  4744. op: op,
  4745. typ: TypeCategory,
  4746. clearedFields: make(map[string]struct{}),
  4747. }
  4748. for _, opt := range opts {
  4749. opt(m)
  4750. }
  4751. return m
  4752. }
  4753. // withCategoryID sets the ID field of the mutation.
  4754. func withCategoryID(id uint64) categoryOption {
  4755. return func(m *CategoryMutation) {
  4756. var (
  4757. err error
  4758. once sync.Once
  4759. value *Category
  4760. )
  4761. m.oldValue = func(ctx context.Context) (*Category, error) {
  4762. once.Do(func() {
  4763. if m.done {
  4764. err = errors.New("querying old values post mutation is not allowed")
  4765. } else {
  4766. value, err = m.Client().Category.Get(ctx, id)
  4767. }
  4768. })
  4769. return value, err
  4770. }
  4771. m.id = &id
  4772. }
  4773. }
  4774. // withCategory sets the old Category of the mutation.
  4775. func withCategory(node *Category) categoryOption {
  4776. return func(m *CategoryMutation) {
  4777. m.oldValue = func(context.Context) (*Category, error) {
  4778. return node, nil
  4779. }
  4780. m.id = &node.ID
  4781. }
  4782. }
  4783. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4784. // executed in a transaction (ent.Tx), a transactional client is returned.
  4785. func (m CategoryMutation) Client() *Client {
  4786. client := &Client{config: m.config}
  4787. client.init()
  4788. return client
  4789. }
  4790. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4791. // it returns an error otherwise.
  4792. func (m CategoryMutation) Tx() (*Tx, error) {
  4793. if _, ok := m.driver.(*txDriver); !ok {
  4794. return nil, errors.New("ent: mutation is not running in a transaction")
  4795. }
  4796. tx := &Tx{config: m.config}
  4797. tx.init()
  4798. return tx, nil
  4799. }
  4800. // SetID sets the value of the id field. Note that this
  4801. // operation is only accepted on creation of Category entities.
  4802. func (m *CategoryMutation) SetID(id uint64) {
  4803. m.id = &id
  4804. }
  4805. // ID returns the ID value in the mutation. Note that the ID is only available
  4806. // if it was provided to the builder or after it was returned from the database.
  4807. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  4808. if m.id == nil {
  4809. return
  4810. }
  4811. return *m.id, true
  4812. }
  4813. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4814. // That means, if the mutation is applied within a transaction with an isolation level such
  4815. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4816. // or updated by the mutation.
  4817. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  4818. switch {
  4819. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4820. id, exists := m.ID()
  4821. if exists {
  4822. return []uint64{id}, nil
  4823. }
  4824. fallthrough
  4825. case m.op.Is(OpUpdate | OpDelete):
  4826. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  4827. default:
  4828. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4829. }
  4830. }
  4831. // SetCreatedAt sets the "created_at" field.
  4832. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  4833. m.created_at = &t
  4834. }
  4835. // CreatedAt returns the value of the "created_at" field in the mutation.
  4836. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  4837. v := m.created_at
  4838. if v == nil {
  4839. return
  4840. }
  4841. return *v, true
  4842. }
  4843. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  4844. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4846. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4847. if !m.op.Is(OpUpdateOne) {
  4848. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4849. }
  4850. if m.id == nil || m.oldValue == nil {
  4851. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4852. }
  4853. oldValue, err := m.oldValue(ctx)
  4854. if err != nil {
  4855. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4856. }
  4857. return oldValue.CreatedAt, nil
  4858. }
  4859. // ResetCreatedAt resets all changes to the "created_at" field.
  4860. func (m *CategoryMutation) ResetCreatedAt() {
  4861. m.created_at = nil
  4862. }
  4863. // SetUpdatedAt sets the "updated_at" field.
  4864. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  4865. m.updated_at = &t
  4866. }
  4867. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4868. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  4869. v := m.updated_at
  4870. if v == nil {
  4871. return
  4872. }
  4873. return *v, true
  4874. }
  4875. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  4876. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4878. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4879. if !m.op.Is(OpUpdateOne) {
  4880. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4881. }
  4882. if m.id == nil || m.oldValue == nil {
  4883. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4884. }
  4885. oldValue, err := m.oldValue(ctx)
  4886. if err != nil {
  4887. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4888. }
  4889. return oldValue.UpdatedAt, nil
  4890. }
  4891. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4892. func (m *CategoryMutation) ResetUpdatedAt() {
  4893. m.updated_at = nil
  4894. }
  4895. // SetDeletedAt sets the "deleted_at" field.
  4896. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  4897. m.deleted_at = &t
  4898. }
  4899. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4900. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  4901. v := m.deleted_at
  4902. if v == nil {
  4903. return
  4904. }
  4905. return *v, true
  4906. }
  4907. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  4908. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4910. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4911. if !m.op.Is(OpUpdateOne) {
  4912. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4913. }
  4914. if m.id == nil || m.oldValue == nil {
  4915. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4916. }
  4917. oldValue, err := m.oldValue(ctx)
  4918. if err != nil {
  4919. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4920. }
  4921. return oldValue.DeletedAt, nil
  4922. }
  4923. // ClearDeletedAt clears the value of the "deleted_at" field.
  4924. func (m *CategoryMutation) ClearDeletedAt() {
  4925. m.deleted_at = nil
  4926. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  4927. }
  4928. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4929. func (m *CategoryMutation) DeletedAtCleared() bool {
  4930. _, ok := m.clearedFields[category.FieldDeletedAt]
  4931. return ok
  4932. }
  4933. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4934. func (m *CategoryMutation) ResetDeletedAt() {
  4935. m.deleted_at = nil
  4936. delete(m.clearedFields, category.FieldDeletedAt)
  4937. }
  4938. // SetName sets the "name" field.
  4939. func (m *CategoryMutation) SetName(s string) {
  4940. m.name = &s
  4941. }
  4942. // Name returns the value of the "name" field in the mutation.
  4943. func (m *CategoryMutation) Name() (r string, exists bool) {
  4944. v := m.name
  4945. if v == nil {
  4946. return
  4947. }
  4948. return *v, true
  4949. }
  4950. // OldName returns the old "name" field's value of the Category entity.
  4951. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4953. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  4954. if !m.op.Is(OpUpdateOne) {
  4955. return v, errors.New("OldName is only allowed on UpdateOne operations")
  4956. }
  4957. if m.id == nil || m.oldValue == nil {
  4958. return v, errors.New("OldName requires an ID field in the mutation")
  4959. }
  4960. oldValue, err := m.oldValue(ctx)
  4961. if err != nil {
  4962. return v, fmt.Errorf("querying old value for OldName: %w", err)
  4963. }
  4964. return oldValue.Name, nil
  4965. }
  4966. // ResetName resets all changes to the "name" field.
  4967. func (m *CategoryMutation) ResetName() {
  4968. m.name = nil
  4969. }
  4970. // SetOrganizationID sets the "organization_id" field.
  4971. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  4972. m.organization_id = &u
  4973. m.addorganization_id = nil
  4974. }
  4975. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4976. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  4977. v := m.organization_id
  4978. if v == nil {
  4979. return
  4980. }
  4981. return *v, true
  4982. }
  4983. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  4984. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  4985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4986. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4987. if !m.op.Is(OpUpdateOne) {
  4988. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4989. }
  4990. if m.id == nil || m.oldValue == nil {
  4991. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4992. }
  4993. oldValue, err := m.oldValue(ctx)
  4994. if err != nil {
  4995. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4996. }
  4997. return oldValue.OrganizationID, nil
  4998. }
  4999. // AddOrganizationID adds u to the "organization_id" field.
  5000. func (m *CategoryMutation) AddOrganizationID(u int64) {
  5001. if m.addorganization_id != nil {
  5002. *m.addorganization_id += u
  5003. } else {
  5004. m.addorganization_id = &u
  5005. }
  5006. }
  5007. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5008. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  5009. v := m.addorganization_id
  5010. if v == nil {
  5011. return
  5012. }
  5013. return *v, true
  5014. }
  5015. // ResetOrganizationID resets all changes to the "organization_id" field.
  5016. func (m *CategoryMutation) ResetOrganizationID() {
  5017. m.organization_id = nil
  5018. m.addorganization_id = nil
  5019. }
  5020. // Where appends a list predicates to the CategoryMutation builder.
  5021. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  5022. m.predicates = append(m.predicates, ps...)
  5023. }
  5024. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  5025. // users can use type-assertion to append predicates that do not depend on any generated package.
  5026. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  5027. p := make([]predicate.Category, len(ps))
  5028. for i := range ps {
  5029. p[i] = ps[i]
  5030. }
  5031. m.Where(p...)
  5032. }
  5033. // Op returns the operation name.
  5034. func (m *CategoryMutation) Op() Op {
  5035. return m.op
  5036. }
  5037. // SetOp allows setting the mutation operation.
  5038. func (m *CategoryMutation) SetOp(op Op) {
  5039. m.op = op
  5040. }
  5041. // Type returns the node type of this mutation (Category).
  5042. func (m *CategoryMutation) Type() string {
  5043. return m.typ
  5044. }
  5045. // Fields returns all fields that were changed during this mutation. Note that in
  5046. // order to get all numeric fields that were incremented/decremented, call
  5047. // AddedFields().
  5048. func (m *CategoryMutation) Fields() []string {
  5049. fields := make([]string, 0, 5)
  5050. if m.created_at != nil {
  5051. fields = append(fields, category.FieldCreatedAt)
  5052. }
  5053. if m.updated_at != nil {
  5054. fields = append(fields, category.FieldUpdatedAt)
  5055. }
  5056. if m.deleted_at != nil {
  5057. fields = append(fields, category.FieldDeletedAt)
  5058. }
  5059. if m.name != nil {
  5060. fields = append(fields, category.FieldName)
  5061. }
  5062. if m.organization_id != nil {
  5063. fields = append(fields, category.FieldOrganizationID)
  5064. }
  5065. return fields
  5066. }
  5067. // Field returns the value of a field with the given name. The second boolean
  5068. // return value indicates that this field was not set, or was not defined in the
  5069. // schema.
  5070. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  5071. switch name {
  5072. case category.FieldCreatedAt:
  5073. return m.CreatedAt()
  5074. case category.FieldUpdatedAt:
  5075. return m.UpdatedAt()
  5076. case category.FieldDeletedAt:
  5077. return m.DeletedAt()
  5078. case category.FieldName:
  5079. return m.Name()
  5080. case category.FieldOrganizationID:
  5081. return m.OrganizationID()
  5082. }
  5083. return nil, false
  5084. }
  5085. // OldField returns the old value of the field from the database. An error is
  5086. // returned if the mutation operation is not UpdateOne, or the query to the
  5087. // database failed.
  5088. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5089. switch name {
  5090. case category.FieldCreatedAt:
  5091. return m.OldCreatedAt(ctx)
  5092. case category.FieldUpdatedAt:
  5093. return m.OldUpdatedAt(ctx)
  5094. case category.FieldDeletedAt:
  5095. return m.OldDeletedAt(ctx)
  5096. case category.FieldName:
  5097. return m.OldName(ctx)
  5098. case category.FieldOrganizationID:
  5099. return m.OldOrganizationID(ctx)
  5100. }
  5101. return nil, fmt.Errorf("unknown Category field %s", name)
  5102. }
  5103. // SetField sets the value of a field with the given name. It returns an error if
  5104. // the field is not defined in the schema, or if the type mismatched the field
  5105. // type.
  5106. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  5107. switch name {
  5108. case category.FieldCreatedAt:
  5109. v, ok := value.(time.Time)
  5110. if !ok {
  5111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5112. }
  5113. m.SetCreatedAt(v)
  5114. return nil
  5115. case category.FieldUpdatedAt:
  5116. v, ok := value.(time.Time)
  5117. if !ok {
  5118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5119. }
  5120. m.SetUpdatedAt(v)
  5121. return nil
  5122. case category.FieldDeletedAt:
  5123. v, ok := value.(time.Time)
  5124. if !ok {
  5125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5126. }
  5127. m.SetDeletedAt(v)
  5128. return nil
  5129. case category.FieldName:
  5130. v, ok := value.(string)
  5131. if !ok {
  5132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5133. }
  5134. m.SetName(v)
  5135. return nil
  5136. case category.FieldOrganizationID:
  5137. v, ok := value.(uint64)
  5138. if !ok {
  5139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5140. }
  5141. m.SetOrganizationID(v)
  5142. return nil
  5143. }
  5144. return fmt.Errorf("unknown Category field %s", name)
  5145. }
  5146. // AddedFields returns all numeric fields that were incremented/decremented during
  5147. // this mutation.
  5148. func (m *CategoryMutation) AddedFields() []string {
  5149. var fields []string
  5150. if m.addorganization_id != nil {
  5151. fields = append(fields, category.FieldOrganizationID)
  5152. }
  5153. return fields
  5154. }
  5155. // AddedField returns the numeric value that was incremented/decremented on a field
  5156. // with the given name. The second boolean return value indicates that this field
  5157. // was not set, or was not defined in the schema.
  5158. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  5159. switch name {
  5160. case category.FieldOrganizationID:
  5161. return m.AddedOrganizationID()
  5162. }
  5163. return nil, false
  5164. }
  5165. // AddField adds the value to the field with the given name. It returns an error if
  5166. // the field is not defined in the schema, or if the type mismatched the field
  5167. // type.
  5168. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  5169. switch name {
  5170. case category.FieldOrganizationID:
  5171. v, ok := value.(int64)
  5172. if !ok {
  5173. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5174. }
  5175. m.AddOrganizationID(v)
  5176. return nil
  5177. }
  5178. return fmt.Errorf("unknown Category numeric field %s", name)
  5179. }
  5180. // ClearedFields returns all nullable fields that were cleared during this
  5181. // mutation.
  5182. func (m *CategoryMutation) ClearedFields() []string {
  5183. var fields []string
  5184. if m.FieldCleared(category.FieldDeletedAt) {
  5185. fields = append(fields, category.FieldDeletedAt)
  5186. }
  5187. return fields
  5188. }
  5189. // FieldCleared returns a boolean indicating if a field with the given name was
  5190. // cleared in this mutation.
  5191. func (m *CategoryMutation) FieldCleared(name string) bool {
  5192. _, ok := m.clearedFields[name]
  5193. return ok
  5194. }
  5195. // ClearField clears the value of the field with the given name. It returns an
  5196. // error if the field is not defined in the schema.
  5197. func (m *CategoryMutation) ClearField(name string) error {
  5198. switch name {
  5199. case category.FieldDeletedAt:
  5200. m.ClearDeletedAt()
  5201. return nil
  5202. }
  5203. return fmt.Errorf("unknown Category nullable field %s", name)
  5204. }
  5205. // ResetField resets all changes in the mutation for the field with the given name.
  5206. // It returns an error if the field is not defined in the schema.
  5207. func (m *CategoryMutation) ResetField(name string) error {
  5208. switch name {
  5209. case category.FieldCreatedAt:
  5210. m.ResetCreatedAt()
  5211. return nil
  5212. case category.FieldUpdatedAt:
  5213. m.ResetUpdatedAt()
  5214. return nil
  5215. case category.FieldDeletedAt:
  5216. m.ResetDeletedAt()
  5217. return nil
  5218. case category.FieldName:
  5219. m.ResetName()
  5220. return nil
  5221. case category.FieldOrganizationID:
  5222. m.ResetOrganizationID()
  5223. return nil
  5224. }
  5225. return fmt.Errorf("unknown Category field %s", name)
  5226. }
  5227. // AddedEdges returns all edge names that were set/added in this mutation.
  5228. func (m *CategoryMutation) AddedEdges() []string {
  5229. edges := make([]string, 0, 0)
  5230. return edges
  5231. }
  5232. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5233. // name in this mutation.
  5234. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  5235. return nil
  5236. }
  5237. // RemovedEdges returns all edge names that were removed in this mutation.
  5238. func (m *CategoryMutation) RemovedEdges() []string {
  5239. edges := make([]string, 0, 0)
  5240. return edges
  5241. }
  5242. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5243. // the given name in this mutation.
  5244. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  5245. return nil
  5246. }
  5247. // ClearedEdges returns all edge names that were cleared in this mutation.
  5248. func (m *CategoryMutation) ClearedEdges() []string {
  5249. edges := make([]string, 0, 0)
  5250. return edges
  5251. }
  5252. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5253. // was cleared in this mutation.
  5254. func (m *CategoryMutation) EdgeCleared(name string) bool {
  5255. return false
  5256. }
  5257. // ClearEdge clears the value of the edge with the given name. It returns an error
  5258. // if that edge is not defined in the schema.
  5259. func (m *CategoryMutation) ClearEdge(name string) error {
  5260. return fmt.Errorf("unknown Category unique edge %s", name)
  5261. }
  5262. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5263. // It returns an error if the edge is not defined in the schema.
  5264. func (m *CategoryMutation) ResetEdge(name string) error {
  5265. return fmt.Errorf("unknown Category edge %s", name)
  5266. }
  5267. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  5268. type ChatRecordsMutation struct {
  5269. config
  5270. op Op
  5271. typ string
  5272. id *uint64
  5273. created_at *time.Time
  5274. updated_at *time.Time
  5275. deleted_at *time.Time
  5276. content *string
  5277. content_type *uint8
  5278. addcontent_type *int8
  5279. session_id *uint64
  5280. addsession_id *int64
  5281. user_id *uint64
  5282. adduser_id *int64
  5283. bot_id *uint64
  5284. addbot_id *int64
  5285. bot_type *uint8
  5286. addbot_type *int8
  5287. clearedFields map[string]struct{}
  5288. done bool
  5289. oldValue func(context.Context) (*ChatRecords, error)
  5290. predicates []predicate.ChatRecords
  5291. }
  5292. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  5293. // chatrecordsOption allows management of the mutation configuration using functional options.
  5294. type chatrecordsOption func(*ChatRecordsMutation)
  5295. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  5296. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  5297. m := &ChatRecordsMutation{
  5298. config: c,
  5299. op: op,
  5300. typ: TypeChatRecords,
  5301. clearedFields: make(map[string]struct{}),
  5302. }
  5303. for _, opt := range opts {
  5304. opt(m)
  5305. }
  5306. return m
  5307. }
  5308. // withChatRecordsID sets the ID field of the mutation.
  5309. func withChatRecordsID(id uint64) chatrecordsOption {
  5310. return func(m *ChatRecordsMutation) {
  5311. var (
  5312. err error
  5313. once sync.Once
  5314. value *ChatRecords
  5315. )
  5316. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  5317. once.Do(func() {
  5318. if m.done {
  5319. err = errors.New("querying old values post mutation is not allowed")
  5320. } else {
  5321. value, err = m.Client().ChatRecords.Get(ctx, id)
  5322. }
  5323. })
  5324. return value, err
  5325. }
  5326. m.id = &id
  5327. }
  5328. }
  5329. // withChatRecords sets the old ChatRecords of the mutation.
  5330. func withChatRecords(node *ChatRecords) chatrecordsOption {
  5331. return func(m *ChatRecordsMutation) {
  5332. m.oldValue = func(context.Context) (*ChatRecords, error) {
  5333. return node, nil
  5334. }
  5335. m.id = &node.ID
  5336. }
  5337. }
  5338. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5339. // executed in a transaction (ent.Tx), a transactional client is returned.
  5340. func (m ChatRecordsMutation) Client() *Client {
  5341. client := &Client{config: m.config}
  5342. client.init()
  5343. return client
  5344. }
  5345. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5346. // it returns an error otherwise.
  5347. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  5348. if _, ok := m.driver.(*txDriver); !ok {
  5349. return nil, errors.New("ent: mutation is not running in a transaction")
  5350. }
  5351. tx := &Tx{config: m.config}
  5352. tx.init()
  5353. return tx, nil
  5354. }
  5355. // SetID sets the value of the id field. Note that this
  5356. // operation is only accepted on creation of ChatRecords entities.
  5357. func (m *ChatRecordsMutation) SetID(id uint64) {
  5358. m.id = &id
  5359. }
  5360. // ID returns the ID value in the mutation. Note that the ID is only available
  5361. // if it was provided to the builder or after it was returned from the database.
  5362. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  5363. if m.id == nil {
  5364. return
  5365. }
  5366. return *m.id, true
  5367. }
  5368. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5369. // That means, if the mutation is applied within a transaction with an isolation level such
  5370. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5371. // or updated by the mutation.
  5372. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  5373. switch {
  5374. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5375. id, exists := m.ID()
  5376. if exists {
  5377. return []uint64{id}, nil
  5378. }
  5379. fallthrough
  5380. case m.op.Is(OpUpdate | OpDelete):
  5381. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  5382. default:
  5383. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5384. }
  5385. }
  5386. // SetCreatedAt sets the "created_at" field.
  5387. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  5388. m.created_at = &t
  5389. }
  5390. // CreatedAt returns the value of the "created_at" field in the mutation.
  5391. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  5392. v := m.created_at
  5393. if v == nil {
  5394. return
  5395. }
  5396. return *v, true
  5397. }
  5398. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  5399. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5400. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5401. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5402. if !m.op.Is(OpUpdateOne) {
  5403. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5404. }
  5405. if m.id == nil || m.oldValue == nil {
  5406. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5407. }
  5408. oldValue, err := m.oldValue(ctx)
  5409. if err != nil {
  5410. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5411. }
  5412. return oldValue.CreatedAt, nil
  5413. }
  5414. // ResetCreatedAt resets all changes to the "created_at" field.
  5415. func (m *ChatRecordsMutation) ResetCreatedAt() {
  5416. m.created_at = nil
  5417. }
  5418. // SetUpdatedAt sets the "updated_at" field.
  5419. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  5420. m.updated_at = &t
  5421. }
  5422. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5423. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  5424. v := m.updated_at
  5425. if v == nil {
  5426. return
  5427. }
  5428. return *v, true
  5429. }
  5430. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  5431. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5432. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5433. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5434. if !m.op.Is(OpUpdateOne) {
  5435. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5436. }
  5437. if m.id == nil || m.oldValue == nil {
  5438. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5439. }
  5440. oldValue, err := m.oldValue(ctx)
  5441. if err != nil {
  5442. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5443. }
  5444. return oldValue.UpdatedAt, nil
  5445. }
  5446. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5447. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  5448. m.updated_at = nil
  5449. }
  5450. // SetDeletedAt sets the "deleted_at" field.
  5451. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  5452. m.deleted_at = &t
  5453. }
  5454. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5455. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  5456. v := m.deleted_at
  5457. if v == nil {
  5458. return
  5459. }
  5460. return *v, true
  5461. }
  5462. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  5463. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5465. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5466. if !m.op.Is(OpUpdateOne) {
  5467. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5468. }
  5469. if m.id == nil || m.oldValue == nil {
  5470. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5471. }
  5472. oldValue, err := m.oldValue(ctx)
  5473. if err != nil {
  5474. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5475. }
  5476. return oldValue.DeletedAt, nil
  5477. }
  5478. // ClearDeletedAt clears the value of the "deleted_at" field.
  5479. func (m *ChatRecordsMutation) ClearDeletedAt() {
  5480. m.deleted_at = nil
  5481. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  5482. }
  5483. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5484. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  5485. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  5486. return ok
  5487. }
  5488. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5489. func (m *ChatRecordsMutation) ResetDeletedAt() {
  5490. m.deleted_at = nil
  5491. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  5492. }
  5493. // SetContent sets the "content" field.
  5494. func (m *ChatRecordsMutation) SetContent(s string) {
  5495. m.content = &s
  5496. }
  5497. // Content returns the value of the "content" field in the mutation.
  5498. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  5499. v := m.content
  5500. if v == nil {
  5501. return
  5502. }
  5503. return *v, true
  5504. }
  5505. // OldContent returns the old "content" field's value of the ChatRecords entity.
  5506. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5508. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  5509. if !m.op.Is(OpUpdateOne) {
  5510. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  5511. }
  5512. if m.id == nil || m.oldValue == nil {
  5513. return v, errors.New("OldContent requires an ID field in the mutation")
  5514. }
  5515. oldValue, err := m.oldValue(ctx)
  5516. if err != nil {
  5517. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  5518. }
  5519. return oldValue.Content, nil
  5520. }
  5521. // ResetContent resets all changes to the "content" field.
  5522. func (m *ChatRecordsMutation) ResetContent() {
  5523. m.content = nil
  5524. }
  5525. // SetContentType sets the "content_type" field.
  5526. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  5527. m.content_type = &u
  5528. m.addcontent_type = nil
  5529. }
  5530. // ContentType returns the value of the "content_type" field in the mutation.
  5531. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  5532. v := m.content_type
  5533. if v == nil {
  5534. return
  5535. }
  5536. return *v, true
  5537. }
  5538. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  5539. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5541. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  5542. if !m.op.Is(OpUpdateOne) {
  5543. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  5544. }
  5545. if m.id == nil || m.oldValue == nil {
  5546. return v, errors.New("OldContentType requires an ID field in the mutation")
  5547. }
  5548. oldValue, err := m.oldValue(ctx)
  5549. if err != nil {
  5550. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  5551. }
  5552. return oldValue.ContentType, nil
  5553. }
  5554. // AddContentType adds u to the "content_type" field.
  5555. func (m *ChatRecordsMutation) AddContentType(u int8) {
  5556. if m.addcontent_type != nil {
  5557. *m.addcontent_type += u
  5558. } else {
  5559. m.addcontent_type = &u
  5560. }
  5561. }
  5562. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  5563. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  5564. v := m.addcontent_type
  5565. if v == nil {
  5566. return
  5567. }
  5568. return *v, true
  5569. }
  5570. // ResetContentType resets all changes to the "content_type" field.
  5571. func (m *ChatRecordsMutation) ResetContentType() {
  5572. m.content_type = nil
  5573. m.addcontent_type = nil
  5574. }
  5575. // SetSessionID sets the "session_id" field.
  5576. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  5577. m.session_id = &u
  5578. m.addsession_id = nil
  5579. }
  5580. // SessionID returns the value of the "session_id" field in the mutation.
  5581. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  5582. v := m.session_id
  5583. if v == nil {
  5584. return
  5585. }
  5586. return *v, true
  5587. }
  5588. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  5589. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5590. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5591. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  5592. if !m.op.Is(OpUpdateOne) {
  5593. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  5594. }
  5595. if m.id == nil || m.oldValue == nil {
  5596. return v, errors.New("OldSessionID requires an ID field in the mutation")
  5597. }
  5598. oldValue, err := m.oldValue(ctx)
  5599. if err != nil {
  5600. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  5601. }
  5602. return oldValue.SessionID, nil
  5603. }
  5604. // AddSessionID adds u to the "session_id" field.
  5605. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  5606. if m.addsession_id != nil {
  5607. *m.addsession_id += u
  5608. } else {
  5609. m.addsession_id = &u
  5610. }
  5611. }
  5612. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  5613. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  5614. v := m.addsession_id
  5615. if v == nil {
  5616. return
  5617. }
  5618. return *v, true
  5619. }
  5620. // ResetSessionID resets all changes to the "session_id" field.
  5621. func (m *ChatRecordsMutation) ResetSessionID() {
  5622. m.session_id = nil
  5623. m.addsession_id = nil
  5624. }
  5625. // SetUserID sets the "user_id" field.
  5626. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  5627. m.user_id = &u
  5628. m.adduser_id = nil
  5629. }
  5630. // UserID returns the value of the "user_id" field in the mutation.
  5631. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  5632. v := m.user_id
  5633. if v == nil {
  5634. return
  5635. }
  5636. return *v, true
  5637. }
  5638. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  5639. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5641. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  5642. if !m.op.Is(OpUpdateOne) {
  5643. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  5644. }
  5645. if m.id == nil || m.oldValue == nil {
  5646. return v, errors.New("OldUserID requires an ID field in the mutation")
  5647. }
  5648. oldValue, err := m.oldValue(ctx)
  5649. if err != nil {
  5650. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  5651. }
  5652. return oldValue.UserID, nil
  5653. }
  5654. // AddUserID adds u to the "user_id" field.
  5655. func (m *ChatRecordsMutation) AddUserID(u int64) {
  5656. if m.adduser_id != nil {
  5657. *m.adduser_id += u
  5658. } else {
  5659. m.adduser_id = &u
  5660. }
  5661. }
  5662. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  5663. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  5664. v := m.adduser_id
  5665. if v == nil {
  5666. return
  5667. }
  5668. return *v, true
  5669. }
  5670. // ResetUserID resets all changes to the "user_id" field.
  5671. func (m *ChatRecordsMutation) ResetUserID() {
  5672. m.user_id = nil
  5673. m.adduser_id = nil
  5674. }
  5675. // SetBotID sets the "bot_id" field.
  5676. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  5677. m.bot_id = &u
  5678. m.addbot_id = nil
  5679. }
  5680. // BotID returns the value of the "bot_id" field in the mutation.
  5681. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  5682. v := m.bot_id
  5683. if v == nil {
  5684. return
  5685. }
  5686. return *v, true
  5687. }
  5688. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  5689. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  5690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5691. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  5692. if !m.op.Is(OpUpdateOne) {
  5693. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  5694. }
  5695. if m.id == nil || m.oldValue == nil {
  5696. return v, errors.New("OldBotID requires an ID field in the mutation")
  5697. }
  5698. oldValue, err := m.oldValue(ctx)
  5699. if err != nil {
  5700. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  5701. }
  5702. return oldValue.BotID, nil
  5703. }
  5704. // AddBotID adds u to the "bot_id" field.
  5705. func (m *ChatRecordsMutation) AddBotID(u int64) {
  5706. if m.addbot_id != nil {
  5707. *m.addbot_id += u
  5708. } else {
  5709. m.addbot_id = &u
  5710. }
  5711. }
  5712. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  5713. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  5714. v := m.addbot_id
  5715. if v == nil {
  5716. return
  5717. }
  5718. return *v, true
  5719. }
  5720. // ResetBotID resets all changes to the "bot_id" field.
  5721. func (m *ChatRecordsMutation) ResetBotID() {
  5722. m.bot_id = nil
  5723. m.addbot_id = nil
  5724. }
  5725. // SetBotType sets the "bot_type" field.
  5726. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  5727. m.bot_type = &u
  5728. m.addbot_type = nil
  5729. }
  5730. // BotType returns the value of the "bot_type" field in the mutation.
  5731. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  5732. v := m.bot_type
  5733. if v == nil {
  5734. return
  5735. }
  5736. return *v, true
  5737. }
  5738. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  5739. // If the ChatRecords 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 *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  5742. if !m.op.Is(OpUpdateOne) {
  5743. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  5744. }
  5745. if m.id == nil || m.oldValue == nil {
  5746. return v, errors.New("OldBotType 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 OldBotType: %w", err)
  5751. }
  5752. return oldValue.BotType, nil
  5753. }
  5754. // AddBotType adds u to the "bot_type" field.
  5755. func (m *ChatRecordsMutation) AddBotType(u int8) {
  5756. if m.addbot_type != nil {
  5757. *m.addbot_type += u
  5758. } else {
  5759. m.addbot_type = &u
  5760. }
  5761. }
  5762. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  5763. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  5764. v := m.addbot_type
  5765. if v == nil {
  5766. return
  5767. }
  5768. return *v, true
  5769. }
  5770. // ResetBotType resets all changes to the "bot_type" field.
  5771. func (m *ChatRecordsMutation) ResetBotType() {
  5772. m.bot_type = nil
  5773. m.addbot_type = nil
  5774. }
  5775. // Where appends a list predicates to the ChatRecordsMutation builder.
  5776. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  5777. m.predicates = append(m.predicates, ps...)
  5778. }
  5779. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  5780. // users can use type-assertion to append predicates that do not depend on any generated package.
  5781. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  5782. p := make([]predicate.ChatRecords, 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 *ChatRecordsMutation) Op() Op {
  5790. return m.op
  5791. }
  5792. // SetOp allows setting the mutation operation.
  5793. func (m *ChatRecordsMutation) SetOp(op Op) {
  5794. m.op = op
  5795. }
  5796. // Type returns the node type of this mutation (ChatRecords).
  5797. func (m *ChatRecordsMutation) 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 *ChatRecordsMutation) Fields() []string {
  5804. fields := make([]string, 0, 9)
  5805. if m.created_at != nil {
  5806. fields = append(fields, chatrecords.FieldCreatedAt)
  5807. }
  5808. if m.updated_at != nil {
  5809. fields = append(fields, chatrecords.FieldUpdatedAt)
  5810. }
  5811. if m.deleted_at != nil {
  5812. fields = append(fields, chatrecords.FieldDeletedAt)
  5813. }
  5814. if m.content != nil {
  5815. fields = append(fields, chatrecords.FieldContent)
  5816. }
  5817. if m.content_type != nil {
  5818. fields = append(fields, chatrecords.FieldContentType)
  5819. }
  5820. if m.session_id != nil {
  5821. fields = append(fields, chatrecords.FieldSessionID)
  5822. }
  5823. if m.user_id != nil {
  5824. fields = append(fields, chatrecords.FieldUserID)
  5825. }
  5826. if m.bot_id != nil {
  5827. fields = append(fields, chatrecords.FieldBotID)
  5828. }
  5829. if m.bot_type != nil {
  5830. fields = append(fields, chatrecords.FieldBotType)
  5831. }
  5832. return fields
  5833. }
  5834. // Field returns the value of a field with the given name. The second boolean
  5835. // return value indicates that this field was not set, or was not defined in the
  5836. // schema.
  5837. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  5838. switch name {
  5839. case chatrecords.FieldCreatedAt:
  5840. return m.CreatedAt()
  5841. case chatrecords.FieldUpdatedAt:
  5842. return m.UpdatedAt()
  5843. case chatrecords.FieldDeletedAt:
  5844. return m.DeletedAt()
  5845. case chatrecords.FieldContent:
  5846. return m.Content()
  5847. case chatrecords.FieldContentType:
  5848. return m.ContentType()
  5849. case chatrecords.FieldSessionID:
  5850. return m.SessionID()
  5851. case chatrecords.FieldUserID:
  5852. return m.UserID()
  5853. case chatrecords.FieldBotID:
  5854. return m.BotID()
  5855. case chatrecords.FieldBotType:
  5856. return m.BotType()
  5857. }
  5858. return nil, false
  5859. }
  5860. // OldField returns the old value of the field from the database. An error is
  5861. // returned if the mutation operation is not UpdateOne, or the query to the
  5862. // database failed.
  5863. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5864. switch name {
  5865. case chatrecords.FieldCreatedAt:
  5866. return m.OldCreatedAt(ctx)
  5867. case chatrecords.FieldUpdatedAt:
  5868. return m.OldUpdatedAt(ctx)
  5869. case chatrecords.FieldDeletedAt:
  5870. return m.OldDeletedAt(ctx)
  5871. case chatrecords.FieldContent:
  5872. return m.OldContent(ctx)
  5873. case chatrecords.FieldContentType:
  5874. return m.OldContentType(ctx)
  5875. case chatrecords.FieldSessionID:
  5876. return m.OldSessionID(ctx)
  5877. case chatrecords.FieldUserID:
  5878. return m.OldUserID(ctx)
  5879. case chatrecords.FieldBotID:
  5880. return m.OldBotID(ctx)
  5881. case chatrecords.FieldBotType:
  5882. return m.OldBotType(ctx)
  5883. }
  5884. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  5885. }
  5886. // SetField sets the value of a field with the given name. It returns an error if
  5887. // the field is not defined in the schema, or if the type mismatched the field
  5888. // type.
  5889. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  5890. switch name {
  5891. case chatrecords.FieldCreatedAt:
  5892. v, ok := value.(time.Time)
  5893. if !ok {
  5894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5895. }
  5896. m.SetCreatedAt(v)
  5897. return nil
  5898. case chatrecords.FieldUpdatedAt:
  5899. v, ok := value.(time.Time)
  5900. if !ok {
  5901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5902. }
  5903. m.SetUpdatedAt(v)
  5904. return nil
  5905. case chatrecords.FieldDeletedAt:
  5906. v, ok := value.(time.Time)
  5907. if !ok {
  5908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5909. }
  5910. m.SetDeletedAt(v)
  5911. return nil
  5912. case chatrecords.FieldContent:
  5913. v, ok := value.(string)
  5914. if !ok {
  5915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5916. }
  5917. m.SetContent(v)
  5918. return nil
  5919. case chatrecords.FieldContentType:
  5920. v, ok := value.(uint8)
  5921. if !ok {
  5922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5923. }
  5924. m.SetContentType(v)
  5925. return nil
  5926. case chatrecords.FieldSessionID:
  5927. v, ok := value.(uint64)
  5928. if !ok {
  5929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5930. }
  5931. m.SetSessionID(v)
  5932. return nil
  5933. case chatrecords.FieldUserID:
  5934. v, ok := value.(uint64)
  5935. if !ok {
  5936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5937. }
  5938. m.SetUserID(v)
  5939. return nil
  5940. case chatrecords.FieldBotID:
  5941. v, ok := value.(uint64)
  5942. if !ok {
  5943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5944. }
  5945. m.SetBotID(v)
  5946. return nil
  5947. case chatrecords.FieldBotType:
  5948. v, ok := value.(uint8)
  5949. if !ok {
  5950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5951. }
  5952. m.SetBotType(v)
  5953. return nil
  5954. }
  5955. return fmt.Errorf("unknown ChatRecords field %s", name)
  5956. }
  5957. // AddedFields returns all numeric fields that were incremented/decremented during
  5958. // this mutation.
  5959. func (m *ChatRecordsMutation) AddedFields() []string {
  5960. var fields []string
  5961. if m.addcontent_type != nil {
  5962. fields = append(fields, chatrecords.FieldContentType)
  5963. }
  5964. if m.addsession_id != nil {
  5965. fields = append(fields, chatrecords.FieldSessionID)
  5966. }
  5967. if m.adduser_id != nil {
  5968. fields = append(fields, chatrecords.FieldUserID)
  5969. }
  5970. if m.addbot_id != nil {
  5971. fields = append(fields, chatrecords.FieldBotID)
  5972. }
  5973. if m.addbot_type != nil {
  5974. fields = append(fields, chatrecords.FieldBotType)
  5975. }
  5976. return fields
  5977. }
  5978. // AddedField returns the numeric value that was incremented/decremented on a field
  5979. // with the given name. The second boolean return value indicates that this field
  5980. // was not set, or was not defined in the schema.
  5981. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  5982. switch name {
  5983. case chatrecords.FieldContentType:
  5984. return m.AddedContentType()
  5985. case chatrecords.FieldSessionID:
  5986. return m.AddedSessionID()
  5987. case chatrecords.FieldUserID:
  5988. return m.AddedUserID()
  5989. case chatrecords.FieldBotID:
  5990. return m.AddedBotID()
  5991. case chatrecords.FieldBotType:
  5992. return m.AddedBotType()
  5993. }
  5994. return nil, false
  5995. }
  5996. // AddField adds the value to the field with the given name. It returns an error if
  5997. // the field is not defined in the schema, or if the type mismatched the field
  5998. // type.
  5999. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  6000. switch name {
  6001. case chatrecords.FieldContentType:
  6002. v, ok := value.(int8)
  6003. if !ok {
  6004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6005. }
  6006. m.AddContentType(v)
  6007. return nil
  6008. case chatrecords.FieldSessionID:
  6009. v, ok := value.(int64)
  6010. if !ok {
  6011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6012. }
  6013. m.AddSessionID(v)
  6014. return nil
  6015. case chatrecords.FieldUserID:
  6016. v, ok := value.(int64)
  6017. if !ok {
  6018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6019. }
  6020. m.AddUserID(v)
  6021. return nil
  6022. case chatrecords.FieldBotID:
  6023. v, ok := value.(int64)
  6024. if !ok {
  6025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6026. }
  6027. m.AddBotID(v)
  6028. return nil
  6029. case chatrecords.FieldBotType:
  6030. v, ok := value.(int8)
  6031. if !ok {
  6032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6033. }
  6034. m.AddBotType(v)
  6035. return nil
  6036. }
  6037. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  6038. }
  6039. // ClearedFields returns all nullable fields that were cleared during this
  6040. // mutation.
  6041. func (m *ChatRecordsMutation) ClearedFields() []string {
  6042. var fields []string
  6043. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  6044. fields = append(fields, chatrecords.FieldDeletedAt)
  6045. }
  6046. return fields
  6047. }
  6048. // FieldCleared returns a boolean indicating if a field with the given name was
  6049. // cleared in this mutation.
  6050. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  6051. _, ok := m.clearedFields[name]
  6052. return ok
  6053. }
  6054. // ClearField clears the value of the field with the given name. It returns an
  6055. // error if the field is not defined in the schema.
  6056. func (m *ChatRecordsMutation) ClearField(name string) error {
  6057. switch name {
  6058. case chatrecords.FieldDeletedAt:
  6059. m.ClearDeletedAt()
  6060. return nil
  6061. }
  6062. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  6063. }
  6064. // ResetField resets all changes in the mutation for the field with the given name.
  6065. // It returns an error if the field is not defined in the schema.
  6066. func (m *ChatRecordsMutation) ResetField(name string) error {
  6067. switch name {
  6068. case chatrecords.FieldCreatedAt:
  6069. m.ResetCreatedAt()
  6070. return nil
  6071. case chatrecords.FieldUpdatedAt:
  6072. m.ResetUpdatedAt()
  6073. return nil
  6074. case chatrecords.FieldDeletedAt:
  6075. m.ResetDeletedAt()
  6076. return nil
  6077. case chatrecords.FieldContent:
  6078. m.ResetContent()
  6079. return nil
  6080. case chatrecords.FieldContentType:
  6081. m.ResetContentType()
  6082. return nil
  6083. case chatrecords.FieldSessionID:
  6084. m.ResetSessionID()
  6085. return nil
  6086. case chatrecords.FieldUserID:
  6087. m.ResetUserID()
  6088. return nil
  6089. case chatrecords.FieldBotID:
  6090. m.ResetBotID()
  6091. return nil
  6092. case chatrecords.FieldBotType:
  6093. m.ResetBotType()
  6094. return nil
  6095. }
  6096. return fmt.Errorf("unknown ChatRecords field %s", name)
  6097. }
  6098. // AddedEdges returns all edge names that were set/added in this mutation.
  6099. func (m *ChatRecordsMutation) AddedEdges() []string {
  6100. edges := make([]string, 0, 0)
  6101. return edges
  6102. }
  6103. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6104. // name in this mutation.
  6105. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  6106. return nil
  6107. }
  6108. // RemovedEdges returns all edge names that were removed in this mutation.
  6109. func (m *ChatRecordsMutation) RemovedEdges() []string {
  6110. edges := make([]string, 0, 0)
  6111. return edges
  6112. }
  6113. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6114. // the given name in this mutation.
  6115. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  6116. return nil
  6117. }
  6118. // ClearedEdges returns all edge names that were cleared in this mutation.
  6119. func (m *ChatRecordsMutation) ClearedEdges() []string {
  6120. edges := make([]string, 0, 0)
  6121. return edges
  6122. }
  6123. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6124. // was cleared in this mutation.
  6125. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  6126. return false
  6127. }
  6128. // ClearEdge clears the value of the edge with the given name. It returns an error
  6129. // if that edge is not defined in the schema.
  6130. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  6131. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  6132. }
  6133. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6134. // It returns an error if the edge is not defined in the schema.
  6135. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  6136. return fmt.Errorf("unknown ChatRecords edge %s", name)
  6137. }
  6138. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  6139. type ChatSessionMutation struct {
  6140. config
  6141. op Op
  6142. typ string
  6143. id *uint64
  6144. created_at *time.Time
  6145. updated_at *time.Time
  6146. deleted_at *time.Time
  6147. name *string
  6148. user_id *uint64
  6149. adduser_id *int64
  6150. bot_id *uint64
  6151. addbot_id *int64
  6152. bot_type *uint8
  6153. addbot_type *int8
  6154. clearedFields map[string]struct{}
  6155. done bool
  6156. oldValue func(context.Context) (*ChatSession, error)
  6157. predicates []predicate.ChatSession
  6158. }
  6159. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  6160. // chatsessionOption allows management of the mutation configuration using functional options.
  6161. type chatsessionOption func(*ChatSessionMutation)
  6162. // newChatSessionMutation creates new mutation for the ChatSession entity.
  6163. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  6164. m := &ChatSessionMutation{
  6165. config: c,
  6166. op: op,
  6167. typ: TypeChatSession,
  6168. clearedFields: make(map[string]struct{}),
  6169. }
  6170. for _, opt := range opts {
  6171. opt(m)
  6172. }
  6173. return m
  6174. }
  6175. // withChatSessionID sets the ID field of the mutation.
  6176. func withChatSessionID(id uint64) chatsessionOption {
  6177. return func(m *ChatSessionMutation) {
  6178. var (
  6179. err error
  6180. once sync.Once
  6181. value *ChatSession
  6182. )
  6183. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  6184. once.Do(func() {
  6185. if m.done {
  6186. err = errors.New("querying old values post mutation is not allowed")
  6187. } else {
  6188. value, err = m.Client().ChatSession.Get(ctx, id)
  6189. }
  6190. })
  6191. return value, err
  6192. }
  6193. m.id = &id
  6194. }
  6195. }
  6196. // withChatSession sets the old ChatSession of the mutation.
  6197. func withChatSession(node *ChatSession) chatsessionOption {
  6198. return func(m *ChatSessionMutation) {
  6199. m.oldValue = func(context.Context) (*ChatSession, error) {
  6200. return node, nil
  6201. }
  6202. m.id = &node.ID
  6203. }
  6204. }
  6205. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6206. // executed in a transaction (ent.Tx), a transactional client is returned.
  6207. func (m ChatSessionMutation) Client() *Client {
  6208. client := &Client{config: m.config}
  6209. client.init()
  6210. return client
  6211. }
  6212. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6213. // it returns an error otherwise.
  6214. func (m ChatSessionMutation) Tx() (*Tx, error) {
  6215. if _, ok := m.driver.(*txDriver); !ok {
  6216. return nil, errors.New("ent: mutation is not running in a transaction")
  6217. }
  6218. tx := &Tx{config: m.config}
  6219. tx.init()
  6220. return tx, nil
  6221. }
  6222. // SetID sets the value of the id field. Note that this
  6223. // operation is only accepted on creation of ChatSession entities.
  6224. func (m *ChatSessionMutation) SetID(id uint64) {
  6225. m.id = &id
  6226. }
  6227. // ID returns the ID value in the mutation. Note that the ID is only available
  6228. // if it was provided to the builder or after it was returned from the database.
  6229. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  6230. if m.id == nil {
  6231. return
  6232. }
  6233. return *m.id, true
  6234. }
  6235. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6236. // That means, if the mutation is applied within a transaction with an isolation level such
  6237. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6238. // or updated by the mutation.
  6239. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  6240. switch {
  6241. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6242. id, exists := m.ID()
  6243. if exists {
  6244. return []uint64{id}, nil
  6245. }
  6246. fallthrough
  6247. case m.op.Is(OpUpdate | OpDelete):
  6248. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  6249. default:
  6250. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6251. }
  6252. }
  6253. // SetCreatedAt sets the "created_at" field.
  6254. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  6255. m.created_at = &t
  6256. }
  6257. // CreatedAt returns the value of the "created_at" field in the mutation.
  6258. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  6259. v := m.created_at
  6260. if v == nil {
  6261. return
  6262. }
  6263. return *v, true
  6264. }
  6265. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  6266. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6268. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6269. if !m.op.Is(OpUpdateOne) {
  6270. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6271. }
  6272. if m.id == nil || m.oldValue == nil {
  6273. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6274. }
  6275. oldValue, err := m.oldValue(ctx)
  6276. if err != nil {
  6277. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6278. }
  6279. return oldValue.CreatedAt, nil
  6280. }
  6281. // ResetCreatedAt resets all changes to the "created_at" field.
  6282. func (m *ChatSessionMutation) ResetCreatedAt() {
  6283. m.created_at = nil
  6284. }
  6285. // SetUpdatedAt sets the "updated_at" field.
  6286. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  6287. m.updated_at = &t
  6288. }
  6289. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6290. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  6291. v := m.updated_at
  6292. if v == nil {
  6293. return
  6294. }
  6295. return *v, true
  6296. }
  6297. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  6298. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6300. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6301. if !m.op.Is(OpUpdateOne) {
  6302. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6303. }
  6304. if m.id == nil || m.oldValue == nil {
  6305. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6306. }
  6307. oldValue, err := m.oldValue(ctx)
  6308. if err != nil {
  6309. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6310. }
  6311. return oldValue.UpdatedAt, nil
  6312. }
  6313. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6314. func (m *ChatSessionMutation) ResetUpdatedAt() {
  6315. m.updated_at = nil
  6316. }
  6317. // SetDeletedAt sets the "deleted_at" field.
  6318. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  6319. m.deleted_at = &t
  6320. }
  6321. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6322. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  6323. v := m.deleted_at
  6324. if v == nil {
  6325. return
  6326. }
  6327. return *v, true
  6328. }
  6329. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  6330. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6332. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6333. if !m.op.Is(OpUpdateOne) {
  6334. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6335. }
  6336. if m.id == nil || m.oldValue == nil {
  6337. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6338. }
  6339. oldValue, err := m.oldValue(ctx)
  6340. if err != nil {
  6341. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6342. }
  6343. return oldValue.DeletedAt, nil
  6344. }
  6345. // ClearDeletedAt clears the value of the "deleted_at" field.
  6346. func (m *ChatSessionMutation) ClearDeletedAt() {
  6347. m.deleted_at = nil
  6348. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  6349. }
  6350. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6351. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  6352. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  6353. return ok
  6354. }
  6355. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6356. func (m *ChatSessionMutation) ResetDeletedAt() {
  6357. m.deleted_at = nil
  6358. delete(m.clearedFields, chatsession.FieldDeletedAt)
  6359. }
  6360. // SetName sets the "name" field.
  6361. func (m *ChatSessionMutation) SetName(s string) {
  6362. m.name = &s
  6363. }
  6364. // Name returns the value of the "name" field in the mutation.
  6365. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  6366. v := m.name
  6367. if v == nil {
  6368. return
  6369. }
  6370. return *v, true
  6371. }
  6372. // OldName returns the old "name" field's value of the ChatSession entity.
  6373. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6374. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6375. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  6376. if !m.op.Is(OpUpdateOne) {
  6377. return v, errors.New("OldName is only allowed on UpdateOne operations")
  6378. }
  6379. if m.id == nil || m.oldValue == nil {
  6380. return v, errors.New("OldName requires an ID field in the mutation")
  6381. }
  6382. oldValue, err := m.oldValue(ctx)
  6383. if err != nil {
  6384. return v, fmt.Errorf("querying old value for OldName: %w", err)
  6385. }
  6386. return oldValue.Name, nil
  6387. }
  6388. // ResetName resets all changes to the "name" field.
  6389. func (m *ChatSessionMutation) ResetName() {
  6390. m.name = nil
  6391. }
  6392. // SetUserID sets the "user_id" field.
  6393. func (m *ChatSessionMutation) SetUserID(u uint64) {
  6394. m.user_id = &u
  6395. m.adduser_id = nil
  6396. }
  6397. // UserID returns the value of the "user_id" field in the mutation.
  6398. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  6399. v := m.user_id
  6400. if v == nil {
  6401. return
  6402. }
  6403. return *v, true
  6404. }
  6405. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  6406. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6408. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6409. if !m.op.Is(OpUpdateOne) {
  6410. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6411. }
  6412. if m.id == nil || m.oldValue == nil {
  6413. return v, errors.New("OldUserID requires an ID field in the mutation")
  6414. }
  6415. oldValue, err := m.oldValue(ctx)
  6416. if err != nil {
  6417. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6418. }
  6419. return oldValue.UserID, nil
  6420. }
  6421. // AddUserID adds u to the "user_id" field.
  6422. func (m *ChatSessionMutation) AddUserID(u int64) {
  6423. if m.adduser_id != nil {
  6424. *m.adduser_id += u
  6425. } else {
  6426. m.adduser_id = &u
  6427. }
  6428. }
  6429. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6430. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  6431. v := m.adduser_id
  6432. if v == nil {
  6433. return
  6434. }
  6435. return *v, true
  6436. }
  6437. // ResetUserID resets all changes to the "user_id" field.
  6438. func (m *ChatSessionMutation) ResetUserID() {
  6439. m.user_id = nil
  6440. m.adduser_id = nil
  6441. }
  6442. // SetBotID sets the "bot_id" field.
  6443. func (m *ChatSessionMutation) SetBotID(u uint64) {
  6444. m.bot_id = &u
  6445. m.addbot_id = nil
  6446. }
  6447. // BotID returns the value of the "bot_id" field in the mutation.
  6448. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  6449. v := m.bot_id
  6450. if v == nil {
  6451. return
  6452. }
  6453. return *v, true
  6454. }
  6455. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  6456. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6457. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6458. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6459. if !m.op.Is(OpUpdateOne) {
  6460. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6461. }
  6462. if m.id == nil || m.oldValue == nil {
  6463. return v, errors.New("OldBotID requires an ID field in the mutation")
  6464. }
  6465. oldValue, err := m.oldValue(ctx)
  6466. if err != nil {
  6467. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6468. }
  6469. return oldValue.BotID, nil
  6470. }
  6471. // AddBotID adds u to the "bot_id" field.
  6472. func (m *ChatSessionMutation) AddBotID(u int64) {
  6473. if m.addbot_id != nil {
  6474. *m.addbot_id += u
  6475. } else {
  6476. m.addbot_id = &u
  6477. }
  6478. }
  6479. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6480. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  6481. v := m.addbot_id
  6482. if v == nil {
  6483. return
  6484. }
  6485. return *v, true
  6486. }
  6487. // ResetBotID resets all changes to the "bot_id" field.
  6488. func (m *ChatSessionMutation) ResetBotID() {
  6489. m.bot_id = nil
  6490. m.addbot_id = nil
  6491. }
  6492. // SetBotType sets the "bot_type" field.
  6493. func (m *ChatSessionMutation) SetBotType(u uint8) {
  6494. m.bot_type = &u
  6495. m.addbot_type = nil
  6496. }
  6497. // BotType returns the value of the "bot_type" field in the mutation.
  6498. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  6499. v := m.bot_type
  6500. if v == nil {
  6501. return
  6502. }
  6503. return *v, true
  6504. }
  6505. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  6506. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  6507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6508. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6509. if !m.op.Is(OpUpdateOne) {
  6510. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6511. }
  6512. if m.id == nil || m.oldValue == nil {
  6513. return v, errors.New("OldBotType requires an ID field in the mutation")
  6514. }
  6515. oldValue, err := m.oldValue(ctx)
  6516. if err != nil {
  6517. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  6518. }
  6519. return oldValue.BotType, nil
  6520. }
  6521. // AddBotType adds u to the "bot_type" field.
  6522. func (m *ChatSessionMutation) AddBotType(u int8) {
  6523. if m.addbot_type != nil {
  6524. *m.addbot_type += u
  6525. } else {
  6526. m.addbot_type = &u
  6527. }
  6528. }
  6529. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  6530. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  6531. v := m.addbot_type
  6532. if v == nil {
  6533. return
  6534. }
  6535. return *v, true
  6536. }
  6537. // ResetBotType resets all changes to the "bot_type" field.
  6538. func (m *ChatSessionMutation) ResetBotType() {
  6539. m.bot_type = nil
  6540. m.addbot_type = nil
  6541. }
  6542. // Where appends a list predicates to the ChatSessionMutation builder.
  6543. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  6544. m.predicates = append(m.predicates, ps...)
  6545. }
  6546. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  6547. // users can use type-assertion to append predicates that do not depend on any generated package.
  6548. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  6549. p := make([]predicate.ChatSession, len(ps))
  6550. for i := range ps {
  6551. p[i] = ps[i]
  6552. }
  6553. m.Where(p...)
  6554. }
  6555. // Op returns the operation name.
  6556. func (m *ChatSessionMutation) Op() Op {
  6557. return m.op
  6558. }
  6559. // SetOp allows setting the mutation operation.
  6560. func (m *ChatSessionMutation) SetOp(op Op) {
  6561. m.op = op
  6562. }
  6563. // Type returns the node type of this mutation (ChatSession).
  6564. func (m *ChatSessionMutation) Type() string {
  6565. return m.typ
  6566. }
  6567. // Fields returns all fields that were changed during this mutation. Note that in
  6568. // order to get all numeric fields that were incremented/decremented, call
  6569. // AddedFields().
  6570. func (m *ChatSessionMutation) Fields() []string {
  6571. fields := make([]string, 0, 7)
  6572. if m.created_at != nil {
  6573. fields = append(fields, chatsession.FieldCreatedAt)
  6574. }
  6575. if m.updated_at != nil {
  6576. fields = append(fields, chatsession.FieldUpdatedAt)
  6577. }
  6578. if m.deleted_at != nil {
  6579. fields = append(fields, chatsession.FieldDeletedAt)
  6580. }
  6581. if m.name != nil {
  6582. fields = append(fields, chatsession.FieldName)
  6583. }
  6584. if m.user_id != nil {
  6585. fields = append(fields, chatsession.FieldUserID)
  6586. }
  6587. if m.bot_id != nil {
  6588. fields = append(fields, chatsession.FieldBotID)
  6589. }
  6590. if m.bot_type != nil {
  6591. fields = append(fields, chatsession.FieldBotType)
  6592. }
  6593. return fields
  6594. }
  6595. // Field returns the value of a field with the given name. The second boolean
  6596. // return value indicates that this field was not set, or was not defined in the
  6597. // schema.
  6598. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  6599. switch name {
  6600. case chatsession.FieldCreatedAt:
  6601. return m.CreatedAt()
  6602. case chatsession.FieldUpdatedAt:
  6603. return m.UpdatedAt()
  6604. case chatsession.FieldDeletedAt:
  6605. return m.DeletedAt()
  6606. case chatsession.FieldName:
  6607. return m.Name()
  6608. case chatsession.FieldUserID:
  6609. return m.UserID()
  6610. case chatsession.FieldBotID:
  6611. return m.BotID()
  6612. case chatsession.FieldBotType:
  6613. return m.BotType()
  6614. }
  6615. return nil, false
  6616. }
  6617. // OldField returns the old value of the field from the database. An error is
  6618. // returned if the mutation operation is not UpdateOne, or the query to the
  6619. // database failed.
  6620. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6621. switch name {
  6622. case chatsession.FieldCreatedAt:
  6623. return m.OldCreatedAt(ctx)
  6624. case chatsession.FieldUpdatedAt:
  6625. return m.OldUpdatedAt(ctx)
  6626. case chatsession.FieldDeletedAt:
  6627. return m.OldDeletedAt(ctx)
  6628. case chatsession.FieldName:
  6629. return m.OldName(ctx)
  6630. case chatsession.FieldUserID:
  6631. return m.OldUserID(ctx)
  6632. case chatsession.FieldBotID:
  6633. return m.OldBotID(ctx)
  6634. case chatsession.FieldBotType:
  6635. return m.OldBotType(ctx)
  6636. }
  6637. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  6638. }
  6639. // SetField sets the value of a field with the given name. It returns an error if
  6640. // the field is not defined in the schema, or if the type mismatched the field
  6641. // type.
  6642. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  6643. switch name {
  6644. case chatsession.FieldCreatedAt:
  6645. v, ok := value.(time.Time)
  6646. if !ok {
  6647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6648. }
  6649. m.SetCreatedAt(v)
  6650. return nil
  6651. case chatsession.FieldUpdatedAt:
  6652. v, ok := value.(time.Time)
  6653. if !ok {
  6654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6655. }
  6656. m.SetUpdatedAt(v)
  6657. return nil
  6658. case chatsession.FieldDeletedAt:
  6659. v, ok := value.(time.Time)
  6660. if !ok {
  6661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6662. }
  6663. m.SetDeletedAt(v)
  6664. return nil
  6665. case chatsession.FieldName:
  6666. v, ok := value.(string)
  6667. if !ok {
  6668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6669. }
  6670. m.SetName(v)
  6671. return nil
  6672. case chatsession.FieldUserID:
  6673. v, ok := value.(uint64)
  6674. if !ok {
  6675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6676. }
  6677. m.SetUserID(v)
  6678. return nil
  6679. case chatsession.FieldBotID:
  6680. v, ok := value.(uint64)
  6681. if !ok {
  6682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6683. }
  6684. m.SetBotID(v)
  6685. return nil
  6686. case chatsession.FieldBotType:
  6687. v, ok := value.(uint8)
  6688. if !ok {
  6689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6690. }
  6691. m.SetBotType(v)
  6692. return nil
  6693. }
  6694. return fmt.Errorf("unknown ChatSession field %s", name)
  6695. }
  6696. // AddedFields returns all numeric fields that were incremented/decremented during
  6697. // this mutation.
  6698. func (m *ChatSessionMutation) AddedFields() []string {
  6699. var fields []string
  6700. if m.adduser_id != nil {
  6701. fields = append(fields, chatsession.FieldUserID)
  6702. }
  6703. if m.addbot_id != nil {
  6704. fields = append(fields, chatsession.FieldBotID)
  6705. }
  6706. if m.addbot_type != nil {
  6707. fields = append(fields, chatsession.FieldBotType)
  6708. }
  6709. return fields
  6710. }
  6711. // AddedField returns the numeric value that was incremented/decremented on a field
  6712. // with the given name. The second boolean return value indicates that this field
  6713. // was not set, or was not defined in the schema.
  6714. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  6715. switch name {
  6716. case chatsession.FieldUserID:
  6717. return m.AddedUserID()
  6718. case chatsession.FieldBotID:
  6719. return m.AddedBotID()
  6720. case chatsession.FieldBotType:
  6721. return m.AddedBotType()
  6722. }
  6723. return nil, false
  6724. }
  6725. // AddField adds the value to the field with the given name. It returns an error if
  6726. // the field is not defined in the schema, or if the type mismatched the field
  6727. // type.
  6728. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  6729. switch name {
  6730. case chatsession.FieldUserID:
  6731. v, ok := value.(int64)
  6732. if !ok {
  6733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6734. }
  6735. m.AddUserID(v)
  6736. return nil
  6737. case chatsession.FieldBotID:
  6738. v, ok := value.(int64)
  6739. if !ok {
  6740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6741. }
  6742. m.AddBotID(v)
  6743. return nil
  6744. case chatsession.FieldBotType:
  6745. v, ok := value.(int8)
  6746. if !ok {
  6747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6748. }
  6749. m.AddBotType(v)
  6750. return nil
  6751. }
  6752. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  6753. }
  6754. // ClearedFields returns all nullable fields that were cleared during this
  6755. // mutation.
  6756. func (m *ChatSessionMutation) ClearedFields() []string {
  6757. var fields []string
  6758. if m.FieldCleared(chatsession.FieldDeletedAt) {
  6759. fields = append(fields, chatsession.FieldDeletedAt)
  6760. }
  6761. return fields
  6762. }
  6763. // FieldCleared returns a boolean indicating if a field with the given name was
  6764. // cleared in this mutation.
  6765. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  6766. _, ok := m.clearedFields[name]
  6767. return ok
  6768. }
  6769. // ClearField clears the value of the field with the given name. It returns an
  6770. // error if the field is not defined in the schema.
  6771. func (m *ChatSessionMutation) ClearField(name string) error {
  6772. switch name {
  6773. case chatsession.FieldDeletedAt:
  6774. m.ClearDeletedAt()
  6775. return nil
  6776. }
  6777. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  6778. }
  6779. // ResetField resets all changes in the mutation for the field with the given name.
  6780. // It returns an error if the field is not defined in the schema.
  6781. func (m *ChatSessionMutation) ResetField(name string) error {
  6782. switch name {
  6783. case chatsession.FieldCreatedAt:
  6784. m.ResetCreatedAt()
  6785. return nil
  6786. case chatsession.FieldUpdatedAt:
  6787. m.ResetUpdatedAt()
  6788. return nil
  6789. case chatsession.FieldDeletedAt:
  6790. m.ResetDeletedAt()
  6791. return nil
  6792. case chatsession.FieldName:
  6793. m.ResetName()
  6794. return nil
  6795. case chatsession.FieldUserID:
  6796. m.ResetUserID()
  6797. return nil
  6798. case chatsession.FieldBotID:
  6799. m.ResetBotID()
  6800. return nil
  6801. case chatsession.FieldBotType:
  6802. m.ResetBotType()
  6803. return nil
  6804. }
  6805. return fmt.Errorf("unknown ChatSession field %s", name)
  6806. }
  6807. // AddedEdges returns all edge names that were set/added in this mutation.
  6808. func (m *ChatSessionMutation) AddedEdges() []string {
  6809. edges := make([]string, 0, 0)
  6810. return edges
  6811. }
  6812. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6813. // name in this mutation.
  6814. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  6815. return nil
  6816. }
  6817. // RemovedEdges returns all edge names that were removed in this mutation.
  6818. func (m *ChatSessionMutation) RemovedEdges() []string {
  6819. edges := make([]string, 0, 0)
  6820. return edges
  6821. }
  6822. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6823. // the given name in this mutation.
  6824. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  6825. return nil
  6826. }
  6827. // ClearedEdges returns all edge names that were cleared in this mutation.
  6828. func (m *ChatSessionMutation) ClearedEdges() []string {
  6829. edges := make([]string, 0, 0)
  6830. return edges
  6831. }
  6832. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6833. // was cleared in this mutation.
  6834. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  6835. return false
  6836. }
  6837. // ClearEdge clears the value of the edge with the given name. It returns an error
  6838. // if that edge is not defined in the schema.
  6839. func (m *ChatSessionMutation) ClearEdge(name string) error {
  6840. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  6841. }
  6842. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6843. // It returns an error if the edge is not defined in the schema.
  6844. func (m *ChatSessionMutation) ResetEdge(name string) error {
  6845. return fmt.Errorf("unknown ChatSession edge %s", name)
  6846. }
  6847. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  6848. type ContactMutation struct {
  6849. config
  6850. op Op
  6851. typ string
  6852. id *uint64
  6853. created_at *time.Time
  6854. updated_at *time.Time
  6855. status *uint8
  6856. addstatus *int8
  6857. deleted_at *time.Time
  6858. wx_wxid *string
  6859. _type *int
  6860. add_type *int
  6861. wxid *string
  6862. account *string
  6863. nickname *string
  6864. markname *string
  6865. headimg *string
  6866. sex *int
  6867. addsex *int
  6868. starrole *string
  6869. dontseeit *int
  6870. adddontseeit *int
  6871. dontseeme *int
  6872. adddontseeme *int
  6873. lag *string
  6874. gid *string
  6875. gname *string
  6876. v3 *string
  6877. organization_id *uint64
  6878. addorganization_id *int64
  6879. clearedFields map[string]struct{}
  6880. contact_relationships map[uint64]struct{}
  6881. removedcontact_relationships map[uint64]struct{}
  6882. clearedcontact_relationships bool
  6883. contact_messages map[uint64]struct{}
  6884. removedcontact_messages map[uint64]struct{}
  6885. clearedcontact_messages bool
  6886. done bool
  6887. oldValue func(context.Context) (*Contact, error)
  6888. predicates []predicate.Contact
  6889. }
  6890. var _ ent.Mutation = (*ContactMutation)(nil)
  6891. // contactOption allows management of the mutation configuration using functional options.
  6892. type contactOption func(*ContactMutation)
  6893. // newContactMutation creates new mutation for the Contact entity.
  6894. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  6895. m := &ContactMutation{
  6896. config: c,
  6897. op: op,
  6898. typ: TypeContact,
  6899. clearedFields: make(map[string]struct{}),
  6900. }
  6901. for _, opt := range opts {
  6902. opt(m)
  6903. }
  6904. return m
  6905. }
  6906. // withContactID sets the ID field of the mutation.
  6907. func withContactID(id uint64) contactOption {
  6908. return func(m *ContactMutation) {
  6909. var (
  6910. err error
  6911. once sync.Once
  6912. value *Contact
  6913. )
  6914. m.oldValue = func(ctx context.Context) (*Contact, error) {
  6915. once.Do(func() {
  6916. if m.done {
  6917. err = errors.New("querying old values post mutation is not allowed")
  6918. } else {
  6919. value, err = m.Client().Contact.Get(ctx, id)
  6920. }
  6921. })
  6922. return value, err
  6923. }
  6924. m.id = &id
  6925. }
  6926. }
  6927. // withContact sets the old Contact of the mutation.
  6928. func withContact(node *Contact) contactOption {
  6929. return func(m *ContactMutation) {
  6930. m.oldValue = func(context.Context) (*Contact, error) {
  6931. return node, nil
  6932. }
  6933. m.id = &node.ID
  6934. }
  6935. }
  6936. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6937. // executed in a transaction (ent.Tx), a transactional client is returned.
  6938. func (m ContactMutation) Client() *Client {
  6939. client := &Client{config: m.config}
  6940. client.init()
  6941. return client
  6942. }
  6943. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6944. // it returns an error otherwise.
  6945. func (m ContactMutation) Tx() (*Tx, error) {
  6946. if _, ok := m.driver.(*txDriver); !ok {
  6947. return nil, errors.New("ent: mutation is not running in a transaction")
  6948. }
  6949. tx := &Tx{config: m.config}
  6950. tx.init()
  6951. return tx, nil
  6952. }
  6953. // SetID sets the value of the id field. Note that this
  6954. // operation is only accepted on creation of Contact entities.
  6955. func (m *ContactMutation) SetID(id uint64) {
  6956. m.id = &id
  6957. }
  6958. // ID returns the ID value in the mutation. Note that the ID is only available
  6959. // if it was provided to the builder or after it was returned from the database.
  6960. func (m *ContactMutation) ID() (id uint64, exists bool) {
  6961. if m.id == nil {
  6962. return
  6963. }
  6964. return *m.id, true
  6965. }
  6966. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6967. // That means, if the mutation is applied within a transaction with an isolation level such
  6968. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6969. // or updated by the mutation.
  6970. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  6971. switch {
  6972. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6973. id, exists := m.ID()
  6974. if exists {
  6975. return []uint64{id}, nil
  6976. }
  6977. fallthrough
  6978. case m.op.Is(OpUpdate | OpDelete):
  6979. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  6980. default:
  6981. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6982. }
  6983. }
  6984. // SetCreatedAt sets the "created_at" field.
  6985. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  6986. m.created_at = &t
  6987. }
  6988. // CreatedAt returns the value of the "created_at" field in the mutation.
  6989. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  6990. v := m.created_at
  6991. if v == nil {
  6992. return
  6993. }
  6994. return *v, true
  6995. }
  6996. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  6997. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  6998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6999. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7000. if !m.op.Is(OpUpdateOne) {
  7001. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7002. }
  7003. if m.id == nil || m.oldValue == nil {
  7004. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7005. }
  7006. oldValue, err := m.oldValue(ctx)
  7007. if err != nil {
  7008. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7009. }
  7010. return oldValue.CreatedAt, nil
  7011. }
  7012. // ResetCreatedAt resets all changes to the "created_at" field.
  7013. func (m *ContactMutation) ResetCreatedAt() {
  7014. m.created_at = nil
  7015. }
  7016. // SetUpdatedAt sets the "updated_at" field.
  7017. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  7018. m.updated_at = &t
  7019. }
  7020. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7021. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  7022. v := m.updated_at
  7023. if v == nil {
  7024. return
  7025. }
  7026. return *v, true
  7027. }
  7028. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  7029. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7031. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7032. if !m.op.Is(OpUpdateOne) {
  7033. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7034. }
  7035. if m.id == nil || m.oldValue == nil {
  7036. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7037. }
  7038. oldValue, err := m.oldValue(ctx)
  7039. if err != nil {
  7040. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7041. }
  7042. return oldValue.UpdatedAt, nil
  7043. }
  7044. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7045. func (m *ContactMutation) ResetUpdatedAt() {
  7046. m.updated_at = nil
  7047. }
  7048. // SetStatus sets the "status" field.
  7049. func (m *ContactMutation) SetStatus(u uint8) {
  7050. m.status = &u
  7051. m.addstatus = nil
  7052. }
  7053. // Status returns the value of the "status" field in the mutation.
  7054. func (m *ContactMutation) Status() (r uint8, exists bool) {
  7055. v := m.status
  7056. if v == nil {
  7057. return
  7058. }
  7059. return *v, true
  7060. }
  7061. // OldStatus returns the old "status" field's value of the Contact entity.
  7062. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7064. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7065. if !m.op.Is(OpUpdateOne) {
  7066. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7067. }
  7068. if m.id == nil || m.oldValue == nil {
  7069. return v, errors.New("OldStatus requires an ID field in the mutation")
  7070. }
  7071. oldValue, err := m.oldValue(ctx)
  7072. if err != nil {
  7073. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7074. }
  7075. return oldValue.Status, nil
  7076. }
  7077. // AddStatus adds u to the "status" field.
  7078. func (m *ContactMutation) AddStatus(u int8) {
  7079. if m.addstatus != nil {
  7080. *m.addstatus += u
  7081. } else {
  7082. m.addstatus = &u
  7083. }
  7084. }
  7085. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7086. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  7087. v := m.addstatus
  7088. if v == nil {
  7089. return
  7090. }
  7091. return *v, true
  7092. }
  7093. // ClearStatus clears the value of the "status" field.
  7094. func (m *ContactMutation) ClearStatus() {
  7095. m.status = nil
  7096. m.addstatus = nil
  7097. m.clearedFields[contact.FieldStatus] = struct{}{}
  7098. }
  7099. // StatusCleared returns if the "status" field was cleared in this mutation.
  7100. func (m *ContactMutation) StatusCleared() bool {
  7101. _, ok := m.clearedFields[contact.FieldStatus]
  7102. return ok
  7103. }
  7104. // ResetStatus resets all changes to the "status" field.
  7105. func (m *ContactMutation) ResetStatus() {
  7106. m.status = nil
  7107. m.addstatus = nil
  7108. delete(m.clearedFields, contact.FieldStatus)
  7109. }
  7110. // SetDeletedAt sets the "deleted_at" field.
  7111. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  7112. m.deleted_at = &t
  7113. }
  7114. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7115. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  7116. v := m.deleted_at
  7117. if v == nil {
  7118. return
  7119. }
  7120. return *v, true
  7121. }
  7122. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  7123. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7125. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7126. if !m.op.Is(OpUpdateOne) {
  7127. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7128. }
  7129. if m.id == nil || m.oldValue == nil {
  7130. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7131. }
  7132. oldValue, err := m.oldValue(ctx)
  7133. if err != nil {
  7134. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7135. }
  7136. return oldValue.DeletedAt, nil
  7137. }
  7138. // ClearDeletedAt clears the value of the "deleted_at" field.
  7139. func (m *ContactMutation) ClearDeletedAt() {
  7140. m.deleted_at = nil
  7141. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  7142. }
  7143. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7144. func (m *ContactMutation) DeletedAtCleared() bool {
  7145. _, ok := m.clearedFields[contact.FieldDeletedAt]
  7146. return ok
  7147. }
  7148. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7149. func (m *ContactMutation) ResetDeletedAt() {
  7150. m.deleted_at = nil
  7151. delete(m.clearedFields, contact.FieldDeletedAt)
  7152. }
  7153. // SetWxWxid sets the "wx_wxid" field.
  7154. func (m *ContactMutation) SetWxWxid(s string) {
  7155. m.wx_wxid = &s
  7156. }
  7157. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7158. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  7159. v := m.wx_wxid
  7160. if v == nil {
  7161. return
  7162. }
  7163. return *v, true
  7164. }
  7165. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  7166. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7167. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7168. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  7169. if !m.op.Is(OpUpdateOne) {
  7170. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  7171. }
  7172. if m.id == nil || m.oldValue == nil {
  7173. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  7174. }
  7175. oldValue, err := m.oldValue(ctx)
  7176. if err != nil {
  7177. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  7178. }
  7179. return oldValue.WxWxid, nil
  7180. }
  7181. // ResetWxWxid resets all changes to the "wx_wxid" field.
  7182. func (m *ContactMutation) ResetWxWxid() {
  7183. m.wx_wxid = nil
  7184. }
  7185. // SetType sets the "type" field.
  7186. func (m *ContactMutation) SetType(i int) {
  7187. m._type = &i
  7188. m.add_type = nil
  7189. }
  7190. // GetType returns the value of the "type" field in the mutation.
  7191. func (m *ContactMutation) GetType() (r int, exists bool) {
  7192. v := m._type
  7193. if v == nil {
  7194. return
  7195. }
  7196. return *v, true
  7197. }
  7198. // OldType returns the old "type" field's value of the Contact entity.
  7199. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7200. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7201. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  7202. if !m.op.Is(OpUpdateOne) {
  7203. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7204. }
  7205. if m.id == nil || m.oldValue == nil {
  7206. return v, errors.New("OldType requires an ID field in the mutation")
  7207. }
  7208. oldValue, err := m.oldValue(ctx)
  7209. if err != nil {
  7210. return v, fmt.Errorf("querying old value for OldType: %w", err)
  7211. }
  7212. return oldValue.Type, nil
  7213. }
  7214. // AddType adds i to the "type" field.
  7215. func (m *ContactMutation) AddType(i int) {
  7216. if m.add_type != nil {
  7217. *m.add_type += i
  7218. } else {
  7219. m.add_type = &i
  7220. }
  7221. }
  7222. // AddedType returns the value that was added to the "type" field in this mutation.
  7223. func (m *ContactMutation) AddedType() (r int, exists bool) {
  7224. v := m.add_type
  7225. if v == nil {
  7226. return
  7227. }
  7228. return *v, true
  7229. }
  7230. // ClearType clears the value of the "type" field.
  7231. func (m *ContactMutation) ClearType() {
  7232. m._type = nil
  7233. m.add_type = nil
  7234. m.clearedFields[contact.FieldType] = struct{}{}
  7235. }
  7236. // TypeCleared returns if the "type" field was cleared in this mutation.
  7237. func (m *ContactMutation) TypeCleared() bool {
  7238. _, ok := m.clearedFields[contact.FieldType]
  7239. return ok
  7240. }
  7241. // ResetType resets all changes to the "type" field.
  7242. func (m *ContactMutation) ResetType() {
  7243. m._type = nil
  7244. m.add_type = nil
  7245. delete(m.clearedFields, contact.FieldType)
  7246. }
  7247. // SetWxid sets the "wxid" field.
  7248. func (m *ContactMutation) SetWxid(s string) {
  7249. m.wxid = &s
  7250. }
  7251. // Wxid returns the value of the "wxid" field in the mutation.
  7252. func (m *ContactMutation) Wxid() (r string, exists bool) {
  7253. v := m.wxid
  7254. if v == nil {
  7255. return
  7256. }
  7257. return *v, true
  7258. }
  7259. // OldWxid returns the old "wxid" field's value of the Contact entity.
  7260. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7262. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  7263. if !m.op.Is(OpUpdateOne) {
  7264. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  7265. }
  7266. if m.id == nil || m.oldValue == nil {
  7267. return v, errors.New("OldWxid requires an ID field in the mutation")
  7268. }
  7269. oldValue, err := m.oldValue(ctx)
  7270. if err != nil {
  7271. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  7272. }
  7273. return oldValue.Wxid, nil
  7274. }
  7275. // ResetWxid resets all changes to the "wxid" field.
  7276. func (m *ContactMutation) ResetWxid() {
  7277. m.wxid = nil
  7278. }
  7279. // SetAccount sets the "account" field.
  7280. func (m *ContactMutation) SetAccount(s string) {
  7281. m.account = &s
  7282. }
  7283. // Account returns the value of the "account" field in the mutation.
  7284. func (m *ContactMutation) Account() (r string, exists bool) {
  7285. v := m.account
  7286. if v == nil {
  7287. return
  7288. }
  7289. return *v, true
  7290. }
  7291. // OldAccount returns the old "account" field's value of the Contact entity.
  7292. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7294. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  7295. if !m.op.Is(OpUpdateOne) {
  7296. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  7297. }
  7298. if m.id == nil || m.oldValue == nil {
  7299. return v, errors.New("OldAccount requires an ID field in the mutation")
  7300. }
  7301. oldValue, err := m.oldValue(ctx)
  7302. if err != nil {
  7303. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  7304. }
  7305. return oldValue.Account, nil
  7306. }
  7307. // ResetAccount resets all changes to the "account" field.
  7308. func (m *ContactMutation) ResetAccount() {
  7309. m.account = nil
  7310. }
  7311. // SetNickname sets the "nickname" field.
  7312. func (m *ContactMutation) SetNickname(s string) {
  7313. m.nickname = &s
  7314. }
  7315. // Nickname returns the value of the "nickname" field in the mutation.
  7316. func (m *ContactMutation) Nickname() (r string, exists bool) {
  7317. v := m.nickname
  7318. if v == nil {
  7319. return
  7320. }
  7321. return *v, true
  7322. }
  7323. // OldNickname returns the old "nickname" field's value of the Contact entity.
  7324. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7326. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  7327. if !m.op.Is(OpUpdateOne) {
  7328. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  7329. }
  7330. if m.id == nil || m.oldValue == nil {
  7331. return v, errors.New("OldNickname requires an ID field in the mutation")
  7332. }
  7333. oldValue, err := m.oldValue(ctx)
  7334. if err != nil {
  7335. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  7336. }
  7337. return oldValue.Nickname, nil
  7338. }
  7339. // ResetNickname resets all changes to the "nickname" field.
  7340. func (m *ContactMutation) ResetNickname() {
  7341. m.nickname = nil
  7342. }
  7343. // SetMarkname sets the "markname" field.
  7344. func (m *ContactMutation) SetMarkname(s string) {
  7345. m.markname = &s
  7346. }
  7347. // Markname returns the value of the "markname" field in the mutation.
  7348. func (m *ContactMutation) Markname() (r string, exists bool) {
  7349. v := m.markname
  7350. if v == nil {
  7351. return
  7352. }
  7353. return *v, true
  7354. }
  7355. // OldMarkname returns the old "markname" field's value of the Contact entity.
  7356. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7357. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7358. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  7359. if !m.op.Is(OpUpdateOne) {
  7360. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  7361. }
  7362. if m.id == nil || m.oldValue == nil {
  7363. return v, errors.New("OldMarkname requires an ID field in the mutation")
  7364. }
  7365. oldValue, err := m.oldValue(ctx)
  7366. if err != nil {
  7367. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  7368. }
  7369. return oldValue.Markname, nil
  7370. }
  7371. // ResetMarkname resets all changes to the "markname" field.
  7372. func (m *ContactMutation) ResetMarkname() {
  7373. m.markname = nil
  7374. }
  7375. // SetHeadimg sets the "headimg" field.
  7376. func (m *ContactMutation) SetHeadimg(s string) {
  7377. m.headimg = &s
  7378. }
  7379. // Headimg returns the value of the "headimg" field in the mutation.
  7380. func (m *ContactMutation) Headimg() (r string, exists bool) {
  7381. v := m.headimg
  7382. if v == nil {
  7383. return
  7384. }
  7385. return *v, true
  7386. }
  7387. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  7388. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7390. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  7391. if !m.op.Is(OpUpdateOne) {
  7392. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  7393. }
  7394. if m.id == nil || m.oldValue == nil {
  7395. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  7396. }
  7397. oldValue, err := m.oldValue(ctx)
  7398. if err != nil {
  7399. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  7400. }
  7401. return oldValue.Headimg, nil
  7402. }
  7403. // ResetHeadimg resets all changes to the "headimg" field.
  7404. func (m *ContactMutation) ResetHeadimg() {
  7405. m.headimg = nil
  7406. }
  7407. // SetSex sets the "sex" field.
  7408. func (m *ContactMutation) SetSex(i int) {
  7409. m.sex = &i
  7410. m.addsex = nil
  7411. }
  7412. // Sex returns the value of the "sex" field in the mutation.
  7413. func (m *ContactMutation) Sex() (r int, exists bool) {
  7414. v := m.sex
  7415. if v == nil {
  7416. return
  7417. }
  7418. return *v, true
  7419. }
  7420. // OldSex returns the old "sex" field's value of the Contact entity.
  7421. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7423. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  7424. if !m.op.Is(OpUpdateOne) {
  7425. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  7426. }
  7427. if m.id == nil || m.oldValue == nil {
  7428. return v, errors.New("OldSex requires an ID field in the mutation")
  7429. }
  7430. oldValue, err := m.oldValue(ctx)
  7431. if err != nil {
  7432. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  7433. }
  7434. return oldValue.Sex, nil
  7435. }
  7436. // AddSex adds i to the "sex" field.
  7437. func (m *ContactMutation) AddSex(i int) {
  7438. if m.addsex != nil {
  7439. *m.addsex += i
  7440. } else {
  7441. m.addsex = &i
  7442. }
  7443. }
  7444. // AddedSex returns the value that was added to the "sex" field in this mutation.
  7445. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  7446. v := m.addsex
  7447. if v == nil {
  7448. return
  7449. }
  7450. return *v, true
  7451. }
  7452. // ResetSex resets all changes to the "sex" field.
  7453. func (m *ContactMutation) ResetSex() {
  7454. m.sex = nil
  7455. m.addsex = nil
  7456. }
  7457. // SetStarrole sets the "starrole" field.
  7458. func (m *ContactMutation) SetStarrole(s string) {
  7459. m.starrole = &s
  7460. }
  7461. // Starrole returns the value of the "starrole" field in the mutation.
  7462. func (m *ContactMutation) Starrole() (r string, exists bool) {
  7463. v := m.starrole
  7464. if v == nil {
  7465. return
  7466. }
  7467. return *v, true
  7468. }
  7469. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  7470. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7472. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  7473. if !m.op.Is(OpUpdateOne) {
  7474. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  7475. }
  7476. if m.id == nil || m.oldValue == nil {
  7477. return v, errors.New("OldStarrole requires an ID field in the mutation")
  7478. }
  7479. oldValue, err := m.oldValue(ctx)
  7480. if err != nil {
  7481. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  7482. }
  7483. return oldValue.Starrole, nil
  7484. }
  7485. // ResetStarrole resets all changes to the "starrole" field.
  7486. func (m *ContactMutation) ResetStarrole() {
  7487. m.starrole = nil
  7488. }
  7489. // SetDontseeit sets the "dontseeit" field.
  7490. func (m *ContactMutation) SetDontseeit(i int) {
  7491. m.dontseeit = &i
  7492. m.adddontseeit = nil
  7493. }
  7494. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  7495. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  7496. v := m.dontseeit
  7497. if v == nil {
  7498. return
  7499. }
  7500. return *v, true
  7501. }
  7502. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  7503. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7505. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  7506. if !m.op.Is(OpUpdateOne) {
  7507. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  7508. }
  7509. if m.id == nil || m.oldValue == nil {
  7510. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  7511. }
  7512. oldValue, err := m.oldValue(ctx)
  7513. if err != nil {
  7514. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  7515. }
  7516. return oldValue.Dontseeit, nil
  7517. }
  7518. // AddDontseeit adds i to the "dontseeit" field.
  7519. func (m *ContactMutation) AddDontseeit(i int) {
  7520. if m.adddontseeit != nil {
  7521. *m.adddontseeit += i
  7522. } else {
  7523. m.adddontseeit = &i
  7524. }
  7525. }
  7526. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  7527. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  7528. v := m.adddontseeit
  7529. if v == nil {
  7530. return
  7531. }
  7532. return *v, true
  7533. }
  7534. // ResetDontseeit resets all changes to the "dontseeit" field.
  7535. func (m *ContactMutation) ResetDontseeit() {
  7536. m.dontseeit = nil
  7537. m.adddontseeit = nil
  7538. }
  7539. // SetDontseeme sets the "dontseeme" field.
  7540. func (m *ContactMutation) SetDontseeme(i int) {
  7541. m.dontseeme = &i
  7542. m.adddontseeme = nil
  7543. }
  7544. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  7545. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  7546. v := m.dontseeme
  7547. if v == nil {
  7548. return
  7549. }
  7550. return *v, true
  7551. }
  7552. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  7553. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7555. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  7556. if !m.op.Is(OpUpdateOne) {
  7557. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  7558. }
  7559. if m.id == nil || m.oldValue == nil {
  7560. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  7561. }
  7562. oldValue, err := m.oldValue(ctx)
  7563. if err != nil {
  7564. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  7565. }
  7566. return oldValue.Dontseeme, nil
  7567. }
  7568. // AddDontseeme adds i to the "dontseeme" field.
  7569. func (m *ContactMutation) AddDontseeme(i int) {
  7570. if m.adddontseeme != nil {
  7571. *m.adddontseeme += i
  7572. } else {
  7573. m.adddontseeme = &i
  7574. }
  7575. }
  7576. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  7577. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  7578. v := m.adddontseeme
  7579. if v == nil {
  7580. return
  7581. }
  7582. return *v, true
  7583. }
  7584. // ResetDontseeme resets all changes to the "dontseeme" field.
  7585. func (m *ContactMutation) ResetDontseeme() {
  7586. m.dontseeme = nil
  7587. m.adddontseeme = nil
  7588. }
  7589. // SetLag sets the "lag" field.
  7590. func (m *ContactMutation) SetLag(s string) {
  7591. m.lag = &s
  7592. }
  7593. // Lag returns the value of the "lag" field in the mutation.
  7594. func (m *ContactMutation) Lag() (r string, exists bool) {
  7595. v := m.lag
  7596. if v == nil {
  7597. return
  7598. }
  7599. return *v, true
  7600. }
  7601. // OldLag returns the old "lag" field's value of the Contact entity.
  7602. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7603. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7604. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  7605. if !m.op.Is(OpUpdateOne) {
  7606. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  7607. }
  7608. if m.id == nil || m.oldValue == nil {
  7609. return v, errors.New("OldLag requires an ID field in the mutation")
  7610. }
  7611. oldValue, err := m.oldValue(ctx)
  7612. if err != nil {
  7613. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  7614. }
  7615. return oldValue.Lag, nil
  7616. }
  7617. // ResetLag resets all changes to the "lag" field.
  7618. func (m *ContactMutation) ResetLag() {
  7619. m.lag = nil
  7620. }
  7621. // SetGid sets the "gid" field.
  7622. func (m *ContactMutation) SetGid(s string) {
  7623. m.gid = &s
  7624. }
  7625. // Gid returns the value of the "gid" field in the mutation.
  7626. func (m *ContactMutation) Gid() (r string, exists bool) {
  7627. v := m.gid
  7628. if v == nil {
  7629. return
  7630. }
  7631. return *v, true
  7632. }
  7633. // OldGid returns the old "gid" field's value of the Contact entity.
  7634. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7635. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7636. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  7637. if !m.op.Is(OpUpdateOne) {
  7638. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  7639. }
  7640. if m.id == nil || m.oldValue == nil {
  7641. return v, errors.New("OldGid requires an ID field in the mutation")
  7642. }
  7643. oldValue, err := m.oldValue(ctx)
  7644. if err != nil {
  7645. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  7646. }
  7647. return oldValue.Gid, nil
  7648. }
  7649. // ResetGid resets all changes to the "gid" field.
  7650. func (m *ContactMutation) ResetGid() {
  7651. m.gid = nil
  7652. }
  7653. // SetGname sets the "gname" field.
  7654. func (m *ContactMutation) SetGname(s string) {
  7655. m.gname = &s
  7656. }
  7657. // Gname returns the value of the "gname" field in the mutation.
  7658. func (m *ContactMutation) Gname() (r string, exists bool) {
  7659. v := m.gname
  7660. if v == nil {
  7661. return
  7662. }
  7663. return *v, true
  7664. }
  7665. // OldGname returns the old "gname" field's value of the Contact entity.
  7666. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7667. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7668. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  7669. if !m.op.Is(OpUpdateOne) {
  7670. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  7671. }
  7672. if m.id == nil || m.oldValue == nil {
  7673. return v, errors.New("OldGname requires an ID field in the mutation")
  7674. }
  7675. oldValue, err := m.oldValue(ctx)
  7676. if err != nil {
  7677. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  7678. }
  7679. return oldValue.Gname, nil
  7680. }
  7681. // ResetGname resets all changes to the "gname" field.
  7682. func (m *ContactMutation) ResetGname() {
  7683. m.gname = nil
  7684. }
  7685. // SetV3 sets the "v3" field.
  7686. func (m *ContactMutation) SetV3(s string) {
  7687. m.v3 = &s
  7688. }
  7689. // V3 returns the value of the "v3" field in the mutation.
  7690. func (m *ContactMutation) V3() (r string, exists bool) {
  7691. v := m.v3
  7692. if v == nil {
  7693. return
  7694. }
  7695. return *v, true
  7696. }
  7697. // OldV3 returns the old "v3" field's value of the Contact entity.
  7698. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7699. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7700. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  7701. if !m.op.Is(OpUpdateOne) {
  7702. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  7703. }
  7704. if m.id == nil || m.oldValue == nil {
  7705. return v, errors.New("OldV3 requires an ID field in the mutation")
  7706. }
  7707. oldValue, err := m.oldValue(ctx)
  7708. if err != nil {
  7709. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  7710. }
  7711. return oldValue.V3, nil
  7712. }
  7713. // ResetV3 resets all changes to the "v3" field.
  7714. func (m *ContactMutation) ResetV3() {
  7715. m.v3 = nil
  7716. }
  7717. // SetOrganizationID sets the "organization_id" field.
  7718. func (m *ContactMutation) SetOrganizationID(u uint64) {
  7719. m.organization_id = &u
  7720. m.addorganization_id = nil
  7721. }
  7722. // OrganizationID returns the value of the "organization_id" field in the mutation.
  7723. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  7724. v := m.organization_id
  7725. if v == nil {
  7726. return
  7727. }
  7728. return *v, true
  7729. }
  7730. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  7731. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7732. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7733. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  7734. if !m.op.Is(OpUpdateOne) {
  7735. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  7736. }
  7737. if m.id == nil || m.oldValue == nil {
  7738. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  7739. }
  7740. oldValue, err := m.oldValue(ctx)
  7741. if err != nil {
  7742. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  7743. }
  7744. return oldValue.OrganizationID, nil
  7745. }
  7746. // AddOrganizationID adds u to the "organization_id" field.
  7747. func (m *ContactMutation) AddOrganizationID(u int64) {
  7748. if m.addorganization_id != nil {
  7749. *m.addorganization_id += u
  7750. } else {
  7751. m.addorganization_id = &u
  7752. }
  7753. }
  7754. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  7755. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  7756. v := m.addorganization_id
  7757. if v == nil {
  7758. return
  7759. }
  7760. return *v, true
  7761. }
  7762. // ClearOrganizationID clears the value of the "organization_id" field.
  7763. func (m *ContactMutation) ClearOrganizationID() {
  7764. m.organization_id = nil
  7765. m.addorganization_id = nil
  7766. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  7767. }
  7768. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  7769. func (m *ContactMutation) OrganizationIDCleared() bool {
  7770. _, ok := m.clearedFields[contact.FieldOrganizationID]
  7771. return ok
  7772. }
  7773. // ResetOrganizationID resets all changes to the "organization_id" field.
  7774. func (m *ContactMutation) ResetOrganizationID() {
  7775. m.organization_id = nil
  7776. m.addorganization_id = nil
  7777. delete(m.clearedFields, contact.FieldOrganizationID)
  7778. }
  7779. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  7780. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  7781. if m.contact_relationships == nil {
  7782. m.contact_relationships = make(map[uint64]struct{})
  7783. }
  7784. for i := range ids {
  7785. m.contact_relationships[ids[i]] = struct{}{}
  7786. }
  7787. }
  7788. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  7789. func (m *ContactMutation) ClearContactRelationships() {
  7790. m.clearedcontact_relationships = true
  7791. }
  7792. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  7793. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  7794. return m.clearedcontact_relationships
  7795. }
  7796. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  7797. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  7798. if m.removedcontact_relationships == nil {
  7799. m.removedcontact_relationships = make(map[uint64]struct{})
  7800. }
  7801. for i := range ids {
  7802. delete(m.contact_relationships, ids[i])
  7803. m.removedcontact_relationships[ids[i]] = struct{}{}
  7804. }
  7805. }
  7806. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  7807. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  7808. for id := range m.removedcontact_relationships {
  7809. ids = append(ids, id)
  7810. }
  7811. return
  7812. }
  7813. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  7814. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  7815. for id := range m.contact_relationships {
  7816. ids = append(ids, id)
  7817. }
  7818. return
  7819. }
  7820. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  7821. func (m *ContactMutation) ResetContactRelationships() {
  7822. m.contact_relationships = nil
  7823. m.clearedcontact_relationships = false
  7824. m.removedcontact_relationships = nil
  7825. }
  7826. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  7827. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  7828. if m.contact_messages == nil {
  7829. m.contact_messages = make(map[uint64]struct{})
  7830. }
  7831. for i := range ids {
  7832. m.contact_messages[ids[i]] = struct{}{}
  7833. }
  7834. }
  7835. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  7836. func (m *ContactMutation) ClearContactMessages() {
  7837. m.clearedcontact_messages = true
  7838. }
  7839. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  7840. func (m *ContactMutation) ContactMessagesCleared() bool {
  7841. return m.clearedcontact_messages
  7842. }
  7843. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  7844. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  7845. if m.removedcontact_messages == nil {
  7846. m.removedcontact_messages = make(map[uint64]struct{})
  7847. }
  7848. for i := range ids {
  7849. delete(m.contact_messages, ids[i])
  7850. m.removedcontact_messages[ids[i]] = struct{}{}
  7851. }
  7852. }
  7853. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  7854. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  7855. for id := range m.removedcontact_messages {
  7856. ids = append(ids, id)
  7857. }
  7858. return
  7859. }
  7860. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  7861. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  7862. for id := range m.contact_messages {
  7863. ids = append(ids, id)
  7864. }
  7865. return
  7866. }
  7867. // ResetContactMessages resets all changes to the "contact_messages" edge.
  7868. func (m *ContactMutation) ResetContactMessages() {
  7869. m.contact_messages = nil
  7870. m.clearedcontact_messages = false
  7871. m.removedcontact_messages = nil
  7872. }
  7873. // Where appends a list predicates to the ContactMutation builder.
  7874. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  7875. m.predicates = append(m.predicates, ps...)
  7876. }
  7877. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  7878. // users can use type-assertion to append predicates that do not depend on any generated package.
  7879. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  7880. p := make([]predicate.Contact, len(ps))
  7881. for i := range ps {
  7882. p[i] = ps[i]
  7883. }
  7884. m.Where(p...)
  7885. }
  7886. // Op returns the operation name.
  7887. func (m *ContactMutation) Op() Op {
  7888. return m.op
  7889. }
  7890. // SetOp allows setting the mutation operation.
  7891. func (m *ContactMutation) SetOp(op Op) {
  7892. m.op = op
  7893. }
  7894. // Type returns the node type of this mutation (Contact).
  7895. func (m *ContactMutation) Type() string {
  7896. return m.typ
  7897. }
  7898. // Fields returns all fields that were changed during this mutation. Note that in
  7899. // order to get all numeric fields that were incremented/decremented, call
  7900. // AddedFields().
  7901. func (m *ContactMutation) Fields() []string {
  7902. fields := make([]string, 0, 20)
  7903. if m.created_at != nil {
  7904. fields = append(fields, contact.FieldCreatedAt)
  7905. }
  7906. if m.updated_at != nil {
  7907. fields = append(fields, contact.FieldUpdatedAt)
  7908. }
  7909. if m.status != nil {
  7910. fields = append(fields, contact.FieldStatus)
  7911. }
  7912. if m.deleted_at != nil {
  7913. fields = append(fields, contact.FieldDeletedAt)
  7914. }
  7915. if m.wx_wxid != nil {
  7916. fields = append(fields, contact.FieldWxWxid)
  7917. }
  7918. if m._type != nil {
  7919. fields = append(fields, contact.FieldType)
  7920. }
  7921. if m.wxid != nil {
  7922. fields = append(fields, contact.FieldWxid)
  7923. }
  7924. if m.account != nil {
  7925. fields = append(fields, contact.FieldAccount)
  7926. }
  7927. if m.nickname != nil {
  7928. fields = append(fields, contact.FieldNickname)
  7929. }
  7930. if m.markname != nil {
  7931. fields = append(fields, contact.FieldMarkname)
  7932. }
  7933. if m.headimg != nil {
  7934. fields = append(fields, contact.FieldHeadimg)
  7935. }
  7936. if m.sex != nil {
  7937. fields = append(fields, contact.FieldSex)
  7938. }
  7939. if m.starrole != nil {
  7940. fields = append(fields, contact.FieldStarrole)
  7941. }
  7942. if m.dontseeit != nil {
  7943. fields = append(fields, contact.FieldDontseeit)
  7944. }
  7945. if m.dontseeme != nil {
  7946. fields = append(fields, contact.FieldDontseeme)
  7947. }
  7948. if m.lag != nil {
  7949. fields = append(fields, contact.FieldLag)
  7950. }
  7951. if m.gid != nil {
  7952. fields = append(fields, contact.FieldGid)
  7953. }
  7954. if m.gname != nil {
  7955. fields = append(fields, contact.FieldGname)
  7956. }
  7957. if m.v3 != nil {
  7958. fields = append(fields, contact.FieldV3)
  7959. }
  7960. if m.organization_id != nil {
  7961. fields = append(fields, contact.FieldOrganizationID)
  7962. }
  7963. return fields
  7964. }
  7965. // Field returns the value of a field with the given name. The second boolean
  7966. // return value indicates that this field was not set, or was not defined in the
  7967. // schema.
  7968. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  7969. switch name {
  7970. case contact.FieldCreatedAt:
  7971. return m.CreatedAt()
  7972. case contact.FieldUpdatedAt:
  7973. return m.UpdatedAt()
  7974. case contact.FieldStatus:
  7975. return m.Status()
  7976. case contact.FieldDeletedAt:
  7977. return m.DeletedAt()
  7978. case contact.FieldWxWxid:
  7979. return m.WxWxid()
  7980. case contact.FieldType:
  7981. return m.GetType()
  7982. case contact.FieldWxid:
  7983. return m.Wxid()
  7984. case contact.FieldAccount:
  7985. return m.Account()
  7986. case contact.FieldNickname:
  7987. return m.Nickname()
  7988. case contact.FieldMarkname:
  7989. return m.Markname()
  7990. case contact.FieldHeadimg:
  7991. return m.Headimg()
  7992. case contact.FieldSex:
  7993. return m.Sex()
  7994. case contact.FieldStarrole:
  7995. return m.Starrole()
  7996. case contact.FieldDontseeit:
  7997. return m.Dontseeit()
  7998. case contact.FieldDontseeme:
  7999. return m.Dontseeme()
  8000. case contact.FieldLag:
  8001. return m.Lag()
  8002. case contact.FieldGid:
  8003. return m.Gid()
  8004. case contact.FieldGname:
  8005. return m.Gname()
  8006. case contact.FieldV3:
  8007. return m.V3()
  8008. case contact.FieldOrganizationID:
  8009. return m.OrganizationID()
  8010. }
  8011. return nil, false
  8012. }
  8013. // OldField returns the old value of the field from the database. An error is
  8014. // returned if the mutation operation is not UpdateOne, or the query to the
  8015. // database failed.
  8016. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8017. switch name {
  8018. case contact.FieldCreatedAt:
  8019. return m.OldCreatedAt(ctx)
  8020. case contact.FieldUpdatedAt:
  8021. return m.OldUpdatedAt(ctx)
  8022. case contact.FieldStatus:
  8023. return m.OldStatus(ctx)
  8024. case contact.FieldDeletedAt:
  8025. return m.OldDeletedAt(ctx)
  8026. case contact.FieldWxWxid:
  8027. return m.OldWxWxid(ctx)
  8028. case contact.FieldType:
  8029. return m.OldType(ctx)
  8030. case contact.FieldWxid:
  8031. return m.OldWxid(ctx)
  8032. case contact.FieldAccount:
  8033. return m.OldAccount(ctx)
  8034. case contact.FieldNickname:
  8035. return m.OldNickname(ctx)
  8036. case contact.FieldMarkname:
  8037. return m.OldMarkname(ctx)
  8038. case contact.FieldHeadimg:
  8039. return m.OldHeadimg(ctx)
  8040. case contact.FieldSex:
  8041. return m.OldSex(ctx)
  8042. case contact.FieldStarrole:
  8043. return m.OldStarrole(ctx)
  8044. case contact.FieldDontseeit:
  8045. return m.OldDontseeit(ctx)
  8046. case contact.FieldDontseeme:
  8047. return m.OldDontseeme(ctx)
  8048. case contact.FieldLag:
  8049. return m.OldLag(ctx)
  8050. case contact.FieldGid:
  8051. return m.OldGid(ctx)
  8052. case contact.FieldGname:
  8053. return m.OldGname(ctx)
  8054. case contact.FieldV3:
  8055. return m.OldV3(ctx)
  8056. case contact.FieldOrganizationID:
  8057. return m.OldOrganizationID(ctx)
  8058. }
  8059. return nil, fmt.Errorf("unknown Contact field %s", name)
  8060. }
  8061. // SetField sets the value of a field with the given name. It returns an error if
  8062. // the field is not defined in the schema, or if the type mismatched the field
  8063. // type.
  8064. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  8065. switch name {
  8066. case contact.FieldCreatedAt:
  8067. v, ok := value.(time.Time)
  8068. if !ok {
  8069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8070. }
  8071. m.SetCreatedAt(v)
  8072. return nil
  8073. case contact.FieldUpdatedAt:
  8074. v, ok := value.(time.Time)
  8075. if !ok {
  8076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8077. }
  8078. m.SetUpdatedAt(v)
  8079. return nil
  8080. case contact.FieldStatus:
  8081. v, ok := value.(uint8)
  8082. if !ok {
  8083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8084. }
  8085. m.SetStatus(v)
  8086. return nil
  8087. case contact.FieldDeletedAt:
  8088. v, ok := value.(time.Time)
  8089. if !ok {
  8090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8091. }
  8092. m.SetDeletedAt(v)
  8093. return nil
  8094. case contact.FieldWxWxid:
  8095. v, ok := value.(string)
  8096. if !ok {
  8097. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8098. }
  8099. m.SetWxWxid(v)
  8100. return nil
  8101. case contact.FieldType:
  8102. v, ok := value.(int)
  8103. if !ok {
  8104. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8105. }
  8106. m.SetType(v)
  8107. return nil
  8108. case contact.FieldWxid:
  8109. v, ok := value.(string)
  8110. if !ok {
  8111. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8112. }
  8113. m.SetWxid(v)
  8114. return nil
  8115. case contact.FieldAccount:
  8116. v, ok := value.(string)
  8117. if !ok {
  8118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8119. }
  8120. m.SetAccount(v)
  8121. return nil
  8122. case contact.FieldNickname:
  8123. v, ok := value.(string)
  8124. if !ok {
  8125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8126. }
  8127. m.SetNickname(v)
  8128. return nil
  8129. case contact.FieldMarkname:
  8130. v, ok := value.(string)
  8131. if !ok {
  8132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8133. }
  8134. m.SetMarkname(v)
  8135. return nil
  8136. case contact.FieldHeadimg:
  8137. v, ok := value.(string)
  8138. if !ok {
  8139. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8140. }
  8141. m.SetHeadimg(v)
  8142. return nil
  8143. case contact.FieldSex:
  8144. v, ok := value.(int)
  8145. if !ok {
  8146. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8147. }
  8148. m.SetSex(v)
  8149. return nil
  8150. case contact.FieldStarrole:
  8151. v, ok := value.(string)
  8152. if !ok {
  8153. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8154. }
  8155. m.SetStarrole(v)
  8156. return nil
  8157. case contact.FieldDontseeit:
  8158. v, ok := value.(int)
  8159. if !ok {
  8160. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8161. }
  8162. m.SetDontseeit(v)
  8163. return nil
  8164. case contact.FieldDontseeme:
  8165. v, ok := value.(int)
  8166. if !ok {
  8167. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8168. }
  8169. m.SetDontseeme(v)
  8170. return nil
  8171. case contact.FieldLag:
  8172. v, ok := value.(string)
  8173. if !ok {
  8174. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8175. }
  8176. m.SetLag(v)
  8177. return nil
  8178. case contact.FieldGid:
  8179. v, ok := value.(string)
  8180. if !ok {
  8181. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8182. }
  8183. m.SetGid(v)
  8184. return nil
  8185. case contact.FieldGname:
  8186. v, ok := value.(string)
  8187. if !ok {
  8188. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8189. }
  8190. m.SetGname(v)
  8191. return nil
  8192. case contact.FieldV3:
  8193. v, ok := value.(string)
  8194. if !ok {
  8195. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8196. }
  8197. m.SetV3(v)
  8198. return nil
  8199. case contact.FieldOrganizationID:
  8200. v, ok := value.(uint64)
  8201. if !ok {
  8202. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8203. }
  8204. m.SetOrganizationID(v)
  8205. return nil
  8206. }
  8207. return fmt.Errorf("unknown Contact field %s", name)
  8208. }
  8209. // AddedFields returns all numeric fields that were incremented/decremented during
  8210. // this mutation.
  8211. func (m *ContactMutation) AddedFields() []string {
  8212. var fields []string
  8213. if m.addstatus != nil {
  8214. fields = append(fields, contact.FieldStatus)
  8215. }
  8216. if m.add_type != nil {
  8217. fields = append(fields, contact.FieldType)
  8218. }
  8219. if m.addsex != nil {
  8220. fields = append(fields, contact.FieldSex)
  8221. }
  8222. if m.adddontseeit != nil {
  8223. fields = append(fields, contact.FieldDontseeit)
  8224. }
  8225. if m.adddontseeme != nil {
  8226. fields = append(fields, contact.FieldDontseeme)
  8227. }
  8228. if m.addorganization_id != nil {
  8229. fields = append(fields, contact.FieldOrganizationID)
  8230. }
  8231. return fields
  8232. }
  8233. // AddedField returns the numeric value that was incremented/decremented on a field
  8234. // with the given name. The second boolean return value indicates that this field
  8235. // was not set, or was not defined in the schema.
  8236. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  8237. switch name {
  8238. case contact.FieldStatus:
  8239. return m.AddedStatus()
  8240. case contact.FieldType:
  8241. return m.AddedType()
  8242. case contact.FieldSex:
  8243. return m.AddedSex()
  8244. case contact.FieldDontseeit:
  8245. return m.AddedDontseeit()
  8246. case contact.FieldDontseeme:
  8247. return m.AddedDontseeme()
  8248. case contact.FieldOrganizationID:
  8249. return m.AddedOrganizationID()
  8250. }
  8251. return nil, false
  8252. }
  8253. // AddField adds the value to the field with the given name. It returns an error if
  8254. // the field is not defined in the schema, or if the type mismatched the field
  8255. // type.
  8256. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  8257. switch name {
  8258. case contact.FieldStatus:
  8259. v, ok := value.(int8)
  8260. if !ok {
  8261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8262. }
  8263. m.AddStatus(v)
  8264. return nil
  8265. case contact.FieldType:
  8266. v, ok := value.(int)
  8267. if !ok {
  8268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8269. }
  8270. m.AddType(v)
  8271. return nil
  8272. case contact.FieldSex:
  8273. v, ok := value.(int)
  8274. if !ok {
  8275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8276. }
  8277. m.AddSex(v)
  8278. return nil
  8279. case contact.FieldDontseeit:
  8280. v, ok := value.(int)
  8281. if !ok {
  8282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8283. }
  8284. m.AddDontseeit(v)
  8285. return nil
  8286. case contact.FieldDontseeme:
  8287. v, ok := value.(int)
  8288. if !ok {
  8289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8290. }
  8291. m.AddDontseeme(v)
  8292. return nil
  8293. case contact.FieldOrganizationID:
  8294. v, ok := value.(int64)
  8295. if !ok {
  8296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8297. }
  8298. m.AddOrganizationID(v)
  8299. return nil
  8300. }
  8301. return fmt.Errorf("unknown Contact numeric field %s", name)
  8302. }
  8303. // ClearedFields returns all nullable fields that were cleared during this
  8304. // mutation.
  8305. func (m *ContactMutation) ClearedFields() []string {
  8306. var fields []string
  8307. if m.FieldCleared(contact.FieldStatus) {
  8308. fields = append(fields, contact.FieldStatus)
  8309. }
  8310. if m.FieldCleared(contact.FieldDeletedAt) {
  8311. fields = append(fields, contact.FieldDeletedAt)
  8312. }
  8313. if m.FieldCleared(contact.FieldType) {
  8314. fields = append(fields, contact.FieldType)
  8315. }
  8316. if m.FieldCleared(contact.FieldOrganizationID) {
  8317. fields = append(fields, contact.FieldOrganizationID)
  8318. }
  8319. return fields
  8320. }
  8321. // FieldCleared returns a boolean indicating if a field with the given name was
  8322. // cleared in this mutation.
  8323. func (m *ContactMutation) FieldCleared(name string) bool {
  8324. _, ok := m.clearedFields[name]
  8325. return ok
  8326. }
  8327. // ClearField clears the value of the field with the given name. It returns an
  8328. // error if the field is not defined in the schema.
  8329. func (m *ContactMutation) ClearField(name string) error {
  8330. switch name {
  8331. case contact.FieldStatus:
  8332. m.ClearStatus()
  8333. return nil
  8334. case contact.FieldDeletedAt:
  8335. m.ClearDeletedAt()
  8336. return nil
  8337. case contact.FieldType:
  8338. m.ClearType()
  8339. return nil
  8340. case contact.FieldOrganizationID:
  8341. m.ClearOrganizationID()
  8342. return nil
  8343. }
  8344. return fmt.Errorf("unknown Contact nullable field %s", name)
  8345. }
  8346. // ResetField resets all changes in the mutation for the field with the given name.
  8347. // It returns an error if the field is not defined in the schema.
  8348. func (m *ContactMutation) ResetField(name string) error {
  8349. switch name {
  8350. case contact.FieldCreatedAt:
  8351. m.ResetCreatedAt()
  8352. return nil
  8353. case contact.FieldUpdatedAt:
  8354. m.ResetUpdatedAt()
  8355. return nil
  8356. case contact.FieldStatus:
  8357. m.ResetStatus()
  8358. return nil
  8359. case contact.FieldDeletedAt:
  8360. m.ResetDeletedAt()
  8361. return nil
  8362. case contact.FieldWxWxid:
  8363. m.ResetWxWxid()
  8364. return nil
  8365. case contact.FieldType:
  8366. m.ResetType()
  8367. return nil
  8368. case contact.FieldWxid:
  8369. m.ResetWxid()
  8370. return nil
  8371. case contact.FieldAccount:
  8372. m.ResetAccount()
  8373. return nil
  8374. case contact.FieldNickname:
  8375. m.ResetNickname()
  8376. return nil
  8377. case contact.FieldMarkname:
  8378. m.ResetMarkname()
  8379. return nil
  8380. case contact.FieldHeadimg:
  8381. m.ResetHeadimg()
  8382. return nil
  8383. case contact.FieldSex:
  8384. m.ResetSex()
  8385. return nil
  8386. case contact.FieldStarrole:
  8387. m.ResetStarrole()
  8388. return nil
  8389. case contact.FieldDontseeit:
  8390. m.ResetDontseeit()
  8391. return nil
  8392. case contact.FieldDontseeme:
  8393. m.ResetDontseeme()
  8394. return nil
  8395. case contact.FieldLag:
  8396. m.ResetLag()
  8397. return nil
  8398. case contact.FieldGid:
  8399. m.ResetGid()
  8400. return nil
  8401. case contact.FieldGname:
  8402. m.ResetGname()
  8403. return nil
  8404. case contact.FieldV3:
  8405. m.ResetV3()
  8406. return nil
  8407. case contact.FieldOrganizationID:
  8408. m.ResetOrganizationID()
  8409. return nil
  8410. }
  8411. return fmt.Errorf("unknown Contact field %s", name)
  8412. }
  8413. // AddedEdges returns all edge names that were set/added in this mutation.
  8414. func (m *ContactMutation) AddedEdges() []string {
  8415. edges := make([]string, 0, 2)
  8416. if m.contact_relationships != nil {
  8417. edges = append(edges, contact.EdgeContactRelationships)
  8418. }
  8419. if m.contact_messages != nil {
  8420. edges = append(edges, contact.EdgeContactMessages)
  8421. }
  8422. return edges
  8423. }
  8424. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  8425. // name in this mutation.
  8426. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  8427. switch name {
  8428. case contact.EdgeContactRelationships:
  8429. ids := make([]ent.Value, 0, len(m.contact_relationships))
  8430. for id := range m.contact_relationships {
  8431. ids = append(ids, id)
  8432. }
  8433. return ids
  8434. case contact.EdgeContactMessages:
  8435. ids := make([]ent.Value, 0, len(m.contact_messages))
  8436. for id := range m.contact_messages {
  8437. ids = append(ids, id)
  8438. }
  8439. return ids
  8440. }
  8441. return nil
  8442. }
  8443. // RemovedEdges returns all edge names that were removed in this mutation.
  8444. func (m *ContactMutation) RemovedEdges() []string {
  8445. edges := make([]string, 0, 2)
  8446. if m.removedcontact_relationships != nil {
  8447. edges = append(edges, contact.EdgeContactRelationships)
  8448. }
  8449. if m.removedcontact_messages != nil {
  8450. edges = append(edges, contact.EdgeContactMessages)
  8451. }
  8452. return edges
  8453. }
  8454. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  8455. // the given name in this mutation.
  8456. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  8457. switch name {
  8458. case contact.EdgeContactRelationships:
  8459. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  8460. for id := range m.removedcontact_relationships {
  8461. ids = append(ids, id)
  8462. }
  8463. return ids
  8464. case contact.EdgeContactMessages:
  8465. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  8466. for id := range m.removedcontact_messages {
  8467. ids = append(ids, id)
  8468. }
  8469. return ids
  8470. }
  8471. return nil
  8472. }
  8473. // ClearedEdges returns all edge names that were cleared in this mutation.
  8474. func (m *ContactMutation) ClearedEdges() []string {
  8475. edges := make([]string, 0, 2)
  8476. if m.clearedcontact_relationships {
  8477. edges = append(edges, contact.EdgeContactRelationships)
  8478. }
  8479. if m.clearedcontact_messages {
  8480. edges = append(edges, contact.EdgeContactMessages)
  8481. }
  8482. return edges
  8483. }
  8484. // EdgeCleared returns a boolean which indicates if the edge with the given name
  8485. // was cleared in this mutation.
  8486. func (m *ContactMutation) EdgeCleared(name string) bool {
  8487. switch name {
  8488. case contact.EdgeContactRelationships:
  8489. return m.clearedcontact_relationships
  8490. case contact.EdgeContactMessages:
  8491. return m.clearedcontact_messages
  8492. }
  8493. return false
  8494. }
  8495. // ClearEdge clears the value of the edge with the given name. It returns an error
  8496. // if that edge is not defined in the schema.
  8497. func (m *ContactMutation) ClearEdge(name string) error {
  8498. switch name {
  8499. }
  8500. return fmt.Errorf("unknown Contact unique edge %s", name)
  8501. }
  8502. // ResetEdge resets all changes to the edge with the given name in this mutation.
  8503. // It returns an error if the edge is not defined in the schema.
  8504. func (m *ContactMutation) ResetEdge(name string) error {
  8505. switch name {
  8506. case contact.EdgeContactRelationships:
  8507. m.ResetContactRelationships()
  8508. return nil
  8509. case contact.EdgeContactMessages:
  8510. m.ResetContactMessages()
  8511. return nil
  8512. }
  8513. return fmt.Errorf("unknown Contact edge %s", name)
  8514. }
  8515. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  8516. type EmployeeMutation struct {
  8517. config
  8518. op Op
  8519. typ string
  8520. id *uint64
  8521. created_at *time.Time
  8522. updated_at *time.Time
  8523. deleted_at *time.Time
  8524. title *string
  8525. avatar *string
  8526. tags *string
  8527. hire_count *int
  8528. addhire_count *int
  8529. service_count *int
  8530. addservice_count *int
  8531. achievement_count *int
  8532. addachievement_count *int
  8533. intro *string
  8534. estimate *string
  8535. skill *string
  8536. ability_type *string
  8537. scene *string
  8538. switch_in *string
  8539. video_url *string
  8540. organization_id *uint64
  8541. addorganization_id *int64
  8542. category_id *uint64
  8543. addcategory_id *int64
  8544. api_base *string
  8545. api_key *string
  8546. ai_info *string
  8547. is_vip *int
  8548. addis_vip *int
  8549. chat_url *string
  8550. clearedFields map[string]struct{}
  8551. em_work_experiences map[uint64]struct{}
  8552. removedem_work_experiences map[uint64]struct{}
  8553. clearedem_work_experiences bool
  8554. em_tutorial map[uint64]struct{}
  8555. removedem_tutorial map[uint64]struct{}
  8556. clearedem_tutorial bool
  8557. done bool
  8558. oldValue func(context.Context) (*Employee, error)
  8559. predicates []predicate.Employee
  8560. }
  8561. var _ ent.Mutation = (*EmployeeMutation)(nil)
  8562. // employeeOption allows management of the mutation configuration using functional options.
  8563. type employeeOption func(*EmployeeMutation)
  8564. // newEmployeeMutation creates new mutation for the Employee entity.
  8565. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  8566. m := &EmployeeMutation{
  8567. config: c,
  8568. op: op,
  8569. typ: TypeEmployee,
  8570. clearedFields: make(map[string]struct{}),
  8571. }
  8572. for _, opt := range opts {
  8573. opt(m)
  8574. }
  8575. return m
  8576. }
  8577. // withEmployeeID sets the ID field of the mutation.
  8578. func withEmployeeID(id uint64) employeeOption {
  8579. return func(m *EmployeeMutation) {
  8580. var (
  8581. err error
  8582. once sync.Once
  8583. value *Employee
  8584. )
  8585. m.oldValue = func(ctx context.Context) (*Employee, error) {
  8586. once.Do(func() {
  8587. if m.done {
  8588. err = errors.New("querying old values post mutation is not allowed")
  8589. } else {
  8590. value, err = m.Client().Employee.Get(ctx, id)
  8591. }
  8592. })
  8593. return value, err
  8594. }
  8595. m.id = &id
  8596. }
  8597. }
  8598. // withEmployee sets the old Employee of the mutation.
  8599. func withEmployee(node *Employee) employeeOption {
  8600. return func(m *EmployeeMutation) {
  8601. m.oldValue = func(context.Context) (*Employee, error) {
  8602. return node, nil
  8603. }
  8604. m.id = &node.ID
  8605. }
  8606. }
  8607. // Client returns a new `ent.Client` from the mutation. If the mutation was
  8608. // executed in a transaction (ent.Tx), a transactional client is returned.
  8609. func (m EmployeeMutation) Client() *Client {
  8610. client := &Client{config: m.config}
  8611. client.init()
  8612. return client
  8613. }
  8614. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  8615. // it returns an error otherwise.
  8616. func (m EmployeeMutation) Tx() (*Tx, error) {
  8617. if _, ok := m.driver.(*txDriver); !ok {
  8618. return nil, errors.New("ent: mutation is not running in a transaction")
  8619. }
  8620. tx := &Tx{config: m.config}
  8621. tx.init()
  8622. return tx, nil
  8623. }
  8624. // SetID sets the value of the id field. Note that this
  8625. // operation is only accepted on creation of Employee entities.
  8626. func (m *EmployeeMutation) SetID(id uint64) {
  8627. m.id = &id
  8628. }
  8629. // ID returns the ID value in the mutation. Note that the ID is only available
  8630. // if it was provided to the builder or after it was returned from the database.
  8631. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  8632. if m.id == nil {
  8633. return
  8634. }
  8635. return *m.id, true
  8636. }
  8637. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  8638. // That means, if the mutation is applied within a transaction with an isolation level such
  8639. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  8640. // or updated by the mutation.
  8641. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  8642. switch {
  8643. case m.op.Is(OpUpdateOne | OpDeleteOne):
  8644. id, exists := m.ID()
  8645. if exists {
  8646. return []uint64{id}, nil
  8647. }
  8648. fallthrough
  8649. case m.op.Is(OpUpdate | OpDelete):
  8650. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  8651. default:
  8652. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  8653. }
  8654. }
  8655. // SetCreatedAt sets the "created_at" field.
  8656. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  8657. m.created_at = &t
  8658. }
  8659. // CreatedAt returns the value of the "created_at" field in the mutation.
  8660. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  8661. v := m.created_at
  8662. if v == nil {
  8663. return
  8664. }
  8665. return *v, true
  8666. }
  8667. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  8668. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8670. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  8671. if !m.op.Is(OpUpdateOne) {
  8672. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  8673. }
  8674. if m.id == nil || m.oldValue == nil {
  8675. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  8676. }
  8677. oldValue, err := m.oldValue(ctx)
  8678. if err != nil {
  8679. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  8680. }
  8681. return oldValue.CreatedAt, nil
  8682. }
  8683. // ResetCreatedAt resets all changes to the "created_at" field.
  8684. func (m *EmployeeMutation) ResetCreatedAt() {
  8685. m.created_at = nil
  8686. }
  8687. // SetUpdatedAt sets the "updated_at" field.
  8688. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  8689. m.updated_at = &t
  8690. }
  8691. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  8692. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  8693. v := m.updated_at
  8694. if v == nil {
  8695. return
  8696. }
  8697. return *v, true
  8698. }
  8699. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  8700. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8702. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  8703. if !m.op.Is(OpUpdateOne) {
  8704. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  8705. }
  8706. if m.id == nil || m.oldValue == nil {
  8707. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  8708. }
  8709. oldValue, err := m.oldValue(ctx)
  8710. if err != nil {
  8711. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  8712. }
  8713. return oldValue.UpdatedAt, nil
  8714. }
  8715. // ResetUpdatedAt resets all changes to the "updated_at" field.
  8716. func (m *EmployeeMutation) ResetUpdatedAt() {
  8717. m.updated_at = nil
  8718. }
  8719. // SetDeletedAt sets the "deleted_at" field.
  8720. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  8721. m.deleted_at = &t
  8722. }
  8723. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  8724. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  8725. v := m.deleted_at
  8726. if v == nil {
  8727. return
  8728. }
  8729. return *v, true
  8730. }
  8731. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  8732. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8734. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  8735. if !m.op.Is(OpUpdateOne) {
  8736. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  8737. }
  8738. if m.id == nil || m.oldValue == nil {
  8739. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  8740. }
  8741. oldValue, err := m.oldValue(ctx)
  8742. if err != nil {
  8743. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  8744. }
  8745. return oldValue.DeletedAt, nil
  8746. }
  8747. // ClearDeletedAt clears the value of the "deleted_at" field.
  8748. func (m *EmployeeMutation) ClearDeletedAt() {
  8749. m.deleted_at = nil
  8750. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  8751. }
  8752. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  8753. func (m *EmployeeMutation) DeletedAtCleared() bool {
  8754. _, ok := m.clearedFields[employee.FieldDeletedAt]
  8755. return ok
  8756. }
  8757. // ResetDeletedAt resets all changes to the "deleted_at" field.
  8758. func (m *EmployeeMutation) ResetDeletedAt() {
  8759. m.deleted_at = nil
  8760. delete(m.clearedFields, employee.FieldDeletedAt)
  8761. }
  8762. // SetTitle sets the "title" field.
  8763. func (m *EmployeeMutation) SetTitle(s string) {
  8764. m.title = &s
  8765. }
  8766. // Title returns the value of the "title" field in the mutation.
  8767. func (m *EmployeeMutation) Title() (r string, exists bool) {
  8768. v := m.title
  8769. if v == nil {
  8770. return
  8771. }
  8772. return *v, true
  8773. }
  8774. // OldTitle returns the old "title" field's value of the Employee entity.
  8775. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8776. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8777. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  8778. if !m.op.Is(OpUpdateOne) {
  8779. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  8780. }
  8781. if m.id == nil || m.oldValue == nil {
  8782. return v, errors.New("OldTitle requires an ID field in the mutation")
  8783. }
  8784. oldValue, err := m.oldValue(ctx)
  8785. if err != nil {
  8786. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  8787. }
  8788. return oldValue.Title, nil
  8789. }
  8790. // ResetTitle resets all changes to the "title" field.
  8791. func (m *EmployeeMutation) ResetTitle() {
  8792. m.title = nil
  8793. }
  8794. // SetAvatar sets the "avatar" field.
  8795. func (m *EmployeeMutation) SetAvatar(s string) {
  8796. m.avatar = &s
  8797. }
  8798. // Avatar returns the value of the "avatar" field in the mutation.
  8799. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  8800. v := m.avatar
  8801. if v == nil {
  8802. return
  8803. }
  8804. return *v, true
  8805. }
  8806. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  8807. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8808. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8809. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  8810. if !m.op.Is(OpUpdateOne) {
  8811. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  8812. }
  8813. if m.id == nil || m.oldValue == nil {
  8814. return v, errors.New("OldAvatar requires an ID field in the mutation")
  8815. }
  8816. oldValue, err := m.oldValue(ctx)
  8817. if err != nil {
  8818. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  8819. }
  8820. return oldValue.Avatar, nil
  8821. }
  8822. // ResetAvatar resets all changes to the "avatar" field.
  8823. func (m *EmployeeMutation) ResetAvatar() {
  8824. m.avatar = nil
  8825. }
  8826. // SetTags sets the "tags" field.
  8827. func (m *EmployeeMutation) SetTags(s string) {
  8828. m.tags = &s
  8829. }
  8830. // Tags returns the value of the "tags" field in the mutation.
  8831. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  8832. v := m.tags
  8833. if v == nil {
  8834. return
  8835. }
  8836. return *v, true
  8837. }
  8838. // OldTags returns the old "tags" field's value of the Employee entity.
  8839. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8841. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  8842. if !m.op.Is(OpUpdateOne) {
  8843. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  8844. }
  8845. if m.id == nil || m.oldValue == nil {
  8846. return v, errors.New("OldTags requires an ID field in the mutation")
  8847. }
  8848. oldValue, err := m.oldValue(ctx)
  8849. if err != nil {
  8850. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  8851. }
  8852. return oldValue.Tags, nil
  8853. }
  8854. // ResetTags resets all changes to the "tags" field.
  8855. func (m *EmployeeMutation) ResetTags() {
  8856. m.tags = nil
  8857. }
  8858. // SetHireCount sets the "hire_count" field.
  8859. func (m *EmployeeMutation) SetHireCount(i int) {
  8860. m.hire_count = &i
  8861. m.addhire_count = nil
  8862. }
  8863. // HireCount returns the value of the "hire_count" field in the mutation.
  8864. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  8865. v := m.hire_count
  8866. if v == nil {
  8867. return
  8868. }
  8869. return *v, true
  8870. }
  8871. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  8872. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8873. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8874. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  8875. if !m.op.Is(OpUpdateOne) {
  8876. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  8877. }
  8878. if m.id == nil || m.oldValue == nil {
  8879. return v, errors.New("OldHireCount requires an ID field in the mutation")
  8880. }
  8881. oldValue, err := m.oldValue(ctx)
  8882. if err != nil {
  8883. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  8884. }
  8885. return oldValue.HireCount, nil
  8886. }
  8887. // AddHireCount adds i to the "hire_count" field.
  8888. func (m *EmployeeMutation) AddHireCount(i int) {
  8889. if m.addhire_count != nil {
  8890. *m.addhire_count += i
  8891. } else {
  8892. m.addhire_count = &i
  8893. }
  8894. }
  8895. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  8896. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  8897. v := m.addhire_count
  8898. if v == nil {
  8899. return
  8900. }
  8901. return *v, true
  8902. }
  8903. // ResetHireCount resets all changes to the "hire_count" field.
  8904. func (m *EmployeeMutation) ResetHireCount() {
  8905. m.hire_count = nil
  8906. m.addhire_count = nil
  8907. }
  8908. // SetServiceCount sets the "service_count" field.
  8909. func (m *EmployeeMutation) SetServiceCount(i int) {
  8910. m.service_count = &i
  8911. m.addservice_count = nil
  8912. }
  8913. // ServiceCount returns the value of the "service_count" field in the mutation.
  8914. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  8915. v := m.service_count
  8916. if v == nil {
  8917. return
  8918. }
  8919. return *v, true
  8920. }
  8921. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  8922. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8924. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  8925. if !m.op.Is(OpUpdateOne) {
  8926. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  8927. }
  8928. if m.id == nil || m.oldValue == nil {
  8929. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  8930. }
  8931. oldValue, err := m.oldValue(ctx)
  8932. if err != nil {
  8933. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  8934. }
  8935. return oldValue.ServiceCount, nil
  8936. }
  8937. // AddServiceCount adds i to the "service_count" field.
  8938. func (m *EmployeeMutation) AddServiceCount(i int) {
  8939. if m.addservice_count != nil {
  8940. *m.addservice_count += i
  8941. } else {
  8942. m.addservice_count = &i
  8943. }
  8944. }
  8945. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  8946. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  8947. v := m.addservice_count
  8948. if v == nil {
  8949. return
  8950. }
  8951. return *v, true
  8952. }
  8953. // ResetServiceCount resets all changes to the "service_count" field.
  8954. func (m *EmployeeMutation) ResetServiceCount() {
  8955. m.service_count = nil
  8956. m.addservice_count = nil
  8957. }
  8958. // SetAchievementCount sets the "achievement_count" field.
  8959. func (m *EmployeeMutation) SetAchievementCount(i int) {
  8960. m.achievement_count = &i
  8961. m.addachievement_count = nil
  8962. }
  8963. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  8964. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  8965. v := m.achievement_count
  8966. if v == nil {
  8967. return
  8968. }
  8969. return *v, true
  8970. }
  8971. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  8972. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  8973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8974. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  8975. if !m.op.Is(OpUpdateOne) {
  8976. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  8977. }
  8978. if m.id == nil || m.oldValue == nil {
  8979. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  8980. }
  8981. oldValue, err := m.oldValue(ctx)
  8982. if err != nil {
  8983. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  8984. }
  8985. return oldValue.AchievementCount, nil
  8986. }
  8987. // AddAchievementCount adds i to the "achievement_count" field.
  8988. func (m *EmployeeMutation) AddAchievementCount(i int) {
  8989. if m.addachievement_count != nil {
  8990. *m.addachievement_count += i
  8991. } else {
  8992. m.addachievement_count = &i
  8993. }
  8994. }
  8995. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  8996. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  8997. v := m.addachievement_count
  8998. if v == nil {
  8999. return
  9000. }
  9001. return *v, true
  9002. }
  9003. // ResetAchievementCount resets all changes to the "achievement_count" field.
  9004. func (m *EmployeeMutation) ResetAchievementCount() {
  9005. m.achievement_count = nil
  9006. m.addachievement_count = nil
  9007. }
  9008. // SetIntro sets the "intro" field.
  9009. func (m *EmployeeMutation) SetIntro(s string) {
  9010. m.intro = &s
  9011. }
  9012. // Intro returns the value of the "intro" field in the mutation.
  9013. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  9014. v := m.intro
  9015. if v == nil {
  9016. return
  9017. }
  9018. return *v, true
  9019. }
  9020. // OldIntro returns the old "intro" field's value of the Employee entity.
  9021. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9023. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  9024. if !m.op.Is(OpUpdateOne) {
  9025. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  9026. }
  9027. if m.id == nil || m.oldValue == nil {
  9028. return v, errors.New("OldIntro requires an ID field in the mutation")
  9029. }
  9030. oldValue, err := m.oldValue(ctx)
  9031. if err != nil {
  9032. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  9033. }
  9034. return oldValue.Intro, nil
  9035. }
  9036. // ResetIntro resets all changes to the "intro" field.
  9037. func (m *EmployeeMutation) ResetIntro() {
  9038. m.intro = nil
  9039. }
  9040. // SetEstimate sets the "estimate" field.
  9041. func (m *EmployeeMutation) SetEstimate(s string) {
  9042. m.estimate = &s
  9043. }
  9044. // Estimate returns the value of the "estimate" field in the mutation.
  9045. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  9046. v := m.estimate
  9047. if v == nil {
  9048. return
  9049. }
  9050. return *v, true
  9051. }
  9052. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  9053. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9055. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  9056. if !m.op.Is(OpUpdateOne) {
  9057. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  9058. }
  9059. if m.id == nil || m.oldValue == nil {
  9060. return v, errors.New("OldEstimate requires an ID field in the mutation")
  9061. }
  9062. oldValue, err := m.oldValue(ctx)
  9063. if err != nil {
  9064. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  9065. }
  9066. return oldValue.Estimate, nil
  9067. }
  9068. // ResetEstimate resets all changes to the "estimate" field.
  9069. func (m *EmployeeMutation) ResetEstimate() {
  9070. m.estimate = nil
  9071. }
  9072. // SetSkill sets the "skill" field.
  9073. func (m *EmployeeMutation) SetSkill(s string) {
  9074. m.skill = &s
  9075. }
  9076. // Skill returns the value of the "skill" field in the mutation.
  9077. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  9078. v := m.skill
  9079. if v == nil {
  9080. return
  9081. }
  9082. return *v, true
  9083. }
  9084. // OldSkill returns the old "skill" field's value of the Employee entity.
  9085. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9087. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  9088. if !m.op.Is(OpUpdateOne) {
  9089. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  9090. }
  9091. if m.id == nil || m.oldValue == nil {
  9092. return v, errors.New("OldSkill requires an ID field in the mutation")
  9093. }
  9094. oldValue, err := m.oldValue(ctx)
  9095. if err != nil {
  9096. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  9097. }
  9098. return oldValue.Skill, nil
  9099. }
  9100. // ResetSkill resets all changes to the "skill" field.
  9101. func (m *EmployeeMutation) ResetSkill() {
  9102. m.skill = nil
  9103. }
  9104. // SetAbilityType sets the "ability_type" field.
  9105. func (m *EmployeeMutation) SetAbilityType(s string) {
  9106. m.ability_type = &s
  9107. }
  9108. // AbilityType returns the value of the "ability_type" field in the mutation.
  9109. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  9110. v := m.ability_type
  9111. if v == nil {
  9112. return
  9113. }
  9114. return *v, true
  9115. }
  9116. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  9117. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9118. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9119. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  9120. if !m.op.Is(OpUpdateOne) {
  9121. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  9122. }
  9123. if m.id == nil || m.oldValue == nil {
  9124. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  9125. }
  9126. oldValue, err := m.oldValue(ctx)
  9127. if err != nil {
  9128. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  9129. }
  9130. return oldValue.AbilityType, nil
  9131. }
  9132. // ResetAbilityType resets all changes to the "ability_type" field.
  9133. func (m *EmployeeMutation) ResetAbilityType() {
  9134. m.ability_type = nil
  9135. }
  9136. // SetScene sets the "scene" field.
  9137. func (m *EmployeeMutation) SetScene(s string) {
  9138. m.scene = &s
  9139. }
  9140. // Scene returns the value of the "scene" field in the mutation.
  9141. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  9142. v := m.scene
  9143. if v == nil {
  9144. return
  9145. }
  9146. return *v, true
  9147. }
  9148. // OldScene returns the old "scene" field's value of the Employee entity.
  9149. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9151. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  9152. if !m.op.Is(OpUpdateOne) {
  9153. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  9154. }
  9155. if m.id == nil || m.oldValue == nil {
  9156. return v, errors.New("OldScene requires an ID field in the mutation")
  9157. }
  9158. oldValue, err := m.oldValue(ctx)
  9159. if err != nil {
  9160. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  9161. }
  9162. return oldValue.Scene, nil
  9163. }
  9164. // ResetScene resets all changes to the "scene" field.
  9165. func (m *EmployeeMutation) ResetScene() {
  9166. m.scene = nil
  9167. }
  9168. // SetSwitchIn sets the "switch_in" field.
  9169. func (m *EmployeeMutation) SetSwitchIn(s string) {
  9170. m.switch_in = &s
  9171. }
  9172. // SwitchIn returns the value of the "switch_in" field in the mutation.
  9173. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  9174. v := m.switch_in
  9175. if v == nil {
  9176. return
  9177. }
  9178. return *v, true
  9179. }
  9180. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  9181. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9182. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9183. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  9184. if !m.op.Is(OpUpdateOne) {
  9185. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  9186. }
  9187. if m.id == nil || m.oldValue == nil {
  9188. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  9189. }
  9190. oldValue, err := m.oldValue(ctx)
  9191. if err != nil {
  9192. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  9193. }
  9194. return oldValue.SwitchIn, nil
  9195. }
  9196. // ResetSwitchIn resets all changes to the "switch_in" field.
  9197. func (m *EmployeeMutation) ResetSwitchIn() {
  9198. m.switch_in = nil
  9199. }
  9200. // SetVideoURL sets the "video_url" field.
  9201. func (m *EmployeeMutation) SetVideoURL(s string) {
  9202. m.video_url = &s
  9203. }
  9204. // VideoURL returns the value of the "video_url" field in the mutation.
  9205. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  9206. v := m.video_url
  9207. if v == nil {
  9208. return
  9209. }
  9210. return *v, true
  9211. }
  9212. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  9213. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9215. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  9216. if !m.op.Is(OpUpdateOne) {
  9217. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  9218. }
  9219. if m.id == nil || m.oldValue == nil {
  9220. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  9221. }
  9222. oldValue, err := m.oldValue(ctx)
  9223. if err != nil {
  9224. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  9225. }
  9226. return oldValue.VideoURL, nil
  9227. }
  9228. // ResetVideoURL resets all changes to the "video_url" field.
  9229. func (m *EmployeeMutation) ResetVideoURL() {
  9230. m.video_url = nil
  9231. }
  9232. // SetOrganizationID sets the "organization_id" field.
  9233. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  9234. m.organization_id = &u
  9235. m.addorganization_id = nil
  9236. }
  9237. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9238. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  9239. v := m.organization_id
  9240. if v == nil {
  9241. return
  9242. }
  9243. return *v, true
  9244. }
  9245. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  9246. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9248. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9249. if !m.op.Is(OpUpdateOne) {
  9250. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9251. }
  9252. if m.id == nil || m.oldValue == nil {
  9253. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9254. }
  9255. oldValue, err := m.oldValue(ctx)
  9256. if err != nil {
  9257. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9258. }
  9259. return oldValue.OrganizationID, nil
  9260. }
  9261. // AddOrganizationID adds u to the "organization_id" field.
  9262. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  9263. if m.addorganization_id != nil {
  9264. *m.addorganization_id += u
  9265. } else {
  9266. m.addorganization_id = &u
  9267. }
  9268. }
  9269. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9270. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  9271. v := m.addorganization_id
  9272. if v == nil {
  9273. return
  9274. }
  9275. return *v, true
  9276. }
  9277. // ResetOrganizationID resets all changes to the "organization_id" field.
  9278. func (m *EmployeeMutation) ResetOrganizationID() {
  9279. m.organization_id = nil
  9280. m.addorganization_id = nil
  9281. }
  9282. // SetCategoryID sets the "category_id" field.
  9283. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  9284. m.category_id = &u
  9285. m.addcategory_id = nil
  9286. }
  9287. // CategoryID returns the value of the "category_id" field in the mutation.
  9288. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  9289. v := m.category_id
  9290. if v == nil {
  9291. return
  9292. }
  9293. return *v, true
  9294. }
  9295. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  9296. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9298. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  9299. if !m.op.Is(OpUpdateOne) {
  9300. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  9301. }
  9302. if m.id == nil || m.oldValue == nil {
  9303. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  9304. }
  9305. oldValue, err := m.oldValue(ctx)
  9306. if err != nil {
  9307. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  9308. }
  9309. return oldValue.CategoryID, nil
  9310. }
  9311. // AddCategoryID adds u to the "category_id" field.
  9312. func (m *EmployeeMutation) AddCategoryID(u int64) {
  9313. if m.addcategory_id != nil {
  9314. *m.addcategory_id += u
  9315. } else {
  9316. m.addcategory_id = &u
  9317. }
  9318. }
  9319. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  9320. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  9321. v := m.addcategory_id
  9322. if v == nil {
  9323. return
  9324. }
  9325. return *v, true
  9326. }
  9327. // ResetCategoryID resets all changes to the "category_id" field.
  9328. func (m *EmployeeMutation) ResetCategoryID() {
  9329. m.category_id = nil
  9330. m.addcategory_id = nil
  9331. }
  9332. // SetAPIBase sets the "api_base" field.
  9333. func (m *EmployeeMutation) SetAPIBase(s string) {
  9334. m.api_base = &s
  9335. }
  9336. // APIBase returns the value of the "api_base" field in the mutation.
  9337. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  9338. v := m.api_base
  9339. if v == nil {
  9340. return
  9341. }
  9342. return *v, true
  9343. }
  9344. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  9345. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9346. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9347. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  9348. if !m.op.Is(OpUpdateOne) {
  9349. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  9350. }
  9351. if m.id == nil || m.oldValue == nil {
  9352. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  9353. }
  9354. oldValue, err := m.oldValue(ctx)
  9355. if err != nil {
  9356. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  9357. }
  9358. return oldValue.APIBase, nil
  9359. }
  9360. // ResetAPIBase resets all changes to the "api_base" field.
  9361. func (m *EmployeeMutation) ResetAPIBase() {
  9362. m.api_base = nil
  9363. }
  9364. // SetAPIKey sets the "api_key" field.
  9365. func (m *EmployeeMutation) SetAPIKey(s string) {
  9366. m.api_key = &s
  9367. }
  9368. // APIKey returns the value of the "api_key" field in the mutation.
  9369. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  9370. v := m.api_key
  9371. if v == nil {
  9372. return
  9373. }
  9374. return *v, true
  9375. }
  9376. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  9377. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9379. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  9380. if !m.op.Is(OpUpdateOne) {
  9381. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  9382. }
  9383. if m.id == nil || m.oldValue == nil {
  9384. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  9385. }
  9386. oldValue, err := m.oldValue(ctx)
  9387. if err != nil {
  9388. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  9389. }
  9390. return oldValue.APIKey, nil
  9391. }
  9392. // ResetAPIKey resets all changes to the "api_key" field.
  9393. func (m *EmployeeMutation) ResetAPIKey() {
  9394. m.api_key = nil
  9395. }
  9396. // SetAiInfo sets the "ai_info" field.
  9397. func (m *EmployeeMutation) SetAiInfo(s string) {
  9398. m.ai_info = &s
  9399. }
  9400. // AiInfo returns the value of the "ai_info" field in the mutation.
  9401. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  9402. v := m.ai_info
  9403. if v == nil {
  9404. return
  9405. }
  9406. return *v, true
  9407. }
  9408. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  9409. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9410. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9411. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  9412. if !m.op.Is(OpUpdateOne) {
  9413. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  9414. }
  9415. if m.id == nil || m.oldValue == nil {
  9416. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  9417. }
  9418. oldValue, err := m.oldValue(ctx)
  9419. if err != nil {
  9420. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  9421. }
  9422. return oldValue.AiInfo, nil
  9423. }
  9424. // ClearAiInfo clears the value of the "ai_info" field.
  9425. func (m *EmployeeMutation) ClearAiInfo() {
  9426. m.ai_info = nil
  9427. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  9428. }
  9429. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  9430. func (m *EmployeeMutation) AiInfoCleared() bool {
  9431. _, ok := m.clearedFields[employee.FieldAiInfo]
  9432. return ok
  9433. }
  9434. // ResetAiInfo resets all changes to the "ai_info" field.
  9435. func (m *EmployeeMutation) ResetAiInfo() {
  9436. m.ai_info = nil
  9437. delete(m.clearedFields, employee.FieldAiInfo)
  9438. }
  9439. // SetIsVip sets the "is_vip" field.
  9440. func (m *EmployeeMutation) SetIsVip(i int) {
  9441. m.is_vip = &i
  9442. m.addis_vip = nil
  9443. }
  9444. // IsVip returns the value of the "is_vip" field in the mutation.
  9445. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  9446. v := m.is_vip
  9447. if v == nil {
  9448. return
  9449. }
  9450. return *v, true
  9451. }
  9452. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  9453. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9455. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  9456. if !m.op.Is(OpUpdateOne) {
  9457. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  9458. }
  9459. if m.id == nil || m.oldValue == nil {
  9460. return v, errors.New("OldIsVip requires an ID field in the mutation")
  9461. }
  9462. oldValue, err := m.oldValue(ctx)
  9463. if err != nil {
  9464. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  9465. }
  9466. return oldValue.IsVip, nil
  9467. }
  9468. // AddIsVip adds i to the "is_vip" field.
  9469. func (m *EmployeeMutation) AddIsVip(i int) {
  9470. if m.addis_vip != nil {
  9471. *m.addis_vip += i
  9472. } else {
  9473. m.addis_vip = &i
  9474. }
  9475. }
  9476. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  9477. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  9478. v := m.addis_vip
  9479. if v == nil {
  9480. return
  9481. }
  9482. return *v, true
  9483. }
  9484. // ResetIsVip resets all changes to the "is_vip" field.
  9485. func (m *EmployeeMutation) ResetIsVip() {
  9486. m.is_vip = nil
  9487. m.addis_vip = nil
  9488. }
  9489. // SetChatURL sets the "chat_url" field.
  9490. func (m *EmployeeMutation) SetChatURL(s string) {
  9491. m.chat_url = &s
  9492. }
  9493. // ChatURL returns the value of the "chat_url" field in the mutation.
  9494. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  9495. v := m.chat_url
  9496. if v == nil {
  9497. return
  9498. }
  9499. return *v, true
  9500. }
  9501. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  9502. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  9503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9504. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  9505. if !m.op.Is(OpUpdateOne) {
  9506. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  9507. }
  9508. if m.id == nil || m.oldValue == nil {
  9509. return v, errors.New("OldChatURL requires an ID field in the mutation")
  9510. }
  9511. oldValue, err := m.oldValue(ctx)
  9512. if err != nil {
  9513. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  9514. }
  9515. return oldValue.ChatURL, nil
  9516. }
  9517. // ResetChatURL resets all changes to the "chat_url" field.
  9518. func (m *EmployeeMutation) ResetChatURL() {
  9519. m.chat_url = nil
  9520. }
  9521. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  9522. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  9523. if m.em_work_experiences == nil {
  9524. m.em_work_experiences = make(map[uint64]struct{})
  9525. }
  9526. for i := range ids {
  9527. m.em_work_experiences[ids[i]] = struct{}{}
  9528. }
  9529. }
  9530. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  9531. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  9532. m.clearedem_work_experiences = true
  9533. }
  9534. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  9535. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  9536. return m.clearedem_work_experiences
  9537. }
  9538. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  9539. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  9540. if m.removedem_work_experiences == nil {
  9541. m.removedem_work_experiences = make(map[uint64]struct{})
  9542. }
  9543. for i := range ids {
  9544. delete(m.em_work_experiences, ids[i])
  9545. m.removedem_work_experiences[ids[i]] = struct{}{}
  9546. }
  9547. }
  9548. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  9549. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  9550. for id := range m.removedem_work_experiences {
  9551. ids = append(ids, id)
  9552. }
  9553. return
  9554. }
  9555. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  9556. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  9557. for id := range m.em_work_experiences {
  9558. ids = append(ids, id)
  9559. }
  9560. return
  9561. }
  9562. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  9563. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  9564. m.em_work_experiences = nil
  9565. m.clearedem_work_experiences = false
  9566. m.removedem_work_experiences = nil
  9567. }
  9568. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  9569. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  9570. if m.em_tutorial == nil {
  9571. m.em_tutorial = make(map[uint64]struct{})
  9572. }
  9573. for i := range ids {
  9574. m.em_tutorial[ids[i]] = struct{}{}
  9575. }
  9576. }
  9577. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  9578. func (m *EmployeeMutation) ClearEmTutorial() {
  9579. m.clearedem_tutorial = true
  9580. }
  9581. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  9582. func (m *EmployeeMutation) EmTutorialCleared() bool {
  9583. return m.clearedem_tutorial
  9584. }
  9585. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  9586. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  9587. if m.removedem_tutorial == nil {
  9588. m.removedem_tutorial = make(map[uint64]struct{})
  9589. }
  9590. for i := range ids {
  9591. delete(m.em_tutorial, ids[i])
  9592. m.removedem_tutorial[ids[i]] = struct{}{}
  9593. }
  9594. }
  9595. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  9596. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  9597. for id := range m.removedem_tutorial {
  9598. ids = append(ids, id)
  9599. }
  9600. return
  9601. }
  9602. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  9603. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  9604. for id := range m.em_tutorial {
  9605. ids = append(ids, id)
  9606. }
  9607. return
  9608. }
  9609. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  9610. func (m *EmployeeMutation) ResetEmTutorial() {
  9611. m.em_tutorial = nil
  9612. m.clearedem_tutorial = false
  9613. m.removedem_tutorial = nil
  9614. }
  9615. // Where appends a list predicates to the EmployeeMutation builder.
  9616. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  9617. m.predicates = append(m.predicates, ps...)
  9618. }
  9619. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  9620. // users can use type-assertion to append predicates that do not depend on any generated package.
  9621. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  9622. p := make([]predicate.Employee, len(ps))
  9623. for i := range ps {
  9624. p[i] = ps[i]
  9625. }
  9626. m.Where(p...)
  9627. }
  9628. // Op returns the operation name.
  9629. func (m *EmployeeMutation) Op() Op {
  9630. return m.op
  9631. }
  9632. // SetOp allows setting the mutation operation.
  9633. func (m *EmployeeMutation) SetOp(op Op) {
  9634. m.op = op
  9635. }
  9636. // Type returns the node type of this mutation (Employee).
  9637. func (m *EmployeeMutation) Type() string {
  9638. return m.typ
  9639. }
  9640. // Fields returns all fields that were changed during this mutation. Note that in
  9641. // order to get all numeric fields that were incremented/decremented, call
  9642. // AddedFields().
  9643. func (m *EmployeeMutation) Fields() []string {
  9644. fields := make([]string, 0, 23)
  9645. if m.created_at != nil {
  9646. fields = append(fields, employee.FieldCreatedAt)
  9647. }
  9648. if m.updated_at != nil {
  9649. fields = append(fields, employee.FieldUpdatedAt)
  9650. }
  9651. if m.deleted_at != nil {
  9652. fields = append(fields, employee.FieldDeletedAt)
  9653. }
  9654. if m.title != nil {
  9655. fields = append(fields, employee.FieldTitle)
  9656. }
  9657. if m.avatar != nil {
  9658. fields = append(fields, employee.FieldAvatar)
  9659. }
  9660. if m.tags != nil {
  9661. fields = append(fields, employee.FieldTags)
  9662. }
  9663. if m.hire_count != nil {
  9664. fields = append(fields, employee.FieldHireCount)
  9665. }
  9666. if m.service_count != nil {
  9667. fields = append(fields, employee.FieldServiceCount)
  9668. }
  9669. if m.achievement_count != nil {
  9670. fields = append(fields, employee.FieldAchievementCount)
  9671. }
  9672. if m.intro != nil {
  9673. fields = append(fields, employee.FieldIntro)
  9674. }
  9675. if m.estimate != nil {
  9676. fields = append(fields, employee.FieldEstimate)
  9677. }
  9678. if m.skill != nil {
  9679. fields = append(fields, employee.FieldSkill)
  9680. }
  9681. if m.ability_type != nil {
  9682. fields = append(fields, employee.FieldAbilityType)
  9683. }
  9684. if m.scene != nil {
  9685. fields = append(fields, employee.FieldScene)
  9686. }
  9687. if m.switch_in != nil {
  9688. fields = append(fields, employee.FieldSwitchIn)
  9689. }
  9690. if m.video_url != nil {
  9691. fields = append(fields, employee.FieldVideoURL)
  9692. }
  9693. if m.organization_id != nil {
  9694. fields = append(fields, employee.FieldOrganizationID)
  9695. }
  9696. if m.category_id != nil {
  9697. fields = append(fields, employee.FieldCategoryID)
  9698. }
  9699. if m.api_base != nil {
  9700. fields = append(fields, employee.FieldAPIBase)
  9701. }
  9702. if m.api_key != nil {
  9703. fields = append(fields, employee.FieldAPIKey)
  9704. }
  9705. if m.ai_info != nil {
  9706. fields = append(fields, employee.FieldAiInfo)
  9707. }
  9708. if m.is_vip != nil {
  9709. fields = append(fields, employee.FieldIsVip)
  9710. }
  9711. if m.chat_url != nil {
  9712. fields = append(fields, employee.FieldChatURL)
  9713. }
  9714. return fields
  9715. }
  9716. // Field returns the value of a field with the given name. The second boolean
  9717. // return value indicates that this field was not set, or was not defined in the
  9718. // schema.
  9719. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  9720. switch name {
  9721. case employee.FieldCreatedAt:
  9722. return m.CreatedAt()
  9723. case employee.FieldUpdatedAt:
  9724. return m.UpdatedAt()
  9725. case employee.FieldDeletedAt:
  9726. return m.DeletedAt()
  9727. case employee.FieldTitle:
  9728. return m.Title()
  9729. case employee.FieldAvatar:
  9730. return m.Avatar()
  9731. case employee.FieldTags:
  9732. return m.Tags()
  9733. case employee.FieldHireCount:
  9734. return m.HireCount()
  9735. case employee.FieldServiceCount:
  9736. return m.ServiceCount()
  9737. case employee.FieldAchievementCount:
  9738. return m.AchievementCount()
  9739. case employee.FieldIntro:
  9740. return m.Intro()
  9741. case employee.FieldEstimate:
  9742. return m.Estimate()
  9743. case employee.FieldSkill:
  9744. return m.Skill()
  9745. case employee.FieldAbilityType:
  9746. return m.AbilityType()
  9747. case employee.FieldScene:
  9748. return m.Scene()
  9749. case employee.FieldSwitchIn:
  9750. return m.SwitchIn()
  9751. case employee.FieldVideoURL:
  9752. return m.VideoURL()
  9753. case employee.FieldOrganizationID:
  9754. return m.OrganizationID()
  9755. case employee.FieldCategoryID:
  9756. return m.CategoryID()
  9757. case employee.FieldAPIBase:
  9758. return m.APIBase()
  9759. case employee.FieldAPIKey:
  9760. return m.APIKey()
  9761. case employee.FieldAiInfo:
  9762. return m.AiInfo()
  9763. case employee.FieldIsVip:
  9764. return m.IsVip()
  9765. case employee.FieldChatURL:
  9766. return m.ChatURL()
  9767. }
  9768. return nil, false
  9769. }
  9770. // OldField returns the old value of the field from the database. An error is
  9771. // returned if the mutation operation is not UpdateOne, or the query to the
  9772. // database failed.
  9773. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9774. switch name {
  9775. case employee.FieldCreatedAt:
  9776. return m.OldCreatedAt(ctx)
  9777. case employee.FieldUpdatedAt:
  9778. return m.OldUpdatedAt(ctx)
  9779. case employee.FieldDeletedAt:
  9780. return m.OldDeletedAt(ctx)
  9781. case employee.FieldTitle:
  9782. return m.OldTitle(ctx)
  9783. case employee.FieldAvatar:
  9784. return m.OldAvatar(ctx)
  9785. case employee.FieldTags:
  9786. return m.OldTags(ctx)
  9787. case employee.FieldHireCount:
  9788. return m.OldHireCount(ctx)
  9789. case employee.FieldServiceCount:
  9790. return m.OldServiceCount(ctx)
  9791. case employee.FieldAchievementCount:
  9792. return m.OldAchievementCount(ctx)
  9793. case employee.FieldIntro:
  9794. return m.OldIntro(ctx)
  9795. case employee.FieldEstimate:
  9796. return m.OldEstimate(ctx)
  9797. case employee.FieldSkill:
  9798. return m.OldSkill(ctx)
  9799. case employee.FieldAbilityType:
  9800. return m.OldAbilityType(ctx)
  9801. case employee.FieldScene:
  9802. return m.OldScene(ctx)
  9803. case employee.FieldSwitchIn:
  9804. return m.OldSwitchIn(ctx)
  9805. case employee.FieldVideoURL:
  9806. return m.OldVideoURL(ctx)
  9807. case employee.FieldOrganizationID:
  9808. return m.OldOrganizationID(ctx)
  9809. case employee.FieldCategoryID:
  9810. return m.OldCategoryID(ctx)
  9811. case employee.FieldAPIBase:
  9812. return m.OldAPIBase(ctx)
  9813. case employee.FieldAPIKey:
  9814. return m.OldAPIKey(ctx)
  9815. case employee.FieldAiInfo:
  9816. return m.OldAiInfo(ctx)
  9817. case employee.FieldIsVip:
  9818. return m.OldIsVip(ctx)
  9819. case employee.FieldChatURL:
  9820. return m.OldChatURL(ctx)
  9821. }
  9822. return nil, fmt.Errorf("unknown Employee field %s", name)
  9823. }
  9824. // SetField sets the value of a field with the given name. It returns an error if
  9825. // the field is not defined in the schema, or if the type mismatched the field
  9826. // type.
  9827. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  9828. switch name {
  9829. case employee.FieldCreatedAt:
  9830. v, ok := value.(time.Time)
  9831. if !ok {
  9832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9833. }
  9834. m.SetCreatedAt(v)
  9835. return nil
  9836. case employee.FieldUpdatedAt:
  9837. v, ok := value.(time.Time)
  9838. if !ok {
  9839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9840. }
  9841. m.SetUpdatedAt(v)
  9842. return nil
  9843. case employee.FieldDeletedAt:
  9844. v, ok := value.(time.Time)
  9845. if !ok {
  9846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9847. }
  9848. m.SetDeletedAt(v)
  9849. return nil
  9850. case employee.FieldTitle:
  9851. v, ok := value.(string)
  9852. if !ok {
  9853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9854. }
  9855. m.SetTitle(v)
  9856. return nil
  9857. case employee.FieldAvatar:
  9858. v, ok := value.(string)
  9859. if !ok {
  9860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9861. }
  9862. m.SetAvatar(v)
  9863. return nil
  9864. case employee.FieldTags:
  9865. v, ok := value.(string)
  9866. if !ok {
  9867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9868. }
  9869. m.SetTags(v)
  9870. return nil
  9871. case employee.FieldHireCount:
  9872. v, ok := value.(int)
  9873. if !ok {
  9874. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9875. }
  9876. m.SetHireCount(v)
  9877. return nil
  9878. case employee.FieldServiceCount:
  9879. v, ok := value.(int)
  9880. if !ok {
  9881. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9882. }
  9883. m.SetServiceCount(v)
  9884. return nil
  9885. case employee.FieldAchievementCount:
  9886. v, ok := value.(int)
  9887. if !ok {
  9888. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9889. }
  9890. m.SetAchievementCount(v)
  9891. return nil
  9892. case employee.FieldIntro:
  9893. v, ok := value.(string)
  9894. if !ok {
  9895. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9896. }
  9897. m.SetIntro(v)
  9898. return nil
  9899. case employee.FieldEstimate:
  9900. v, ok := value.(string)
  9901. if !ok {
  9902. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9903. }
  9904. m.SetEstimate(v)
  9905. return nil
  9906. case employee.FieldSkill:
  9907. v, ok := value.(string)
  9908. if !ok {
  9909. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9910. }
  9911. m.SetSkill(v)
  9912. return nil
  9913. case employee.FieldAbilityType:
  9914. v, ok := value.(string)
  9915. if !ok {
  9916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9917. }
  9918. m.SetAbilityType(v)
  9919. return nil
  9920. case employee.FieldScene:
  9921. v, ok := value.(string)
  9922. if !ok {
  9923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9924. }
  9925. m.SetScene(v)
  9926. return nil
  9927. case employee.FieldSwitchIn:
  9928. v, ok := value.(string)
  9929. if !ok {
  9930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9931. }
  9932. m.SetSwitchIn(v)
  9933. return nil
  9934. case employee.FieldVideoURL:
  9935. v, ok := value.(string)
  9936. if !ok {
  9937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9938. }
  9939. m.SetVideoURL(v)
  9940. return nil
  9941. case employee.FieldOrganizationID:
  9942. v, ok := value.(uint64)
  9943. if !ok {
  9944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9945. }
  9946. m.SetOrganizationID(v)
  9947. return nil
  9948. case employee.FieldCategoryID:
  9949. v, ok := value.(uint64)
  9950. if !ok {
  9951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9952. }
  9953. m.SetCategoryID(v)
  9954. return nil
  9955. case employee.FieldAPIBase:
  9956. v, ok := value.(string)
  9957. if !ok {
  9958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9959. }
  9960. m.SetAPIBase(v)
  9961. return nil
  9962. case employee.FieldAPIKey:
  9963. v, ok := value.(string)
  9964. if !ok {
  9965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9966. }
  9967. m.SetAPIKey(v)
  9968. return nil
  9969. case employee.FieldAiInfo:
  9970. v, ok := value.(string)
  9971. if !ok {
  9972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9973. }
  9974. m.SetAiInfo(v)
  9975. return nil
  9976. case employee.FieldIsVip:
  9977. v, ok := value.(int)
  9978. if !ok {
  9979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9980. }
  9981. m.SetIsVip(v)
  9982. return nil
  9983. case employee.FieldChatURL:
  9984. v, ok := value.(string)
  9985. if !ok {
  9986. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9987. }
  9988. m.SetChatURL(v)
  9989. return nil
  9990. }
  9991. return fmt.Errorf("unknown Employee field %s", name)
  9992. }
  9993. // AddedFields returns all numeric fields that were incremented/decremented during
  9994. // this mutation.
  9995. func (m *EmployeeMutation) AddedFields() []string {
  9996. var fields []string
  9997. if m.addhire_count != nil {
  9998. fields = append(fields, employee.FieldHireCount)
  9999. }
  10000. if m.addservice_count != nil {
  10001. fields = append(fields, employee.FieldServiceCount)
  10002. }
  10003. if m.addachievement_count != nil {
  10004. fields = append(fields, employee.FieldAchievementCount)
  10005. }
  10006. if m.addorganization_id != nil {
  10007. fields = append(fields, employee.FieldOrganizationID)
  10008. }
  10009. if m.addcategory_id != nil {
  10010. fields = append(fields, employee.FieldCategoryID)
  10011. }
  10012. if m.addis_vip != nil {
  10013. fields = append(fields, employee.FieldIsVip)
  10014. }
  10015. return fields
  10016. }
  10017. // AddedField returns the numeric value that was incremented/decremented on a field
  10018. // with the given name. The second boolean return value indicates that this field
  10019. // was not set, or was not defined in the schema.
  10020. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  10021. switch name {
  10022. case employee.FieldHireCount:
  10023. return m.AddedHireCount()
  10024. case employee.FieldServiceCount:
  10025. return m.AddedServiceCount()
  10026. case employee.FieldAchievementCount:
  10027. return m.AddedAchievementCount()
  10028. case employee.FieldOrganizationID:
  10029. return m.AddedOrganizationID()
  10030. case employee.FieldCategoryID:
  10031. return m.AddedCategoryID()
  10032. case employee.FieldIsVip:
  10033. return m.AddedIsVip()
  10034. }
  10035. return nil, false
  10036. }
  10037. // AddField adds the value to the field with the given name. It returns an error if
  10038. // the field is not defined in the schema, or if the type mismatched the field
  10039. // type.
  10040. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  10041. switch name {
  10042. case employee.FieldHireCount:
  10043. v, ok := value.(int)
  10044. if !ok {
  10045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10046. }
  10047. m.AddHireCount(v)
  10048. return nil
  10049. case employee.FieldServiceCount:
  10050. v, ok := value.(int)
  10051. if !ok {
  10052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10053. }
  10054. m.AddServiceCount(v)
  10055. return nil
  10056. case employee.FieldAchievementCount:
  10057. v, ok := value.(int)
  10058. if !ok {
  10059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10060. }
  10061. m.AddAchievementCount(v)
  10062. return nil
  10063. case employee.FieldOrganizationID:
  10064. v, ok := value.(int64)
  10065. if !ok {
  10066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10067. }
  10068. m.AddOrganizationID(v)
  10069. return nil
  10070. case employee.FieldCategoryID:
  10071. v, ok := value.(int64)
  10072. if !ok {
  10073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10074. }
  10075. m.AddCategoryID(v)
  10076. return nil
  10077. case employee.FieldIsVip:
  10078. v, ok := value.(int)
  10079. if !ok {
  10080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10081. }
  10082. m.AddIsVip(v)
  10083. return nil
  10084. }
  10085. return fmt.Errorf("unknown Employee numeric field %s", name)
  10086. }
  10087. // ClearedFields returns all nullable fields that were cleared during this
  10088. // mutation.
  10089. func (m *EmployeeMutation) ClearedFields() []string {
  10090. var fields []string
  10091. if m.FieldCleared(employee.FieldDeletedAt) {
  10092. fields = append(fields, employee.FieldDeletedAt)
  10093. }
  10094. if m.FieldCleared(employee.FieldAiInfo) {
  10095. fields = append(fields, employee.FieldAiInfo)
  10096. }
  10097. return fields
  10098. }
  10099. // FieldCleared returns a boolean indicating if a field with the given name was
  10100. // cleared in this mutation.
  10101. func (m *EmployeeMutation) FieldCleared(name string) bool {
  10102. _, ok := m.clearedFields[name]
  10103. return ok
  10104. }
  10105. // ClearField clears the value of the field with the given name. It returns an
  10106. // error if the field is not defined in the schema.
  10107. func (m *EmployeeMutation) ClearField(name string) error {
  10108. switch name {
  10109. case employee.FieldDeletedAt:
  10110. m.ClearDeletedAt()
  10111. return nil
  10112. case employee.FieldAiInfo:
  10113. m.ClearAiInfo()
  10114. return nil
  10115. }
  10116. return fmt.Errorf("unknown Employee nullable field %s", name)
  10117. }
  10118. // ResetField resets all changes in the mutation for the field with the given name.
  10119. // It returns an error if the field is not defined in the schema.
  10120. func (m *EmployeeMutation) ResetField(name string) error {
  10121. switch name {
  10122. case employee.FieldCreatedAt:
  10123. m.ResetCreatedAt()
  10124. return nil
  10125. case employee.FieldUpdatedAt:
  10126. m.ResetUpdatedAt()
  10127. return nil
  10128. case employee.FieldDeletedAt:
  10129. m.ResetDeletedAt()
  10130. return nil
  10131. case employee.FieldTitle:
  10132. m.ResetTitle()
  10133. return nil
  10134. case employee.FieldAvatar:
  10135. m.ResetAvatar()
  10136. return nil
  10137. case employee.FieldTags:
  10138. m.ResetTags()
  10139. return nil
  10140. case employee.FieldHireCount:
  10141. m.ResetHireCount()
  10142. return nil
  10143. case employee.FieldServiceCount:
  10144. m.ResetServiceCount()
  10145. return nil
  10146. case employee.FieldAchievementCount:
  10147. m.ResetAchievementCount()
  10148. return nil
  10149. case employee.FieldIntro:
  10150. m.ResetIntro()
  10151. return nil
  10152. case employee.FieldEstimate:
  10153. m.ResetEstimate()
  10154. return nil
  10155. case employee.FieldSkill:
  10156. m.ResetSkill()
  10157. return nil
  10158. case employee.FieldAbilityType:
  10159. m.ResetAbilityType()
  10160. return nil
  10161. case employee.FieldScene:
  10162. m.ResetScene()
  10163. return nil
  10164. case employee.FieldSwitchIn:
  10165. m.ResetSwitchIn()
  10166. return nil
  10167. case employee.FieldVideoURL:
  10168. m.ResetVideoURL()
  10169. return nil
  10170. case employee.FieldOrganizationID:
  10171. m.ResetOrganizationID()
  10172. return nil
  10173. case employee.FieldCategoryID:
  10174. m.ResetCategoryID()
  10175. return nil
  10176. case employee.FieldAPIBase:
  10177. m.ResetAPIBase()
  10178. return nil
  10179. case employee.FieldAPIKey:
  10180. m.ResetAPIKey()
  10181. return nil
  10182. case employee.FieldAiInfo:
  10183. m.ResetAiInfo()
  10184. return nil
  10185. case employee.FieldIsVip:
  10186. m.ResetIsVip()
  10187. return nil
  10188. case employee.FieldChatURL:
  10189. m.ResetChatURL()
  10190. return nil
  10191. }
  10192. return fmt.Errorf("unknown Employee field %s", name)
  10193. }
  10194. // AddedEdges returns all edge names that were set/added in this mutation.
  10195. func (m *EmployeeMutation) AddedEdges() []string {
  10196. edges := make([]string, 0, 2)
  10197. if m.em_work_experiences != nil {
  10198. edges = append(edges, employee.EdgeEmWorkExperiences)
  10199. }
  10200. if m.em_tutorial != nil {
  10201. edges = append(edges, employee.EdgeEmTutorial)
  10202. }
  10203. return edges
  10204. }
  10205. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10206. // name in this mutation.
  10207. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  10208. switch name {
  10209. case employee.EdgeEmWorkExperiences:
  10210. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  10211. for id := range m.em_work_experiences {
  10212. ids = append(ids, id)
  10213. }
  10214. return ids
  10215. case employee.EdgeEmTutorial:
  10216. ids := make([]ent.Value, 0, len(m.em_tutorial))
  10217. for id := range m.em_tutorial {
  10218. ids = append(ids, id)
  10219. }
  10220. return ids
  10221. }
  10222. return nil
  10223. }
  10224. // RemovedEdges returns all edge names that were removed in this mutation.
  10225. func (m *EmployeeMutation) RemovedEdges() []string {
  10226. edges := make([]string, 0, 2)
  10227. if m.removedem_work_experiences != nil {
  10228. edges = append(edges, employee.EdgeEmWorkExperiences)
  10229. }
  10230. if m.removedem_tutorial != nil {
  10231. edges = append(edges, employee.EdgeEmTutorial)
  10232. }
  10233. return edges
  10234. }
  10235. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10236. // the given name in this mutation.
  10237. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  10238. switch name {
  10239. case employee.EdgeEmWorkExperiences:
  10240. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  10241. for id := range m.removedem_work_experiences {
  10242. ids = append(ids, id)
  10243. }
  10244. return ids
  10245. case employee.EdgeEmTutorial:
  10246. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  10247. for id := range m.removedem_tutorial {
  10248. ids = append(ids, id)
  10249. }
  10250. return ids
  10251. }
  10252. return nil
  10253. }
  10254. // ClearedEdges returns all edge names that were cleared in this mutation.
  10255. func (m *EmployeeMutation) ClearedEdges() []string {
  10256. edges := make([]string, 0, 2)
  10257. if m.clearedem_work_experiences {
  10258. edges = append(edges, employee.EdgeEmWorkExperiences)
  10259. }
  10260. if m.clearedem_tutorial {
  10261. edges = append(edges, employee.EdgeEmTutorial)
  10262. }
  10263. return edges
  10264. }
  10265. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10266. // was cleared in this mutation.
  10267. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  10268. switch name {
  10269. case employee.EdgeEmWorkExperiences:
  10270. return m.clearedem_work_experiences
  10271. case employee.EdgeEmTutorial:
  10272. return m.clearedem_tutorial
  10273. }
  10274. return false
  10275. }
  10276. // ClearEdge clears the value of the edge with the given name. It returns an error
  10277. // if that edge is not defined in the schema.
  10278. func (m *EmployeeMutation) ClearEdge(name string) error {
  10279. switch name {
  10280. }
  10281. return fmt.Errorf("unknown Employee unique edge %s", name)
  10282. }
  10283. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10284. // It returns an error if the edge is not defined in the schema.
  10285. func (m *EmployeeMutation) ResetEdge(name string) error {
  10286. switch name {
  10287. case employee.EdgeEmWorkExperiences:
  10288. m.ResetEmWorkExperiences()
  10289. return nil
  10290. case employee.EdgeEmTutorial:
  10291. m.ResetEmTutorial()
  10292. return nil
  10293. }
  10294. return fmt.Errorf("unknown Employee edge %s", name)
  10295. }
  10296. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  10297. type EmployeeConfigMutation struct {
  10298. config
  10299. op Op
  10300. typ string
  10301. id *uint64
  10302. created_at *time.Time
  10303. updated_at *time.Time
  10304. deleted_at *time.Time
  10305. stype *string
  10306. title *string
  10307. photo *string
  10308. organization_id *uint64
  10309. addorganization_id *int64
  10310. clearedFields map[string]struct{}
  10311. done bool
  10312. oldValue func(context.Context) (*EmployeeConfig, error)
  10313. predicates []predicate.EmployeeConfig
  10314. }
  10315. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  10316. // employeeconfigOption allows management of the mutation configuration using functional options.
  10317. type employeeconfigOption func(*EmployeeConfigMutation)
  10318. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  10319. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  10320. m := &EmployeeConfigMutation{
  10321. config: c,
  10322. op: op,
  10323. typ: TypeEmployeeConfig,
  10324. clearedFields: make(map[string]struct{}),
  10325. }
  10326. for _, opt := range opts {
  10327. opt(m)
  10328. }
  10329. return m
  10330. }
  10331. // withEmployeeConfigID sets the ID field of the mutation.
  10332. func withEmployeeConfigID(id uint64) employeeconfigOption {
  10333. return func(m *EmployeeConfigMutation) {
  10334. var (
  10335. err error
  10336. once sync.Once
  10337. value *EmployeeConfig
  10338. )
  10339. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  10340. once.Do(func() {
  10341. if m.done {
  10342. err = errors.New("querying old values post mutation is not allowed")
  10343. } else {
  10344. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  10345. }
  10346. })
  10347. return value, err
  10348. }
  10349. m.id = &id
  10350. }
  10351. }
  10352. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  10353. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  10354. return func(m *EmployeeConfigMutation) {
  10355. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  10356. return node, nil
  10357. }
  10358. m.id = &node.ID
  10359. }
  10360. }
  10361. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10362. // executed in a transaction (ent.Tx), a transactional client is returned.
  10363. func (m EmployeeConfigMutation) Client() *Client {
  10364. client := &Client{config: m.config}
  10365. client.init()
  10366. return client
  10367. }
  10368. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10369. // it returns an error otherwise.
  10370. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  10371. if _, ok := m.driver.(*txDriver); !ok {
  10372. return nil, errors.New("ent: mutation is not running in a transaction")
  10373. }
  10374. tx := &Tx{config: m.config}
  10375. tx.init()
  10376. return tx, nil
  10377. }
  10378. // SetID sets the value of the id field. Note that this
  10379. // operation is only accepted on creation of EmployeeConfig entities.
  10380. func (m *EmployeeConfigMutation) SetID(id uint64) {
  10381. m.id = &id
  10382. }
  10383. // ID returns the ID value in the mutation. Note that the ID is only available
  10384. // if it was provided to the builder or after it was returned from the database.
  10385. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  10386. if m.id == nil {
  10387. return
  10388. }
  10389. return *m.id, true
  10390. }
  10391. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10392. // That means, if the mutation is applied within a transaction with an isolation level such
  10393. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10394. // or updated by the mutation.
  10395. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  10396. switch {
  10397. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10398. id, exists := m.ID()
  10399. if exists {
  10400. return []uint64{id}, nil
  10401. }
  10402. fallthrough
  10403. case m.op.Is(OpUpdate | OpDelete):
  10404. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  10405. default:
  10406. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10407. }
  10408. }
  10409. // SetCreatedAt sets the "created_at" field.
  10410. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  10411. m.created_at = &t
  10412. }
  10413. // CreatedAt returns the value of the "created_at" field in the mutation.
  10414. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  10415. v := m.created_at
  10416. if v == nil {
  10417. return
  10418. }
  10419. return *v, true
  10420. }
  10421. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  10422. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10424. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10425. if !m.op.Is(OpUpdateOne) {
  10426. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10427. }
  10428. if m.id == nil || m.oldValue == nil {
  10429. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10430. }
  10431. oldValue, err := m.oldValue(ctx)
  10432. if err != nil {
  10433. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10434. }
  10435. return oldValue.CreatedAt, nil
  10436. }
  10437. // ResetCreatedAt resets all changes to the "created_at" field.
  10438. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  10439. m.created_at = nil
  10440. }
  10441. // SetUpdatedAt sets the "updated_at" field.
  10442. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  10443. m.updated_at = &t
  10444. }
  10445. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10446. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  10447. v := m.updated_at
  10448. if v == nil {
  10449. return
  10450. }
  10451. return *v, true
  10452. }
  10453. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  10454. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10456. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10457. if !m.op.Is(OpUpdateOne) {
  10458. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10459. }
  10460. if m.id == nil || m.oldValue == nil {
  10461. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10462. }
  10463. oldValue, err := m.oldValue(ctx)
  10464. if err != nil {
  10465. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10466. }
  10467. return oldValue.UpdatedAt, nil
  10468. }
  10469. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10470. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  10471. m.updated_at = nil
  10472. }
  10473. // SetDeletedAt sets the "deleted_at" field.
  10474. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  10475. m.deleted_at = &t
  10476. }
  10477. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10478. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  10479. v := m.deleted_at
  10480. if v == nil {
  10481. return
  10482. }
  10483. return *v, true
  10484. }
  10485. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  10486. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10488. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10489. if !m.op.Is(OpUpdateOne) {
  10490. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10491. }
  10492. if m.id == nil || m.oldValue == nil {
  10493. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10494. }
  10495. oldValue, err := m.oldValue(ctx)
  10496. if err != nil {
  10497. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10498. }
  10499. return oldValue.DeletedAt, nil
  10500. }
  10501. // ClearDeletedAt clears the value of the "deleted_at" field.
  10502. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  10503. m.deleted_at = nil
  10504. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  10505. }
  10506. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10507. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  10508. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  10509. return ok
  10510. }
  10511. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10512. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  10513. m.deleted_at = nil
  10514. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  10515. }
  10516. // SetStype sets the "stype" field.
  10517. func (m *EmployeeConfigMutation) SetStype(s string) {
  10518. m.stype = &s
  10519. }
  10520. // Stype returns the value of the "stype" field in the mutation.
  10521. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  10522. v := m.stype
  10523. if v == nil {
  10524. return
  10525. }
  10526. return *v, true
  10527. }
  10528. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  10529. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10531. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  10532. if !m.op.Is(OpUpdateOne) {
  10533. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  10534. }
  10535. if m.id == nil || m.oldValue == nil {
  10536. return v, errors.New("OldStype requires an ID field in the mutation")
  10537. }
  10538. oldValue, err := m.oldValue(ctx)
  10539. if err != nil {
  10540. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  10541. }
  10542. return oldValue.Stype, nil
  10543. }
  10544. // ResetStype resets all changes to the "stype" field.
  10545. func (m *EmployeeConfigMutation) ResetStype() {
  10546. m.stype = nil
  10547. }
  10548. // SetTitle sets the "title" field.
  10549. func (m *EmployeeConfigMutation) SetTitle(s string) {
  10550. m.title = &s
  10551. }
  10552. // Title returns the value of the "title" field in the mutation.
  10553. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  10554. v := m.title
  10555. if v == nil {
  10556. return
  10557. }
  10558. return *v, true
  10559. }
  10560. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  10561. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10563. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  10564. if !m.op.Is(OpUpdateOne) {
  10565. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  10566. }
  10567. if m.id == nil || m.oldValue == nil {
  10568. return v, errors.New("OldTitle requires an ID field in the mutation")
  10569. }
  10570. oldValue, err := m.oldValue(ctx)
  10571. if err != nil {
  10572. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  10573. }
  10574. return oldValue.Title, nil
  10575. }
  10576. // ResetTitle resets all changes to the "title" field.
  10577. func (m *EmployeeConfigMutation) ResetTitle() {
  10578. m.title = nil
  10579. }
  10580. // SetPhoto sets the "photo" field.
  10581. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  10582. m.photo = &s
  10583. }
  10584. // Photo returns the value of the "photo" field in the mutation.
  10585. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  10586. v := m.photo
  10587. if v == nil {
  10588. return
  10589. }
  10590. return *v, true
  10591. }
  10592. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  10593. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10595. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  10596. if !m.op.Is(OpUpdateOne) {
  10597. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  10598. }
  10599. if m.id == nil || m.oldValue == nil {
  10600. return v, errors.New("OldPhoto requires an ID field in the mutation")
  10601. }
  10602. oldValue, err := m.oldValue(ctx)
  10603. if err != nil {
  10604. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  10605. }
  10606. return oldValue.Photo, nil
  10607. }
  10608. // ResetPhoto resets all changes to the "photo" field.
  10609. func (m *EmployeeConfigMutation) ResetPhoto() {
  10610. m.photo = nil
  10611. }
  10612. // SetOrganizationID sets the "organization_id" field.
  10613. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  10614. m.organization_id = &u
  10615. m.addorganization_id = nil
  10616. }
  10617. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10618. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  10619. v := m.organization_id
  10620. if v == nil {
  10621. return
  10622. }
  10623. return *v, true
  10624. }
  10625. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  10626. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  10627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10628. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10629. if !m.op.Is(OpUpdateOne) {
  10630. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10631. }
  10632. if m.id == nil || m.oldValue == nil {
  10633. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10634. }
  10635. oldValue, err := m.oldValue(ctx)
  10636. if err != nil {
  10637. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10638. }
  10639. return oldValue.OrganizationID, nil
  10640. }
  10641. // AddOrganizationID adds u to the "organization_id" field.
  10642. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  10643. if m.addorganization_id != nil {
  10644. *m.addorganization_id += u
  10645. } else {
  10646. m.addorganization_id = &u
  10647. }
  10648. }
  10649. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10650. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  10651. v := m.addorganization_id
  10652. if v == nil {
  10653. return
  10654. }
  10655. return *v, true
  10656. }
  10657. // ClearOrganizationID clears the value of the "organization_id" field.
  10658. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  10659. m.organization_id = nil
  10660. m.addorganization_id = nil
  10661. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  10662. }
  10663. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10664. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  10665. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  10666. return ok
  10667. }
  10668. // ResetOrganizationID resets all changes to the "organization_id" field.
  10669. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  10670. m.organization_id = nil
  10671. m.addorganization_id = nil
  10672. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  10673. }
  10674. // Where appends a list predicates to the EmployeeConfigMutation builder.
  10675. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  10676. m.predicates = append(m.predicates, ps...)
  10677. }
  10678. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  10679. // users can use type-assertion to append predicates that do not depend on any generated package.
  10680. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  10681. p := make([]predicate.EmployeeConfig, len(ps))
  10682. for i := range ps {
  10683. p[i] = ps[i]
  10684. }
  10685. m.Where(p...)
  10686. }
  10687. // Op returns the operation name.
  10688. func (m *EmployeeConfigMutation) Op() Op {
  10689. return m.op
  10690. }
  10691. // SetOp allows setting the mutation operation.
  10692. func (m *EmployeeConfigMutation) SetOp(op Op) {
  10693. m.op = op
  10694. }
  10695. // Type returns the node type of this mutation (EmployeeConfig).
  10696. func (m *EmployeeConfigMutation) Type() string {
  10697. return m.typ
  10698. }
  10699. // Fields returns all fields that were changed during this mutation. Note that in
  10700. // order to get all numeric fields that were incremented/decremented, call
  10701. // AddedFields().
  10702. func (m *EmployeeConfigMutation) Fields() []string {
  10703. fields := make([]string, 0, 7)
  10704. if m.created_at != nil {
  10705. fields = append(fields, employeeconfig.FieldCreatedAt)
  10706. }
  10707. if m.updated_at != nil {
  10708. fields = append(fields, employeeconfig.FieldUpdatedAt)
  10709. }
  10710. if m.deleted_at != nil {
  10711. fields = append(fields, employeeconfig.FieldDeletedAt)
  10712. }
  10713. if m.stype != nil {
  10714. fields = append(fields, employeeconfig.FieldStype)
  10715. }
  10716. if m.title != nil {
  10717. fields = append(fields, employeeconfig.FieldTitle)
  10718. }
  10719. if m.photo != nil {
  10720. fields = append(fields, employeeconfig.FieldPhoto)
  10721. }
  10722. if m.organization_id != nil {
  10723. fields = append(fields, employeeconfig.FieldOrganizationID)
  10724. }
  10725. return fields
  10726. }
  10727. // Field returns the value of a field with the given name. The second boolean
  10728. // return value indicates that this field was not set, or was not defined in the
  10729. // schema.
  10730. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  10731. switch name {
  10732. case employeeconfig.FieldCreatedAt:
  10733. return m.CreatedAt()
  10734. case employeeconfig.FieldUpdatedAt:
  10735. return m.UpdatedAt()
  10736. case employeeconfig.FieldDeletedAt:
  10737. return m.DeletedAt()
  10738. case employeeconfig.FieldStype:
  10739. return m.Stype()
  10740. case employeeconfig.FieldTitle:
  10741. return m.Title()
  10742. case employeeconfig.FieldPhoto:
  10743. return m.Photo()
  10744. case employeeconfig.FieldOrganizationID:
  10745. return m.OrganizationID()
  10746. }
  10747. return nil, false
  10748. }
  10749. // OldField returns the old value of the field from the database. An error is
  10750. // returned if the mutation operation is not UpdateOne, or the query to the
  10751. // database failed.
  10752. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10753. switch name {
  10754. case employeeconfig.FieldCreatedAt:
  10755. return m.OldCreatedAt(ctx)
  10756. case employeeconfig.FieldUpdatedAt:
  10757. return m.OldUpdatedAt(ctx)
  10758. case employeeconfig.FieldDeletedAt:
  10759. return m.OldDeletedAt(ctx)
  10760. case employeeconfig.FieldStype:
  10761. return m.OldStype(ctx)
  10762. case employeeconfig.FieldTitle:
  10763. return m.OldTitle(ctx)
  10764. case employeeconfig.FieldPhoto:
  10765. return m.OldPhoto(ctx)
  10766. case employeeconfig.FieldOrganizationID:
  10767. return m.OldOrganizationID(ctx)
  10768. }
  10769. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  10770. }
  10771. // SetField sets the value of a field with the given name. It returns an error if
  10772. // the field is not defined in the schema, or if the type mismatched the field
  10773. // type.
  10774. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  10775. switch name {
  10776. case employeeconfig.FieldCreatedAt:
  10777. v, ok := value.(time.Time)
  10778. if !ok {
  10779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10780. }
  10781. m.SetCreatedAt(v)
  10782. return nil
  10783. case employeeconfig.FieldUpdatedAt:
  10784. v, ok := value.(time.Time)
  10785. if !ok {
  10786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10787. }
  10788. m.SetUpdatedAt(v)
  10789. return nil
  10790. case employeeconfig.FieldDeletedAt:
  10791. v, ok := value.(time.Time)
  10792. if !ok {
  10793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10794. }
  10795. m.SetDeletedAt(v)
  10796. return nil
  10797. case employeeconfig.FieldStype:
  10798. v, ok := value.(string)
  10799. if !ok {
  10800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10801. }
  10802. m.SetStype(v)
  10803. return nil
  10804. case employeeconfig.FieldTitle:
  10805. v, ok := value.(string)
  10806. if !ok {
  10807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10808. }
  10809. m.SetTitle(v)
  10810. return nil
  10811. case employeeconfig.FieldPhoto:
  10812. v, ok := value.(string)
  10813. if !ok {
  10814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10815. }
  10816. m.SetPhoto(v)
  10817. return nil
  10818. case employeeconfig.FieldOrganizationID:
  10819. v, ok := value.(uint64)
  10820. if !ok {
  10821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10822. }
  10823. m.SetOrganizationID(v)
  10824. return nil
  10825. }
  10826. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  10827. }
  10828. // AddedFields returns all numeric fields that were incremented/decremented during
  10829. // this mutation.
  10830. func (m *EmployeeConfigMutation) AddedFields() []string {
  10831. var fields []string
  10832. if m.addorganization_id != nil {
  10833. fields = append(fields, employeeconfig.FieldOrganizationID)
  10834. }
  10835. return fields
  10836. }
  10837. // AddedField returns the numeric value that was incremented/decremented on a field
  10838. // with the given name. The second boolean return value indicates that this field
  10839. // was not set, or was not defined in the schema.
  10840. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  10841. switch name {
  10842. case employeeconfig.FieldOrganizationID:
  10843. return m.AddedOrganizationID()
  10844. }
  10845. return nil, false
  10846. }
  10847. // AddField adds the value to the field with the given name. It returns an error if
  10848. // the field is not defined in the schema, or if the type mismatched the field
  10849. // type.
  10850. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  10851. switch name {
  10852. case employeeconfig.FieldOrganizationID:
  10853. v, ok := value.(int64)
  10854. if !ok {
  10855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10856. }
  10857. m.AddOrganizationID(v)
  10858. return nil
  10859. }
  10860. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  10861. }
  10862. // ClearedFields returns all nullable fields that were cleared during this
  10863. // mutation.
  10864. func (m *EmployeeConfigMutation) ClearedFields() []string {
  10865. var fields []string
  10866. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  10867. fields = append(fields, employeeconfig.FieldDeletedAt)
  10868. }
  10869. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  10870. fields = append(fields, employeeconfig.FieldOrganizationID)
  10871. }
  10872. return fields
  10873. }
  10874. // FieldCleared returns a boolean indicating if a field with the given name was
  10875. // cleared in this mutation.
  10876. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  10877. _, ok := m.clearedFields[name]
  10878. return ok
  10879. }
  10880. // ClearField clears the value of the field with the given name. It returns an
  10881. // error if the field is not defined in the schema.
  10882. func (m *EmployeeConfigMutation) ClearField(name string) error {
  10883. switch name {
  10884. case employeeconfig.FieldDeletedAt:
  10885. m.ClearDeletedAt()
  10886. return nil
  10887. case employeeconfig.FieldOrganizationID:
  10888. m.ClearOrganizationID()
  10889. return nil
  10890. }
  10891. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  10892. }
  10893. // ResetField resets all changes in the mutation for the field with the given name.
  10894. // It returns an error if the field is not defined in the schema.
  10895. func (m *EmployeeConfigMutation) ResetField(name string) error {
  10896. switch name {
  10897. case employeeconfig.FieldCreatedAt:
  10898. m.ResetCreatedAt()
  10899. return nil
  10900. case employeeconfig.FieldUpdatedAt:
  10901. m.ResetUpdatedAt()
  10902. return nil
  10903. case employeeconfig.FieldDeletedAt:
  10904. m.ResetDeletedAt()
  10905. return nil
  10906. case employeeconfig.FieldStype:
  10907. m.ResetStype()
  10908. return nil
  10909. case employeeconfig.FieldTitle:
  10910. m.ResetTitle()
  10911. return nil
  10912. case employeeconfig.FieldPhoto:
  10913. m.ResetPhoto()
  10914. return nil
  10915. case employeeconfig.FieldOrganizationID:
  10916. m.ResetOrganizationID()
  10917. return nil
  10918. }
  10919. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  10920. }
  10921. // AddedEdges returns all edge names that were set/added in this mutation.
  10922. func (m *EmployeeConfigMutation) AddedEdges() []string {
  10923. edges := make([]string, 0, 0)
  10924. return edges
  10925. }
  10926. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10927. // name in this mutation.
  10928. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  10929. return nil
  10930. }
  10931. // RemovedEdges returns all edge names that were removed in this mutation.
  10932. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  10933. edges := make([]string, 0, 0)
  10934. return edges
  10935. }
  10936. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10937. // the given name in this mutation.
  10938. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  10939. return nil
  10940. }
  10941. // ClearedEdges returns all edge names that were cleared in this mutation.
  10942. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  10943. edges := make([]string, 0, 0)
  10944. return edges
  10945. }
  10946. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10947. // was cleared in this mutation.
  10948. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  10949. return false
  10950. }
  10951. // ClearEdge clears the value of the edge with the given name. It returns an error
  10952. // if that edge is not defined in the schema.
  10953. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  10954. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  10955. }
  10956. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10957. // It returns an error if the edge is not defined in the schema.
  10958. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  10959. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  10960. }
  10961. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  10962. type LabelMutation struct {
  10963. config
  10964. op Op
  10965. typ string
  10966. id *uint64
  10967. created_at *time.Time
  10968. updated_at *time.Time
  10969. status *uint8
  10970. addstatus *int8
  10971. _type *int
  10972. add_type *int
  10973. name *string
  10974. from *int
  10975. addfrom *int
  10976. mode *int
  10977. addmode *int
  10978. conditions *string
  10979. organization_id *uint64
  10980. addorganization_id *int64
  10981. clearedFields map[string]struct{}
  10982. label_relationships map[uint64]struct{}
  10983. removedlabel_relationships map[uint64]struct{}
  10984. clearedlabel_relationships bool
  10985. done bool
  10986. oldValue func(context.Context) (*Label, error)
  10987. predicates []predicate.Label
  10988. }
  10989. var _ ent.Mutation = (*LabelMutation)(nil)
  10990. // labelOption allows management of the mutation configuration using functional options.
  10991. type labelOption func(*LabelMutation)
  10992. // newLabelMutation creates new mutation for the Label entity.
  10993. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  10994. m := &LabelMutation{
  10995. config: c,
  10996. op: op,
  10997. typ: TypeLabel,
  10998. clearedFields: make(map[string]struct{}),
  10999. }
  11000. for _, opt := range opts {
  11001. opt(m)
  11002. }
  11003. return m
  11004. }
  11005. // withLabelID sets the ID field of the mutation.
  11006. func withLabelID(id uint64) labelOption {
  11007. return func(m *LabelMutation) {
  11008. var (
  11009. err error
  11010. once sync.Once
  11011. value *Label
  11012. )
  11013. m.oldValue = func(ctx context.Context) (*Label, error) {
  11014. once.Do(func() {
  11015. if m.done {
  11016. err = errors.New("querying old values post mutation is not allowed")
  11017. } else {
  11018. value, err = m.Client().Label.Get(ctx, id)
  11019. }
  11020. })
  11021. return value, err
  11022. }
  11023. m.id = &id
  11024. }
  11025. }
  11026. // withLabel sets the old Label of the mutation.
  11027. func withLabel(node *Label) labelOption {
  11028. return func(m *LabelMutation) {
  11029. m.oldValue = func(context.Context) (*Label, error) {
  11030. return node, nil
  11031. }
  11032. m.id = &node.ID
  11033. }
  11034. }
  11035. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11036. // executed in a transaction (ent.Tx), a transactional client is returned.
  11037. func (m LabelMutation) Client() *Client {
  11038. client := &Client{config: m.config}
  11039. client.init()
  11040. return client
  11041. }
  11042. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11043. // it returns an error otherwise.
  11044. func (m LabelMutation) Tx() (*Tx, error) {
  11045. if _, ok := m.driver.(*txDriver); !ok {
  11046. return nil, errors.New("ent: mutation is not running in a transaction")
  11047. }
  11048. tx := &Tx{config: m.config}
  11049. tx.init()
  11050. return tx, nil
  11051. }
  11052. // SetID sets the value of the id field. Note that this
  11053. // operation is only accepted on creation of Label entities.
  11054. func (m *LabelMutation) SetID(id uint64) {
  11055. m.id = &id
  11056. }
  11057. // ID returns the ID value in the mutation. Note that the ID is only available
  11058. // if it was provided to the builder or after it was returned from the database.
  11059. func (m *LabelMutation) ID() (id uint64, exists bool) {
  11060. if m.id == nil {
  11061. return
  11062. }
  11063. return *m.id, true
  11064. }
  11065. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11066. // That means, if the mutation is applied within a transaction with an isolation level such
  11067. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11068. // or updated by the mutation.
  11069. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  11070. switch {
  11071. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11072. id, exists := m.ID()
  11073. if exists {
  11074. return []uint64{id}, nil
  11075. }
  11076. fallthrough
  11077. case m.op.Is(OpUpdate | OpDelete):
  11078. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  11079. default:
  11080. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11081. }
  11082. }
  11083. // SetCreatedAt sets the "created_at" field.
  11084. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  11085. m.created_at = &t
  11086. }
  11087. // CreatedAt returns the value of the "created_at" field in the mutation.
  11088. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  11089. v := m.created_at
  11090. if v == nil {
  11091. return
  11092. }
  11093. return *v, true
  11094. }
  11095. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  11096. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11097. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11098. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11099. if !m.op.Is(OpUpdateOne) {
  11100. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11101. }
  11102. if m.id == nil || m.oldValue == nil {
  11103. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11104. }
  11105. oldValue, err := m.oldValue(ctx)
  11106. if err != nil {
  11107. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11108. }
  11109. return oldValue.CreatedAt, nil
  11110. }
  11111. // ResetCreatedAt resets all changes to the "created_at" field.
  11112. func (m *LabelMutation) ResetCreatedAt() {
  11113. m.created_at = nil
  11114. }
  11115. // SetUpdatedAt sets the "updated_at" field.
  11116. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  11117. m.updated_at = &t
  11118. }
  11119. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11120. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  11121. v := m.updated_at
  11122. if v == nil {
  11123. return
  11124. }
  11125. return *v, true
  11126. }
  11127. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  11128. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11130. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11131. if !m.op.Is(OpUpdateOne) {
  11132. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11133. }
  11134. if m.id == nil || m.oldValue == nil {
  11135. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11136. }
  11137. oldValue, err := m.oldValue(ctx)
  11138. if err != nil {
  11139. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11140. }
  11141. return oldValue.UpdatedAt, nil
  11142. }
  11143. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11144. func (m *LabelMutation) ResetUpdatedAt() {
  11145. m.updated_at = nil
  11146. }
  11147. // SetStatus sets the "status" field.
  11148. func (m *LabelMutation) SetStatus(u uint8) {
  11149. m.status = &u
  11150. m.addstatus = nil
  11151. }
  11152. // Status returns the value of the "status" field in the mutation.
  11153. func (m *LabelMutation) Status() (r uint8, exists bool) {
  11154. v := m.status
  11155. if v == nil {
  11156. return
  11157. }
  11158. return *v, true
  11159. }
  11160. // OldStatus returns the old "status" field's value of the Label entity.
  11161. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11162. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11163. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  11164. if !m.op.Is(OpUpdateOne) {
  11165. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  11166. }
  11167. if m.id == nil || m.oldValue == nil {
  11168. return v, errors.New("OldStatus requires an ID field in the mutation")
  11169. }
  11170. oldValue, err := m.oldValue(ctx)
  11171. if err != nil {
  11172. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  11173. }
  11174. return oldValue.Status, nil
  11175. }
  11176. // AddStatus adds u to the "status" field.
  11177. func (m *LabelMutation) AddStatus(u int8) {
  11178. if m.addstatus != nil {
  11179. *m.addstatus += u
  11180. } else {
  11181. m.addstatus = &u
  11182. }
  11183. }
  11184. // AddedStatus returns the value that was added to the "status" field in this mutation.
  11185. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  11186. v := m.addstatus
  11187. if v == nil {
  11188. return
  11189. }
  11190. return *v, true
  11191. }
  11192. // ClearStatus clears the value of the "status" field.
  11193. func (m *LabelMutation) ClearStatus() {
  11194. m.status = nil
  11195. m.addstatus = nil
  11196. m.clearedFields[label.FieldStatus] = struct{}{}
  11197. }
  11198. // StatusCleared returns if the "status" field was cleared in this mutation.
  11199. func (m *LabelMutation) StatusCleared() bool {
  11200. _, ok := m.clearedFields[label.FieldStatus]
  11201. return ok
  11202. }
  11203. // ResetStatus resets all changes to the "status" field.
  11204. func (m *LabelMutation) ResetStatus() {
  11205. m.status = nil
  11206. m.addstatus = nil
  11207. delete(m.clearedFields, label.FieldStatus)
  11208. }
  11209. // SetType sets the "type" field.
  11210. func (m *LabelMutation) SetType(i int) {
  11211. m._type = &i
  11212. m.add_type = nil
  11213. }
  11214. // GetType returns the value of the "type" field in the mutation.
  11215. func (m *LabelMutation) GetType() (r int, exists bool) {
  11216. v := m._type
  11217. if v == nil {
  11218. return
  11219. }
  11220. return *v, true
  11221. }
  11222. // OldType returns the old "type" field's value of the Label entity.
  11223. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11224. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11225. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  11226. if !m.op.Is(OpUpdateOne) {
  11227. return v, errors.New("OldType is only allowed on UpdateOne operations")
  11228. }
  11229. if m.id == nil || m.oldValue == nil {
  11230. return v, errors.New("OldType requires an ID field in the mutation")
  11231. }
  11232. oldValue, err := m.oldValue(ctx)
  11233. if err != nil {
  11234. return v, fmt.Errorf("querying old value for OldType: %w", err)
  11235. }
  11236. return oldValue.Type, nil
  11237. }
  11238. // AddType adds i to the "type" field.
  11239. func (m *LabelMutation) AddType(i int) {
  11240. if m.add_type != nil {
  11241. *m.add_type += i
  11242. } else {
  11243. m.add_type = &i
  11244. }
  11245. }
  11246. // AddedType returns the value that was added to the "type" field in this mutation.
  11247. func (m *LabelMutation) AddedType() (r int, exists bool) {
  11248. v := m.add_type
  11249. if v == nil {
  11250. return
  11251. }
  11252. return *v, true
  11253. }
  11254. // ResetType resets all changes to the "type" field.
  11255. func (m *LabelMutation) ResetType() {
  11256. m._type = nil
  11257. m.add_type = nil
  11258. }
  11259. // SetName sets the "name" field.
  11260. func (m *LabelMutation) SetName(s string) {
  11261. m.name = &s
  11262. }
  11263. // Name returns the value of the "name" field in the mutation.
  11264. func (m *LabelMutation) Name() (r string, exists bool) {
  11265. v := m.name
  11266. if v == nil {
  11267. return
  11268. }
  11269. return *v, true
  11270. }
  11271. // OldName returns the old "name" field's value of the Label entity.
  11272. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11274. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  11275. if !m.op.Is(OpUpdateOne) {
  11276. return v, errors.New("OldName is only allowed on UpdateOne operations")
  11277. }
  11278. if m.id == nil || m.oldValue == nil {
  11279. return v, errors.New("OldName requires an ID field in the mutation")
  11280. }
  11281. oldValue, err := m.oldValue(ctx)
  11282. if err != nil {
  11283. return v, fmt.Errorf("querying old value for OldName: %w", err)
  11284. }
  11285. return oldValue.Name, nil
  11286. }
  11287. // ResetName resets all changes to the "name" field.
  11288. func (m *LabelMutation) ResetName() {
  11289. m.name = nil
  11290. }
  11291. // SetFrom sets the "from" field.
  11292. func (m *LabelMutation) SetFrom(i int) {
  11293. m.from = &i
  11294. m.addfrom = nil
  11295. }
  11296. // From returns the value of the "from" field in the mutation.
  11297. func (m *LabelMutation) From() (r int, exists bool) {
  11298. v := m.from
  11299. if v == nil {
  11300. return
  11301. }
  11302. return *v, true
  11303. }
  11304. // OldFrom returns the old "from" field's value of the Label entity.
  11305. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11307. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  11308. if !m.op.Is(OpUpdateOne) {
  11309. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  11310. }
  11311. if m.id == nil || m.oldValue == nil {
  11312. return v, errors.New("OldFrom requires an ID field in the mutation")
  11313. }
  11314. oldValue, err := m.oldValue(ctx)
  11315. if err != nil {
  11316. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  11317. }
  11318. return oldValue.From, nil
  11319. }
  11320. // AddFrom adds i to the "from" field.
  11321. func (m *LabelMutation) AddFrom(i int) {
  11322. if m.addfrom != nil {
  11323. *m.addfrom += i
  11324. } else {
  11325. m.addfrom = &i
  11326. }
  11327. }
  11328. // AddedFrom returns the value that was added to the "from" field in this mutation.
  11329. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  11330. v := m.addfrom
  11331. if v == nil {
  11332. return
  11333. }
  11334. return *v, true
  11335. }
  11336. // ResetFrom resets all changes to the "from" field.
  11337. func (m *LabelMutation) ResetFrom() {
  11338. m.from = nil
  11339. m.addfrom = nil
  11340. }
  11341. // SetMode sets the "mode" field.
  11342. func (m *LabelMutation) SetMode(i int) {
  11343. m.mode = &i
  11344. m.addmode = nil
  11345. }
  11346. // Mode returns the value of the "mode" field in the mutation.
  11347. func (m *LabelMutation) Mode() (r int, exists bool) {
  11348. v := m.mode
  11349. if v == nil {
  11350. return
  11351. }
  11352. return *v, true
  11353. }
  11354. // OldMode returns the old "mode" field's value of the Label entity.
  11355. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11357. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  11358. if !m.op.Is(OpUpdateOne) {
  11359. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  11360. }
  11361. if m.id == nil || m.oldValue == nil {
  11362. return v, errors.New("OldMode requires an ID field in the mutation")
  11363. }
  11364. oldValue, err := m.oldValue(ctx)
  11365. if err != nil {
  11366. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  11367. }
  11368. return oldValue.Mode, nil
  11369. }
  11370. // AddMode adds i to the "mode" field.
  11371. func (m *LabelMutation) AddMode(i int) {
  11372. if m.addmode != nil {
  11373. *m.addmode += i
  11374. } else {
  11375. m.addmode = &i
  11376. }
  11377. }
  11378. // AddedMode returns the value that was added to the "mode" field in this mutation.
  11379. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  11380. v := m.addmode
  11381. if v == nil {
  11382. return
  11383. }
  11384. return *v, true
  11385. }
  11386. // ResetMode resets all changes to the "mode" field.
  11387. func (m *LabelMutation) ResetMode() {
  11388. m.mode = nil
  11389. m.addmode = nil
  11390. }
  11391. // SetConditions sets the "conditions" field.
  11392. func (m *LabelMutation) SetConditions(s string) {
  11393. m.conditions = &s
  11394. }
  11395. // Conditions returns the value of the "conditions" field in the mutation.
  11396. func (m *LabelMutation) Conditions() (r string, exists bool) {
  11397. v := m.conditions
  11398. if v == nil {
  11399. return
  11400. }
  11401. return *v, true
  11402. }
  11403. // OldConditions returns the old "conditions" field's value of the Label entity.
  11404. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11406. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  11407. if !m.op.Is(OpUpdateOne) {
  11408. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  11409. }
  11410. if m.id == nil || m.oldValue == nil {
  11411. return v, errors.New("OldConditions requires an ID field in the mutation")
  11412. }
  11413. oldValue, err := m.oldValue(ctx)
  11414. if err != nil {
  11415. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  11416. }
  11417. return oldValue.Conditions, nil
  11418. }
  11419. // ClearConditions clears the value of the "conditions" field.
  11420. func (m *LabelMutation) ClearConditions() {
  11421. m.conditions = nil
  11422. m.clearedFields[label.FieldConditions] = struct{}{}
  11423. }
  11424. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  11425. func (m *LabelMutation) ConditionsCleared() bool {
  11426. _, ok := m.clearedFields[label.FieldConditions]
  11427. return ok
  11428. }
  11429. // ResetConditions resets all changes to the "conditions" field.
  11430. func (m *LabelMutation) ResetConditions() {
  11431. m.conditions = nil
  11432. delete(m.clearedFields, label.FieldConditions)
  11433. }
  11434. // SetOrganizationID sets the "organization_id" field.
  11435. func (m *LabelMutation) SetOrganizationID(u uint64) {
  11436. m.organization_id = &u
  11437. m.addorganization_id = nil
  11438. }
  11439. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11440. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  11441. v := m.organization_id
  11442. if v == nil {
  11443. return
  11444. }
  11445. return *v, true
  11446. }
  11447. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  11448. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  11449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11450. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11451. if !m.op.Is(OpUpdateOne) {
  11452. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11453. }
  11454. if m.id == nil || m.oldValue == nil {
  11455. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11456. }
  11457. oldValue, err := m.oldValue(ctx)
  11458. if err != nil {
  11459. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11460. }
  11461. return oldValue.OrganizationID, nil
  11462. }
  11463. // AddOrganizationID adds u to the "organization_id" field.
  11464. func (m *LabelMutation) AddOrganizationID(u int64) {
  11465. if m.addorganization_id != nil {
  11466. *m.addorganization_id += u
  11467. } else {
  11468. m.addorganization_id = &u
  11469. }
  11470. }
  11471. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11472. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  11473. v := m.addorganization_id
  11474. if v == nil {
  11475. return
  11476. }
  11477. return *v, true
  11478. }
  11479. // ClearOrganizationID clears the value of the "organization_id" field.
  11480. func (m *LabelMutation) ClearOrganizationID() {
  11481. m.organization_id = nil
  11482. m.addorganization_id = nil
  11483. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  11484. }
  11485. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  11486. func (m *LabelMutation) OrganizationIDCleared() bool {
  11487. _, ok := m.clearedFields[label.FieldOrganizationID]
  11488. return ok
  11489. }
  11490. // ResetOrganizationID resets all changes to the "organization_id" field.
  11491. func (m *LabelMutation) ResetOrganizationID() {
  11492. m.organization_id = nil
  11493. m.addorganization_id = nil
  11494. delete(m.clearedFields, label.FieldOrganizationID)
  11495. }
  11496. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  11497. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  11498. if m.label_relationships == nil {
  11499. m.label_relationships = make(map[uint64]struct{})
  11500. }
  11501. for i := range ids {
  11502. m.label_relationships[ids[i]] = struct{}{}
  11503. }
  11504. }
  11505. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  11506. func (m *LabelMutation) ClearLabelRelationships() {
  11507. m.clearedlabel_relationships = true
  11508. }
  11509. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  11510. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  11511. return m.clearedlabel_relationships
  11512. }
  11513. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  11514. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  11515. if m.removedlabel_relationships == nil {
  11516. m.removedlabel_relationships = make(map[uint64]struct{})
  11517. }
  11518. for i := range ids {
  11519. delete(m.label_relationships, ids[i])
  11520. m.removedlabel_relationships[ids[i]] = struct{}{}
  11521. }
  11522. }
  11523. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  11524. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  11525. for id := range m.removedlabel_relationships {
  11526. ids = append(ids, id)
  11527. }
  11528. return
  11529. }
  11530. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  11531. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  11532. for id := range m.label_relationships {
  11533. ids = append(ids, id)
  11534. }
  11535. return
  11536. }
  11537. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  11538. func (m *LabelMutation) ResetLabelRelationships() {
  11539. m.label_relationships = nil
  11540. m.clearedlabel_relationships = false
  11541. m.removedlabel_relationships = nil
  11542. }
  11543. // Where appends a list predicates to the LabelMutation builder.
  11544. func (m *LabelMutation) Where(ps ...predicate.Label) {
  11545. m.predicates = append(m.predicates, ps...)
  11546. }
  11547. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  11548. // users can use type-assertion to append predicates that do not depend on any generated package.
  11549. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  11550. p := make([]predicate.Label, len(ps))
  11551. for i := range ps {
  11552. p[i] = ps[i]
  11553. }
  11554. m.Where(p...)
  11555. }
  11556. // Op returns the operation name.
  11557. func (m *LabelMutation) Op() Op {
  11558. return m.op
  11559. }
  11560. // SetOp allows setting the mutation operation.
  11561. func (m *LabelMutation) SetOp(op Op) {
  11562. m.op = op
  11563. }
  11564. // Type returns the node type of this mutation (Label).
  11565. func (m *LabelMutation) Type() string {
  11566. return m.typ
  11567. }
  11568. // Fields returns all fields that were changed during this mutation. Note that in
  11569. // order to get all numeric fields that were incremented/decremented, call
  11570. // AddedFields().
  11571. func (m *LabelMutation) Fields() []string {
  11572. fields := make([]string, 0, 9)
  11573. if m.created_at != nil {
  11574. fields = append(fields, label.FieldCreatedAt)
  11575. }
  11576. if m.updated_at != nil {
  11577. fields = append(fields, label.FieldUpdatedAt)
  11578. }
  11579. if m.status != nil {
  11580. fields = append(fields, label.FieldStatus)
  11581. }
  11582. if m._type != nil {
  11583. fields = append(fields, label.FieldType)
  11584. }
  11585. if m.name != nil {
  11586. fields = append(fields, label.FieldName)
  11587. }
  11588. if m.from != nil {
  11589. fields = append(fields, label.FieldFrom)
  11590. }
  11591. if m.mode != nil {
  11592. fields = append(fields, label.FieldMode)
  11593. }
  11594. if m.conditions != nil {
  11595. fields = append(fields, label.FieldConditions)
  11596. }
  11597. if m.organization_id != nil {
  11598. fields = append(fields, label.FieldOrganizationID)
  11599. }
  11600. return fields
  11601. }
  11602. // Field returns the value of a field with the given name. The second boolean
  11603. // return value indicates that this field was not set, or was not defined in the
  11604. // schema.
  11605. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  11606. switch name {
  11607. case label.FieldCreatedAt:
  11608. return m.CreatedAt()
  11609. case label.FieldUpdatedAt:
  11610. return m.UpdatedAt()
  11611. case label.FieldStatus:
  11612. return m.Status()
  11613. case label.FieldType:
  11614. return m.GetType()
  11615. case label.FieldName:
  11616. return m.Name()
  11617. case label.FieldFrom:
  11618. return m.From()
  11619. case label.FieldMode:
  11620. return m.Mode()
  11621. case label.FieldConditions:
  11622. return m.Conditions()
  11623. case label.FieldOrganizationID:
  11624. return m.OrganizationID()
  11625. }
  11626. return nil, false
  11627. }
  11628. // OldField returns the old value of the field from the database. An error is
  11629. // returned if the mutation operation is not UpdateOne, or the query to the
  11630. // database failed.
  11631. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  11632. switch name {
  11633. case label.FieldCreatedAt:
  11634. return m.OldCreatedAt(ctx)
  11635. case label.FieldUpdatedAt:
  11636. return m.OldUpdatedAt(ctx)
  11637. case label.FieldStatus:
  11638. return m.OldStatus(ctx)
  11639. case label.FieldType:
  11640. return m.OldType(ctx)
  11641. case label.FieldName:
  11642. return m.OldName(ctx)
  11643. case label.FieldFrom:
  11644. return m.OldFrom(ctx)
  11645. case label.FieldMode:
  11646. return m.OldMode(ctx)
  11647. case label.FieldConditions:
  11648. return m.OldConditions(ctx)
  11649. case label.FieldOrganizationID:
  11650. return m.OldOrganizationID(ctx)
  11651. }
  11652. return nil, fmt.Errorf("unknown Label field %s", name)
  11653. }
  11654. // SetField sets the value of a field with the given name. It returns an error if
  11655. // the field is not defined in the schema, or if the type mismatched the field
  11656. // type.
  11657. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  11658. switch name {
  11659. case label.FieldCreatedAt:
  11660. v, ok := value.(time.Time)
  11661. if !ok {
  11662. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11663. }
  11664. m.SetCreatedAt(v)
  11665. return nil
  11666. case label.FieldUpdatedAt:
  11667. v, ok := value.(time.Time)
  11668. if !ok {
  11669. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11670. }
  11671. m.SetUpdatedAt(v)
  11672. return nil
  11673. case label.FieldStatus:
  11674. v, ok := value.(uint8)
  11675. if !ok {
  11676. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11677. }
  11678. m.SetStatus(v)
  11679. return nil
  11680. case label.FieldType:
  11681. v, ok := value.(int)
  11682. if !ok {
  11683. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11684. }
  11685. m.SetType(v)
  11686. return nil
  11687. case label.FieldName:
  11688. v, ok := value.(string)
  11689. if !ok {
  11690. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11691. }
  11692. m.SetName(v)
  11693. return nil
  11694. case label.FieldFrom:
  11695. v, ok := value.(int)
  11696. if !ok {
  11697. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11698. }
  11699. m.SetFrom(v)
  11700. return nil
  11701. case label.FieldMode:
  11702. v, ok := value.(int)
  11703. if !ok {
  11704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11705. }
  11706. m.SetMode(v)
  11707. return nil
  11708. case label.FieldConditions:
  11709. v, ok := value.(string)
  11710. if !ok {
  11711. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11712. }
  11713. m.SetConditions(v)
  11714. return nil
  11715. case label.FieldOrganizationID:
  11716. v, ok := value.(uint64)
  11717. if !ok {
  11718. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11719. }
  11720. m.SetOrganizationID(v)
  11721. return nil
  11722. }
  11723. return fmt.Errorf("unknown Label field %s", name)
  11724. }
  11725. // AddedFields returns all numeric fields that were incremented/decremented during
  11726. // this mutation.
  11727. func (m *LabelMutation) AddedFields() []string {
  11728. var fields []string
  11729. if m.addstatus != nil {
  11730. fields = append(fields, label.FieldStatus)
  11731. }
  11732. if m.add_type != nil {
  11733. fields = append(fields, label.FieldType)
  11734. }
  11735. if m.addfrom != nil {
  11736. fields = append(fields, label.FieldFrom)
  11737. }
  11738. if m.addmode != nil {
  11739. fields = append(fields, label.FieldMode)
  11740. }
  11741. if m.addorganization_id != nil {
  11742. fields = append(fields, label.FieldOrganizationID)
  11743. }
  11744. return fields
  11745. }
  11746. // AddedField returns the numeric value that was incremented/decremented on a field
  11747. // with the given name. The second boolean return value indicates that this field
  11748. // was not set, or was not defined in the schema.
  11749. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  11750. switch name {
  11751. case label.FieldStatus:
  11752. return m.AddedStatus()
  11753. case label.FieldType:
  11754. return m.AddedType()
  11755. case label.FieldFrom:
  11756. return m.AddedFrom()
  11757. case label.FieldMode:
  11758. return m.AddedMode()
  11759. case label.FieldOrganizationID:
  11760. return m.AddedOrganizationID()
  11761. }
  11762. return nil, false
  11763. }
  11764. // AddField adds the value to the field with the given name. It returns an error if
  11765. // the field is not defined in the schema, or if the type mismatched the field
  11766. // type.
  11767. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  11768. switch name {
  11769. case label.FieldStatus:
  11770. v, ok := value.(int8)
  11771. if !ok {
  11772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11773. }
  11774. m.AddStatus(v)
  11775. return nil
  11776. case label.FieldType:
  11777. v, ok := value.(int)
  11778. if !ok {
  11779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11780. }
  11781. m.AddType(v)
  11782. return nil
  11783. case label.FieldFrom:
  11784. v, ok := value.(int)
  11785. if !ok {
  11786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11787. }
  11788. m.AddFrom(v)
  11789. return nil
  11790. case label.FieldMode:
  11791. v, ok := value.(int)
  11792. if !ok {
  11793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11794. }
  11795. m.AddMode(v)
  11796. return nil
  11797. case label.FieldOrganizationID:
  11798. v, ok := value.(int64)
  11799. if !ok {
  11800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11801. }
  11802. m.AddOrganizationID(v)
  11803. return nil
  11804. }
  11805. return fmt.Errorf("unknown Label numeric field %s", name)
  11806. }
  11807. // ClearedFields returns all nullable fields that were cleared during this
  11808. // mutation.
  11809. func (m *LabelMutation) ClearedFields() []string {
  11810. var fields []string
  11811. if m.FieldCleared(label.FieldStatus) {
  11812. fields = append(fields, label.FieldStatus)
  11813. }
  11814. if m.FieldCleared(label.FieldConditions) {
  11815. fields = append(fields, label.FieldConditions)
  11816. }
  11817. if m.FieldCleared(label.FieldOrganizationID) {
  11818. fields = append(fields, label.FieldOrganizationID)
  11819. }
  11820. return fields
  11821. }
  11822. // FieldCleared returns a boolean indicating if a field with the given name was
  11823. // cleared in this mutation.
  11824. func (m *LabelMutation) FieldCleared(name string) bool {
  11825. _, ok := m.clearedFields[name]
  11826. return ok
  11827. }
  11828. // ClearField clears the value of the field with the given name. It returns an
  11829. // error if the field is not defined in the schema.
  11830. func (m *LabelMutation) ClearField(name string) error {
  11831. switch name {
  11832. case label.FieldStatus:
  11833. m.ClearStatus()
  11834. return nil
  11835. case label.FieldConditions:
  11836. m.ClearConditions()
  11837. return nil
  11838. case label.FieldOrganizationID:
  11839. m.ClearOrganizationID()
  11840. return nil
  11841. }
  11842. return fmt.Errorf("unknown Label nullable field %s", name)
  11843. }
  11844. // ResetField resets all changes in the mutation for the field with the given name.
  11845. // It returns an error if the field is not defined in the schema.
  11846. func (m *LabelMutation) ResetField(name string) error {
  11847. switch name {
  11848. case label.FieldCreatedAt:
  11849. m.ResetCreatedAt()
  11850. return nil
  11851. case label.FieldUpdatedAt:
  11852. m.ResetUpdatedAt()
  11853. return nil
  11854. case label.FieldStatus:
  11855. m.ResetStatus()
  11856. return nil
  11857. case label.FieldType:
  11858. m.ResetType()
  11859. return nil
  11860. case label.FieldName:
  11861. m.ResetName()
  11862. return nil
  11863. case label.FieldFrom:
  11864. m.ResetFrom()
  11865. return nil
  11866. case label.FieldMode:
  11867. m.ResetMode()
  11868. return nil
  11869. case label.FieldConditions:
  11870. m.ResetConditions()
  11871. return nil
  11872. case label.FieldOrganizationID:
  11873. m.ResetOrganizationID()
  11874. return nil
  11875. }
  11876. return fmt.Errorf("unknown Label field %s", name)
  11877. }
  11878. // AddedEdges returns all edge names that were set/added in this mutation.
  11879. func (m *LabelMutation) AddedEdges() []string {
  11880. edges := make([]string, 0, 1)
  11881. if m.label_relationships != nil {
  11882. edges = append(edges, label.EdgeLabelRelationships)
  11883. }
  11884. return edges
  11885. }
  11886. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11887. // name in this mutation.
  11888. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  11889. switch name {
  11890. case label.EdgeLabelRelationships:
  11891. ids := make([]ent.Value, 0, len(m.label_relationships))
  11892. for id := range m.label_relationships {
  11893. ids = append(ids, id)
  11894. }
  11895. return ids
  11896. }
  11897. return nil
  11898. }
  11899. // RemovedEdges returns all edge names that were removed in this mutation.
  11900. func (m *LabelMutation) RemovedEdges() []string {
  11901. edges := make([]string, 0, 1)
  11902. if m.removedlabel_relationships != nil {
  11903. edges = append(edges, label.EdgeLabelRelationships)
  11904. }
  11905. return edges
  11906. }
  11907. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11908. // the given name in this mutation.
  11909. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  11910. switch name {
  11911. case label.EdgeLabelRelationships:
  11912. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  11913. for id := range m.removedlabel_relationships {
  11914. ids = append(ids, id)
  11915. }
  11916. return ids
  11917. }
  11918. return nil
  11919. }
  11920. // ClearedEdges returns all edge names that were cleared in this mutation.
  11921. func (m *LabelMutation) ClearedEdges() []string {
  11922. edges := make([]string, 0, 1)
  11923. if m.clearedlabel_relationships {
  11924. edges = append(edges, label.EdgeLabelRelationships)
  11925. }
  11926. return edges
  11927. }
  11928. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11929. // was cleared in this mutation.
  11930. func (m *LabelMutation) EdgeCleared(name string) bool {
  11931. switch name {
  11932. case label.EdgeLabelRelationships:
  11933. return m.clearedlabel_relationships
  11934. }
  11935. return false
  11936. }
  11937. // ClearEdge clears the value of the edge with the given name. It returns an error
  11938. // if that edge is not defined in the schema.
  11939. func (m *LabelMutation) ClearEdge(name string) error {
  11940. switch name {
  11941. }
  11942. return fmt.Errorf("unknown Label unique edge %s", name)
  11943. }
  11944. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11945. // It returns an error if the edge is not defined in the schema.
  11946. func (m *LabelMutation) ResetEdge(name string) error {
  11947. switch name {
  11948. case label.EdgeLabelRelationships:
  11949. m.ResetLabelRelationships()
  11950. return nil
  11951. }
  11952. return fmt.Errorf("unknown Label edge %s", name)
  11953. }
  11954. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  11955. type LabelRelationshipMutation struct {
  11956. config
  11957. op Op
  11958. typ string
  11959. id *uint64
  11960. created_at *time.Time
  11961. updated_at *time.Time
  11962. status *uint8
  11963. addstatus *int8
  11964. organization_id *uint64
  11965. addorganization_id *int64
  11966. clearedFields map[string]struct{}
  11967. contacts *uint64
  11968. clearedcontacts bool
  11969. labels *uint64
  11970. clearedlabels bool
  11971. done bool
  11972. oldValue func(context.Context) (*LabelRelationship, error)
  11973. predicates []predicate.LabelRelationship
  11974. }
  11975. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  11976. // labelrelationshipOption allows management of the mutation configuration using functional options.
  11977. type labelrelationshipOption func(*LabelRelationshipMutation)
  11978. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  11979. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  11980. m := &LabelRelationshipMutation{
  11981. config: c,
  11982. op: op,
  11983. typ: TypeLabelRelationship,
  11984. clearedFields: make(map[string]struct{}),
  11985. }
  11986. for _, opt := range opts {
  11987. opt(m)
  11988. }
  11989. return m
  11990. }
  11991. // withLabelRelationshipID sets the ID field of the mutation.
  11992. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  11993. return func(m *LabelRelationshipMutation) {
  11994. var (
  11995. err error
  11996. once sync.Once
  11997. value *LabelRelationship
  11998. )
  11999. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  12000. once.Do(func() {
  12001. if m.done {
  12002. err = errors.New("querying old values post mutation is not allowed")
  12003. } else {
  12004. value, err = m.Client().LabelRelationship.Get(ctx, id)
  12005. }
  12006. })
  12007. return value, err
  12008. }
  12009. m.id = &id
  12010. }
  12011. }
  12012. // withLabelRelationship sets the old LabelRelationship of the mutation.
  12013. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  12014. return func(m *LabelRelationshipMutation) {
  12015. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  12016. return node, nil
  12017. }
  12018. m.id = &node.ID
  12019. }
  12020. }
  12021. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12022. // executed in a transaction (ent.Tx), a transactional client is returned.
  12023. func (m LabelRelationshipMutation) Client() *Client {
  12024. client := &Client{config: m.config}
  12025. client.init()
  12026. return client
  12027. }
  12028. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12029. // it returns an error otherwise.
  12030. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  12031. if _, ok := m.driver.(*txDriver); !ok {
  12032. return nil, errors.New("ent: mutation is not running in a transaction")
  12033. }
  12034. tx := &Tx{config: m.config}
  12035. tx.init()
  12036. return tx, nil
  12037. }
  12038. // SetID sets the value of the id field. Note that this
  12039. // operation is only accepted on creation of LabelRelationship entities.
  12040. func (m *LabelRelationshipMutation) SetID(id uint64) {
  12041. m.id = &id
  12042. }
  12043. // ID returns the ID value in the mutation. Note that the ID is only available
  12044. // if it was provided to the builder or after it was returned from the database.
  12045. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  12046. if m.id == nil {
  12047. return
  12048. }
  12049. return *m.id, true
  12050. }
  12051. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12052. // That means, if the mutation is applied within a transaction with an isolation level such
  12053. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12054. // or updated by the mutation.
  12055. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  12056. switch {
  12057. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12058. id, exists := m.ID()
  12059. if exists {
  12060. return []uint64{id}, nil
  12061. }
  12062. fallthrough
  12063. case m.op.Is(OpUpdate | OpDelete):
  12064. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  12065. default:
  12066. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12067. }
  12068. }
  12069. // SetCreatedAt sets the "created_at" field.
  12070. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  12071. m.created_at = &t
  12072. }
  12073. // CreatedAt returns the value of the "created_at" field in the mutation.
  12074. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  12075. v := m.created_at
  12076. if v == nil {
  12077. return
  12078. }
  12079. return *v, true
  12080. }
  12081. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  12082. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12084. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12085. if !m.op.Is(OpUpdateOne) {
  12086. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12087. }
  12088. if m.id == nil || m.oldValue == nil {
  12089. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12090. }
  12091. oldValue, err := m.oldValue(ctx)
  12092. if err != nil {
  12093. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12094. }
  12095. return oldValue.CreatedAt, nil
  12096. }
  12097. // ResetCreatedAt resets all changes to the "created_at" field.
  12098. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  12099. m.created_at = nil
  12100. }
  12101. // SetUpdatedAt sets the "updated_at" field.
  12102. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  12103. m.updated_at = &t
  12104. }
  12105. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12106. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  12107. v := m.updated_at
  12108. if v == nil {
  12109. return
  12110. }
  12111. return *v, true
  12112. }
  12113. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  12114. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12116. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12117. if !m.op.Is(OpUpdateOne) {
  12118. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12119. }
  12120. if m.id == nil || m.oldValue == nil {
  12121. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12122. }
  12123. oldValue, err := m.oldValue(ctx)
  12124. if err != nil {
  12125. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12126. }
  12127. return oldValue.UpdatedAt, nil
  12128. }
  12129. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12130. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  12131. m.updated_at = nil
  12132. }
  12133. // SetStatus sets the "status" field.
  12134. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  12135. m.status = &u
  12136. m.addstatus = nil
  12137. }
  12138. // Status returns the value of the "status" field in the mutation.
  12139. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  12140. v := m.status
  12141. if v == nil {
  12142. return
  12143. }
  12144. return *v, true
  12145. }
  12146. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  12147. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12149. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12150. if !m.op.Is(OpUpdateOne) {
  12151. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12152. }
  12153. if m.id == nil || m.oldValue == nil {
  12154. return v, errors.New("OldStatus requires an ID field in the mutation")
  12155. }
  12156. oldValue, err := m.oldValue(ctx)
  12157. if err != nil {
  12158. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12159. }
  12160. return oldValue.Status, nil
  12161. }
  12162. // AddStatus adds u to the "status" field.
  12163. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  12164. if m.addstatus != nil {
  12165. *m.addstatus += u
  12166. } else {
  12167. m.addstatus = &u
  12168. }
  12169. }
  12170. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12171. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  12172. v := m.addstatus
  12173. if v == nil {
  12174. return
  12175. }
  12176. return *v, true
  12177. }
  12178. // ClearStatus clears the value of the "status" field.
  12179. func (m *LabelRelationshipMutation) ClearStatus() {
  12180. m.status = nil
  12181. m.addstatus = nil
  12182. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  12183. }
  12184. // StatusCleared returns if the "status" field was cleared in this mutation.
  12185. func (m *LabelRelationshipMutation) StatusCleared() bool {
  12186. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  12187. return ok
  12188. }
  12189. // ResetStatus resets all changes to the "status" field.
  12190. func (m *LabelRelationshipMutation) ResetStatus() {
  12191. m.status = nil
  12192. m.addstatus = nil
  12193. delete(m.clearedFields, labelrelationship.FieldStatus)
  12194. }
  12195. // SetLabelID sets the "label_id" field.
  12196. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  12197. m.labels = &u
  12198. }
  12199. // LabelID returns the value of the "label_id" field in the mutation.
  12200. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  12201. v := m.labels
  12202. if v == nil {
  12203. return
  12204. }
  12205. return *v, true
  12206. }
  12207. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  12208. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12210. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  12211. if !m.op.Is(OpUpdateOne) {
  12212. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  12213. }
  12214. if m.id == nil || m.oldValue == nil {
  12215. return v, errors.New("OldLabelID requires an ID field in the mutation")
  12216. }
  12217. oldValue, err := m.oldValue(ctx)
  12218. if err != nil {
  12219. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  12220. }
  12221. return oldValue.LabelID, nil
  12222. }
  12223. // ResetLabelID resets all changes to the "label_id" field.
  12224. func (m *LabelRelationshipMutation) ResetLabelID() {
  12225. m.labels = nil
  12226. }
  12227. // SetContactID sets the "contact_id" field.
  12228. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  12229. m.contacts = &u
  12230. }
  12231. // ContactID returns the value of the "contact_id" field in the mutation.
  12232. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  12233. v := m.contacts
  12234. if v == nil {
  12235. return
  12236. }
  12237. return *v, true
  12238. }
  12239. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  12240. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12242. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  12243. if !m.op.Is(OpUpdateOne) {
  12244. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  12245. }
  12246. if m.id == nil || m.oldValue == nil {
  12247. return v, errors.New("OldContactID requires an ID field in the mutation")
  12248. }
  12249. oldValue, err := m.oldValue(ctx)
  12250. if err != nil {
  12251. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  12252. }
  12253. return oldValue.ContactID, nil
  12254. }
  12255. // ResetContactID resets all changes to the "contact_id" field.
  12256. func (m *LabelRelationshipMutation) ResetContactID() {
  12257. m.contacts = nil
  12258. }
  12259. // SetOrganizationID sets the "organization_id" field.
  12260. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  12261. m.organization_id = &u
  12262. m.addorganization_id = nil
  12263. }
  12264. // OrganizationID returns the value of the "organization_id" field in the mutation.
  12265. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  12266. v := m.organization_id
  12267. if v == nil {
  12268. return
  12269. }
  12270. return *v, true
  12271. }
  12272. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  12273. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  12274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12275. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  12276. if !m.op.Is(OpUpdateOne) {
  12277. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  12278. }
  12279. if m.id == nil || m.oldValue == nil {
  12280. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  12281. }
  12282. oldValue, err := m.oldValue(ctx)
  12283. if err != nil {
  12284. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  12285. }
  12286. return oldValue.OrganizationID, nil
  12287. }
  12288. // AddOrganizationID adds u to the "organization_id" field.
  12289. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  12290. if m.addorganization_id != nil {
  12291. *m.addorganization_id += u
  12292. } else {
  12293. m.addorganization_id = &u
  12294. }
  12295. }
  12296. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  12297. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  12298. v := m.addorganization_id
  12299. if v == nil {
  12300. return
  12301. }
  12302. return *v, true
  12303. }
  12304. // ClearOrganizationID clears the value of the "organization_id" field.
  12305. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  12306. m.organization_id = nil
  12307. m.addorganization_id = nil
  12308. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  12309. }
  12310. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  12311. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  12312. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  12313. return ok
  12314. }
  12315. // ResetOrganizationID resets all changes to the "organization_id" field.
  12316. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  12317. m.organization_id = nil
  12318. m.addorganization_id = nil
  12319. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  12320. }
  12321. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  12322. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  12323. m.contacts = &id
  12324. }
  12325. // ClearContacts clears the "contacts" edge to the Contact entity.
  12326. func (m *LabelRelationshipMutation) ClearContacts() {
  12327. m.clearedcontacts = true
  12328. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  12329. }
  12330. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  12331. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  12332. return m.clearedcontacts
  12333. }
  12334. // ContactsID returns the "contacts" edge ID in the mutation.
  12335. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  12336. if m.contacts != nil {
  12337. return *m.contacts, true
  12338. }
  12339. return
  12340. }
  12341. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  12342. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12343. // ContactsID instead. It exists only for internal usage by the builders.
  12344. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  12345. if id := m.contacts; id != nil {
  12346. ids = append(ids, *id)
  12347. }
  12348. return
  12349. }
  12350. // ResetContacts resets all changes to the "contacts" edge.
  12351. func (m *LabelRelationshipMutation) ResetContacts() {
  12352. m.contacts = nil
  12353. m.clearedcontacts = false
  12354. }
  12355. // SetLabelsID sets the "labels" edge to the Label entity by id.
  12356. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  12357. m.labels = &id
  12358. }
  12359. // ClearLabels clears the "labels" edge to the Label entity.
  12360. func (m *LabelRelationshipMutation) ClearLabels() {
  12361. m.clearedlabels = true
  12362. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  12363. }
  12364. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  12365. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  12366. return m.clearedlabels
  12367. }
  12368. // LabelsID returns the "labels" edge ID in the mutation.
  12369. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  12370. if m.labels != nil {
  12371. return *m.labels, true
  12372. }
  12373. return
  12374. }
  12375. // LabelsIDs returns the "labels" edge IDs in the mutation.
  12376. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  12377. // LabelsID instead. It exists only for internal usage by the builders.
  12378. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  12379. if id := m.labels; id != nil {
  12380. ids = append(ids, *id)
  12381. }
  12382. return
  12383. }
  12384. // ResetLabels resets all changes to the "labels" edge.
  12385. func (m *LabelRelationshipMutation) ResetLabels() {
  12386. m.labels = nil
  12387. m.clearedlabels = false
  12388. }
  12389. // Where appends a list predicates to the LabelRelationshipMutation builder.
  12390. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  12391. m.predicates = append(m.predicates, ps...)
  12392. }
  12393. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  12394. // users can use type-assertion to append predicates that do not depend on any generated package.
  12395. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  12396. p := make([]predicate.LabelRelationship, len(ps))
  12397. for i := range ps {
  12398. p[i] = ps[i]
  12399. }
  12400. m.Where(p...)
  12401. }
  12402. // Op returns the operation name.
  12403. func (m *LabelRelationshipMutation) Op() Op {
  12404. return m.op
  12405. }
  12406. // SetOp allows setting the mutation operation.
  12407. func (m *LabelRelationshipMutation) SetOp(op Op) {
  12408. m.op = op
  12409. }
  12410. // Type returns the node type of this mutation (LabelRelationship).
  12411. func (m *LabelRelationshipMutation) Type() string {
  12412. return m.typ
  12413. }
  12414. // Fields returns all fields that were changed during this mutation. Note that in
  12415. // order to get all numeric fields that were incremented/decremented, call
  12416. // AddedFields().
  12417. func (m *LabelRelationshipMutation) Fields() []string {
  12418. fields := make([]string, 0, 6)
  12419. if m.created_at != nil {
  12420. fields = append(fields, labelrelationship.FieldCreatedAt)
  12421. }
  12422. if m.updated_at != nil {
  12423. fields = append(fields, labelrelationship.FieldUpdatedAt)
  12424. }
  12425. if m.status != nil {
  12426. fields = append(fields, labelrelationship.FieldStatus)
  12427. }
  12428. if m.labels != nil {
  12429. fields = append(fields, labelrelationship.FieldLabelID)
  12430. }
  12431. if m.contacts != nil {
  12432. fields = append(fields, labelrelationship.FieldContactID)
  12433. }
  12434. if m.organization_id != nil {
  12435. fields = append(fields, labelrelationship.FieldOrganizationID)
  12436. }
  12437. return fields
  12438. }
  12439. // Field returns the value of a field with the given name. The second boolean
  12440. // return value indicates that this field was not set, or was not defined in the
  12441. // schema.
  12442. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  12443. switch name {
  12444. case labelrelationship.FieldCreatedAt:
  12445. return m.CreatedAt()
  12446. case labelrelationship.FieldUpdatedAt:
  12447. return m.UpdatedAt()
  12448. case labelrelationship.FieldStatus:
  12449. return m.Status()
  12450. case labelrelationship.FieldLabelID:
  12451. return m.LabelID()
  12452. case labelrelationship.FieldContactID:
  12453. return m.ContactID()
  12454. case labelrelationship.FieldOrganizationID:
  12455. return m.OrganizationID()
  12456. }
  12457. return nil, false
  12458. }
  12459. // OldField returns the old value of the field from the database. An error is
  12460. // returned if the mutation operation is not UpdateOne, or the query to the
  12461. // database failed.
  12462. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12463. switch name {
  12464. case labelrelationship.FieldCreatedAt:
  12465. return m.OldCreatedAt(ctx)
  12466. case labelrelationship.FieldUpdatedAt:
  12467. return m.OldUpdatedAt(ctx)
  12468. case labelrelationship.FieldStatus:
  12469. return m.OldStatus(ctx)
  12470. case labelrelationship.FieldLabelID:
  12471. return m.OldLabelID(ctx)
  12472. case labelrelationship.FieldContactID:
  12473. return m.OldContactID(ctx)
  12474. case labelrelationship.FieldOrganizationID:
  12475. return m.OldOrganizationID(ctx)
  12476. }
  12477. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  12478. }
  12479. // SetField sets the value of a field with the given name. It returns an error if
  12480. // the field is not defined in the schema, or if the type mismatched the field
  12481. // type.
  12482. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  12483. switch name {
  12484. case labelrelationship.FieldCreatedAt:
  12485. v, ok := value.(time.Time)
  12486. if !ok {
  12487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12488. }
  12489. m.SetCreatedAt(v)
  12490. return nil
  12491. case labelrelationship.FieldUpdatedAt:
  12492. v, ok := value.(time.Time)
  12493. if !ok {
  12494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12495. }
  12496. m.SetUpdatedAt(v)
  12497. return nil
  12498. case labelrelationship.FieldStatus:
  12499. v, ok := value.(uint8)
  12500. if !ok {
  12501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12502. }
  12503. m.SetStatus(v)
  12504. return nil
  12505. case labelrelationship.FieldLabelID:
  12506. v, ok := value.(uint64)
  12507. if !ok {
  12508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12509. }
  12510. m.SetLabelID(v)
  12511. return nil
  12512. case labelrelationship.FieldContactID:
  12513. v, ok := value.(uint64)
  12514. if !ok {
  12515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12516. }
  12517. m.SetContactID(v)
  12518. return nil
  12519. case labelrelationship.FieldOrganizationID:
  12520. v, ok := value.(uint64)
  12521. if !ok {
  12522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12523. }
  12524. m.SetOrganizationID(v)
  12525. return nil
  12526. }
  12527. return fmt.Errorf("unknown LabelRelationship field %s", name)
  12528. }
  12529. // AddedFields returns all numeric fields that were incremented/decremented during
  12530. // this mutation.
  12531. func (m *LabelRelationshipMutation) AddedFields() []string {
  12532. var fields []string
  12533. if m.addstatus != nil {
  12534. fields = append(fields, labelrelationship.FieldStatus)
  12535. }
  12536. if m.addorganization_id != nil {
  12537. fields = append(fields, labelrelationship.FieldOrganizationID)
  12538. }
  12539. return fields
  12540. }
  12541. // AddedField returns the numeric value that was incremented/decremented on a field
  12542. // with the given name. The second boolean return value indicates that this field
  12543. // was not set, or was not defined in the schema.
  12544. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  12545. switch name {
  12546. case labelrelationship.FieldStatus:
  12547. return m.AddedStatus()
  12548. case labelrelationship.FieldOrganizationID:
  12549. return m.AddedOrganizationID()
  12550. }
  12551. return nil, false
  12552. }
  12553. // AddField adds the value to the field with the given name. It returns an error if
  12554. // the field is not defined in the schema, or if the type mismatched the field
  12555. // type.
  12556. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  12557. switch name {
  12558. case labelrelationship.FieldStatus:
  12559. v, ok := value.(int8)
  12560. if !ok {
  12561. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12562. }
  12563. m.AddStatus(v)
  12564. return nil
  12565. case labelrelationship.FieldOrganizationID:
  12566. v, ok := value.(int64)
  12567. if !ok {
  12568. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12569. }
  12570. m.AddOrganizationID(v)
  12571. return nil
  12572. }
  12573. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  12574. }
  12575. // ClearedFields returns all nullable fields that were cleared during this
  12576. // mutation.
  12577. func (m *LabelRelationshipMutation) ClearedFields() []string {
  12578. var fields []string
  12579. if m.FieldCleared(labelrelationship.FieldStatus) {
  12580. fields = append(fields, labelrelationship.FieldStatus)
  12581. }
  12582. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  12583. fields = append(fields, labelrelationship.FieldOrganizationID)
  12584. }
  12585. return fields
  12586. }
  12587. // FieldCleared returns a boolean indicating if a field with the given name was
  12588. // cleared in this mutation.
  12589. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  12590. _, ok := m.clearedFields[name]
  12591. return ok
  12592. }
  12593. // ClearField clears the value of the field with the given name. It returns an
  12594. // error if the field is not defined in the schema.
  12595. func (m *LabelRelationshipMutation) ClearField(name string) error {
  12596. switch name {
  12597. case labelrelationship.FieldStatus:
  12598. m.ClearStatus()
  12599. return nil
  12600. case labelrelationship.FieldOrganizationID:
  12601. m.ClearOrganizationID()
  12602. return nil
  12603. }
  12604. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  12605. }
  12606. // ResetField resets all changes in the mutation for the field with the given name.
  12607. // It returns an error if the field is not defined in the schema.
  12608. func (m *LabelRelationshipMutation) ResetField(name string) error {
  12609. switch name {
  12610. case labelrelationship.FieldCreatedAt:
  12611. m.ResetCreatedAt()
  12612. return nil
  12613. case labelrelationship.FieldUpdatedAt:
  12614. m.ResetUpdatedAt()
  12615. return nil
  12616. case labelrelationship.FieldStatus:
  12617. m.ResetStatus()
  12618. return nil
  12619. case labelrelationship.FieldLabelID:
  12620. m.ResetLabelID()
  12621. return nil
  12622. case labelrelationship.FieldContactID:
  12623. m.ResetContactID()
  12624. return nil
  12625. case labelrelationship.FieldOrganizationID:
  12626. m.ResetOrganizationID()
  12627. return nil
  12628. }
  12629. return fmt.Errorf("unknown LabelRelationship field %s", name)
  12630. }
  12631. // AddedEdges returns all edge names that were set/added in this mutation.
  12632. func (m *LabelRelationshipMutation) AddedEdges() []string {
  12633. edges := make([]string, 0, 2)
  12634. if m.contacts != nil {
  12635. edges = append(edges, labelrelationship.EdgeContacts)
  12636. }
  12637. if m.labels != nil {
  12638. edges = append(edges, labelrelationship.EdgeLabels)
  12639. }
  12640. return edges
  12641. }
  12642. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12643. // name in this mutation.
  12644. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  12645. switch name {
  12646. case labelrelationship.EdgeContacts:
  12647. if id := m.contacts; id != nil {
  12648. return []ent.Value{*id}
  12649. }
  12650. case labelrelationship.EdgeLabels:
  12651. if id := m.labels; id != nil {
  12652. return []ent.Value{*id}
  12653. }
  12654. }
  12655. return nil
  12656. }
  12657. // RemovedEdges returns all edge names that were removed in this mutation.
  12658. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  12659. edges := make([]string, 0, 2)
  12660. return edges
  12661. }
  12662. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12663. // the given name in this mutation.
  12664. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  12665. return nil
  12666. }
  12667. // ClearedEdges returns all edge names that were cleared in this mutation.
  12668. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  12669. edges := make([]string, 0, 2)
  12670. if m.clearedcontacts {
  12671. edges = append(edges, labelrelationship.EdgeContacts)
  12672. }
  12673. if m.clearedlabels {
  12674. edges = append(edges, labelrelationship.EdgeLabels)
  12675. }
  12676. return edges
  12677. }
  12678. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12679. // was cleared in this mutation.
  12680. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  12681. switch name {
  12682. case labelrelationship.EdgeContacts:
  12683. return m.clearedcontacts
  12684. case labelrelationship.EdgeLabels:
  12685. return m.clearedlabels
  12686. }
  12687. return false
  12688. }
  12689. // ClearEdge clears the value of the edge with the given name. It returns an error
  12690. // if that edge is not defined in the schema.
  12691. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  12692. switch name {
  12693. case labelrelationship.EdgeContacts:
  12694. m.ClearContacts()
  12695. return nil
  12696. case labelrelationship.EdgeLabels:
  12697. m.ClearLabels()
  12698. return nil
  12699. }
  12700. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  12701. }
  12702. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12703. // It returns an error if the edge is not defined in the schema.
  12704. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  12705. switch name {
  12706. case labelrelationship.EdgeContacts:
  12707. m.ResetContacts()
  12708. return nil
  12709. case labelrelationship.EdgeLabels:
  12710. m.ResetLabels()
  12711. return nil
  12712. }
  12713. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  12714. }
  12715. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  12716. type LabelTaggingMutation struct {
  12717. config
  12718. op Op
  12719. typ string
  12720. id *uint64
  12721. created_at *time.Time
  12722. updated_at *time.Time
  12723. status *uint8
  12724. addstatus *int8
  12725. deleted_at *time.Time
  12726. organization_id *uint64
  12727. addorganization_id *int64
  12728. _type *int
  12729. add_type *int
  12730. conditions *string
  12731. action_label_add *[]uint64
  12732. appendaction_label_add []uint64
  12733. action_label_del *[]uint64
  12734. appendaction_label_del []uint64
  12735. clearedFields map[string]struct{}
  12736. done bool
  12737. oldValue func(context.Context) (*LabelTagging, error)
  12738. predicates []predicate.LabelTagging
  12739. }
  12740. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  12741. // labeltaggingOption allows management of the mutation configuration using functional options.
  12742. type labeltaggingOption func(*LabelTaggingMutation)
  12743. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  12744. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  12745. m := &LabelTaggingMutation{
  12746. config: c,
  12747. op: op,
  12748. typ: TypeLabelTagging,
  12749. clearedFields: make(map[string]struct{}),
  12750. }
  12751. for _, opt := range opts {
  12752. opt(m)
  12753. }
  12754. return m
  12755. }
  12756. // withLabelTaggingID sets the ID field of the mutation.
  12757. func withLabelTaggingID(id uint64) labeltaggingOption {
  12758. return func(m *LabelTaggingMutation) {
  12759. var (
  12760. err error
  12761. once sync.Once
  12762. value *LabelTagging
  12763. )
  12764. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  12765. once.Do(func() {
  12766. if m.done {
  12767. err = errors.New("querying old values post mutation is not allowed")
  12768. } else {
  12769. value, err = m.Client().LabelTagging.Get(ctx, id)
  12770. }
  12771. })
  12772. return value, err
  12773. }
  12774. m.id = &id
  12775. }
  12776. }
  12777. // withLabelTagging sets the old LabelTagging of the mutation.
  12778. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  12779. return func(m *LabelTaggingMutation) {
  12780. m.oldValue = func(context.Context) (*LabelTagging, error) {
  12781. return node, nil
  12782. }
  12783. m.id = &node.ID
  12784. }
  12785. }
  12786. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12787. // executed in a transaction (ent.Tx), a transactional client is returned.
  12788. func (m LabelTaggingMutation) Client() *Client {
  12789. client := &Client{config: m.config}
  12790. client.init()
  12791. return client
  12792. }
  12793. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12794. // it returns an error otherwise.
  12795. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  12796. if _, ok := m.driver.(*txDriver); !ok {
  12797. return nil, errors.New("ent: mutation is not running in a transaction")
  12798. }
  12799. tx := &Tx{config: m.config}
  12800. tx.init()
  12801. return tx, nil
  12802. }
  12803. // SetID sets the value of the id field. Note that this
  12804. // operation is only accepted on creation of LabelTagging entities.
  12805. func (m *LabelTaggingMutation) SetID(id uint64) {
  12806. m.id = &id
  12807. }
  12808. // ID returns the ID value in the mutation. Note that the ID is only available
  12809. // if it was provided to the builder or after it was returned from the database.
  12810. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  12811. if m.id == nil {
  12812. return
  12813. }
  12814. return *m.id, true
  12815. }
  12816. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12817. // That means, if the mutation is applied within a transaction with an isolation level such
  12818. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12819. // or updated by the mutation.
  12820. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  12821. switch {
  12822. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12823. id, exists := m.ID()
  12824. if exists {
  12825. return []uint64{id}, nil
  12826. }
  12827. fallthrough
  12828. case m.op.Is(OpUpdate | OpDelete):
  12829. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  12830. default:
  12831. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12832. }
  12833. }
  12834. // SetCreatedAt sets the "created_at" field.
  12835. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  12836. m.created_at = &t
  12837. }
  12838. // CreatedAt returns the value of the "created_at" field in the mutation.
  12839. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  12840. v := m.created_at
  12841. if v == nil {
  12842. return
  12843. }
  12844. return *v, true
  12845. }
  12846. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  12847. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  12848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12849. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12850. if !m.op.Is(OpUpdateOne) {
  12851. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12852. }
  12853. if m.id == nil || m.oldValue == nil {
  12854. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12855. }
  12856. oldValue, err := m.oldValue(ctx)
  12857. if err != nil {
  12858. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12859. }
  12860. return oldValue.CreatedAt, nil
  12861. }
  12862. // ResetCreatedAt resets all changes to the "created_at" field.
  12863. func (m *LabelTaggingMutation) ResetCreatedAt() {
  12864. m.created_at = nil
  12865. }
  12866. // SetUpdatedAt sets the "updated_at" field.
  12867. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  12868. m.updated_at = &t
  12869. }
  12870. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12871. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  12872. v := m.updated_at
  12873. if v == nil {
  12874. return
  12875. }
  12876. return *v, true
  12877. }
  12878. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  12879. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  12880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12881. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12882. if !m.op.Is(OpUpdateOne) {
  12883. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12884. }
  12885. if m.id == nil || m.oldValue == nil {
  12886. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12887. }
  12888. oldValue, err := m.oldValue(ctx)
  12889. if err != nil {
  12890. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12891. }
  12892. return oldValue.UpdatedAt, nil
  12893. }
  12894. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12895. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  12896. m.updated_at = nil
  12897. }
  12898. // SetStatus sets the "status" field.
  12899. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  12900. m.status = &u
  12901. m.addstatus = nil
  12902. }
  12903. // Status returns the value of the "status" field in the mutation.
  12904. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  12905. v := m.status
  12906. if v == nil {
  12907. return
  12908. }
  12909. return *v, true
  12910. }
  12911. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  12912. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  12913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12914. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  12915. if !m.op.Is(OpUpdateOne) {
  12916. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  12917. }
  12918. if m.id == nil || m.oldValue == nil {
  12919. return v, errors.New("OldStatus requires an ID field in the mutation")
  12920. }
  12921. oldValue, err := m.oldValue(ctx)
  12922. if err != nil {
  12923. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  12924. }
  12925. return oldValue.Status, nil
  12926. }
  12927. // AddStatus adds u to the "status" field.
  12928. func (m *LabelTaggingMutation) AddStatus(u int8) {
  12929. if m.addstatus != nil {
  12930. *m.addstatus += u
  12931. } else {
  12932. m.addstatus = &u
  12933. }
  12934. }
  12935. // AddedStatus returns the value that was added to the "status" field in this mutation.
  12936. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  12937. v := m.addstatus
  12938. if v == nil {
  12939. return
  12940. }
  12941. return *v, true
  12942. }
  12943. // ClearStatus clears the value of the "status" field.
  12944. func (m *LabelTaggingMutation) ClearStatus() {
  12945. m.status = nil
  12946. m.addstatus = nil
  12947. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  12948. }
  12949. // StatusCleared returns if the "status" field was cleared in this mutation.
  12950. func (m *LabelTaggingMutation) StatusCleared() bool {
  12951. _, ok := m.clearedFields[labeltagging.FieldStatus]
  12952. return ok
  12953. }
  12954. // ResetStatus resets all changes to the "status" field.
  12955. func (m *LabelTaggingMutation) ResetStatus() {
  12956. m.status = nil
  12957. m.addstatus = nil
  12958. delete(m.clearedFields, labeltagging.FieldStatus)
  12959. }
  12960. // SetDeletedAt sets the "deleted_at" field.
  12961. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  12962. m.deleted_at = &t
  12963. }
  12964. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12965. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  12966. v := m.deleted_at
  12967. if v == nil {
  12968. return
  12969. }
  12970. return *v, true
  12971. }
  12972. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  12973. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  12974. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12975. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  12976. if !m.op.Is(OpUpdateOne) {
  12977. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  12978. }
  12979. if m.id == nil || m.oldValue == nil {
  12980. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  12981. }
  12982. oldValue, err := m.oldValue(ctx)
  12983. if err != nil {
  12984. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  12985. }
  12986. return oldValue.DeletedAt, nil
  12987. }
  12988. // ClearDeletedAt clears the value of the "deleted_at" field.
  12989. func (m *LabelTaggingMutation) ClearDeletedAt() {
  12990. m.deleted_at = nil
  12991. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  12992. }
  12993. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  12994. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  12995. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  12996. return ok
  12997. }
  12998. // ResetDeletedAt resets all changes to the "deleted_at" field.
  12999. func (m *LabelTaggingMutation) ResetDeletedAt() {
  13000. m.deleted_at = nil
  13001. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  13002. }
  13003. // SetOrganizationID sets the "organization_id" field.
  13004. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  13005. m.organization_id = &u
  13006. m.addorganization_id = nil
  13007. }
  13008. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13009. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  13010. v := m.organization_id
  13011. if v == nil {
  13012. return
  13013. }
  13014. return *v, true
  13015. }
  13016. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  13017. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13019. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13020. if !m.op.Is(OpUpdateOne) {
  13021. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13022. }
  13023. if m.id == nil || m.oldValue == nil {
  13024. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13025. }
  13026. oldValue, err := m.oldValue(ctx)
  13027. if err != nil {
  13028. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13029. }
  13030. return oldValue.OrganizationID, nil
  13031. }
  13032. // AddOrganizationID adds u to the "organization_id" field.
  13033. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  13034. if m.addorganization_id != nil {
  13035. *m.addorganization_id += u
  13036. } else {
  13037. m.addorganization_id = &u
  13038. }
  13039. }
  13040. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13041. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  13042. v := m.addorganization_id
  13043. if v == nil {
  13044. return
  13045. }
  13046. return *v, true
  13047. }
  13048. // ResetOrganizationID resets all changes to the "organization_id" field.
  13049. func (m *LabelTaggingMutation) ResetOrganizationID() {
  13050. m.organization_id = nil
  13051. m.addorganization_id = nil
  13052. }
  13053. // SetType sets the "type" field.
  13054. func (m *LabelTaggingMutation) SetType(i int) {
  13055. m._type = &i
  13056. m.add_type = nil
  13057. }
  13058. // GetType returns the value of the "type" field in the mutation.
  13059. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  13060. v := m._type
  13061. if v == nil {
  13062. return
  13063. }
  13064. return *v, true
  13065. }
  13066. // OldType returns the old "type" field's value of the LabelTagging entity.
  13067. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13069. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  13070. if !m.op.Is(OpUpdateOne) {
  13071. return v, errors.New("OldType is only allowed on UpdateOne operations")
  13072. }
  13073. if m.id == nil || m.oldValue == nil {
  13074. return v, errors.New("OldType requires an ID field in the mutation")
  13075. }
  13076. oldValue, err := m.oldValue(ctx)
  13077. if err != nil {
  13078. return v, fmt.Errorf("querying old value for OldType: %w", err)
  13079. }
  13080. return oldValue.Type, nil
  13081. }
  13082. // AddType adds i to the "type" field.
  13083. func (m *LabelTaggingMutation) AddType(i int) {
  13084. if m.add_type != nil {
  13085. *m.add_type += i
  13086. } else {
  13087. m.add_type = &i
  13088. }
  13089. }
  13090. // AddedType returns the value that was added to the "type" field in this mutation.
  13091. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  13092. v := m.add_type
  13093. if v == nil {
  13094. return
  13095. }
  13096. return *v, true
  13097. }
  13098. // ResetType resets all changes to the "type" field.
  13099. func (m *LabelTaggingMutation) ResetType() {
  13100. m._type = nil
  13101. m.add_type = nil
  13102. }
  13103. // SetConditions sets the "conditions" field.
  13104. func (m *LabelTaggingMutation) SetConditions(s string) {
  13105. m.conditions = &s
  13106. }
  13107. // Conditions returns the value of the "conditions" field in the mutation.
  13108. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  13109. v := m.conditions
  13110. if v == nil {
  13111. return
  13112. }
  13113. return *v, true
  13114. }
  13115. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  13116. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13117. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13118. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  13119. if !m.op.Is(OpUpdateOne) {
  13120. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  13121. }
  13122. if m.id == nil || m.oldValue == nil {
  13123. return v, errors.New("OldConditions requires an ID field in the mutation")
  13124. }
  13125. oldValue, err := m.oldValue(ctx)
  13126. if err != nil {
  13127. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  13128. }
  13129. return oldValue.Conditions, nil
  13130. }
  13131. // ResetConditions resets all changes to the "conditions" field.
  13132. func (m *LabelTaggingMutation) ResetConditions() {
  13133. m.conditions = nil
  13134. }
  13135. // SetActionLabelAdd sets the "action_label_add" field.
  13136. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  13137. m.action_label_add = &u
  13138. m.appendaction_label_add = nil
  13139. }
  13140. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  13141. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  13142. v := m.action_label_add
  13143. if v == nil {
  13144. return
  13145. }
  13146. return *v, true
  13147. }
  13148. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  13149. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13151. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  13152. if !m.op.Is(OpUpdateOne) {
  13153. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  13154. }
  13155. if m.id == nil || m.oldValue == nil {
  13156. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  13157. }
  13158. oldValue, err := m.oldValue(ctx)
  13159. if err != nil {
  13160. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  13161. }
  13162. return oldValue.ActionLabelAdd, nil
  13163. }
  13164. // AppendActionLabelAdd adds u to the "action_label_add" field.
  13165. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  13166. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  13167. }
  13168. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  13169. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  13170. if len(m.appendaction_label_add) == 0 {
  13171. return nil, false
  13172. }
  13173. return m.appendaction_label_add, true
  13174. }
  13175. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  13176. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  13177. m.action_label_add = nil
  13178. m.appendaction_label_add = nil
  13179. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  13180. }
  13181. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  13182. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  13183. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  13184. return ok
  13185. }
  13186. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  13187. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  13188. m.action_label_add = nil
  13189. m.appendaction_label_add = nil
  13190. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  13191. }
  13192. // SetActionLabelDel sets the "action_label_del" field.
  13193. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  13194. m.action_label_del = &u
  13195. m.appendaction_label_del = nil
  13196. }
  13197. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  13198. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  13199. v := m.action_label_del
  13200. if v == nil {
  13201. return
  13202. }
  13203. return *v, true
  13204. }
  13205. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  13206. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  13207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13208. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  13209. if !m.op.Is(OpUpdateOne) {
  13210. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  13211. }
  13212. if m.id == nil || m.oldValue == nil {
  13213. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  13214. }
  13215. oldValue, err := m.oldValue(ctx)
  13216. if err != nil {
  13217. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  13218. }
  13219. return oldValue.ActionLabelDel, nil
  13220. }
  13221. // AppendActionLabelDel adds u to the "action_label_del" field.
  13222. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  13223. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  13224. }
  13225. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  13226. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  13227. if len(m.appendaction_label_del) == 0 {
  13228. return nil, false
  13229. }
  13230. return m.appendaction_label_del, true
  13231. }
  13232. // ClearActionLabelDel clears the value of the "action_label_del" field.
  13233. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  13234. m.action_label_del = nil
  13235. m.appendaction_label_del = nil
  13236. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  13237. }
  13238. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  13239. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  13240. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  13241. return ok
  13242. }
  13243. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  13244. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  13245. m.action_label_del = nil
  13246. m.appendaction_label_del = nil
  13247. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  13248. }
  13249. // Where appends a list predicates to the LabelTaggingMutation builder.
  13250. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  13251. m.predicates = append(m.predicates, ps...)
  13252. }
  13253. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  13254. // users can use type-assertion to append predicates that do not depend on any generated package.
  13255. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  13256. p := make([]predicate.LabelTagging, len(ps))
  13257. for i := range ps {
  13258. p[i] = ps[i]
  13259. }
  13260. m.Where(p...)
  13261. }
  13262. // Op returns the operation name.
  13263. func (m *LabelTaggingMutation) Op() Op {
  13264. return m.op
  13265. }
  13266. // SetOp allows setting the mutation operation.
  13267. func (m *LabelTaggingMutation) SetOp(op Op) {
  13268. m.op = op
  13269. }
  13270. // Type returns the node type of this mutation (LabelTagging).
  13271. func (m *LabelTaggingMutation) Type() string {
  13272. return m.typ
  13273. }
  13274. // Fields returns all fields that were changed during this mutation. Note that in
  13275. // order to get all numeric fields that were incremented/decremented, call
  13276. // AddedFields().
  13277. func (m *LabelTaggingMutation) Fields() []string {
  13278. fields := make([]string, 0, 9)
  13279. if m.created_at != nil {
  13280. fields = append(fields, labeltagging.FieldCreatedAt)
  13281. }
  13282. if m.updated_at != nil {
  13283. fields = append(fields, labeltagging.FieldUpdatedAt)
  13284. }
  13285. if m.status != nil {
  13286. fields = append(fields, labeltagging.FieldStatus)
  13287. }
  13288. if m.deleted_at != nil {
  13289. fields = append(fields, labeltagging.FieldDeletedAt)
  13290. }
  13291. if m.organization_id != nil {
  13292. fields = append(fields, labeltagging.FieldOrganizationID)
  13293. }
  13294. if m._type != nil {
  13295. fields = append(fields, labeltagging.FieldType)
  13296. }
  13297. if m.conditions != nil {
  13298. fields = append(fields, labeltagging.FieldConditions)
  13299. }
  13300. if m.action_label_add != nil {
  13301. fields = append(fields, labeltagging.FieldActionLabelAdd)
  13302. }
  13303. if m.action_label_del != nil {
  13304. fields = append(fields, labeltagging.FieldActionLabelDel)
  13305. }
  13306. return fields
  13307. }
  13308. // Field returns the value of a field with the given name. The second boolean
  13309. // return value indicates that this field was not set, or was not defined in the
  13310. // schema.
  13311. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  13312. switch name {
  13313. case labeltagging.FieldCreatedAt:
  13314. return m.CreatedAt()
  13315. case labeltagging.FieldUpdatedAt:
  13316. return m.UpdatedAt()
  13317. case labeltagging.FieldStatus:
  13318. return m.Status()
  13319. case labeltagging.FieldDeletedAt:
  13320. return m.DeletedAt()
  13321. case labeltagging.FieldOrganizationID:
  13322. return m.OrganizationID()
  13323. case labeltagging.FieldType:
  13324. return m.GetType()
  13325. case labeltagging.FieldConditions:
  13326. return m.Conditions()
  13327. case labeltagging.FieldActionLabelAdd:
  13328. return m.ActionLabelAdd()
  13329. case labeltagging.FieldActionLabelDel:
  13330. return m.ActionLabelDel()
  13331. }
  13332. return nil, false
  13333. }
  13334. // OldField returns the old value of the field from the database. An error is
  13335. // returned if the mutation operation is not UpdateOne, or the query to the
  13336. // database failed.
  13337. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13338. switch name {
  13339. case labeltagging.FieldCreatedAt:
  13340. return m.OldCreatedAt(ctx)
  13341. case labeltagging.FieldUpdatedAt:
  13342. return m.OldUpdatedAt(ctx)
  13343. case labeltagging.FieldStatus:
  13344. return m.OldStatus(ctx)
  13345. case labeltagging.FieldDeletedAt:
  13346. return m.OldDeletedAt(ctx)
  13347. case labeltagging.FieldOrganizationID:
  13348. return m.OldOrganizationID(ctx)
  13349. case labeltagging.FieldType:
  13350. return m.OldType(ctx)
  13351. case labeltagging.FieldConditions:
  13352. return m.OldConditions(ctx)
  13353. case labeltagging.FieldActionLabelAdd:
  13354. return m.OldActionLabelAdd(ctx)
  13355. case labeltagging.FieldActionLabelDel:
  13356. return m.OldActionLabelDel(ctx)
  13357. }
  13358. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  13359. }
  13360. // SetField sets the value of a field with the given name. It returns an error if
  13361. // the field is not defined in the schema, or if the type mismatched the field
  13362. // type.
  13363. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  13364. switch name {
  13365. case labeltagging.FieldCreatedAt:
  13366. v, ok := value.(time.Time)
  13367. if !ok {
  13368. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13369. }
  13370. m.SetCreatedAt(v)
  13371. return nil
  13372. case labeltagging.FieldUpdatedAt:
  13373. v, ok := value.(time.Time)
  13374. if !ok {
  13375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13376. }
  13377. m.SetUpdatedAt(v)
  13378. return nil
  13379. case labeltagging.FieldStatus:
  13380. v, ok := value.(uint8)
  13381. if !ok {
  13382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13383. }
  13384. m.SetStatus(v)
  13385. return nil
  13386. case labeltagging.FieldDeletedAt:
  13387. v, ok := value.(time.Time)
  13388. if !ok {
  13389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13390. }
  13391. m.SetDeletedAt(v)
  13392. return nil
  13393. case labeltagging.FieldOrganizationID:
  13394. v, ok := value.(uint64)
  13395. if !ok {
  13396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13397. }
  13398. m.SetOrganizationID(v)
  13399. return nil
  13400. case labeltagging.FieldType:
  13401. v, ok := value.(int)
  13402. if !ok {
  13403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13404. }
  13405. m.SetType(v)
  13406. return nil
  13407. case labeltagging.FieldConditions:
  13408. v, ok := value.(string)
  13409. if !ok {
  13410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13411. }
  13412. m.SetConditions(v)
  13413. return nil
  13414. case labeltagging.FieldActionLabelAdd:
  13415. v, ok := value.([]uint64)
  13416. if !ok {
  13417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13418. }
  13419. m.SetActionLabelAdd(v)
  13420. return nil
  13421. case labeltagging.FieldActionLabelDel:
  13422. v, ok := value.([]uint64)
  13423. if !ok {
  13424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13425. }
  13426. m.SetActionLabelDel(v)
  13427. return nil
  13428. }
  13429. return fmt.Errorf("unknown LabelTagging field %s", name)
  13430. }
  13431. // AddedFields returns all numeric fields that were incremented/decremented during
  13432. // this mutation.
  13433. func (m *LabelTaggingMutation) AddedFields() []string {
  13434. var fields []string
  13435. if m.addstatus != nil {
  13436. fields = append(fields, labeltagging.FieldStatus)
  13437. }
  13438. if m.addorganization_id != nil {
  13439. fields = append(fields, labeltagging.FieldOrganizationID)
  13440. }
  13441. if m.add_type != nil {
  13442. fields = append(fields, labeltagging.FieldType)
  13443. }
  13444. return fields
  13445. }
  13446. // AddedField returns the numeric value that was incremented/decremented on a field
  13447. // with the given name. The second boolean return value indicates that this field
  13448. // was not set, or was not defined in the schema.
  13449. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  13450. switch name {
  13451. case labeltagging.FieldStatus:
  13452. return m.AddedStatus()
  13453. case labeltagging.FieldOrganizationID:
  13454. return m.AddedOrganizationID()
  13455. case labeltagging.FieldType:
  13456. return m.AddedType()
  13457. }
  13458. return nil, false
  13459. }
  13460. // AddField adds the value to the field with the given name. It returns an error if
  13461. // the field is not defined in the schema, or if the type mismatched the field
  13462. // type.
  13463. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  13464. switch name {
  13465. case labeltagging.FieldStatus:
  13466. v, ok := value.(int8)
  13467. if !ok {
  13468. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13469. }
  13470. m.AddStatus(v)
  13471. return nil
  13472. case labeltagging.FieldOrganizationID:
  13473. v, ok := value.(int64)
  13474. if !ok {
  13475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13476. }
  13477. m.AddOrganizationID(v)
  13478. return nil
  13479. case labeltagging.FieldType:
  13480. v, ok := value.(int)
  13481. if !ok {
  13482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13483. }
  13484. m.AddType(v)
  13485. return nil
  13486. }
  13487. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  13488. }
  13489. // ClearedFields returns all nullable fields that were cleared during this
  13490. // mutation.
  13491. func (m *LabelTaggingMutation) ClearedFields() []string {
  13492. var fields []string
  13493. if m.FieldCleared(labeltagging.FieldStatus) {
  13494. fields = append(fields, labeltagging.FieldStatus)
  13495. }
  13496. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  13497. fields = append(fields, labeltagging.FieldDeletedAt)
  13498. }
  13499. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  13500. fields = append(fields, labeltagging.FieldActionLabelAdd)
  13501. }
  13502. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  13503. fields = append(fields, labeltagging.FieldActionLabelDel)
  13504. }
  13505. return fields
  13506. }
  13507. // FieldCleared returns a boolean indicating if a field with the given name was
  13508. // cleared in this mutation.
  13509. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  13510. _, ok := m.clearedFields[name]
  13511. return ok
  13512. }
  13513. // ClearField clears the value of the field with the given name. It returns an
  13514. // error if the field is not defined in the schema.
  13515. func (m *LabelTaggingMutation) ClearField(name string) error {
  13516. switch name {
  13517. case labeltagging.FieldStatus:
  13518. m.ClearStatus()
  13519. return nil
  13520. case labeltagging.FieldDeletedAt:
  13521. m.ClearDeletedAt()
  13522. return nil
  13523. case labeltagging.FieldActionLabelAdd:
  13524. m.ClearActionLabelAdd()
  13525. return nil
  13526. case labeltagging.FieldActionLabelDel:
  13527. m.ClearActionLabelDel()
  13528. return nil
  13529. }
  13530. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  13531. }
  13532. // ResetField resets all changes in the mutation for the field with the given name.
  13533. // It returns an error if the field is not defined in the schema.
  13534. func (m *LabelTaggingMutation) ResetField(name string) error {
  13535. switch name {
  13536. case labeltagging.FieldCreatedAt:
  13537. m.ResetCreatedAt()
  13538. return nil
  13539. case labeltagging.FieldUpdatedAt:
  13540. m.ResetUpdatedAt()
  13541. return nil
  13542. case labeltagging.FieldStatus:
  13543. m.ResetStatus()
  13544. return nil
  13545. case labeltagging.FieldDeletedAt:
  13546. m.ResetDeletedAt()
  13547. return nil
  13548. case labeltagging.FieldOrganizationID:
  13549. m.ResetOrganizationID()
  13550. return nil
  13551. case labeltagging.FieldType:
  13552. m.ResetType()
  13553. return nil
  13554. case labeltagging.FieldConditions:
  13555. m.ResetConditions()
  13556. return nil
  13557. case labeltagging.FieldActionLabelAdd:
  13558. m.ResetActionLabelAdd()
  13559. return nil
  13560. case labeltagging.FieldActionLabelDel:
  13561. m.ResetActionLabelDel()
  13562. return nil
  13563. }
  13564. return fmt.Errorf("unknown LabelTagging field %s", name)
  13565. }
  13566. // AddedEdges returns all edge names that were set/added in this mutation.
  13567. func (m *LabelTaggingMutation) AddedEdges() []string {
  13568. edges := make([]string, 0, 0)
  13569. return edges
  13570. }
  13571. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13572. // name in this mutation.
  13573. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  13574. return nil
  13575. }
  13576. // RemovedEdges returns all edge names that were removed in this mutation.
  13577. func (m *LabelTaggingMutation) RemovedEdges() []string {
  13578. edges := make([]string, 0, 0)
  13579. return edges
  13580. }
  13581. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13582. // the given name in this mutation.
  13583. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  13584. return nil
  13585. }
  13586. // ClearedEdges returns all edge names that were cleared in this mutation.
  13587. func (m *LabelTaggingMutation) ClearedEdges() []string {
  13588. edges := make([]string, 0, 0)
  13589. return edges
  13590. }
  13591. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13592. // was cleared in this mutation.
  13593. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  13594. return false
  13595. }
  13596. // ClearEdge clears the value of the edge with the given name. It returns an error
  13597. // if that edge is not defined in the schema.
  13598. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  13599. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  13600. }
  13601. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13602. // It returns an error if the edge is not defined in the schema.
  13603. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  13604. return fmt.Errorf("unknown LabelTagging edge %s", name)
  13605. }
  13606. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  13607. type MessageMutation struct {
  13608. config
  13609. op Op
  13610. typ string
  13611. id *int
  13612. wx_wxid *string
  13613. wxid *string
  13614. content *string
  13615. clearedFields map[string]struct{}
  13616. done bool
  13617. oldValue func(context.Context) (*Message, error)
  13618. predicates []predicate.Message
  13619. }
  13620. var _ ent.Mutation = (*MessageMutation)(nil)
  13621. // messageOption allows management of the mutation configuration using functional options.
  13622. type messageOption func(*MessageMutation)
  13623. // newMessageMutation creates new mutation for the Message entity.
  13624. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  13625. m := &MessageMutation{
  13626. config: c,
  13627. op: op,
  13628. typ: TypeMessage,
  13629. clearedFields: make(map[string]struct{}),
  13630. }
  13631. for _, opt := range opts {
  13632. opt(m)
  13633. }
  13634. return m
  13635. }
  13636. // withMessageID sets the ID field of the mutation.
  13637. func withMessageID(id int) messageOption {
  13638. return func(m *MessageMutation) {
  13639. var (
  13640. err error
  13641. once sync.Once
  13642. value *Message
  13643. )
  13644. m.oldValue = func(ctx context.Context) (*Message, error) {
  13645. once.Do(func() {
  13646. if m.done {
  13647. err = errors.New("querying old values post mutation is not allowed")
  13648. } else {
  13649. value, err = m.Client().Message.Get(ctx, id)
  13650. }
  13651. })
  13652. return value, err
  13653. }
  13654. m.id = &id
  13655. }
  13656. }
  13657. // withMessage sets the old Message of the mutation.
  13658. func withMessage(node *Message) messageOption {
  13659. return func(m *MessageMutation) {
  13660. m.oldValue = func(context.Context) (*Message, error) {
  13661. return node, nil
  13662. }
  13663. m.id = &node.ID
  13664. }
  13665. }
  13666. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13667. // executed in a transaction (ent.Tx), a transactional client is returned.
  13668. func (m MessageMutation) Client() *Client {
  13669. client := &Client{config: m.config}
  13670. client.init()
  13671. return client
  13672. }
  13673. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13674. // it returns an error otherwise.
  13675. func (m MessageMutation) Tx() (*Tx, error) {
  13676. if _, ok := m.driver.(*txDriver); !ok {
  13677. return nil, errors.New("ent: mutation is not running in a transaction")
  13678. }
  13679. tx := &Tx{config: m.config}
  13680. tx.init()
  13681. return tx, nil
  13682. }
  13683. // ID returns the ID value in the mutation. Note that the ID is only available
  13684. // if it was provided to the builder or after it was returned from the database.
  13685. func (m *MessageMutation) ID() (id int, exists bool) {
  13686. if m.id == nil {
  13687. return
  13688. }
  13689. return *m.id, true
  13690. }
  13691. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13692. // That means, if the mutation is applied within a transaction with an isolation level such
  13693. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13694. // or updated by the mutation.
  13695. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  13696. switch {
  13697. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13698. id, exists := m.ID()
  13699. if exists {
  13700. return []int{id}, nil
  13701. }
  13702. fallthrough
  13703. case m.op.Is(OpUpdate | OpDelete):
  13704. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  13705. default:
  13706. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13707. }
  13708. }
  13709. // SetWxWxid sets the "wx_wxid" field.
  13710. func (m *MessageMutation) SetWxWxid(s string) {
  13711. m.wx_wxid = &s
  13712. }
  13713. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  13714. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  13715. v := m.wx_wxid
  13716. if v == nil {
  13717. return
  13718. }
  13719. return *v, true
  13720. }
  13721. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  13722. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  13723. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13724. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  13725. if !m.op.Is(OpUpdateOne) {
  13726. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  13727. }
  13728. if m.id == nil || m.oldValue == nil {
  13729. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  13730. }
  13731. oldValue, err := m.oldValue(ctx)
  13732. if err != nil {
  13733. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  13734. }
  13735. return oldValue.WxWxid, nil
  13736. }
  13737. // ClearWxWxid clears the value of the "wx_wxid" field.
  13738. func (m *MessageMutation) ClearWxWxid() {
  13739. m.wx_wxid = nil
  13740. m.clearedFields[message.FieldWxWxid] = struct{}{}
  13741. }
  13742. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  13743. func (m *MessageMutation) WxWxidCleared() bool {
  13744. _, ok := m.clearedFields[message.FieldWxWxid]
  13745. return ok
  13746. }
  13747. // ResetWxWxid resets all changes to the "wx_wxid" field.
  13748. func (m *MessageMutation) ResetWxWxid() {
  13749. m.wx_wxid = nil
  13750. delete(m.clearedFields, message.FieldWxWxid)
  13751. }
  13752. // SetWxid sets the "wxid" field.
  13753. func (m *MessageMutation) SetWxid(s string) {
  13754. m.wxid = &s
  13755. }
  13756. // Wxid returns the value of the "wxid" field in the mutation.
  13757. func (m *MessageMutation) Wxid() (r string, exists bool) {
  13758. v := m.wxid
  13759. if v == nil {
  13760. return
  13761. }
  13762. return *v, true
  13763. }
  13764. // OldWxid returns the old "wxid" field's value of the Message entity.
  13765. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  13766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13767. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  13768. if !m.op.Is(OpUpdateOne) {
  13769. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  13770. }
  13771. if m.id == nil || m.oldValue == nil {
  13772. return v, errors.New("OldWxid requires an ID field in the mutation")
  13773. }
  13774. oldValue, err := m.oldValue(ctx)
  13775. if err != nil {
  13776. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  13777. }
  13778. return oldValue.Wxid, nil
  13779. }
  13780. // ResetWxid resets all changes to the "wxid" field.
  13781. func (m *MessageMutation) ResetWxid() {
  13782. m.wxid = nil
  13783. }
  13784. // SetContent sets the "content" field.
  13785. func (m *MessageMutation) SetContent(s string) {
  13786. m.content = &s
  13787. }
  13788. // Content returns the value of the "content" field in the mutation.
  13789. func (m *MessageMutation) Content() (r string, exists bool) {
  13790. v := m.content
  13791. if v == nil {
  13792. return
  13793. }
  13794. return *v, true
  13795. }
  13796. // OldContent returns the old "content" field's value of the Message entity.
  13797. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  13798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13799. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  13800. if !m.op.Is(OpUpdateOne) {
  13801. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  13802. }
  13803. if m.id == nil || m.oldValue == nil {
  13804. return v, errors.New("OldContent requires an ID field in the mutation")
  13805. }
  13806. oldValue, err := m.oldValue(ctx)
  13807. if err != nil {
  13808. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  13809. }
  13810. return oldValue.Content, nil
  13811. }
  13812. // ResetContent resets all changes to the "content" field.
  13813. func (m *MessageMutation) ResetContent() {
  13814. m.content = nil
  13815. }
  13816. // Where appends a list predicates to the MessageMutation builder.
  13817. func (m *MessageMutation) Where(ps ...predicate.Message) {
  13818. m.predicates = append(m.predicates, ps...)
  13819. }
  13820. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  13821. // users can use type-assertion to append predicates that do not depend on any generated package.
  13822. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  13823. p := make([]predicate.Message, len(ps))
  13824. for i := range ps {
  13825. p[i] = ps[i]
  13826. }
  13827. m.Where(p...)
  13828. }
  13829. // Op returns the operation name.
  13830. func (m *MessageMutation) Op() Op {
  13831. return m.op
  13832. }
  13833. // SetOp allows setting the mutation operation.
  13834. func (m *MessageMutation) SetOp(op Op) {
  13835. m.op = op
  13836. }
  13837. // Type returns the node type of this mutation (Message).
  13838. func (m *MessageMutation) Type() string {
  13839. return m.typ
  13840. }
  13841. // Fields returns all fields that were changed during this mutation. Note that in
  13842. // order to get all numeric fields that were incremented/decremented, call
  13843. // AddedFields().
  13844. func (m *MessageMutation) Fields() []string {
  13845. fields := make([]string, 0, 3)
  13846. if m.wx_wxid != nil {
  13847. fields = append(fields, message.FieldWxWxid)
  13848. }
  13849. if m.wxid != nil {
  13850. fields = append(fields, message.FieldWxid)
  13851. }
  13852. if m.content != nil {
  13853. fields = append(fields, message.FieldContent)
  13854. }
  13855. return fields
  13856. }
  13857. // Field returns the value of a field with the given name. The second boolean
  13858. // return value indicates that this field was not set, or was not defined in the
  13859. // schema.
  13860. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  13861. switch name {
  13862. case message.FieldWxWxid:
  13863. return m.WxWxid()
  13864. case message.FieldWxid:
  13865. return m.Wxid()
  13866. case message.FieldContent:
  13867. return m.Content()
  13868. }
  13869. return nil, false
  13870. }
  13871. // OldField returns the old value of the field from the database. An error is
  13872. // returned if the mutation operation is not UpdateOne, or the query to the
  13873. // database failed.
  13874. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13875. switch name {
  13876. case message.FieldWxWxid:
  13877. return m.OldWxWxid(ctx)
  13878. case message.FieldWxid:
  13879. return m.OldWxid(ctx)
  13880. case message.FieldContent:
  13881. return m.OldContent(ctx)
  13882. }
  13883. return nil, fmt.Errorf("unknown Message field %s", name)
  13884. }
  13885. // SetField sets the value of a field with the given name. It returns an error if
  13886. // the field is not defined in the schema, or if the type mismatched the field
  13887. // type.
  13888. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  13889. switch name {
  13890. case message.FieldWxWxid:
  13891. v, ok := value.(string)
  13892. if !ok {
  13893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13894. }
  13895. m.SetWxWxid(v)
  13896. return nil
  13897. case message.FieldWxid:
  13898. v, ok := value.(string)
  13899. if !ok {
  13900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13901. }
  13902. m.SetWxid(v)
  13903. return nil
  13904. case message.FieldContent:
  13905. v, ok := value.(string)
  13906. if !ok {
  13907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13908. }
  13909. m.SetContent(v)
  13910. return nil
  13911. }
  13912. return fmt.Errorf("unknown Message field %s", name)
  13913. }
  13914. // AddedFields returns all numeric fields that were incremented/decremented during
  13915. // this mutation.
  13916. func (m *MessageMutation) AddedFields() []string {
  13917. return nil
  13918. }
  13919. // AddedField returns the numeric value that was incremented/decremented on a field
  13920. // with the given name. The second boolean return value indicates that this field
  13921. // was not set, or was not defined in the schema.
  13922. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  13923. return nil, false
  13924. }
  13925. // AddField adds the value to the field with the given name. It returns an error if
  13926. // the field is not defined in the schema, or if the type mismatched the field
  13927. // type.
  13928. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  13929. switch name {
  13930. }
  13931. return fmt.Errorf("unknown Message numeric field %s", name)
  13932. }
  13933. // ClearedFields returns all nullable fields that were cleared during this
  13934. // mutation.
  13935. func (m *MessageMutation) ClearedFields() []string {
  13936. var fields []string
  13937. if m.FieldCleared(message.FieldWxWxid) {
  13938. fields = append(fields, message.FieldWxWxid)
  13939. }
  13940. return fields
  13941. }
  13942. // FieldCleared returns a boolean indicating if a field with the given name was
  13943. // cleared in this mutation.
  13944. func (m *MessageMutation) FieldCleared(name string) bool {
  13945. _, ok := m.clearedFields[name]
  13946. return ok
  13947. }
  13948. // ClearField clears the value of the field with the given name. It returns an
  13949. // error if the field is not defined in the schema.
  13950. func (m *MessageMutation) ClearField(name string) error {
  13951. switch name {
  13952. case message.FieldWxWxid:
  13953. m.ClearWxWxid()
  13954. return nil
  13955. }
  13956. return fmt.Errorf("unknown Message nullable field %s", name)
  13957. }
  13958. // ResetField resets all changes in the mutation for the field with the given name.
  13959. // It returns an error if the field is not defined in the schema.
  13960. func (m *MessageMutation) ResetField(name string) error {
  13961. switch name {
  13962. case message.FieldWxWxid:
  13963. m.ResetWxWxid()
  13964. return nil
  13965. case message.FieldWxid:
  13966. m.ResetWxid()
  13967. return nil
  13968. case message.FieldContent:
  13969. m.ResetContent()
  13970. return nil
  13971. }
  13972. return fmt.Errorf("unknown Message field %s", name)
  13973. }
  13974. // AddedEdges returns all edge names that were set/added in this mutation.
  13975. func (m *MessageMutation) AddedEdges() []string {
  13976. edges := make([]string, 0, 0)
  13977. return edges
  13978. }
  13979. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13980. // name in this mutation.
  13981. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  13982. return nil
  13983. }
  13984. // RemovedEdges returns all edge names that were removed in this mutation.
  13985. func (m *MessageMutation) RemovedEdges() []string {
  13986. edges := make([]string, 0, 0)
  13987. return edges
  13988. }
  13989. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13990. // the given name in this mutation.
  13991. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  13992. return nil
  13993. }
  13994. // ClearedEdges returns all edge names that were cleared in this mutation.
  13995. func (m *MessageMutation) ClearedEdges() []string {
  13996. edges := make([]string, 0, 0)
  13997. return edges
  13998. }
  13999. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14000. // was cleared in this mutation.
  14001. func (m *MessageMutation) EdgeCleared(name string) bool {
  14002. return false
  14003. }
  14004. // ClearEdge clears the value of the edge with the given name. It returns an error
  14005. // if that edge is not defined in the schema.
  14006. func (m *MessageMutation) ClearEdge(name string) error {
  14007. return fmt.Errorf("unknown Message unique edge %s", name)
  14008. }
  14009. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14010. // It returns an error if the edge is not defined in the schema.
  14011. func (m *MessageMutation) ResetEdge(name string) error {
  14012. return fmt.Errorf("unknown Message edge %s", name)
  14013. }
  14014. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  14015. type MessageRecordsMutation struct {
  14016. config
  14017. op Op
  14018. typ string
  14019. id *uint64
  14020. created_at *time.Time
  14021. updated_at *time.Time
  14022. status *uint8
  14023. addstatus *int8
  14024. bot_wxid *string
  14025. contact_type *int
  14026. addcontact_type *int
  14027. contact_wxid *string
  14028. content_type *int
  14029. addcontent_type *int
  14030. content *string
  14031. meta *custom_types.Meta
  14032. error_detail *string
  14033. send_time *time.Time
  14034. source_type *int
  14035. addsource_type *int
  14036. organization_id *uint64
  14037. addorganization_id *int64
  14038. clearedFields map[string]struct{}
  14039. sop_stage *uint64
  14040. clearedsop_stage bool
  14041. sop_node *uint64
  14042. clearedsop_node bool
  14043. message_contact *uint64
  14044. clearedmessage_contact bool
  14045. done bool
  14046. oldValue func(context.Context) (*MessageRecords, error)
  14047. predicates []predicate.MessageRecords
  14048. }
  14049. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  14050. // messagerecordsOption allows management of the mutation configuration using functional options.
  14051. type messagerecordsOption func(*MessageRecordsMutation)
  14052. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  14053. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  14054. m := &MessageRecordsMutation{
  14055. config: c,
  14056. op: op,
  14057. typ: TypeMessageRecords,
  14058. clearedFields: make(map[string]struct{}),
  14059. }
  14060. for _, opt := range opts {
  14061. opt(m)
  14062. }
  14063. return m
  14064. }
  14065. // withMessageRecordsID sets the ID field of the mutation.
  14066. func withMessageRecordsID(id uint64) messagerecordsOption {
  14067. return func(m *MessageRecordsMutation) {
  14068. var (
  14069. err error
  14070. once sync.Once
  14071. value *MessageRecords
  14072. )
  14073. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  14074. once.Do(func() {
  14075. if m.done {
  14076. err = errors.New("querying old values post mutation is not allowed")
  14077. } else {
  14078. value, err = m.Client().MessageRecords.Get(ctx, id)
  14079. }
  14080. })
  14081. return value, err
  14082. }
  14083. m.id = &id
  14084. }
  14085. }
  14086. // withMessageRecords sets the old MessageRecords of the mutation.
  14087. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  14088. return func(m *MessageRecordsMutation) {
  14089. m.oldValue = func(context.Context) (*MessageRecords, error) {
  14090. return node, nil
  14091. }
  14092. m.id = &node.ID
  14093. }
  14094. }
  14095. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14096. // executed in a transaction (ent.Tx), a transactional client is returned.
  14097. func (m MessageRecordsMutation) Client() *Client {
  14098. client := &Client{config: m.config}
  14099. client.init()
  14100. return client
  14101. }
  14102. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14103. // it returns an error otherwise.
  14104. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  14105. if _, ok := m.driver.(*txDriver); !ok {
  14106. return nil, errors.New("ent: mutation is not running in a transaction")
  14107. }
  14108. tx := &Tx{config: m.config}
  14109. tx.init()
  14110. return tx, nil
  14111. }
  14112. // SetID sets the value of the id field. Note that this
  14113. // operation is only accepted on creation of MessageRecords entities.
  14114. func (m *MessageRecordsMutation) SetID(id uint64) {
  14115. m.id = &id
  14116. }
  14117. // ID returns the ID value in the mutation. Note that the ID is only available
  14118. // if it was provided to the builder or after it was returned from the database.
  14119. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  14120. if m.id == nil {
  14121. return
  14122. }
  14123. return *m.id, true
  14124. }
  14125. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14126. // That means, if the mutation is applied within a transaction with an isolation level such
  14127. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14128. // or updated by the mutation.
  14129. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  14130. switch {
  14131. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14132. id, exists := m.ID()
  14133. if exists {
  14134. return []uint64{id}, nil
  14135. }
  14136. fallthrough
  14137. case m.op.Is(OpUpdate | OpDelete):
  14138. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  14139. default:
  14140. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14141. }
  14142. }
  14143. // SetCreatedAt sets the "created_at" field.
  14144. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  14145. m.created_at = &t
  14146. }
  14147. // CreatedAt returns the value of the "created_at" field in the mutation.
  14148. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  14149. v := m.created_at
  14150. if v == nil {
  14151. return
  14152. }
  14153. return *v, true
  14154. }
  14155. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  14156. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14158. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14159. if !m.op.Is(OpUpdateOne) {
  14160. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14161. }
  14162. if m.id == nil || m.oldValue == nil {
  14163. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14164. }
  14165. oldValue, err := m.oldValue(ctx)
  14166. if err != nil {
  14167. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14168. }
  14169. return oldValue.CreatedAt, nil
  14170. }
  14171. // ResetCreatedAt resets all changes to the "created_at" field.
  14172. func (m *MessageRecordsMutation) ResetCreatedAt() {
  14173. m.created_at = nil
  14174. }
  14175. // SetUpdatedAt sets the "updated_at" field.
  14176. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  14177. m.updated_at = &t
  14178. }
  14179. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14180. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  14181. v := m.updated_at
  14182. if v == nil {
  14183. return
  14184. }
  14185. return *v, true
  14186. }
  14187. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  14188. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14190. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14191. if !m.op.Is(OpUpdateOne) {
  14192. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14193. }
  14194. if m.id == nil || m.oldValue == nil {
  14195. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14196. }
  14197. oldValue, err := m.oldValue(ctx)
  14198. if err != nil {
  14199. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14200. }
  14201. return oldValue.UpdatedAt, nil
  14202. }
  14203. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14204. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  14205. m.updated_at = nil
  14206. }
  14207. // SetStatus sets the "status" field.
  14208. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  14209. m.status = &u
  14210. m.addstatus = nil
  14211. }
  14212. // Status returns the value of the "status" field in the mutation.
  14213. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  14214. v := m.status
  14215. if v == nil {
  14216. return
  14217. }
  14218. return *v, true
  14219. }
  14220. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  14221. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14223. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14224. if !m.op.Is(OpUpdateOne) {
  14225. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14226. }
  14227. if m.id == nil || m.oldValue == nil {
  14228. return v, errors.New("OldStatus requires an ID field in the mutation")
  14229. }
  14230. oldValue, err := m.oldValue(ctx)
  14231. if err != nil {
  14232. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14233. }
  14234. return oldValue.Status, nil
  14235. }
  14236. // AddStatus adds u to the "status" field.
  14237. func (m *MessageRecordsMutation) AddStatus(u int8) {
  14238. if m.addstatus != nil {
  14239. *m.addstatus += u
  14240. } else {
  14241. m.addstatus = &u
  14242. }
  14243. }
  14244. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14245. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  14246. v := m.addstatus
  14247. if v == nil {
  14248. return
  14249. }
  14250. return *v, true
  14251. }
  14252. // ClearStatus clears the value of the "status" field.
  14253. func (m *MessageRecordsMutation) ClearStatus() {
  14254. m.status = nil
  14255. m.addstatus = nil
  14256. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  14257. }
  14258. // StatusCleared returns if the "status" field was cleared in this mutation.
  14259. func (m *MessageRecordsMutation) StatusCleared() bool {
  14260. _, ok := m.clearedFields[messagerecords.FieldStatus]
  14261. return ok
  14262. }
  14263. // ResetStatus resets all changes to the "status" field.
  14264. func (m *MessageRecordsMutation) ResetStatus() {
  14265. m.status = nil
  14266. m.addstatus = nil
  14267. delete(m.clearedFields, messagerecords.FieldStatus)
  14268. }
  14269. // SetBotWxid sets the "bot_wxid" field.
  14270. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  14271. m.bot_wxid = &s
  14272. }
  14273. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  14274. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  14275. v := m.bot_wxid
  14276. if v == nil {
  14277. return
  14278. }
  14279. return *v, true
  14280. }
  14281. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  14282. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14283. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14284. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  14285. if !m.op.Is(OpUpdateOne) {
  14286. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  14287. }
  14288. if m.id == nil || m.oldValue == nil {
  14289. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  14290. }
  14291. oldValue, err := m.oldValue(ctx)
  14292. if err != nil {
  14293. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  14294. }
  14295. return oldValue.BotWxid, nil
  14296. }
  14297. // ResetBotWxid resets all changes to the "bot_wxid" field.
  14298. func (m *MessageRecordsMutation) ResetBotWxid() {
  14299. m.bot_wxid = nil
  14300. }
  14301. // SetContactID sets the "contact_id" field.
  14302. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  14303. m.message_contact = &u
  14304. }
  14305. // ContactID returns the value of the "contact_id" field in the mutation.
  14306. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  14307. v := m.message_contact
  14308. if v == nil {
  14309. return
  14310. }
  14311. return *v, true
  14312. }
  14313. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  14314. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14316. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  14317. if !m.op.Is(OpUpdateOne) {
  14318. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  14319. }
  14320. if m.id == nil || m.oldValue == nil {
  14321. return v, errors.New("OldContactID requires an ID field in the mutation")
  14322. }
  14323. oldValue, err := m.oldValue(ctx)
  14324. if err != nil {
  14325. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  14326. }
  14327. return oldValue.ContactID, nil
  14328. }
  14329. // ClearContactID clears the value of the "contact_id" field.
  14330. func (m *MessageRecordsMutation) ClearContactID() {
  14331. m.message_contact = nil
  14332. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  14333. }
  14334. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  14335. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  14336. _, ok := m.clearedFields[messagerecords.FieldContactID]
  14337. return ok
  14338. }
  14339. // ResetContactID resets all changes to the "contact_id" field.
  14340. func (m *MessageRecordsMutation) ResetContactID() {
  14341. m.message_contact = nil
  14342. delete(m.clearedFields, messagerecords.FieldContactID)
  14343. }
  14344. // SetContactType sets the "contact_type" field.
  14345. func (m *MessageRecordsMutation) SetContactType(i int) {
  14346. m.contact_type = &i
  14347. m.addcontact_type = nil
  14348. }
  14349. // ContactType returns the value of the "contact_type" field in the mutation.
  14350. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  14351. v := m.contact_type
  14352. if v == nil {
  14353. return
  14354. }
  14355. return *v, true
  14356. }
  14357. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  14358. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14360. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  14361. if !m.op.Is(OpUpdateOne) {
  14362. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  14363. }
  14364. if m.id == nil || m.oldValue == nil {
  14365. return v, errors.New("OldContactType requires an ID field in the mutation")
  14366. }
  14367. oldValue, err := m.oldValue(ctx)
  14368. if err != nil {
  14369. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  14370. }
  14371. return oldValue.ContactType, nil
  14372. }
  14373. // AddContactType adds i to the "contact_type" field.
  14374. func (m *MessageRecordsMutation) AddContactType(i int) {
  14375. if m.addcontact_type != nil {
  14376. *m.addcontact_type += i
  14377. } else {
  14378. m.addcontact_type = &i
  14379. }
  14380. }
  14381. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  14382. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  14383. v := m.addcontact_type
  14384. if v == nil {
  14385. return
  14386. }
  14387. return *v, true
  14388. }
  14389. // ResetContactType resets all changes to the "contact_type" field.
  14390. func (m *MessageRecordsMutation) ResetContactType() {
  14391. m.contact_type = nil
  14392. m.addcontact_type = nil
  14393. }
  14394. // SetContactWxid sets the "contact_wxid" field.
  14395. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  14396. m.contact_wxid = &s
  14397. }
  14398. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  14399. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  14400. v := m.contact_wxid
  14401. if v == nil {
  14402. return
  14403. }
  14404. return *v, true
  14405. }
  14406. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  14407. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14408. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14409. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  14410. if !m.op.Is(OpUpdateOne) {
  14411. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  14412. }
  14413. if m.id == nil || m.oldValue == nil {
  14414. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  14415. }
  14416. oldValue, err := m.oldValue(ctx)
  14417. if err != nil {
  14418. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  14419. }
  14420. return oldValue.ContactWxid, nil
  14421. }
  14422. // ResetContactWxid resets all changes to the "contact_wxid" field.
  14423. func (m *MessageRecordsMutation) ResetContactWxid() {
  14424. m.contact_wxid = nil
  14425. }
  14426. // SetContentType sets the "content_type" field.
  14427. func (m *MessageRecordsMutation) SetContentType(i int) {
  14428. m.content_type = &i
  14429. m.addcontent_type = nil
  14430. }
  14431. // ContentType returns the value of the "content_type" field in the mutation.
  14432. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  14433. v := m.content_type
  14434. if v == nil {
  14435. return
  14436. }
  14437. return *v, true
  14438. }
  14439. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  14440. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14442. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  14443. if !m.op.Is(OpUpdateOne) {
  14444. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  14445. }
  14446. if m.id == nil || m.oldValue == nil {
  14447. return v, errors.New("OldContentType requires an ID field in the mutation")
  14448. }
  14449. oldValue, err := m.oldValue(ctx)
  14450. if err != nil {
  14451. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  14452. }
  14453. return oldValue.ContentType, nil
  14454. }
  14455. // AddContentType adds i to the "content_type" field.
  14456. func (m *MessageRecordsMutation) AddContentType(i int) {
  14457. if m.addcontent_type != nil {
  14458. *m.addcontent_type += i
  14459. } else {
  14460. m.addcontent_type = &i
  14461. }
  14462. }
  14463. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  14464. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  14465. v := m.addcontent_type
  14466. if v == nil {
  14467. return
  14468. }
  14469. return *v, true
  14470. }
  14471. // ResetContentType resets all changes to the "content_type" field.
  14472. func (m *MessageRecordsMutation) ResetContentType() {
  14473. m.content_type = nil
  14474. m.addcontent_type = nil
  14475. }
  14476. // SetContent sets the "content" field.
  14477. func (m *MessageRecordsMutation) SetContent(s string) {
  14478. m.content = &s
  14479. }
  14480. // Content returns the value of the "content" field in the mutation.
  14481. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  14482. v := m.content
  14483. if v == nil {
  14484. return
  14485. }
  14486. return *v, true
  14487. }
  14488. // OldContent returns the old "content" field's value of the MessageRecords entity.
  14489. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14491. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  14492. if !m.op.Is(OpUpdateOne) {
  14493. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  14494. }
  14495. if m.id == nil || m.oldValue == nil {
  14496. return v, errors.New("OldContent requires an ID field in the mutation")
  14497. }
  14498. oldValue, err := m.oldValue(ctx)
  14499. if err != nil {
  14500. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  14501. }
  14502. return oldValue.Content, nil
  14503. }
  14504. // ResetContent resets all changes to the "content" field.
  14505. func (m *MessageRecordsMutation) ResetContent() {
  14506. m.content = nil
  14507. }
  14508. // SetMeta sets the "meta" field.
  14509. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  14510. m.meta = &ct
  14511. }
  14512. // Meta returns the value of the "meta" field in the mutation.
  14513. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  14514. v := m.meta
  14515. if v == nil {
  14516. return
  14517. }
  14518. return *v, true
  14519. }
  14520. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  14521. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14523. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  14524. if !m.op.Is(OpUpdateOne) {
  14525. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  14526. }
  14527. if m.id == nil || m.oldValue == nil {
  14528. return v, errors.New("OldMeta requires an ID field in the mutation")
  14529. }
  14530. oldValue, err := m.oldValue(ctx)
  14531. if err != nil {
  14532. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  14533. }
  14534. return oldValue.Meta, nil
  14535. }
  14536. // ClearMeta clears the value of the "meta" field.
  14537. func (m *MessageRecordsMutation) ClearMeta() {
  14538. m.meta = nil
  14539. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  14540. }
  14541. // MetaCleared returns if the "meta" field was cleared in this mutation.
  14542. func (m *MessageRecordsMutation) MetaCleared() bool {
  14543. _, ok := m.clearedFields[messagerecords.FieldMeta]
  14544. return ok
  14545. }
  14546. // ResetMeta resets all changes to the "meta" field.
  14547. func (m *MessageRecordsMutation) ResetMeta() {
  14548. m.meta = nil
  14549. delete(m.clearedFields, messagerecords.FieldMeta)
  14550. }
  14551. // SetErrorDetail sets the "error_detail" field.
  14552. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  14553. m.error_detail = &s
  14554. }
  14555. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  14556. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  14557. v := m.error_detail
  14558. if v == nil {
  14559. return
  14560. }
  14561. return *v, true
  14562. }
  14563. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  14564. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14566. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  14567. if !m.op.Is(OpUpdateOne) {
  14568. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  14569. }
  14570. if m.id == nil || m.oldValue == nil {
  14571. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  14572. }
  14573. oldValue, err := m.oldValue(ctx)
  14574. if err != nil {
  14575. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  14576. }
  14577. return oldValue.ErrorDetail, nil
  14578. }
  14579. // ResetErrorDetail resets all changes to the "error_detail" field.
  14580. func (m *MessageRecordsMutation) ResetErrorDetail() {
  14581. m.error_detail = nil
  14582. }
  14583. // SetSendTime sets the "send_time" field.
  14584. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  14585. m.send_time = &t
  14586. }
  14587. // SendTime returns the value of the "send_time" field in the mutation.
  14588. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  14589. v := m.send_time
  14590. if v == nil {
  14591. return
  14592. }
  14593. return *v, true
  14594. }
  14595. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  14596. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14598. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  14599. if !m.op.Is(OpUpdateOne) {
  14600. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  14601. }
  14602. if m.id == nil || m.oldValue == nil {
  14603. return v, errors.New("OldSendTime requires an ID field in the mutation")
  14604. }
  14605. oldValue, err := m.oldValue(ctx)
  14606. if err != nil {
  14607. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  14608. }
  14609. return oldValue.SendTime, nil
  14610. }
  14611. // ClearSendTime clears the value of the "send_time" field.
  14612. func (m *MessageRecordsMutation) ClearSendTime() {
  14613. m.send_time = nil
  14614. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  14615. }
  14616. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  14617. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  14618. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  14619. return ok
  14620. }
  14621. // ResetSendTime resets all changes to the "send_time" field.
  14622. func (m *MessageRecordsMutation) ResetSendTime() {
  14623. m.send_time = nil
  14624. delete(m.clearedFields, messagerecords.FieldSendTime)
  14625. }
  14626. // SetSourceType sets the "source_type" field.
  14627. func (m *MessageRecordsMutation) SetSourceType(i int) {
  14628. m.source_type = &i
  14629. m.addsource_type = nil
  14630. }
  14631. // SourceType returns the value of the "source_type" field in the mutation.
  14632. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  14633. v := m.source_type
  14634. if v == nil {
  14635. return
  14636. }
  14637. return *v, true
  14638. }
  14639. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  14640. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14641. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14642. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  14643. if !m.op.Is(OpUpdateOne) {
  14644. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  14645. }
  14646. if m.id == nil || m.oldValue == nil {
  14647. return v, errors.New("OldSourceType requires an ID field in the mutation")
  14648. }
  14649. oldValue, err := m.oldValue(ctx)
  14650. if err != nil {
  14651. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  14652. }
  14653. return oldValue.SourceType, nil
  14654. }
  14655. // AddSourceType adds i to the "source_type" field.
  14656. func (m *MessageRecordsMutation) AddSourceType(i int) {
  14657. if m.addsource_type != nil {
  14658. *m.addsource_type += i
  14659. } else {
  14660. m.addsource_type = &i
  14661. }
  14662. }
  14663. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  14664. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  14665. v := m.addsource_type
  14666. if v == nil {
  14667. return
  14668. }
  14669. return *v, true
  14670. }
  14671. // ResetSourceType resets all changes to the "source_type" field.
  14672. func (m *MessageRecordsMutation) ResetSourceType() {
  14673. m.source_type = nil
  14674. m.addsource_type = nil
  14675. }
  14676. // SetSourceID sets the "source_id" field.
  14677. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  14678. m.sop_stage = &u
  14679. }
  14680. // SourceID returns the value of the "source_id" field in the mutation.
  14681. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  14682. v := m.sop_stage
  14683. if v == nil {
  14684. return
  14685. }
  14686. return *v, true
  14687. }
  14688. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  14689. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14691. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  14692. if !m.op.Is(OpUpdateOne) {
  14693. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  14694. }
  14695. if m.id == nil || m.oldValue == nil {
  14696. return v, errors.New("OldSourceID requires an ID field in the mutation")
  14697. }
  14698. oldValue, err := m.oldValue(ctx)
  14699. if err != nil {
  14700. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  14701. }
  14702. return oldValue.SourceID, nil
  14703. }
  14704. // ClearSourceID clears the value of the "source_id" field.
  14705. func (m *MessageRecordsMutation) ClearSourceID() {
  14706. m.sop_stage = nil
  14707. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  14708. }
  14709. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  14710. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  14711. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  14712. return ok
  14713. }
  14714. // ResetSourceID resets all changes to the "source_id" field.
  14715. func (m *MessageRecordsMutation) ResetSourceID() {
  14716. m.sop_stage = nil
  14717. delete(m.clearedFields, messagerecords.FieldSourceID)
  14718. }
  14719. // SetSubSourceID sets the "sub_source_id" field.
  14720. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  14721. m.sop_node = &u
  14722. }
  14723. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  14724. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  14725. v := m.sop_node
  14726. if v == nil {
  14727. return
  14728. }
  14729. return *v, true
  14730. }
  14731. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  14732. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14734. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  14735. if !m.op.Is(OpUpdateOne) {
  14736. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  14737. }
  14738. if m.id == nil || m.oldValue == nil {
  14739. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  14740. }
  14741. oldValue, err := m.oldValue(ctx)
  14742. if err != nil {
  14743. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  14744. }
  14745. return oldValue.SubSourceID, nil
  14746. }
  14747. // ClearSubSourceID clears the value of the "sub_source_id" field.
  14748. func (m *MessageRecordsMutation) ClearSubSourceID() {
  14749. m.sop_node = nil
  14750. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  14751. }
  14752. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  14753. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  14754. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  14755. return ok
  14756. }
  14757. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  14758. func (m *MessageRecordsMutation) ResetSubSourceID() {
  14759. m.sop_node = nil
  14760. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  14761. }
  14762. // SetOrganizationID sets the "organization_id" field.
  14763. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  14764. m.organization_id = &u
  14765. m.addorganization_id = nil
  14766. }
  14767. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14768. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  14769. v := m.organization_id
  14770. if v == nil {
  14771. return
  14772. }
  14773. return *v, true
  14774. }
  14775. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  14776. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  14777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14778. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14779. if !m.op.Is(OpUpdateOne) {
  14780. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14781. }
  14782. if m.id == nil || m.oldValue == nil {
  14783. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14784. }
  14785. oldValue, err := m.oldValue(ctx)
  14786. if err != nil {
  14787. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14788. }
  14789. return oldValue.OrganizationID, nil
  14790. }
  14791. // AddOrganizationID adds u to the "organization_id" field.
  14792. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  14793. if m.addorganization_id != nil {
  14794. *m.addorganization_id += u
  14795. } else {
  14796. m.addorganization_id = &u
  14797. }
  14798. }
  14799. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14800. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  14801. v := m.addorganization_id
  14802. if v == nil {
  14803. return
  14804. }
  14805. return *v, true
  14806. }
  14807. // ClearOrganizationID clears the value of the "organization_id" field.
  14808. func (m *MessageRecordsMutation) ClearOrganizationID() {
  14809. m.organization_id = nil
  14810. m.addorganization_id = nil
  14811. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  14812. }
  14813. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14814. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  14815. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  14816. return ok
  14817. }
  14818. // ResetOrganizationID resets all changes to the "organization_id" field.
  14819. func (m *MessageRecordsMutation) ResetOrganizationID() {
  14820. m.organization_id = nil
  14821. m.addorganization_id = nil
  14822. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  14823. }
  14824. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  14825. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  14826. m.sop_stage = &id
  14827. }
  14828. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  14829. func (m *MessageRecordsMutation) ClearSopStage() {
  14830. m.clearedsop_stage = true
  14831. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  14832. }
  14833. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  14834. func (m *MessageRecordsMutation) SopStageCleared() bool {
  14835. return m.SourceIDCleared() || m.clearedsop_stage
  14836. }
  14837. // SopStageID returns the "sop_stage" edge ID in the mutation.
  14838. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  14839. if m.sop_stage != nil {
  14840. return *m.sop_stage, true
  14841. }
  14842. return
  14843. }
  14844. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  14845. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14846. // SopStageID instead. It exists only for internal usage by the builders.
  14847. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  14848. if id := m.sop_stage; id != nil {
  14849. ids = append(ids, *id)
  14850. }
  14851. return
  14852. }
  14853. // ResetSopStage resets all changes to the "sop_stage" edge.
  14854. func (m *MessageRecordsMutation) ResetSopStage() {
  14855. m.sop_stage = nil
  14856. m.clearedsop_stage = false
  14857. }
  14858. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  14859. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  14860. m.sop_node = &id
  14861. }
  14862. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  14863. func (m *MessageRecordsMutation) ClearSopNode() {
  14864. m.clearedsop_node = true
  14865. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  14866. }
  14867. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  14868. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  14869. return m.SubSourceIDCleared() || m.clearedsop_node
  14870. }
  14871. // SopNodeID returns the "sop_node" edge ID in the mutation.
  14872. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  14873. if m.sop_node != nil {
  14874. return *m.sop_node, true
  14875. }
  14876. return
  14877. }
  14878. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  14879. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14880. // SopNodeID instead. It exists only for internal usage by the builders.
  14881. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  14882. if id := m.sop_node; id != nil {
  14883. ids = append(ids, *id)
  14884. }
  14885. return
  14886. }
  14887. // ResetSopNode resets all changes to the "sop_node" edge.
  14888. func (m *MessageRecordsMutation) ResetSopNode() {
  14889. m.sop_node = nil
  14890. m.clearedsop_node = false
  14891. }
  14892. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  14893. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  14894. m.message_contact = &id
  14895. }
  14896. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  14897. func (m *MessageRecordsMutation) ClearMessageContact() {
  14898. m.clearedmessage_contact = true
  14899. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  14900. }
  14901. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  14902. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  14903. return m.ContactIDCleared() || m.clearedmessage_contact
  14904. }
  14905. // MessageContactID returns the "message_contact" edge ID in the mutation.
  14906. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  14907. if m.message_contact != nil {
  14908. return *m.message_contact, true
  14909. }
  14910. return
  14911. }
  14912. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  14913. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14914. // MessageContactID instead. It exists only for internal usage by the builders.
  14915. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  14916. if id := m.message_contact; id != nil {
  14917. ids = append(ids, *id)
  14918. }
  14919. return
  14920. }
  14921. // ResetMessageContact resets all changes to the "message_contact" edge.
  14922. func (m *MessageRecordsMutation) ResetMessageContact() {
  14923. m.message_contact = nil
  14924. m.clearedmessage_contact = false
  14925. }
  14926. // Where appends a list predicates to the MessageRecordsMutation builder.
  14927. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  14928. m.predicates = append(m.predicates, ps...)
  14929. }
  14930. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  14931. // users can use type-assertion to append predicates that do not depend on any generated package.
  14932. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  14933. p := make([]predicate.MessageRecords, len(ps))
  14934. for i := range ps {
  14935. p[i] = ps[i]
  14936. }
  14937. m.Where(p...)
  14938. }
  14939. // Op returns the operation name.
  14940. func (m *MessageRecordsMutation) Op() Op {
  14941. return m.op
  14942. }
  14943. // SetOp allows setting the mutation operation.
  14944. func (m *MessageRecordsMutation) SetOp(op Op) {
  14945. m.op = op
  14946. }
  14947. // Type returns the node type of this mutation (MessageRecords).
  14948. func (m *MessageRecordsMutation) Type() string {
  14949. return m.typ
  14950. }
  14951. // Fields returns all fields that were changed during this mutation. Note that in
  14952. // order to get all numeric fields that were incremented/decremented, call
  14953. // AddedFields().
  14954. func (m *MessageRecordsMutation) Fields() []string {
  14955. fields := make([]string, 0, 16)
  14956. if m.created_at != nil {
  14957. fields = append(fields, messagerecords.FieldCreatedAt)
  14958. }
  14959. if m.updated_at != nil {
  14960. fields = append(fields, messagerecords.FieldUpdatedAt)
  14961. }
  14962. if m.status != nil {
  14963. fields = append(fields, messagerecords.FieldStatus)
  14964. }
  14965. if m.bot_wxid != nil {
  14966. fields = append(fields, messagerecords.FieldBotWxid)
  14967. }
  14968. if m.message_contact != nil {
  14969. fields = append(fields, messagerecords.FieldContactID)
  14970. }
  14971. if m.contact_type != nil {
  14972. fields = append(fields, messagerecords.FieldContactType)
  14973. }
  14974. if m.contact_wxid != nil {
  14975. fields = append(fields, messagerecords.FieldContactWxid)
  14976. }
  14977. if m.content_type != nil {
  14978. fields = append(fields, messagerecords.FieldContentType)
  14979. }
  14980. if m.content != nil {
  14981. fields = append(fields, messagerecords.FieldContent)
  14982. }
  14983. if m.meta != nil {
  14984. fields = append(fields, messagerecords.FieldMeta)
  14985. }
  14986. if m.error_detail != nil {
  14987. fields = append(fields, messagerecords.FieldErrorDetail)
  14988. }
  14989. if m.send_time != nil {
  14990. fields = append(fields, messagerecords.FieldSendTime)
  14991. }
  14992. if m.source_type != nil {
  14993. fields = append(fields, messagerecords.FieldSourceType)
  14994. }
  14995. if m.sop_stage != nil {
  14996. fields = append(fields, messagerecords.FieldSourceID)
  14997. }
  14998. if m.sop_node != nil {
  14999. fields = append(fields, messagerecords.FieldSubSourceID)
  15000. }
  15001. if m.organization_id != nil {
  15002. fields = append(fields, messagerecords.FieldOrganizationID)
  15003. }
  15004. return fields
  15005. }
  15006. // Field returns the value of a field with the given name. The second boolean
  15007. // return value indicates that this field was not set, or was not defined in the
  15008. // schema.
  15009. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  15010. switch name {
  15011. case messagerecords.FieldCreatedAt:
  15012. return m.CreatedAt()
  15013. case messagerecords.FieldUpdatedAt:
  15014. return m.UpdatedAt()
  15015. case messagerecords.FieldStatus:
  15016. return m.Status()
  15017. case messagerecords.FieldBotWxid:
  15018. return m.BotWxid()
  15019. case messagerecords.FieldContactID:
  15020. return m.ContactID()
  15021. case messagerecords.FieldContactType:
  15022. return m.ContactType()
  15023. case messagerecords.FieldContactWxid:
  15024. return m.ContactWxid()
  15025. case messagerecords.FieldContentType:
  15026. return m.ContentType()
  15027. case messagerecords.FieldContent:
  15028. return m.Content()
  15029. case messagerecords.FieldMeta:
  15030. return m.Meta()
  15031. case messagerecords.FieldErrorDetail:
  15032. return m.ErrorDetail()
  15033. case messagerecords.FieldSendTime:
  15034. return m.SendTime()
  15035. case messagerecords.FieldSourceType:
  15036. return m.SourceType()
  15037. case messagerecords.FieldSourceID:
  15038. return m.SourceID()
  15039. case messagerecords.FieldSubSourceID:
  15040. return m.SubSourceID()
  15041. case messagerecords.FieldOrganizationID:
  15042. return m.OrganizationID()
  15043. }
  15044. return nil, false
  15045. }
  15046. // OldField returns the old value of the field from the database. An error is
  15047. // returned if the mutation operation is not UpdateOne, or the query to the
  15048. // database failed.
  15049. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15050. switch name {
  15051. case messagerecords.FieldCreatedAt:
  15052. return m.OldCreatedAt(ctx)
  15053. case messagerecords.FieldUpdatedAt:
  15054. return m.OldUpdatedAt(ctx)
  15055. case messagerecords.FieldStatus:
  15056. return m.OldStatus(ctx)
  15057. case messagerecords.FieldBotWxid:
  15058. return m.OldBotWxid(ctx)
  15059. case messagerecords.FieldContactID:
  15060. return m.OldContactID(ctx)
  15061. case messagerecords.FieldContactType:
  15062. return m.OldContactType(ctx)
  15063. case messagerecords.FieldContactWxid:
  15064. return m.OldContactWxid(ctx)
  15065. case messagerecords.FieldContentType:
  15066. return m.OldContentType(ctx)
  15067. case messagerecords.FieldContent:
  15068. return m.OldContent(ctx)
  15069. case messagerecords.FieldMeta:
  15070. return m.OldMeta(ctx)
  15071. case messagerecords.FieldErrorDetail:
  15072. return m.OldErrorDetail(ctx)
  15073. case messagerecords.FieldSendTime:
  15074. return m.OldSendTime(ctx)
  15075. case messagerecords.FieldSourceType:
  15076. return m.OldSourceType(ctx)
  15077. case messagerecords.FieldSourceID:
  15078. return m.OldSourceID(ctx)
  15079. case messagerecords.FieldSubSourceID:
  15080. return m.OldSubSourceID(ctx)
  15081. case messagerecords.FieldOrganizationID:
  15082. return m.OldOrganizationID(ctx)
  15083. }
  15084. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  15085. }
  15086. // SetField sets the value of a field with the given name. It returns an error if
  15087. // the field is not defined in the schema, or if the type mismatched the field
  15088. // type.
  15089. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  15090. switch name {
  15091. case messagerecords.FieldCreatedAt:
  15092. v, ok := value.(time.Time)
  15093. if !ok {
  15094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15095. }
  15096. m.SetCreatedAt(v)
  15097. return nil
  15098. case messagerecords.FieldUpdatedAt:
  15099. v, ok := value.(time.Time)
  15100. if !ok {
  15101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15102. }
  15103. m.SetUpdatedAt(v)
  15104. return nil
  15105. case messagerecords.FieldStatus:
  15106. v, ok := value.(uint8)
  15107. if !ok {
  15108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15109. }
  15110. m.SetStatus(v)
  15111. return nil
  15112. case messagerecords.FieldBotWxid:
  15113. v, ok := value.(string)
  15114. if !ok {
  15115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15116. }
  15117. m.SetBotWxid(v)
  15118. return nil
  15119. case messagerecords.FieldContactID:
  15120. v, ok := value.(uint64)
  15121. if !ok {
  15122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15123. }
  15124. m.SetContactID(v)
  15125. return nil
  15126. case messagerecords.FieldContactType:
  15127. v, ok := value.(int)
  15128. if !ok {
  15129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15130. }
  15131. m.SetContactType(v)
  15132. return nil
  15133. case messagerecords.FieldContactWxid:
  15134. v, ok := value.(string)
  15135. if !ok {
  15136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15137. }
  15138. m.SetContactWxid(v)
  15139. return nil
  15140. case messagerecords.FieldContentType:
  15141. v, ok := value.(int)
  15142. if !ok {
  15143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15144. }
  15145. m.SetContentType(v)
  15146. return nil
  15147. case messagerecords.FieldContent:
  15148. v, ok := value.(string)
  15149. if !ok {
  15150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15151. }
  15152. m.SetContent(v)
  15153. return nil
  15154. case messagerecords.FieldMeta:
  15155. v, ok := value.(custom_types.Meta)
  15156. if !ok {
  15157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15158. }
  15159. m.SetMeta(v)
  15160. return nil
  15161. case messagerecords.FieldErrorDetail:
  15162. v, ok := value.(string)
  15163. if !ok {
  15164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15165. }
  15166. m.SetErrorDetail(v)
  15167. return nil
  15168. case messagerecords.FieldSendTime:
  15169. v, ok := value.(time.Time)
  15170. if !ok {
  15171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15172. }
  15173. m.SetSendTime(v)
  15174. return nil
  15175. case messagerecords.FieldSourceType:
  15176. v, ok := value.(int)
  15177. if !ok {
  15178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15179. }
  15180. m.SetSourceType(v)
  15181. return nil
  15182. case messagerecords.FieldSourceID:
  15183. v, ok := value.(uint64)
  15184. if !ok {
  15185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15186. }
  15187. m.SetSourceID(v)
  15188. return nil
  15189. case messagerecords.FieldSubSourceID:
  15190. v, ok := value.(uint64)
  15191. if !ok {
  15192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15193. }
  15194. m.SetSubSourceID(v)
  15195. return nil
  15196. case messagerecords.FieldOrganizationID:
  15197. v, ok := value.(uint64)
  15198. if !ok {
  15199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15200. }
  15201. m.SetOrganizationID(v)
  15202. return nil
  15203. }
  15204. return fmt.Errorf("unknown MessageRecords field %s", name)
  15205. }
  15206. // AddedFields returns all numeric fields that were incremented/decremented during
  15207. // this mutation.
  15208. func (m *MessageRecordsMutation) AddedFields() []string {
  15209. var fields []string
  15210. if m.addstatus != nil {
  15211. fields = append(fields, messagerecords.FieldStatus)
  15212. }
  15213. if m.addcontact_type != nil {
  15214. fields = append(fields, messagerecords.FieldContactType)
  15215. }
  15216. if m.addcontent_type != nil {
  15217. fields = append(fields, messagerecords.FieldContentType)
  15218. }
  15219. if m.addsource_type != nil {
  15220. fields = append(fields, messagerecords.FieldSourceType)
  15221. }
  15222. if m.addorganization_id != nil {
  15223. fields = append(fields, messagerecords.FieldOrganizationID)
  15224. }
  15225. return fields
  15226. }
  15227. // AddedField returns the numeric value that was incremented/decremented on a field
  15228. // with the given name. The second boolean return value indicates that this field
  15229. // was not set, or was not defined in the schema.
  15230. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  15231. switch name {
  15232. case messagerecords.FieldStatus:
  15233. return m.AddedStatus()
  15234. case messagerecords.FieldContactType:
  15235. return m.AddedContactType()
  15236. case messagerecords.FieldContentType:
  15237. return m.AddedContentType()
  15238. case messagerecords.FieldSourceType:
  15239. return m.AddedSourceType()
  15240. case messagerecords.FieldOrganizationID:
  15241. return m.AddedOrganizationID()
  15242. }
  15243. return nil, false
  15244. }
  15245. // AddField adds the value to the field with the given name. It returns an error if
  15246. // the field is not defined in the schema, or if the type mismatched the field
  15247. // type.
  15248. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  15249. switch name {
  15250. case messagerecords.FieldStatus:
  15251. v, ok := value.(int8)
  15252. if !ok {
  15253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15254. }
  15255. m.AddStatus(v)
  15256. return nil
  15257. case messagerecords.FieldContactType:
  15258. v, ok := value.(int)
  15259. if !ok {
  15260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15261. }
  15262. m.AddContactType(v)
  15263. return nil
  15264. case messagerecords.FieldContentType:
  15265. v, ok := value.(int)
  15266. if !ok {
  15267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15268. }
  15269. m.AddContentType(v)
  15270. return nil
  15271. case messagerecords.FieldSourceType:
  15272. v, ok := value.(int)
  15273. if !ok {
  15274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15275. }
  15276. m.AddSourceType(v)
  15277. return nil
  15278. case messagerecords.FieldOrganizationID:
  15279. v, ok := value.(int64)
  15280. if !ok {
  15281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15282. }
  15283. m.AddOrganizationID(v)
  15284. return nil
  15285. }
  15286. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  15287. }
  15288. // ClearedFields returns all nullable fields that were cleared during this
  15289. // mutation.
  15290. func (m *MessageRecordsMutation) ClearedFields() []string {
  15291. var fields []string
  15292. if m.FieldCleared(messagerecords.FieldStatus) {
  15293. fields = append(fields, messagerecords.FieldStatus)
  15294. }
  15295. if m.FieldCleared(messagerecords.FieldContactID) {
  15296. fields = append(fields, messagerecords.FieldContactID)
  15297. }
  15298. if m.FieldCleared(messagerecords.FieldMeta) {
  15299. fields = append(fields, messagerecords.FieldMeta)
  15300. }
  15301. if m.FieldCleared(messagerecords.FieldSendTime) {
  15302. fields = append(fields, messagerecords.FieldSendTime)
  15303. }
  15304. if m.FieldCleared(messagerecords.FieldSourceID) {
  15305. fields = append(fields, messagerecords.FieldSourceID)
  15306. }
  15307. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  15308. fields = append(fields, messagerecords.FieldSubSourceID)
  15309. }
  15310. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  15311. fields = append(fields, messagerecords.FieldOrganizationID)
  15312. }
  15313. return fields
  15314. }
  15315. // FieldCleared returns a boolean indicating if a field with the given name was
  15316. // cleared in this mutation.
  15317. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  15318. _, ok := m.clearedFields[name]
  15319. return ok
  15320. }
  15321. // ClearField clears the value of the field with the given name. It returns an
  15322. // error if the field is not defined in the schema.
  15323. func (m *MessageRecordsMutation) ClearField(name string) error {
  15324. switch name {
  15325. case messagerecords.FieldStatus:
  15326. m.ClearStatus()
  15327. return nil
  15328. case messagerecords.FieldContactID:
  15329. m.ClearContactID()
  15330. return nil
  15331. case messagerecords.FieldMeta:
  15332. m.ClearMeta()
  15333. return nil
  15334. case messagerecords.FieldSendTime:
  15335. m.ClearSendTime()
  15336. return nil
  15337. case messagerecords.FieldSourceID:
  15338. m.ClearSourceID()
  15339. return nil
  15340. case messagerecords.FieldSubSourceID:
  15341. m.ClearSubSourceID()
  15342. return nil
  15343. case messagerecords.FieldOrganizationID:
  15344. m.ClearOrganizationID()
  15345. return nil
  15346. }
  15347. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  15348. }
  15349. // ResetField resets all changes in the mutation for the field with the given name.
  15350. // It returns an error if the field is not defined in the schema.
  15351. func (m *MessageRecordsMutation) ResetField(name string) error {
  15352. switch name {
  15353. case messagerecords.FieldCreatedAt:
  15354. m.ResetCreatedAt()
  15355. return nil
  15356. case messagerecords.FieldUpdatedAt:
  15357. m.ResetUpdatedAt()
  15358. return nil
  15359. case messagerecords.FieldStatus:
  15360. m.ResetStatus()
  15361. return nil
  15362. case messagerecords.FieldBotWxid:
  15363. m.ResetBotWxid()
  15364. return nil
  15365. case messagerecords.FieldContactID:
  15366. m.ResetContactID()
  15367. return nil
  15368. case messagerecords.FieldContactType:
  15369. m.ResetContactType()
  15370. return nil
  15371. case messagerecords.FieldContactWxid:
  15372. m.ResetContactWxid()
  15373. return nil
  15374. case messagerecords.FieldContentType:
  15375. m.ResetContentType()
  15376. return nil
  15377. case messagerecords.FieldContent:
  15378. m.ResetContent()
  15379. return nil
  15380. case messagerecords.FieldMeta:
  15381. m.ResetMeta()
  15382. return nil
  15383. case messagerecords.FieldErrorDetail:
  15384. m.ResetErrorDetail()
  15385. return nil
  15386. case messagerecords.FieldSendTime:
  15387. m.ResetSendTime()
  15388. return nil
  15389. case messagerecords.FieldSourceType:
  15390. m.ResetSourceType()
  15391. return nil
  15392. case messagerecords.FieldSourceID:
  15393. m.ResetSourceID()
  15394. return nil
  15395. case messagerecords.FieldSubSourceID:
  15396. m.ResetSubSourceID()
  15397. return nil
  15398. case messagerecords.FieldOrganizationID:
  15399. m.ResetOrganizationID()
  15400. return nil
  15401. }
  15402. return fmt.Errorf("unknown MessageRecords field %s", name)
  15403. }
  15404. // AddedEdges returns all edge names that were set/added in this mutation.
  15405. func (m *MessageRecordsMutation) AddedEdges() []string {
  15406. edges := make([]string, 0, 3)
  15407. if m.sop_stage != nil {
  15408. edges = append(edges, messagerecords.EdgeSopStage)
  15409. }
  15410. if m.sop_node != nil {
  15411. edges = append(edges, messagerecords.EdgeSopNode)
  15412. }
  15413. if m.message_contact != nil {
  15414. edges = append(edges, messagerecords.EdgeMessageContact)
  15415. }
  15416. return edges
  15417. }
  15418. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15419. // name in this mutation.
  15420. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  15421. switch name {
  15422. case messagerecords.EdgeSopStage:
  15423. if id := m.sop_stage; id != nil {
  15424. return []ent.Value{*id}
  15425. }
  15426. case messagerecords.EdgeSopNode:
  15427. if id := m.sop_node; id != nil {
  15428. return []ent.Value{*id}
  15429. }
  15430. case messagerecords.EdgeMessageContact:
  15431. if id := m.message_contact; id != nil {
  15432. return []ent.Value{*id}
  15433. }
  15434. }
  15435. return nil
  15436. }
  15437. // RemovedEdges returns all edge names that were removed in this mutation.
  15438. func (m *MessageRecordsMutation) RemovedEdges() []string {
  15439. edges := make([]string, 0, 3)
  15440. return edges
  15441. }
  15442. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15443. // the given name in this mutation.
  15444. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  15445. return nil
  15446. }
  15447. // ClearedEdges returns all edge names that were cleared in this mutation.
  15448. func (m *MessageRecordsMutation) ClearedEdges() []string {
  15449. edges := make([]string, 0, 3)
  15450. if m.clearedsop_stage {
  15451. edges = append(edges, messagerecords.EdgeSopStage)
  15452. }
  15453. if m.clearedsop_node {
  15454. edges = append(edges, messagerecords.EdgeSopNode)
  15455. }
  15456. if m.clearedmessage_contact {
  15457. edges = append(edges, messagerecords.EdgeMessageContact)
  15458. }
  15459. return edges
  15460. }
  15461. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15462. // was cleared in this mutation.
  15463. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  15464. switch name {
  15465. case messagerecords.EdgeSopStage:
  15466. return m.clearedsop_stage
  15467. case messagerecords.EdgeSopNode:
  15468. return m.clearedsop_node
  15469. case messagerecords.EdgeMessageContact:
  15470. return m.clearedmessage_contact
  15471. }
  15472. return false
  15473. }
  15474. // ClearEdge clears the value of the edge with the given name. It returns an error
  15475. // if that edge is not defined in the schema.
  15476. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  15477. switch name {
  15478. case messagerecords.EdgeSopStage:
  15479. m.ClearSopStage()
  15480. return nil
  15481. case messagerecords.EdgeSopNode:
  15482. m.ClearSopNode()
  15483. return nil
  15484. case messagerecords.EdgeMessageContact:
  15485. m.ClearMessageContact()
  15486. return nil
  15487. }
  15488. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  15489. }
  15490. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15491. // It returns an error if the edge is not defined in the schema.
  15492. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  15493. switch name {
  15494. case messagerecords.EdgeSopStage:
  15495. m.ResetSopStage()
  15496. return nil
  15497. case messagerecords.EdgeSopNode:
  15498. m.ResetSopNode()
  15499. return nil
  15500. case messagerecords.EdgeMessageContact:
  15501. m.ResetMessageContact()
  15502. return nil
  15503. }
  15504. return fmt.Errorf("unknown MessageRecords edge %s", name)
  15505. }
  15506. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  15507. type MsgMutation struct {
  15508. config
  15509. op Op
  15510. typ string
  15511. id *uint64
  15512. created_at *time.Time
  15513. updated_at *time.Time
  15514. deleted_at *time.Time
  15515. status *uint8
  15516. addstatus *int8
  15517. fromwxid *string
  15518. toid *string
  15519. msgtype *int32
  15520. addmsgtype *int32
  15521. msg *string
  15522. batch_no *string
  15523. clearedFields map[string]struct{}
  15524. done bool
  15525. oldValue func(context.Context) (*Msg, error)
  15526. predicates []predicate.Msg
  15527. }
  15528. var _ ent.Mutation = (*MsgMutation)(nil)
  15529. // msgOption allows management of the mutation configuration using functional options.
  15530. type msgOption func(*MsgMutation)
  15531. // newMsgMutation creates new mutation for the Msg entity.
  15532. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  15533. m := &MsgMutation{
  15534. config: c,
  15535. op: op,
  15536. typ: TypeMsg,
  15537. clearedFields: make(map[string]struct{}),
  15538. }
  15539. for _, opt := range opts {
  15540. opt(m)
  15541. }
  15542. return m
  15543. }
  15544. // withMsgID sets the ID field of the mutation.
  15545. func withMsgID(id uint64) msgOption {
  15546. return func(m *MsgMutation) {
  15547. var (
  15548. err error
  15549. once sync.Once
  15550. value *Msg
  15551. )
  15552. m.oldValue = func(ctx context.Context) (*Msg, error) {
  15553. once.Do(func() {
  15554. if m.done {
  15555. err = errors.New("querying old values post mutation is not allowed")
  15556. } else {
  15557. value, err = m.Client().Msg.Get(ctx, id)
  15558. }
  15559. })
  15560. return value, err
  15561. }
  15562. m.id = &id
  15563. }
  15564. }
  15565. // withMsg sets the old Msg of the mutation.
  15566. func withMsg(node *Msg) msgOption {
  15567. return func(m *MsgMutation) {
  15568. m.oldValue = func(context.Context) (*Msg, error) {
  15569. return node, nil
  15570. }
  15571. m.id = &node.ID
  15572. }
  15573. }
  15574. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15575. // executed in a transaction (ent.Tx), a transactional client is returned.
  15576. func (m MsgMutation) Client() *Client {
  15577. client := &Client{config: m.config}
  15578. client.init()
  15579. return client
  15580. }
  15581. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15582. // it returns an error otherwise.
  15583. func (m MsgMutation) Tx() (*Tx, error) {
  15584. if _, ok := m.driver.(*txDriver); !ok {
  15585. return nil, errors.New("ent: mutation is not running in a transaction")
  15586. }
  15587. tx := &Tx{config: m.config}
  15588. tx.init()
  15589. return tx, nil
  15590. }
  15591. // SetID sets the value of the id field. Note that this
  15592. // operation is only accepted on creation of Msg entities.
  15593. func (m *MsgMutation) SetID(id uint64) {
  15594. m.id = &id
  15595. }
  15596. // ID returns the ID value in the mutation. Note that the ID is only available
  15597. // if it was provided to the builder or after it was returned from the database.
  15598. func (m *MsgMutation) ID() (id uint64, exists bool) {
  15599. if m.id == nil {
  15600. return
  15601. }
  15602. return *m.id, true
  15603. }
  15604. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15605. // That means, if the mutation is applied within a transaction with an isolation level such
  15606. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15607. // or updated by the mutation.
  15608. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  15609. switch {
  15610. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15611. id, exists := m.ID()
  15612. if exists {
  15613. return []uint64{id}, nil
  15614. }
  15615. fallthrough
  15616. case m.op.Is(OpUpdate | OpDelete):
  15617. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  15618. default:
  15619. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15620. }
  15621. }
  15622. // SetCreatedAt sets the "created_at" field.
  15623. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  15624. m.created_at = &t
  15625. }
  15626. // CreatedAt returns the value of the "created_at" field in the mutation.
  15627. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  15628. v := m.created_at
  15629. if v == nil {
  15630. return
  15631. }
  15632. return *v, true
  15633. }
  15634. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  15635. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15637. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15638. if !m.op.Is(OpUpdateOne) {
  15639. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15640. }
  15641. if m.id == nil || m.oldValue == nil {
  15642. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15643. }
  15644. oldValue, err := m.oldValue(ctx)
  15645. if err != nil {
  15646. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15647. }
  15648. return oldValue.CreatedAt, nil
  15649. }
  15650. // ResetCreatedAt resets all changes to the "created_at" field.
  15651. func (m *MsgMutation) ResetCreatedAt() {
  15652. m.created_at = nil
  15653. }
  15654. // SetUpdatedAt sets the "updated_at" field.
  15655. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  15656. m.updated_at = &t
  15657. }
  15658. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15659. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  15660. v := m.updated_at
  15661. if v == nil {
  15662. return
  15663. }
  15664. return *v, true
  15665. }
  15666. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  15667. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15669. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15670. if !m.op.Is(OpUpdateOne) {
  15671. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15672. }
  15673. if m.id == nil || m.oldValue == nil {
  15674. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15675. }
  15676. oldValue, err := m.oldValue(ctx)
  15677. if err != nil {
  15678. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15679. }
  15680. return oldValue.UpdatedAt, nil
  15681. }
  15682. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15683. func (m *MsgMutation) ResetUpdatedAt() {
  15684. m.updated_at = nil
  15685. }
  15686. // SetDeletedAt sets the "deleted_at" field.
  15687. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  15688. m.deleted_at = &t
  15689. }
  15690. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15691. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  15692. v := m.deleted_at
  15693. if v == nil {
  15694. return
  15695. }
  15696. return *v, true
  15697. }
  15698. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  15699. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15700. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15701. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15702. if !m.op.Is(OpUpdateOne) {
  15703. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15704. }
  15705. if m.id == nil || m.oldValue == nil {
  15706. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15707. }
  15708. oldValue, err := m.oldValue(ctx)
  15709. if err != nil {
  15710. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15711. }
  15712. return oldValue.DeletedAt, nil
  15713. }
  15714. // ClearDeletedAt clears the value of the "deleted_at" field.
  15715. func (m *MsgMutation) ClearDeletedAt() {
  15716. m.deleted_at = nil
  15717. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  15718. }
  15719. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15720. func (m *MsgMutation) DeletedAtCleared() bool {
  15721. _, ok := m.clearedFields[msg.FieldDeletedAt]
  15722. return ok
  15723. }
  15724. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15725. func (m *MsgMutation) ResetDeletedAt() {
  15726. m.deleted_at = nil
  15727. delete(m.clearedFields, msg.FieldDeletedAt)
  15728. }
  15729. // SetStatus sets the "status" field.
  15730. func (m *MsgMutation) SetStatus(u uint8) {
  15731. m.status = &u
  15732. m.addstatus = nil
  15733. }
  15734. // Status returns the value of the "status" field in the mutation.
  15735. func (m *MsgMutation) Status() (r uint8, exists bool) {
  15736. v := m.status
  15737. if v == nil {
  15738. return
  15739. }
  15740. return *v, true
  15741. }
  15742. // OldStatus returns the old "status" field's value of the Msg entity.
  15743. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15744. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15745. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15746. if !m.op.Is(OpUpdateOne) {
  15747. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15748. }
  15749. if m.id == nil || m.oldValue == nil {
  15750. return v, errors.New("OldStatus requires an ID field in the mutation")
  15751. }
  15752. oldValue, err := m.oldValue(ctx)
  15753. if err != nil {
  15754. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15755. }
  15756. return oldValue.Status, nil
  15757. }
  15758. // AddStatus adds u to the "status" field.
  15759. func (m *MsgMutation) AddStatus(u int8) {
  15760. if m.addstatus != nil {
  15761. *m.addstatus += u
  15762. } else {
  15763. m.addstatus = &u
  15764. }
  15765. }
  15766. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15767. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  15768. v := m.addstatus
  15769. if v == nil {
  15770. return
  15771. }
  15772. return *v, true
  15773. }
  15774. // ClearStatus clears the value of the "status" field.
  15775. func (m *MsgMutation) ClearStatus() {
  15776. m.status = nil
  15777. m.addstatus = nil
  15778. m.clearedFields[msg.FieldStatus] = struct{}{}
  15779. }
  15780. // StatusCleared returns if the "status" field was cleared in this mutation.
  15781. func (m *MsgMutation) StatusCleared() bool {
  15782. _, ok := m.clearedFields[msg.FieldStatus]
  15783. return ok
  15784. }
  15785. // ResetStatus resets all changes to the "status" field.
  15786. func (m *MsgMutation) ResetStatus() {
  15787. m.status = nil
  15788. m.addstatus = nil
  15789. delete(m.clearedFields, msg.FieldStatus)
  15790. }
  15791. // SetFromwxid sets the "fromwxid" field.
  15792. func (m *MsgMutation) SetFromwxid(s string) {
  15793. m.fromwxid = &s
  15794. }
  15795. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  15796. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  15797. v := m.fromwxid
  15798. if v == nil {
  15799. return
  15800. }
  15801. return *v, true
  15802. }
  15803. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  15804. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15805. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15806. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  15807. if !m.op.Is(OpUpdateOne) {
  15808. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  15809. }
  15810. if m.id == nil || m.oldValue == nil {
  15811. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  15812. }
  15813. oldValue, err := m.oldValue(ctx)
  15814. if err != nil {
  15815. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  15816. }
  15817. return oldValue.Fromwxid, nil
  15818. }
  15819. // ClearFromwxid clears the value of the "fromwxid" field.
  15820. func (m *MsgMutation) ClearFromwxid() {
  15821. m.fromwxid = nil
  15822. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  15823. }
  15824. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  15825. func (m *MsgMutation) FromwxidCleared() bool {
  15826. _, ok := m.clearedFields[msg.FieldFromwxid]
  15827. return ok
  15828. }
  15829. // ResetFromwxid resets all changes to the "fromwxid" field.
  15830. func (m *MsgMutation) ResetFromwxid() {
  15831. m.fromwxid = nil
  15832. delete(m.clearedFields, msg.FieldFromwxid)
  15833. }
  15834. // SetToid sets the "toid" field.
  15835. func (m *MsgMutation) SetToid(s string) {
  15836. m.toid = &s
  15837. }
  15838. // Toid returns the value of the "toid" field in the mutation.
  15839. func (m *MsgMutation) Toid() (r string, exists bool) {
  15840. v := m.toid
  15841. if v == nil {
  15842. return
  15843. }
  15844. return *v, true
  15845. }
  15846. // OldToid returns the old "toid" field's value of the Msg entity.
  15847. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15848. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15849. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  15850. if !m.op.Is(OpUpdateOne) {
  15851. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  15852. }
  15853. if m.id == nil || m.oldValue == nil {
  15854. return v, errors.New("OldToid requires an ID field in the mutation")
  15855. }
  15856. oldValue, err := m.oldValue(ctx)
  15857. if err != nil {
  15858. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  15859. }
  15860. return oldValue.Toid, nil
  15861. }
  15862. // ClearToid clears the value of the "toid" field.
  15863. func (m *MsgMutation) ClearToid() {
  15864. m.toid = nil
  15865. m.clearedFields[msg.FieldToid] = struct{}{}
  15866. }
  15867. // ToidCleared returns if the "toid" field was cleared in this mutation.
  15868. func (m *MsgMutation) ToidCleared() bool {
  15869. _, ok := m.clearedFields[msg.FieldToid]
  15870. return ok
  15871. }
  15872. // ResetToid resets all changes to the "toid" field.
  15873. func (m *MsgMutation) ResetToid() {
  15874. m.toid = nil
  15875. delete(m.clearedFields, msg.FieldToid)
  15876. }
  15877. // SetMsgtype sets the "msgtype" field.
  15878. func (m *MsgMutation) SetMsgtype(i int32) {
  15879. m.msgtype = &i
  15880. m.addmsgtype = nil
  15881. }
  15882. // Msgtype returns the value of the "msgtype" field in the mutation.
  15883. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  15884. v := m.msgtype
  15885. if v == nil {
  15886. return
  15887. }
  15888. return *v, true
  15889. }
  15890. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  15891. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15892. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15893. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  15894. if !m.op.Is(OpUpdateOne) {
  15895. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  15896. }
  15897. if m.id == nil || m.oldValue == nil {
  15898. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  15899. }
  15900. oldValue, err := m.oldValue(ctx)
  15901. if err != nil {
  15902. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  15903. }
  15904. return oldValue.Msgtype, nil
  15905. }
  15906. // AddMsgtype adds i to the "msgtype" field.
  15907. func (m *MsgMutation) AddMsgtype(i int32) {
  15908. if m.addmsgtype != nil {
  15909. *m.addmsgtype += i
  15910. } else {
  15911. m.addmsgtype = &i
  15912. }
  15913. }
  15914. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  15915. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  15916. v := m.addmsgtype
  15917. if v == nil {
  15918. return
  15919. }
  15920. return *v, true
  15921. }
  15922. // ClearMsgtype clears the value of the "msgtype" field.
  15923. func (m *MsgMutation) ClearMsgtype() {
  15924. m.msgtype = nil
  15925. m.addmsgtype = nil
  15926. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  15927. }
  15928. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  15929. func (m *MsgMutation) MsgtypeCleared() bool {
  15930. _, ok := m.clearedFields[msg.FieldMsgtype]
  15931. return ok
  15932. }
  15933. // ResetMsgtype resets all changes to the "msgtype" field.
  15934. func (m *MsgMutation) ResetMsgtype() {
  15935. m.msgtype = nil
  15936. m.addmsgtype = nil
  15937. delete(m.clearedFields, msg.FieldMsgtype)
  15938. }
  15939. // SetMsg sets the "msg" field.
  15940. func (m *MsgMutation) SetMsg(s string) {
  15941. m.msg = &s
  15942. }
  15943. // Msg returns the value of the "msg" field in the mutation.
  15944. func (m *MsgMutation) Msg() (r string, exists bool) {
  15945. v := m.msg
  15946. if v == nil {
  15947. return
  15948. }
  15949. return *v, true
  15950. }
  15951. // OldMsg returns the old "msg" field's value of the Msg entity.
  15952. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15954. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  15955. if !m.op.Is(OpUpdateOne) {
  15956. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  15957. }
  15958. if m.id == nil || m.oldValue == nil {
  15959. return v, errors.New("OldMsg requires an ID field in the mutation")
  15960. }
  15961. oldValue, err := m.oldValue(ctx)
  15962. if err != nil {
  15963. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  15964. }
  15965. return oldValue.Msg, nil
  15966. }
  15967. // ClearMsg clears the value of the "msg" field.
  15968. func (m *MsgMutation) ClearMsg() {
  15969. m.msg = nil
  15970. m.clearedFields[msg.FieldMsg] = struct{}{}
  15971. }
  15972. // MsgCleared returns if the "msg" field was cleared in this mutation.
  15973. func (m *MsgMutation) MsgCleared() bool {
  15974. _, ok := m.clearedFields[msg.FieldMsg]
  15975. return ok
  15976. }
  15977. // ResetMsg resets all changes to the "msg" field.
  15978. func (m *MsgMutation) ResetMsg() {
  15979. m.msg = nil
  15980. delete(m.clearedFields, msg.FieldMsg)
  15981. }
  15982. // SetBatchNo sets the "batch_no" field.
  15983. func (m *MsgMutation) SetBatchNo(s string) {
  15984. m.batch_no = &s
  15985. }
  15986. // BatchNo returns the value of the "batch_no" field in the mutation.
  15987. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  15988. v := m.batch_no
  15989. if v == nil {
  15990. return
  15991. }
  15992. return *v, true
  15993. }
  15994. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  15995. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  15996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15997. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  15998. if !m.op.Is(OpUpdateOne) {
  15999. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  16000. }
  16001. if m.id == nil || m.oldValue == nil {
  16002. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  16003. }
  16004. oldValue, err := m.oldValue(ctx)
  16005. if err != nil {
  16006. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  16007. }
  16008. return oldValue.BatchNo, nil
  16009. }
  16010. // ClearBatchNo clears the value of the "batch_no" field.
  16011. func (m *MsgMutation) ClearBatchNo() {
  16012. m.batch_no = nil
  16013. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  16014. }
  16015. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  16016. func (m *MsgMutation) BatchNoCleared() bool {
  16017. _, ok := m.clearedFields[msg.FieldBatchNo]
  16018. return ok
  16019. }
  16020. // ResetBatchNo resets all changes to the "batch_no" field.
  16021. func (m *MsgMutation) ResetBatchNo() {
  16022. m.batch_no = nil
  16023. delete(m.clearedFields, msg.FieldBatchNo)
  16024. }
  16025. // Where appends a list predicates to the MsgMutation builder.
  16026. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  16027. m.predicates = append(m.predicates, ps...)
  16028. }
  16029. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  16030. // users can use type-assertion to append predicates that do not depend on any generated package.
  16031. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  16032. p := make([]predicate.Msg, len(ps))
  16033. for i := range ps {
  16034. p[i] = ps[i]
  16035. }
  16036. m.Where(p...)
  16037. }
  16038. // Op returns the operation name.
  16039. func (m *MsgMutation) Op() Op {
  16040. return m.op
  16041. }
  16042. // SetOp allows setting the mutation operation.
  16043. func (m *MsgMutation) SetOp(op Op) {
  16044. m.op = op
  16045. }
  16046. // Type returns the node type of this mutation (Msg).
  16047. func (m *MsgMutation) Type() string {
  16048. return m.typ
  16049. }
  16050. // Fields returns all fields that were changed during this mutation. Note that in
  16051. // order to get all numeric fields that were incremented/decremented, call
  16052. // AddedFields().
  16053. func (m *MsgMutation) Fields() []string {
  16054. fields := make([]string, 0, 9)
  16055. if m.created_at != nil {
  16056. fields = append(fields, msg.FieldCreatedAt)
  16057. }
  16058. if m.updated_at != nil {
  16059. fields = append(fields, msg.FieldUpdatedAt)
  16060. }
  16061. if m.deleted_at != nil {
  16062. fields = append(fields, msg.FieldDeletedAt)
  16063. }
  16064. if m.status != nil {
  16065. fields = append(fields, msg.FieldStatus)
  16066. }
  16067. if m.fromwxid != nil {
  16068. fields = append(fields, msg.FieldFromwxid)
  16069. }
  16070. if m.toid != nil {
  16071. fields = append(fields, msg.FieldToid)
  16072. }
  16073. if m.msgtype != nil {
  16074. fields = append(fields, msg.FieldMsgtype)
  16075. }
  16076. if m.msg != nil {
  16077. fields = append(fields, msg.FieldMsg)
  16078. }
  16079. if m.batch_no != nil {
  16080. fields = append(fields, msg.FieldBatchNo)
  16081. }
  16082. return fields
  16083. }
  16084. // Field returns the value of a field with the given name. The second boolean
  16085. // return value indicates that this field was not set, or was not defined in the
  16086. // schema.
  16087. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  16088. switch name {
  16089. case msg.FieldCreatedAt:
  16090. return m.CreatedAt()
  16091. case msg.FieldUpdatedAt:
  16092. return m.UpdatedAt()
  16093. case msg.FieldDeletedAt:
  16094. return m.DeletedAt()
  16095. case msg.FieldStatus:
  16096. return m.Status()
  16097. case msg.FieldFromwxid:
  16098. return m.Fromwxid()
  16099. case msg.FieldToid:
  16100. return m.Toid()
  16101. case msg.FieldMsgtype:
  16102. return m.Msgtype()
  16103. case msg.FieldMsg:
  16104. return m.Msg()
  16105. case msg.FieldBatchNo:
  16106. return m.BatchNo()
  16107. }
  16108. return nil, false
  16109. }
  16110. // OldField returns the old value of the field from the database. An error is
  16111. // returned if the mutation operation is not UpdateOne, or the query to the
  16112. // database failed.
  16113. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16114. switch name {
  16115. case msg.FieldCreatedAt:
  16116. return m.OldCreatedAt(ctx)
  16117. case msg.FieldUpdatedAt:
  16118. return m.OldUpdatedAt(ctx)
  16119. case msg.FieldDeletedAt:
  16120. return m.OldDeletedAt(ctx)
  16121. case msg.FieldStatus:
  16122. return m.OldStatus(ctx)
  16123. case msg.FieldFromwxid:
  16124. return m.OldFromwxid(ctx)
  16125. case msg.FieldToid:
  16126. return m.OldToid(ctx)
  16127. case msg.FieldMsgtype:
  16128. return m.OldMsgtype(ctx)
  16129. case msg.FieldMsg:
  16130. return m.OldMsg(ctx)
  16131. case msg.FieldBatchNo:
  16132. return m.OldBatchNo(ctx)
  16133. }
  16134. return nil, fmt.Errorf("unknown Msg field %s", name)
  16135. }
  16136. // SetField sets the value of a field with the given name. It returns an error if
  16137. // the field is not defined in the schema, or if the type mismatched the field
  16138. // type.
  16139. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  16140. switch name {
  16141. case msg.FieldCreatedAt:
  16142. v, ok := value.(time.Time)
  16143. if !ok {
  16144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16145. }
  16146. m.SetCreatedAt(v)
  16147. return nil
  16148. case msg.FieldUpdatedAt:
  16149. v, ok := value.(time.Time)
  16150. if !ok {
  16151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16152. }
  16153. m.SetUpdatedAt(v)
  16154. return nil
  16155. case msg.FieldDeletedAt:
  16156. v, ok := value.(time.Time)
  16157. if !ok {
  16158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16159. }
  16160. m.SetDeletedAt(v)
  16161. return nil
  16162. case msg.FieldStatus:
  16163. v, ok := value.(uint8)
  16164. if !ok {
  16165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16166. }
  16167. m.SetStatus(v)
  16168. return nil
  16169. case msg.FieldFromwxid:
  16170. v, ok := value.(string)
  16171. if !ok {
  16172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16173. }
  16174. m.SetFromwxid(v)
  16175. return nil
  16176. case msg.FieldToid:
  16177. v, ok := value.(string)
  16178. if !ok {
  16179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16180. }
  16181. m.SetToid(v)
  16182. return nil
  16183. case msg.FieldMsgtype:
  16184. v, ok := value.(int32)
  16185. if !ok {
  16186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16187. }
  16188. m.SetMsgtype(v)
  16189. return nil
  16190. case msg.FieldMsg:
  16191. v, ok := value.(string)
  16192. if !ok {
  16193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16194. }
  16195. m.SetMsg(v)
  16196. return nil
  16197. case msg.FieldBatchNo:
  16198. v, ok := value.(string)
  16199. if !ok {
  16200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16201. }
  16202. m.SetBatchNo(v)
  16203. return nil
  16204. }
  16205. return fmt.Errorf("unknown Msg field %s", name)
  16206. }
  16207. // AddedFields returns all numeric fields that were incremented/decremented during
  16208. // this mutation.
  16209. func (m *MsgMutation) AddedFields() []string {
  16210. var fields []string
  16211. if m.addstatus != nil {
  16212. fields = append(fields, msg.FieldStatus)
  16213. }
  16214. if m.addmsgtype != nil {
  16215. fields = append(fields, msg.FieldMsgtype)
  16216. }
  16217. return fields
  16218. }
  16219. // AddedField returns the numeric value that was incremented/decremented on a field
  16220. // with the given name. The second boolean return value indicates that this field
  16221. // was not set, or was not defined in the schema.
  16222. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  16223. switch name {
  16224. case msg.FieldStatus:
  16225. return m.AddedStatus()
  16226. case msg.FieldMsgtype:
  16227. return m.AddedMsgtype()
  16228. }
  16229. return nil, false
  16230. }
  16231. // AddField adds the value to the field with the given name. It returns an error if
  16232. // the field is not defined in the schema, or if the type mismatched the field
  16233. // type.
  16234. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  16235. switch name {
  16236. case msg.FieldStatus:
  16237. v, ok := value.(int8)
  16238. if !ok {
  16239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16240. }
  16241. m.AddStatus(v)
  16242. return nil
  16243. case msg.FieldMsgtype:
  16244. v, ok := value.(int32)
  16245. if !ok {
  16246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16247. }
  16248. m.AddMsgtype(v)
  16249. return nil
  16250. }
  16251. return fmt.Errorf("unknown Msg numeric field %s", name)
  16252. }
  16253. // ClearedFields returns all nullable fields that were cleared during this
  16254. // mutation.
  16255. func (m *MsgMutation) ClearedFields() []string {
  16256. var fields []string
  16257. if m.FieldCleared(msg.FieldDeletedAt) {
  16258. fields = append(fields, msg.FieldDeletedAt)
  16259. }
  16260. if m.FieldCleared(msg.FieldStatus) {
  16261. fields = append(fields, msg.FieldStatus)
  16262. }
  16263. if m.FieldCleared(msg.FieldFromwxid) {
  16264. fields = append(fields, msg.FieldFromwxid)
  16265. }
  16266. if m.FieldCleared(msg.FieldToid) {
  16267. fields = append(fields, msg.FieldToid)
  16268. }
  16269. if m.FieldCleared(msg.FieldMsgtype) {
  16270. fields = append(fields, msg.FieldMsgtype)
  16271. }
  16272. if m.FieldCleared(msg.FieldMsg) {
  16273. fields = append(fields, msg.FieldMsg)
  16274. }
  16275. if m.FieldCleared(msg.FieldBatchNo) {
  16276. fields = append(fields, msg.FieldBatchNo)
  16277. }
  16278. return fields
  16279. }
  16280. // FieldCleared returns a boolean indicating if a field with the given name was
  16281. // cleared in this mutation.
  16282. func (m *MsgMutation) FieldCleared(name string) bool {
  16283. _, ok := m.clearedFields[name]
  16284. return ok
  16285. }
  16286. // ClearField clears the value of the field with the given name. It returns an
  16287. // error if the field is not defined in the schema.
  16288. func (m *MsgMutation) ClearField(name string) error {
  16289. switch name {
  16290. case msg.FieldDeletedAt:
  16291. m.ClearDeletedAt()
  16292. return nil
  16293. case msg.FieldStatus:
  16294. m.ClearStatus()
  16295. return nil
  16296. case msg.FieldFromwxid:
  16297. m.ClearFromwxid()
  16298. return nil
  16299. case msg.FieldToid:
  16300. m.ClearToid()
  16301. return nil
  16302. case msg.FieldMsgtype:
  16303. m.ClearMsgtype()
  16304. return nil
  16305. case msg.FieldMsg:
  16306. m.ClearMsg()
  16307. return nil
  16308. case msg.FieldBatchNo:
  16309. m.ClearBatchNo()
  16310. return nil
  16311. }
  16312. return fmt.Errorf("unknown Msg nullable field %s", name)
  16313. }
  16314. // ResetField resets all changes in the mutation for the field with the given name.
  16315. // It returns an error if the field is not defined in the schema.
  16316. func (m *MsgMutation) ResetField(name string) error {
  16317. switch name {
  16318. case msg.FieldCreatedAt:
  16319. m.ResetCreatedAt()
  16320. return nil
  16321. case msg.FieldUpdatedAt:
  16322. m.ResetUpdatedAt()
  16323. return nil
  16324. case msg.FieldDeletedAt:
  16325. m.ResetDeletedAt()
  16326. return nil
  16327. case msg.FieldStatus:
  16328. m.ResetStatus()
  16329. return nil
  16330. case msg.FieldFromwxid:
  16331. m.ResetFromwxid()
  16332. return nil
  16333. case msg.FieldToid:
  16334. m.ResetToid()
  16335. return nil
  16336. case msg.FieldMsgtype:
  16337. m.ResetMsgtype()
  16338. return nil
  16339. case msg.FieldMsg:
  16340. m.ResetMsg()
  16341. return nil
  16342. case msg.FieldBatchNo:
  16343. m.ResetBatchNo()
  16344. return nil
  16345. }
  16346. return fmt.Errorf("unknown Msg field %s", name)
  16347. }
  16348. // AddedEdges returns all edge names that were set/added in this mutation.
  16349. func (m *MsgMutation) AddedEdges() []string {
  16350. edges := make([]string, 0, 0)
  16351. return edges
  16352. }
  16353. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16354. // name in this mutation.
  16355. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  16356. return nil
  16357. }
  16358. // RemovedEdges returns all edge names that were removed in this mutation.
  16359. func (m *MsgMutation) RemovedEdges() []string {
  16360. edges := make([]string, 0, 0)
  16361. return edges
  16362. }
  16363. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16364. // the given name in this mutation.
  16365. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  16366. return nil
  16367. }
  16368. // ClearedEdges returns all edge names that were cleared in this mutation.
  16369. func (m *MsgMutation) ClearedEdges() []string {
  16370. edges := make([]string, 0, 0)
  16371. return edges
  16372. }
  16373. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16374. // was cleared in this mutation.
  16375. func (m *MsgMutation) EdgeCleared(name string) bool {
  16376. return false
  16377. }
  16378. // ClearEdge clears the value of the edge with the given name. It returns an error
  16379. // if that edge is not defined in the schema.
  16380. func (m *MsgMutation) ClearEdge(name string) error {
  16381. return fmt.Errorf("unknown Msg unique edge %s", name)
  16382. }
  16383. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16384. // It returns an error if the edge is not defined in the schema.
  16385. func (m *MsgMutation) ResetEdge(name string) error {
  16386. return fmt.Errorf("unknown Msg edge %s", name)
  16387. }
  16388. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  16389. type ServerMutation struct {
  16390. config
  16391. op Op
  16392. typ string
  16393. id *uint64
  16394. created_at *time.Time
  16395. updated_at *time.Time
  16396. status *uint8
  16397. addstatus *int8
  16398. deleted_at *time.Time
  16399. name *string
  16400. public_ip *string
  16401. private_ip *string
  16402. admin_port *string
  16403. clearedFields map[string]struct{}
  16404. wxs map[uint64]struct{}
  16405. removedwxs map[uint64]struct{}
  16406. clearedwxs bool
  16407. done bool
  16408. oldValue func(context.Context) (*Server, error)
  16409. predicates []predicate.Server
  16410. }
  16411. var _ ent.Mutation = (*ServerMutation)(nil)
  16412. // serverOption allows management of the mutation configuration using functional options.
  16413. type serverOption func(*ServerMutation)
  16414. // newServerMutation creates new mutation for the Server entity.
  16415. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  16416. m := &ServerMutation{
  16417. config: c,
  16418. op: op,
  16419. typ: TypeServer,
  16420. clearedFields: make(map[string]struct{}),
  16421. }
  16422. for _, opt := range opts {
  16423. opt(m)
  16424. }
  16425. return m
  16426. }
  16427. // withServerID sets the ID field of the mutation.
  16428. func withServerID(id uint64) serverOption {
  16429. return func(m *ServerMutation) {
  16430. var (
  16431. err error
  16432. once sync.Once
  16433. value *Server
  16434. )
  16435. m.oldValue = func(ctx context.Context) (*Server, error) {
  16436. once.Do(func() {
  16437. if m.done {
  16438. err = errors.New("querying old values post mutation is not allowed")
  16439. } else {
  16440. value, err = m.Client().Server.Get(ctx, id)
  16441. }
  16442. })
  16443. return value, err
  16444. }
  16445. m.id = &id
  16446. }
  16447. }
  16448. // withServer sets the old Server of the mutation.
  16449. func withServer(node *Server) serverOption {
  16450. return func(m *ServerMutation) {
  16451. m.oldValue = func(context.Context) (*Server, error) {
  16452. return node, nil
  16453. }
  16454. m.id = &node.ID
  16455. }
  16456. }
  16457. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16458. // executed in a transaction (ent.Tx), a transactional client is returned.
  16459. func (m ServerMutation) Client() *Client {
  16460. client := &Client{config: m.config}
  16461. client.init()
  16462. return client
  16463. }
  16464. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16465. // it returns an error otherwise.
  16466. func (m ServerMutation) Tx() (*Tx, error) {
  16467. if _, ok := m.driver.(*txDriver); !ok {
  16468. return nil, errors.New("ent: mutation is not running in a transaction")
  16469. }
  16470. tx := &Tx{config: m.config}
  16471. tx.init()
  16472. return tx, nil
  16473. }
  16474. // SetID sets the value of the id field. Note that this
  16475. // operation is only accepted on creation of Server entities.
  16476. func (m *ServerMutation) SetID(id uint64) {
  16477. m.id = &id
  16478. }
  16479. // ID returns the ID value in the mutation. Note that the ID is only available
  16480. // if it was provided to the builder or after it was returned from the database.
  16481. func (m *ServerMutation) ID() (id uint64, exists bool) {
  16482. if m.id == nil {
  16483. return
  16484. }
  16485. return *m.id, true
  16486. }
  16487. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16488. // That means, if the mutation is applied within a transaction with an isolation level such
  16489. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16490. // or updated by the mutation.
  16491. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  16492. switch {
  16493. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16494. id, exists := m.ID()
  16495. if exists {
  16496. return []uint64{id}, nil
  16497. }
  16498. fallthrough
  16499. case m.op.Is(OpUpdate | OpDelete):
  16500. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  16501. default:
  16502. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16503. }
  16504. }
  16505. // SetCreatedAt sets the "created_at" field.
  16506. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  16507. m.created_at = &t
  16508. }
  16509. // CreatedAt returns the value of the "created_at" field in the mutation.
  16510. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  16511. v := m.created_at
  16512. if v == nil {
  16513. return
  16514. }
  16515. return *v, true
  16516. }
  16517. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  16518. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16519. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16520. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16521. if !m.op.Is(OpUpdateOne) {
  16522. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16523. }
  16524. if m.id == nil || m.oldValue == nil {
  16525. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16526. }
  16527. oldValue, err := m.oldValue(ctx)
  16528. if err != nil {
  16529. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16530. }
  16531. return oldValue.CreatedAt, nil
  16532. }
  16533. // ResetCreatedAt resets all changes to the "created_at" field.
  16534. func (m *ServerMutation) ResetCreatedAt() {
  16535. m.created_at = nil
  16536. }
  16537. // SetUpdatedAt sets the "updated_at" field.
  16538. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  16539. m.updated_at = &t
  16540. }
  16541. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16542. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  16543. v := m.updated_at
  16544. if v == nil {
  16545. return
  16546. }
  16547. return *v, true
  16548. }
  16549. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  16550. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16551. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16552. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16553. if !m.op.Is(OpUpdateOne) {
  16554. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16555. }
  16556. if m.id == nil || m.oldValue == nil {
  16557. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16558. }
  16559. oldValue, err := m.oldValue(ctx)
  16560. if err != nil {
  16561. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16562. }
  16563. return oldValue.UpdatedAt, nil
  16564. }
  16565. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16566. func (m *ServerMutation) ResetUpdatedAt() {
  16567. m.updated_at = nil
  16568. }
  16569. // SetStatus sets the "status" field.
  16570. func (m *ServerMutation) SetStatus(u uint8) {
  16571. m.status = &u
  16572. m.addstatus = nil
  16573. }
  16574. // Status returns the value of the "status" field in the mutation.
  16575. func (m *ServerMutation) Status() (r uint8, exists bool) {
  16576. v := m.status
  16577. if v == nil {
  16578. return
  16579. }
  16580. return *v, true
  16581. }
  16582. // OldStatus returns the old "status" field's value of the Server entity.
  16583. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16585. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16586. if !m.op.Is(OpUpdateOne) {
  16587. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16588. }
  16589. if m.id == nil || m.oldValue == nil {
  16590. return v, errors.New("OldStatus requires an ID field in the mutation")
  16591. }
  16592. oldValue, err := m.oldValue(ctx)
  16593. if err != nil {
  16594. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16595. }
  16596. return oldValue.Status, nil
  16597. }
  16598. // AddStatus adds u to the "status" field.
  16599. func (m *ServerMutation) AddStatus(u int8) {
  16600. if m.addstatus != nil {
  16601. *m.addstatus += u
  16602. } else {
  16603. m.addstatus = &u
  16604. }
  16605. }
  16606. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16607. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  16608. v := m.addstatus
  16609. if v == nil {
  16610. return
  16611. }
  16612. return *v, true
  16613. }
  16614. // ClearStatus clears the value of the "status" field.
  16615. func (m *ServerMutation) ClearStatus() {
  16616. m.status = nil
  16617. m.addstatus = nil
  16618. m.clearedFields[server.FieldStatus] = struct{}{}
  16619. }
  16620. // StatusCleared returns if the "status" field was cleared in this mutation.
  16621. func (m *ServerMutation) StatusCleared() bool {
  16622. _, ok := m.clearedFields[server.FieldStatus]
  16623. return ok
  16624. }
  16625. // ResetStatus resets all changes to the "status" field.
  16626. func (m *ServerMutation) ResetStatus() {
  16627. m.status = nil
  16628. m.addstatus = nil
  16629. delete(m.clearedFields, server.FieldStatus)
  16630. }
  16631. // SetDeletedAt sets the "deleted_at" field.
  16632. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  16633. m.deleted_at = &t
  16634. }
  16635. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  16636. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  16637. v := m.deleted_at
  16638. if v == nil {
  16639. return
  16640. }
  16641. return *v, true
  16642. }
  16643. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  16644. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16646. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  16647. if !m.op.Is(OpUpdateOne) {
  16648. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  16649. }
  16650. if m.id == nil || m.oldValue == nil {
  16651. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  16652. }
  16653. oldValue, err := m.oldValue(ctx)
  16654. if err != nil {
  16655. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  16656. }
  16657. return oldValue.DeletedAt, nil
  16658. }
  16659. // ClearDeletedAt clears the value of the "deleted_at" field.
  16660. func (m *ServerMutation) ClearDeletedAt() {
  16661. m.deleted_at = nil
  16662. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  16663. }
  16664. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  16665. func (m *ServerMutation) DeletedAtCleared() bool {
  16666. _, ok := m.clearedFields[server.FieldDeletedAt]
  16667. return ok
  16668. }
  16669. // ResetDeletedAt resets all changes to the "deleted_at" field.
  16670. func (m *ServerMutation) ResetDeletedAt() {
  16671. m.deleted_at = nil
  16672. delete(m.clearedFields, server.FieldDeletedAt)
  16673. }
  16674. // SetName sets the "name" field.
  16675. func (m *ServerMutation) SetName(s string) {
  16676. m.name = &s
  16677. }
  16678. // Name returns the value of the "name" field in the mutation.
  16679. func (m *ServerMutation) Name() (r string, exists bool) {
  16680. v := m.name
  16681. if v == nil {
  16682. return
  16683. }
  16684. return *v, true
  16685. }
  16686. // OldName returns the old "name" field's value of the Server entity.
  16687. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16689. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  16690. if !m.op.Is(OpUpdateOne) {
  16691. return v, errors.New("OldName is only allowed on UpdateOne operations")
  16692. }
  16693. if m.id == nil || m.oldValue == nil {
  16694. return v, errors.New("OldName requires an ID field in the mutation")
  16695. }
  16696. oldValue, err := m.oldValue(ctx)
  16697. if err != nil {
  16698. return v, fmt.Errorf("querying old value for OldName: %w", err)
  16699. }
  16700. return oldValue.Name, nil
  16701. }
  16702. // ResetName resets all changes to the "name" field.
  16703. func (m *ServerMutation) ResetName() {
  16704. m.name = nil
  16705. }
  16706. // SetPublicIP sets the "public_ip" field.
  16707. func (m *ServerMutation) SetPublicIP(s string) {
  16708. m.public_ip = &s
  16709. }
  16710. // PublicIP returns the value of the "public_ip" field in the mutation.
  16711. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  16712. v := m.public_ip
  16713. if v == nil {
  16714. return
  16715. }
  16716. return *v, true
  16717. }
  16718. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  16719. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16721. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  16722. if !m.op.Is(OpUpdateOne) {
  16723. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  16724. }
  16725. if m.id == nil || m.oldValue == nil {
  16726. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  16727. }
  16728. oldValue, err := m.oldValue(ctx)
  16729. if err != nil {
  16730. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  16731. }
  16732. return oldValue.PublicIP, nil
  16733. }
  16734. // ResetPublicIP resets all changes to the "public_ip" field.
  16735. func (m *ServerMutation) ResetPublicIP() {
  16736. m.public_ip = nil
  16737. }
  16738. // SetPrivateIP sets the "private_ip" field.
  16739. func (m *ServerMutation) SetPrivateIP(s string) {
  16740. m.private_ip = &s
  16741. }
  16742. // PrivateIP returns the value of the "private_ip" field in the mutation.
  16743. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  16744. v := m.private_ip
  16745. if v == nil {
  16746. return
  16747. }
  16748. return *v, true
  16749. }
  16750. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  16751. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16752. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16753. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  16754. if !m.op.Is(OpUpdateOne) {
  16755. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  16756. }
  16757. if m.id == nil || m.oldValue == nil {
  16758. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  16759. }
  16760. oldValue, err := m.oldValue(ctx)
  16761. if err != nil {
  16762. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  16763. }
  16764. return oldValue.PrivateIP, nil
  16765. }
  16766. // ResetPrivateIP resets all changes to the "private_ip" field.
  16767. func (m *ServerMutation) ResetPrivateIP() {
  16768. m.private_ip = nil
  16769. }
  16770. // SetAdminPort sets the "admin_port" field.
  16771. func (m *ServerMutation) SetAdminPort(s string) {
  16772. m.admin_port = &s
  16773. }
  16774. // AdminPort returns the value of the "admin_port" field in the mutation.
  16775. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  16776. v := m.admin_port
  16777. if v == nil {
  16778. return
  16779. }
  16780. return *v, true
  16781. }
  16782. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  16783. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  16784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16785. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  16786. if !m.op.Is(OpUpdateOne) {
  16787. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  16788. }
  16789. if m.id == nil || m.oldValue == nil {
  16790. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  16791. }
  16792. oldValue, err := m.oldValue(ctx)
  16793. if err != nil {
  16794. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  16795. }
  16796. return oldValue.AdminPort, nil
  16797. }
  16798. // ResetAdminPort resets all changes to the "admin_port" field.
  16799. func (m *ServerMutation) ResetAdminPort() {
  16800. m.admin_port = nil
  16801. }
  16802. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  16803. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  16804. if m.wxs == nil {
  16805. m.wxs = make(map[uint64]struct{})
  16806. }
  16807. for i := range ids {
  16808. m.wxs[ids[i]] = struct{}{}
  16809. }
  16810. }
  16811. // ClearWxs clears the "wxs" edge to the Wx entity.
  16812. func (m *ServerMutation) ClearWxs() {
  16813. m.clearedwxs = true
  16814. }
  16815. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  16816. func (m *ServerMutation) WxsCleared() bool {
  16817. return m.clearedwxs
  16818. }
  16819. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  16820. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  16821. if m.removedwxs == nil {
  16822. m.removedwxs = make(map[uint64]struct{})
  16823. }
  16824. for i := range ids {
  16825. delete(m.wxs, ids[i])
  16826. m.removedwxs[ids[i]] = struct{}{}
  16827. }
  16828. }
  16829. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  16830. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  16831. for id := range m.removedwxs {
  16832. ids = append(ids, id)
  16833. }
  16834. return
  16835. }
  16836. // WxsIDs returns the "wxs" edge IDs in the mutation.
  16837. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  16838. for id := range m.wxs {
  16839. ids = append(ids, id)
  16840. }
  16841. return
  16842. }
  16843. // ResetWxs resets all changes to the "wxs" edge.
  16844. func (m *ServerMutation) ResetWxs() {
  16845. m.wxs = nil
  16846. m.clearedwxs = false
  16847. m.removedwxs = nil
  16848. }
  16849. // Where appends a list predicates to the ServerMutation builder.
  16850. func (m *ServerMutation) Where(ps ...predicate.Server) {
  16851. m.predicates = append(m.predicates, ps...)
  16852. }
  16853. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  16854. // users can use type-assertion to append predicates that do not depend on any generated package.
  16855. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  16856. p := make([]predicate.Server, len(ps))
  16857. for i := range ps {
  16858. p[i] = ps[i]
  16859. }
  16860. m.Where(p...)
  16861. }
  16862. // Op returns the operation name.
  16863. func (m *ServerMutation) Op() Op {
  16864. return m.op
  16865. }
  16866. // SetOp allows setting the mutation operation.
  16867. func (m *ServerMutation) SetOp(op Op) {
  16868. m.op = op
  16869. }
  16870. // Type returns the node type of this mutation (Server).
  16871. func (m *ServerMutation) Type() string {
  16872. return m.typ
  16873. }
  16874. // Fields returns all fields that were changed during this mutation. Note that in
  16875. // order to get all numeric fields that were incremented/decremented, call
  16876. // AddedFields().
  16877. func (m *ServerMutation) Fields() []string {
  16878. fields := make([]string, 0, 8)
  16879. if m.created_at != nil {
  16880. fields = append(fields, server.FieldCreatedAt)
  16881. }
  16882. if m.updated_at != nil {
  16883. fields = append(fields, server.FieldUpdatedAt)
  16884. }
  16885. if m.status != nil {
  16886. fields = append(fields, server.FieldStatus)
  16887. }
  16888. if m.deleted_at != nil {
  16889. fields = append(fields, server.FieldDeletedAt)
  16890. }
  16891. if m.name != nil {
  16892. fields = append(fields, server.FieldName)
  16893. }
  16894. if m.public_ip != nil {
  16895. fields = append(fields, server.FieldPublicIP)
  16896. }
  16897. if m.private_ip != nil {
  16898. fields = append(fields, server.FieldPrivateIP)
  16899. }
  16900. if m.admin_port != nil {
  16901. fields = append(fields, server.FieldAdminPort)
  16902. }
  16903. return fields
  16904. }
  16905. // Field returns the value of a field with the given name. The second boolean
  16906. // return value indicates that this field was not set, or was not defined in the
  16907. // schema.
  16908. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  16909. switch name {
  16910. case server.FieldCreatedAt:
  16911. return m.CreatedAt()
  16912. case server.FieldUpdatedAt:
  16913. return m.UpdatedAt()
  16914. case server.FieldStatus:
  16915. return m.Status()
  16916. case server.FieldDeletedAt:
  16917. return m.DeletedAt()
  16918. case server.FieldName:
  16919. return m.Name()
  16920. case server.FieldPublicIP:
  16921. return m.PublicIP()
  16922. case server.FieldPrivateIP:
  16923. return m.PrivateIP()
  16924. case server.FieldAdminPort:
  16925. return m.AdminPort()
  16926. }
  16927. return nil, false
  16928. }
  16929. // OldField returns the old value of the field from the database. An error is
  16930. // returned if the mutation operation is not UpdateOne, or the query to the
  16931. // database failed.
  16932. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16933. switch name {
  16934. case server.FieldCreatedAt:
  16935. return m.OldCreatedAt(ctx)
  16936. case server.FieldUpdatedAt:
  16937. return m.OldUpdatedAt(ctx)
  16938. case server.FieldStatus:
  16939. return m.OldStatus(ctx)
  16940. case server.FieldDeletedAt:
  16941. return m.OldDeletedAt(ctx)
  16942. case server.FieldName:
  16943. return m.OldName(ctx)
  16944. case server.FieldPublicIP:
  16945. return m.OldPublicIP(ctx)
  16946. case server.FieldPrivateIP:
  16947. return m.OldPrivateIP(ctx)
  16948. case server.FieldAdminPort:
  16949. return m.OldAdminPort(ctx)
  16950. }
  16951. return nil, fmt.Errorf("unknown Server field %s", name)
  16952. }
  16953. // SetField sets the value of a field with the given name. It returns an error if
  16954. // the field is not defined in the schema, or if the type mismatched the field
  16955. // type.
  16956. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  16957. switch name {
  16958. case server.FieldCreatedAt:
  16959. v, ok := value.(time.Time)
  16960. if !ok {
  16961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16962. }
  16963. m.SetCreatedAt(v)
  16964. return nil
  16965. case server.FieldUpdatedAt:
  16966. v, ok := value.(time.Time)
  16967. if !ok {
  16968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16969. }
  16970. m.SetUpdatedAt(v)
  16971. return nil
  16972. case server.FieldStatus:
  16973. v, ok := value.(uint8)
  16974. if !ok {
  16975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16976. }
  16977. m.SetStatus(v)
  16978. return nil
  16979. case server.FieldDeletedAt:
  16980. v, ok := value.(time.Time)
  16981. if !ok {
  16982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16983. }
  16984. m.SetDeletedAt(v)
  16985. return nil
  16986. case server.FieldName:
  16987. v, ok := value.(string)
  16988. if !ok {
  16989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16990. }
  16991. m.SetName(v)
  16992. return nil
  16993. case server.FieldPublicIP:
  16994. v, ok := value.(string)
  16995. if !ok {
  16996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16997. }
  16998. m.SetPublicIP(v)
  16999. return nil
  17000. case server.FieldPrivateIP:
  17001. v, ok := value.(string)
  17002. if !ok {
  17003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17004. }
  17005. m.SetPrivateIP(v)
  17006. return nil
  17007. case server.FieldAdminPort:
  17008. v, ok := value.(string)
  17009. if !ok {
  17010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17011. }
  17012. m.SetAdminPort(v)
  17013. return nil
  17014. }
  17015. return fmt.Errorf("unknown Server field %s", name)
  17016. }
  17017. // AddedFields returns all numeric fields that were incremented/decremented during
  17018. // this mutation.
  17019. func (m *ServerMutation) AddedFields() []string {
  17020. var fields []string
  17021. if m.addstatus != nil {
  17022. fields = append(fields, server.FieldStatus)
  17023. }
  17024. return fields
  17025. }
  17026. // AddedField returns the numeric value that was incremented/decremented on a field
  17027. // with the given name. The second boolean return value indicates that this field
  17028. // was not set, or was not defined in the schema.
  17029. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  17030. switch name {
  17031. case server.FieldStatus:
  17032. return m.AddedStatus()
  17033. }
  17034. return nil, false
  17035. }
  17036. // AddField adds the value to the field with the given name. It returns an error if
  17037. // the field is not defined in the schema, or if the type mismatched the field
  17038. // type.
  17039. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  17040. switch name {
  17041. case server.FieldStatus:
  17042. v, ok := value.(int8)
  17043. if !ok {
  17044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17045. }
  17046. m.AddStatus(v)
  17047. return nil
  17048. }
  17049. return fmt.Errorf("unknown Server numeric field %s", name)
  17050. }
  17051. // ClearedFields returns all nullable fields that were cleared during this
  17052. // mutation.
  17053. func (m *ServerMutation) ClearedFields() []string {
  17054. var fields []string
  17055. if m.FieldCleared(server.FieldStatus) {
  17056. fields = append(fields, server.FieldStatus)
  17057. }
  17058. if m.FieldCleared(server.FieldDeletedAt) {
  17059. fields = append(fields, server.FieldDeletedAt)
  17060. }
  17061. return fields
  17062. }
  17063. // FieldCleared returns a boolean indicating if a field with the given name was
  17064. // cleared in this mutation.
  17065. func (m *ServerMutation) FieldCleared(name string) bool {
  17066. _, ok := m.clearedFields[name]
  17067. return ok
  17068. }
  17069. // ClearField clears the value of the field with the given name. It returns an
  17070. // error if the field is not defined in the schema.
  17071. func (m *ServerMutation) ClearField(name string) error {
  17072. switch name {
  17073. case server.FieldStatus:
  17074. m.ClearStatus()
  17075. return nil
  17076. case server.FieldDeletedAt:
  17077. m.ClearDeletedAt()
  17078. return nil
  17079. }
  17080. return fmt.Errorf("unknown Server nullable field %s", name)
  17081. }
  17082. // ResetField resets all changes in the mutation for the field with the given name.
  17083. // It returns an error if the field is not defined in the schema.
  17084. func (m *ServerMutation) ResetField(name string) error {
  17085. switch name {
  17086. case server.FieldCreatedAt:
  17087. m.ResetCreatedAt()
  17088. return nil
  17089. case server.FieldUpdatedAt:
  17090. m.ResetUpdatedAt()
  17091. return nil
  17092. case server.FieldStatus:
  17093. m.ResetStatus()
  17094. return nil
  17095. case server.FieldDeletedAt:
  17096. m.ResetDeletedAt()
  17097. return nil
  17098. case server.FieldName:
  17099. m.ResetName()
  17100. return nil
  17101. case server.FieldPublicIP:
  17102. m.ResetPublicIP()
  17103. return nil
  17104. case server.FieldPrivateIP:
  17105. m.ResetPrivateIP()
  17106. return nil
  17107. case server.FieldAdminPort:
  17108. m.ResetAdminPort()
  17109. return nil
  17110. }
  17111. return fmt.Errorf("unknown Server field %s", name)
  17112. }
  17113. // AddedEdges returns all edge names that were set/added in this mutation.
  17114. func (m *ServerMutation) AddedEdges() []string {
  17115. edges := make([]string, 0, 1)
  17116. if m.wxs != nil {
  17117. edges = append(edges, server.EdgeWxs)
  17118. }
  17119. return edges
  17120. }
  17121. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17122. // name in this mutation.
  17123. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  17124. switch name {
  17125. case server.EdgeWxs:
  17126. ids := make([]ent.Value, 0, len(m.wxs))
  17127. for id := range m.wxs {
  17128. ids = append(ids, id)
  17129. }
  17130. return ids
  17131. }
  17132. return nil
  17133. }
  17134. // RemovedEdges returns all edge names that were removed in this mutation.
  17135. func (m *ServerMutation) RemovedEdges() []string {
  17136. edges := make([]string, 0, 1)
  17137. if m.removedwxs != nil {
  17138. edges = append(edges, server.EdgeWxs)
  17139. }
  17140. return edges
  17141. }
  17142. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17143. // the given name in this mutation.
  17144. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  17145. switch name {
  17146. case server.EdgeWxs:
  17147. ids := make([]ent.Value, 0, len(m.removedwxs))
  17148. for id := range m.removedwxs {
  17149. ids = append(ids, id)
  17150. }
  17151. return ids
  17152. }
  17153. return nil
  17154. }
  17155. // ClearedEdges returns all edge names that were cleared in this mutation.
  17156. func (m *ServerMutation) ClearedEdges() []string {
  17157. edges := make([]string, 0, 1)
  17158. if m.clearedwxs {
  17159. edges = append(edges, server.EdgeWxs)
  17160. }
  17161. return edges
  17162. }
  17163. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17164. // was cleared in this mutation.
  17165. func (m *ServerMutation) EdgeCleared(name string) bool {
  17166. switch name {
  17167. case server.EdgeWxs:
  17168. return m.clearedwxs
  17169. }
  17170. return false
  17171. }
  17172. // ClearEdge clears the value of the edge with the given name. It returns an error
  17173. // if that edge is not defined in the schema.
  17174. func (m *ServerMutation) ClearEdge(name string) error {
  17175. switch name {
  17176. }
  17177. return fmt.Errorf("unknown Server unique edge %s", name)
  17178. }
  17179. // ResetEdge resets all changes to the edge with the given name in this mutation.
  17180. // It returns an error if the edge is not defined in the schema.
  17181. func (m *ServerMutation) ResetEdge(name string) error {
  17182. switch name {
  17183. case server.EdgeWxs:
  17184. m.ResetWxs()
  17185. return nil
  17186. }
  17187. return fmt.Errorf("unknown Server edge %s", name)
  17188. }
  17189. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  17190. type SopNodeMutation struct {
  17191. config
  17192. op Op
  17193. typ string
  17194. id *uint64
  17195. created_at *time.Time
  17196. updated_at *time.Time
  17197. status *uint8
  17198. addstatus *int8
  17199. deleted_at *time.Time
  17200. parent_id *uint64
  17201. addparent_id *int64
  17202. name *string
  17203. condition_type *int
  17204. addcondition_type *int
  17205. condition_list *[]string
  17206. appendcondition_list []string
  17207. no_reply_condition *uint64
  17208. addno_reply_condition *int64
  17209. no_reply_unit *string
  17210. action_message *[]custom_types.Action
  17211. appendaction_message []custom_types.Action
  17212. action_label_add *[]uint64
  17213. appendaction_label_add []uint64
  17214. action_label_del *[]uint64
  17215. appendaction_label_del []uint64
  17216. action_forward **custom_types.ActionForward
  17217. clearedFields map[string]struct{}
  17218. sop_stage *uint64
  17219. clearedsop_stage bool
  17220. node_messages map[uint64]struct{}
  17221. removednode_messages map[uint64]struct{}
  17222. clearednode_messages bool
  17223. done bool
  17224. oldValue func(context.Context) (*SopNode, error)
  17225. predicates []predicate.SopNode
  17226. }
  17227. var _ ent.Mutation = (*SopNodeMutation)(nil)
  17228. // sopnodeOption allows management of the mutation configuration using functional options.
  17229. type sopnodeOption func(*SopNodeMutation)
  17230. // newSopNodeMutation creates new mutation for the SopNode entity.
  17231. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  17232. m := &SopNodeMutation{
  17233. config: c,
  17234. op: op,
  17235. typ: TypeSopNode,
  17236. clearedFields: make(map[string]struct{}),
  17237. }
  17238. for _, opt := range opts {
  17239. opt(m)
  17240. }
  17241. return m
  17242. }
  17243. // withSopNodeID sets the ID field of the mutation.
  17244. func withSopNodeID(id uint64) sopnodeOption {
  17245. return func(m *SopNodeMutation) {
  17246. var (
  17247. err error
  17248. once sync.Once
  17249. value *SopNode
  17250. )
  17251. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  17252. once.Do(func() {
  17253. if m.done {
  17254. err = errors.New("querying old values post mutation is not allowed")
  17255. } else {
  17256. value, err = m.Client().SopNode.Get(ctx, id)
  17257. }
  17258. })
  17259. return value, err
  17260. }
  17261. m.id = &id
  17262. }
  17263. }
  17264. // withSopNode sets the old SopNode of the mutation.
  17265. func withSopNode(node *SopNode) sopnodeOption {
  17266. return func(m *SopNodeMutation) {
  17267. m.oldValue = func(context.Context) (*SopNode, error) {
  17268. return node, nil
  17269. }
  17270. m.id = &node.ID
  17271. }
  17272. }
  17273. // Client returns a new `ent.Client` from the mutation. If the mutation was
  17274. // executed in a transaction (ent.Tx), a transactional client is returned.
  17275. func (m SopNodeMutation) Client() *Client {
  17276. client := &Client{config: m.config}
  17277. client.init()
  17278. return client
  17279. }
  17280. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  17281. // it returns an error otherwise.
  17282. func (m SopNodeMutation) Tx() (*Tx, error) {
  17283. if _, ok := m.driver.(*txDriver); !ok {
  17284. return nil, errors.New("ent: mutation is not running in a transaction")
  17285. }
  17286. tx := &Tx{config: m.config}
  17287. tx.init()
  17288. return tx, nil
  17289. }
  17290. // SetID sets the value of the id field. Note that this
  17291. // operation is only accepted on creation of SopNode entities.
  17292. func (m *SopNodeMutation) SetID(id uint64) {
  17293. m.id = &id
  17294. }
  17295. // ID returns the ID value in the mutation. Note that the ID is only available
  17296. // if it was provided to the builder or after it was returned from the database.
  17297. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  17298. if m.id == nil {
  17299. return
  17300. }
  17301. return *m.id, true
  17302. }
  17303. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  17304. // That means, if the mutation is applied within a transaction with an isolation level such
  17305. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  17306. // or updated by the mutation.
  17307. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  17308. switch {
  17309. case m.op.Is(OpUpdateOne | OpDeleteOne):
  17310. id, exists := m.ID()
  17311. if exists {
  17312. return []uint64{id}, nil
  17313. }
  17314. fallthrough
  17315. case m.op.Is(OpUpdate | OpDelete):
  17316. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  17317. default:
  17318. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  17319. }
  17320. }
  17321. // SetCreatedAt sets the "created_at" field.
  17322. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  17323. m.created_at = &t
  17324. }
  17325. // CreatedAt returns the value of the "created_at" field in the mutation.
  17326. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  17327. v := m.created_at
  17328. if v == nil {
  17329. return
  17330. }
  17331. return *v, true
  17332. }
  17333. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  17334. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17336. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  17337. if !m.op.Is(OpUpdateOne) {
  17338. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  17339. }
  17340. if m.id == nil || m.oldValue == nil {
  17341. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  17342. }
  17343. oldValue, err := m.oldValue(ctx)
  17344. if err != nil {
  17345. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  17346. }
  17347. return oldValue.CreatedAt, nil
  17348. }
  17349. // ResetCreatedAt resets all changes to the "created_at" field.
  17350. func (m *SopNodeMutation) ResetCreatedAt() {
  17351. m.created_at = nil
  17352. }
  17353. // SetUpdatedAt sets the "updated_at" field.
  17354. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  17355. m.updated_at = &t
  17356. }
  17357. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  17358. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  17359. v := m.updated_at
  17360. if v == nil {
  17361. return
  17362. }
  17363. return *v, true
  17364. }
  17365. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  17366. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17368. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  17369. if !m.op.Is(OpUpdateOne) {
  17370. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  17371. }
  17372. if m.id == nil || m.oldValue == nil {
  17373. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  17374. }
  17375. oldValue, err := m.oldValue(ctx)
  17376. if err != nil {
  17377. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  17378. }
  17379. return oldValue.UpdatedAt, nil
  17380. }
  17381. // ResetUpdatedAt resets all changes to the "updated_at" field.
  17382. func (m *SopNodeMutation) ResetUpdatedAt() {
  17383. m.updated_at = nil
  17384. }
  17385. // SetStatus sets the "status" field.
  17386. func (m *SopNodeMutation) SetStatus(u uint8) {
  17387. m.status = &u
  17388. m.addstatus = nil
  17389. }
  17390. // Status returns the value of the "status" field in the mutation.
  17391. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  17392. v := m.status
  17393. if v == nil {
  17394. return
  17395. }
  17396. return *v, true
  17397. }
  17398. // OldStatus returns the old "status" field's value of the SopNode entity.
  17399. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17400. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17401. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  17402. if !m.op.Is(OpUpdateOne) {
  17403. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  17404. }
  17405. if m.id == nil || m.oldValue == nil {
  17406. return v, errors.New("OldStatus requires an ID field in the mutation")
  17407. }
  17408. oldValue, err := m.oldValue(ctx)
  17409. if err != nil {
  17410. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  17411. }
  17412. return oldValue.Status, nil
  17413. }
  17414. // AddStatus adds u to the "status" field.
  17415. func (m *SopNodeMutation) AddStatus(u int8) {
  17416. if m.addstatus != nil {
  17417. *m.addstatus += u
  17418. } else {
  17419. m.addstatus = &u
  17420. }
  17421. }
  17422. // AddedStatus returns the value that was added to the "status" field in this mutation.
  17423. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  17424. v := m.addstatus
  17425. if v == nil {
  17426. return
  17427. }
  17428. return *v, true
  17429. }
  17430. // ClearStatus clears the value of the "status" field.
  17431. func (m *SopNodeMutation) ClearStatus() {
  17432. m.status = nil
  17433. m.addstatus = nil
  17434. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  17435. }
  17436. // StatusCleared returns if the "status" field was cleared in this mutation.
  17437. func (m *SopNodeMutation) StatusCleared() bool {
  17438. _, ok := m.clearedFields[sopnode.FieldStatus]
  17439. return ok
  17440. }
  17441. // ResetStatus resets all changes to the "status" field.
  17442. func (m *SopNodeMutation) ResetStatus() {
  17443. m.status = nil
  17444. m.addstatus = nil
  17445. delete(m.clearedFields, sopnode.FieldStatus)
  17446. }
  17447. // SetDeletedAt sets the "deleted_at" field.
  17448. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  17449. m.deleted_at = &t
  17450. }
  17451. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  17452. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  17453. v := m.deleted_at
  17454. if v == nil {
  17455. return
  17456. }
  17457. return *v, true
  17458. }
  17459. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  17460. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17462. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  17463. if !m.op.Is(OpUpdateOne) {
  17464. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  17465. }
  17466. if m.id == nil || m.oldValue == nil {
  17467. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  17468. }
  17469. oldValue, err := m.oldValue(ctx)
  17470. if err != nil {
  17471. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  17472. }
  17473. return oldValue.DeletedAt, nil
  17474. }
  17475. // ClearDeletedAt clears the value of the "deleted_at" field.
  17476. func (m *SopNodeMutation) ClearDeletedAt() {
  17477. m.deleted_at = nil
  17478. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  17479. }
  17480. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  17481. func (m *SopNodeMutation) DeletedAtCleared() bool {
  17482. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  17483. return ok
  17484. }
  17485. // ResetDeletedAt resets all changes to the "deleted_at" field.
  17486. func (m *SopNodeMutation) ResetDeletedAt() {
  17487. m.deleted_at = nil
  17488. delete(m.clearedFields, sopnode.FieldDeletedAt)
  17489. }
  17490. // SetStageID sets the "stage_id" field.
  17491. func (m *SopNodeMutation) SetStageID(u uint64) {
  17492. m.sop_stage = &u
  17493. }
  17494. // StageID returns the value of the "stage_id" field in the mutation.
  17495. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  17496. v := m.sop_stage
  17497. if v == nil {
  17498. return
  17499. }
  17500. return *v, true
  17501. }
  17502. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  17503. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17505. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  17506. if !m.op.Is(OpUpdateOne) {
  17507. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  17508. }
  17509. if m.id == nil || m.oldValue == nil {
  17510. return v, errors.New("OldStageID requires an ID field in the mutation")
  17511. }
  17512. oldValue, err := m.oldValue(ctx)
  17513. if err != nil {
  17514. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  17515. }
  17516. return oldValue.StageID, nil
  17517. }
  17518. // ResetStageID resets all changes to the "stage_id" field.
  17519. func (m *SopNodeMutation) ResetStageID() {
  17520. m.sop_stage = nil
  17521. }
  17522. // SetParentID sets the "parent_id" field.
  17523. func (m *SopNodeMutation) SetParentID(u uint64) {
  17524. m.parent_id = &u
  17525. m.addparent_id = nil
  17526. }
  17527. // ParentID returns the value of the "parent_id" field in the mutation.
  17528. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  17529. v := m.parent_id
  17530. if v == nil {
  17531. return
  17532. }
  17533. return *v, true
  17534. }
  17535. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  17536. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17537. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17538. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  17539. if !m.op.Is(OpUpdateOne) {
  17540. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  17541. }
  17542. if m.id == nil || m.oldValue == nil {
  17543. return v, errors.New("OldParentID requires an ID field in the mutation")
  17544. }
  17545. oldValue, err := m.oldValue(ctx)
  17546. if err != nil {
  17547. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  17548. }
  17549. return oldValue.ParentID, nil
  17550. }
  17551. // AddParentID adds u to the "parent_id" field.
  17552. func (m *SopNodeMutation) AddParentID(u int64) {
  17553. if m.addparent_id != nil {
  17554. *m.addparent_id += u
  17555. } else {
  17556. m.addparent_id = &u
  17557. }
  17558. }
  17559. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  17560. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  17561. v := m.addparent_id
  17562. if v == nil {
  17563. return
  17564. }
  17565. return *v, true
  17566. }
  17567. // ResetParentID resets all changes to the "parent_id" field.
  17568. func (m *SopNodeMutation) ResetParentID() {
  17569. m.parent_id = nil
  17570. m.addparent_id = nil
  17571. }
  17572. // SetName sets the "name" field.
  17573. func (m *SopNodeMutation) SetName(s string) {
  17574. m.name = &s
  17575. }
  17576. // Name returns the value of the "name" field in the mutation.
  17577. func (m *SopNodeMutation) Name() (r string, exists bool) {
  17578. v := m.name
  17579. if v == nil {
  17580. return
  17581. }
  17582. return *v, true
  17583. }
  17584. // OldName returns the old "name" field's value of the SopNode entity.
  17585. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17587. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  17588. if !m.op.Is(OpUpdateOne) {
  17589. return v, errors.New("OldName is only allowed on UpdateOne operations")
  17590. }
  17591. if m.id == nil || m.oldValue == nil {
  17592. return v, errors.New("OldName requires an ID field in the mutation")
  17593. }
  17594. oldValue, err := m.oldValue(ctx)
  17595. if err != nil {
  17596. return v, fmt.Errorf("querying old value for OldName: %w", err)
  17597. }
  17598. return oldValue.Name, nil
  17599. }
  17600. // ResetName resets all changes to the "name" field.
  17601. func (m *SopNodeMutation) ResetName() {
  17602. m.name = nil
  17603. }
  17604. // SetConditionType sets the "condition_type" field.
  17605. func (m *SopNodeMutation) SetConditionType(i int) {
  17606. m.condition_type = &i
  17607. m.addcondition_type = nil
  17608. }
  17609. // ConditionType returns the value of the "condition_type" field in the mutation.
  17610. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  17611. v := m.condition_type
  17612. if v == nil {
  17613. return
  17614. }
  17615. return *v, true
  17616. }
  17617. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  17618. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17620. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  17621. if !m.op.Is(OpUpdateOne) {
  17622. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  17623. }
  17624. if m.id == nil || m.oldValue == nil {
  17625. return v, errors.New("OldConditionType requires an ID field in the mutation")
  17626. }
  17627. oldValue, err := m.oldValue(ctx)
  17628. if err != nil {
  17629. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  17630. }
  17631. return oldValue.ConditionType, nil
  17632. }
  17633. // AddConditionType adds i to the "condition_type" field.
  17634. func (m *SopNodeMutation) AddConditionType(i int) {
  17635. if m.addcondition_type != nil {
  17636. *m.addcondition_type += i
  17637. } else {
  17638. m.addcondition_type = &i
  17639. }
  17640. }
  17641. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  17642. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  17643. v := m.addcondition_type
  17644. if v == nil {
  17645. return
  17646. }
  17647. return *v, true
  17648. }
  17649. // ResetConditionType resets all changes to the "condition_type" field.
  17650. func (m *SopNodeMutation) ResetConditionType() {
  17651. m.condition_type = nil
  17652. m.addcondition_type = nil
  17653. }
  17654. // SetConditionList sets the "condition_list" field.
  17655. func (m *SopNodeMutation) SetConditionList(s []string) {
  17656. m.condition_list = &s
  17657. m.appendcondition_list = nil
  17658. }
  17659. // ConditionList returns the value of the "condition_list" field in the mutation.
  17660. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  17661. v := m.condition_list
  17662. if v == nil {
  17663. return
  17664. }
  17665. return *v, true
  17666. }
  17667. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  17668. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17670. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  17671. if !m.op.Is(OpUpdateOne) {
  17672. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  17673. }
  17674. if m.id == nil || m.oldValue == nil {
  17675. return v, errors.New("OldConditionList requires an ID field in the mutation")
  17676. }
  17677. oldValue, err := m.oldValue(ctx)
  17678. if err != nil {
  17679. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  17680. }
  17681. return oldValue.ConditionList, nil
  17682. }
  17683. // AppendConditionList adds s to the "condition_list" field.
  17684. func (m *SopNodeMutation) AppendConditionList(s []string) {
  17685. m.appendcondition_list = append(m.appendcondition_list, s...)
  17686. }
  17687. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  17688. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  17689. if len(m.appendcondition_list) == 0 {
  17690. return nil, false
  17691. }
  17692. return m.appendcondition_list, true
  17693. }
  17694. // ClearConditionList clears the value of the "condition_list" field.
  17695. func (m *SopNodeMutation) ClearConditionList() {
  17696. m.condition_list = nil
  17697. m.appendcondition_list = nil
  17698. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  17699. }
  17700. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  17701. func (m *SopNodeMutation) ConditionListCleared() bool {
  17702. _, ok := m.clearedFields[sopnode.FieldConditionList]
  17703. return ok
  17704. }
  17705. // ResetConditionList resets all changes to the "condition_list" field.
  17706. func (m *SopNodeMutation) ResetConditionList() {
  17707. m.condition_list = nil
  17708. m.appendcondition_list = nil
  17709. delete(m.clearedFields, sopnode.FieldConditionList)
  17710. }
  17711. // SetNoReplyCondition sets the "no_reply_condition" field.
  17712. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  17713. m.no_reply_condition = &u
  17714. m.addno_reply_condition = nil
  17715. }
  17716. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  17717. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  17718. v := m.no_reply_condition
  17719. if v == nil {
  17720. return
  17721. }
  17722. return *v, true
  17723. }
  17724. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  17725. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17726. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17727. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  17728. if !m.op.Is(OpUpdateOne) {
  17729. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  17730. }
  17731. if m.id == nil || m.oldValue == nil {
  17732. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  17733. }
  17734. oldValue, err := m.oldValue(ctx)
  17735. if err != nil {
  17736. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  17737. }
  17738. return oldValue.NoReplyCondition, nil
  17739. }
  17740. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  17741. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  17742. if m.addno_reply_condition != nil {
  17743. *m.addno_reply_condition += u
  17744. } else {
  17745. m.addno_reply_condition = &u
  17746. }
  17747. }
  17748. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  17749. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  17750. v := m.addno_reply_condition
  17751. if v == nil {
  17752. return
  17753. }
  17754. return *v, true
  17755. }
  17756. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  17757. func (m *SopNodeMutation) ResetNoReplyCondition() {
  17758. m.no_reply_condition = nil
  17759. m.addno_reply_condition = nil
  17760. }
  17761. // SetNoReplyUnit sets the "no_reply_unit" field.
  17762. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  17763. m.no_reply_unit = &s
  17764. }
  17765. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  17766. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  17767. v := m.no_reply_unit
  17768. if v == nil {
  17769. return
  17770. }
  17771. return *v, true
  17772. }
  17773. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  17774. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17776. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  17777. if !m.op.Is(OpUpdateOne) {
  17778. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  17779. }
  17780. if m.id == nil || m.oldValue == nil {
  17781. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  17782. }
  17783. oldValue, err := m.oldValue(ctx)
  17784. if err != nil {
  17785. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  17786. }
  17787. return oldValue.NoReplyUnit, nil
  17788. }
  17789. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  17790. func (m *SopNodeMutation) ResetNoReplyUnit() {
  17791. m.no_reply_unit = nil
  17792. }
  17793. // SetActionMessage sets the "action_message" field.
  17794. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  17795. m.action_message = &ct
  17796. m.appendaction_message = nil
  17797. }
  17798. // ActionMessage returns the value of the "action_message" field in the mutation.
  17799. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  17800. v := m.action_message
  17801. if v == nil {
  17802. return
  17803. }
  17804. return *v, true
  17805. }
  17806. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  17807. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17808. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17809. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  17810. if !m.op.Is(OpUpdateOne) {
  17811. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  17812. }
  17813. if m.id == nil || m.oldValue == nil {
  17814. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  17815. }
  17816. oldValue, err := m.oldValue(ctx)
  17817. if err != nil {
  17818. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  17819. }
  17820. return oldValue.ActionMessage, nil
  17821. }
  17822. // AppendActionMessage adds ct to the "action_message" field.
  17823. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  17824. m.appendaction_message = append(m.appendaction_message, ct...)
  17825. }
  17826. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  17827. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  17828. if len(m.appendaction_message) == 0 {
  17829. return nil, false
  17830. }
  17831. return m.appendaction_message, true
  17832. }
  17833. // ClearActionMessage clears the value of the "action_message" field.
  17834. func (m *SopNodeMutation) ClearActionMessage() {
  17835. m.action_message = nil
  17836. m.appendaction_message = nil
  17837. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  17838. }
  17839. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  17840. func (m *SopNodeMutation) ActionMessageCleared() bool {
  17841. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  17842. return ok
  17843. }
  17844. // ResetActionMessage resets all changes to the "action_message" field.
  17845. func (m *SopNodeMutation) ResetActionMessage() {
  17846. m.action_message = nil
  17847. m.appendaction_message = nil
  17848. delete(m.clearedFields, sopnode.FieldActionMessage)
  17849. }
  17850. // SetActionLabelAdd sets the "action_label_add" field.
  17851. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  17852. m.action_label_add = &u
  17853. m.appendaction_label_add = nil
  17854. }
  17855. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  17856. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  17857. v := m.action_label_add
  17858. if v == nil {
  17859. return
  17860. }
  17861. return *v, true
  17862. }
  17863. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  17864. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17865. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17866. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  17867. if !m.op.Is(OpUpdateOne) {
  17868. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  17869. }
  17870. if m.id == nil || m.oldValue == nil {
  17871. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  17872. }
  17873. oldValue, err := m.oldValue(ctx)
  17874. if err != nil {
  17875. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  17876. }
  17877. return oldValue.ActionLabelAdd, nil
  17878. }
  17879. // AppendActionLabelAdd adds u to the "action_label_add" field.
  17880. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  17881. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  17882. }
  17883. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  17884. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  17885. if len(m.appendaction_label_add) == 0 {
  17886. return nil, false
  17887. }
  17888. return m.appendaction_label_add, true
  17889. }
  17890. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  17891. func (m *SopNodeMutation) ClearActionLabelAdd() {
  17892. m.action_label_add = nil
  17893. m.appendaction_label_add = nil
  17894. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  17895. }
  17896. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  17897. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  17898. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  17899. return ok
  17900. }
  17901. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  17902. func (m *SopNodeMutation) ResetActionLabelAdd() {
  17903. m.action_label_add = nil
  17904. m.appendaction_label_add = nil
  17905. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  17906. }
  17907. // SetActionLabelDel sets the "action_label_del" field.
  17908. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  17909. m.action_label_del = &u
  17910. m.appendaction_label_del = nil
  17911. }
  17912. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  17913. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  17914. v := m.action_label_del
  17915. if v == nil {
  17916. return
  17917. }
  17918. return *v, true
  17919. }
  17920. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  17921. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17923. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  17924. if !m.op.Is(OpUpdateOne) {
  17925. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  17926. }
  17927. if m.id == nil || m.oldValue == nil {
  17928. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  17929. }
  17930. oldValue, err := m.oldValue(ctx)
  17931. if err != nil {
  17932. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  17933. }
  17934. return oldValue.ActionLabelDel, nil
  17935. }
  17936. // AppendActionLabelDel adds u to the "action_label_del" field.
  17937. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  17938. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  17939. }
  17940. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  17941. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  17942. if len(m.appendaction_label_del) == 0 {
  17943. return nil, false
  17944. }
  17945. return m.appendaction_label_del, true
  17946. }
  17947. // ClearActionLabelDel clears the value of the "action_label_del" field.
  17948. func (m *SopNodeMutation) ClearActionLabelDel() {
  17949. m.action_label_del = nil
  17950. m.appendaction_label_del = nil
  17951. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  17952. }
  17953. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  17954. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  17955. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  17956. return ok
  17957. }
  17958. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  17959. func (m *SopNodeMutation) ResetActionLabelDel() {
  17960. m.action_label_del = nil
  17961. m.appendaction_label_del = nil
  17962. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  17963. }
  17964. // SetActionForward sets the "action_forward" field.
  17965. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  17966. m.action_forward = &ctf
  17967. }
  17968. // ActionForward returns the value of the "action_forward" field in the mutation.
  17969. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  17970. v := m.action_forward
  17971. if v == nil {
  17972. return
  17973. }
  17974. return *v, true
  17975. }
  17976. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  17977. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  17978. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17979. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  17980. if !m.op.Is(OpUpdateOne) {
  17981. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  17982. }
  17983. if m.id == nil || m.oldValue == nil {
  17984. return v, errors.New("OldActionForward requires an ID field in the mutation")
  17985. }
  17986. oldValue, err := m.oldValue(ctx)
  17987. if err != nil {
  17988. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  17989. }
  17990. return oldValue.ActionForward, nil
  17991. }
  17992. // ClearActionForward clears the value of the "action_forward" field.
  17993. func (m *SopNodeMutation) ClearActionForward() {
  17994. m.action_forward = nil
  17995. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  17996. }
  17997. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  17998. func (m *SopNodeMutation) ActionForwardCleared() bool {
  17999. _, ok := m.clearedFields[sopnode.FieldActionForward]
  18000. return ok
  18001. }
  18002. // ResetActionForward resets all changes to the "action_forward" field.
  18003. func (m *SopNodeMutation) ResetActionForward() {
  18004. m.action_forward = nil
  18005. delete(m.clearedFields, sopnode.FieldActionForward)
  18006. }
  18007. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  18008. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  18009. m.sop_stage = &id
  18010. }
  18011. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  18012. func (m *SopNodeMutation) ClearSopStage() {
  18013. m.clearedsop_stage = true
  18014. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  18015. }
  18016. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  18017. func (m *SopNodeMutation) SopStageCleared() bool {
  18018. return m.clearedsop_stage
  18019. }
  18020. // SopStageID returns the "sop_stage" edge ID in the mutation.
  18021. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  18022. if m.sop_stage != nil {
  18023. return *m.sop_stage, true
  18024. }
  18025. return
  18026. }
  18027. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  18028. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  18029. // SopStageID instead. It exists only for internal usage by the builders.
  18030. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  18031. if id := m.sop_stage; id != nil {
  18032. ids = append(ids, *id)
  18033. }
  18034. return
  18035. }
  18036. // ResetSopStage resets all changes to the "sop_stage" edge.
  18037. func (m *SopNodeMutation) ResetSopStage() {
  18038. m.sop_stage = nil
  18039. m.clearedsop_stage = false
  18040. }
  18041. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  18042. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  18043. if m.node_messages == nil {
  18044. m.node_messages = make(map[uint64]struct{})
  18045. }
  18046. for i := range ids {
  18047. m.node_messages[ids[i]] = struct{}{}
  18048. }
  18049. }
  18050. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  18051. func (m *SopNodeMutation) ClearNodeMessages() {
  18052. m.clearednode_messages = true
  18053. }
  18054. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  18055. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  18056. return m.clearednode_messages
  18057. }
  18058. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  18059. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  18060. if m.removednode_messages == nil {
  18061. m.removednode_messages = make(map[uint64]struct{})
  18062. }
  18063. for i := range ids {
  18064. delete(m.node_messages, ids[i])
  18065. m.removednode_messages[ids[i]] = struct{}{}
  18066. }
  18067. }
  18068. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  18069. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  18070. for id := range m.removednode_messages {
  18071. ids = append(ids, id)
  18072. }
  18073. return
  18074. }
  18075. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  18076. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  18077. for id := range m.node_messages {
  18078. ids = append(ids, id)
  18079. }
  18080. return
  18081. }
  18082. // ResetNodeMessages resets all changes to the "node_messages" edge.
  18083. func (m *SopNodeMutation) ResetNodeMessages() {
  18084. m.node_messages = nil
  18085. m.clearednode_messages = false
  18086. m.removednode_messages = nil
  18087. }
  18088. // Where appends a list predicates to the SopNodeMutation builder.
  18089. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  18090. m.predicates = append(m.predicates, ps...)
  18091. }
  18092. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  18093. // users can use type-assertion to append predicates that do not depend on any generated package.
  18094. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  18095. p := make([]predicate.SopNode, len(ps))
  18096. for i := range ps {
  18097. p[i] = ps[i]
  18098. }
  18099. m.Where(p...)
  18100. }
  18101. // Op returns the operation name.
  18102. func (m *SopNodeMutation) Op() Op {
  18103. return m.op
  18104. }
  18105. // SetOp allows setting the mutation operation.
  18106. func (m *SopNodeMutation) SetOp(op Op) {
  18107. m.op = op
  18108. }
  18109. // Type returns the node type of this mutation (SopNode).
  18110. func (m *SopNodeMutation) Type() string {
  18111. return m.typ
  18112. }
  18113. // Fields returns all fields that were changed during this mutation. Note that in
  18114. // order to get all numeric fields that were incremented/decremented, call
  18115. // AddedFields().
  18116. func (m *SopNodeMutation) Fields() []string {
  18117. fields := make([]string, 0, 15)
  18118. if m.created_at != nil {
  18119. fields = append(fields, sopnode.FieldCreatedAt)
  18120. }
  18121. if m.updated_at != nil {
  18122. fields = append(fields, sopnode.FieldUpdatedAt)
  18123. }
  18124. if m.status != nil {
  18125. fields = append(fields, sopnode.FieldStatus)
  18126. }
  18127. if m.deleted_at != nil {
  18128. fields = append(fields, sopnode.FieldDeletedAt)
  18129. }
  18130. if m.sop_stage != nil {
  18131. fields = append(fields, sopnode.FieldStageID)
  18132. }
  18133. if m.parent_id != nil {
  18134. fields = append(fields, sopnode.FieldParentID)
  18135. }
  18136. if m.name != nil {
  18137. fields = append(fields, sopnode.FieldName)
  18138. }
  18139. if m.condition_type != nil {
  18140. fields = append(fields, sopnode.FieldConditionType)
  18141. }
  18142. if m.condition_list != nil {
  18143. fields = append(fields, sopnode.FieldConditionList)
  18144. }
  18145. if m.no_reply_condition != nil {
  18146. fields = append(fields, sopnode.FieldNoReplyCondition)
  18147. }
  18148. if m.no_reply_unit != nil {
  18149. fields = append(fields, sopnode.FieldNoReplyUnit)
  18150. }
  18151. if m.action_message != nil {
  18152. fields = append(fields, sopnode.FieldActionMessage)
  18153. }
  18154. if m.action_label_add != nil {
  18155. fields = append(fields, sopnode.FieldActionLabelAdd)
  18156. }
  18157. if m.action_label_del != nil {
  18158. fields = append(fields, sopnode.FieldActionLabelDel)
  18159. }
  18160. if m.action_forward != nil {
  18161. fields = append(fields, sopnode.FieldActionForward)
  18162. }
  18163. return fields
  18164. }
  18165. // Field returns the value of a field with the given name. The second boolean
  18166. // return value indicates that this field was not set, or was not defined in the
  18167. // schema.
  18168. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  18169. switch name {
  18170. case sopnode.FieldCreatedAt:
  18171. return m.CreatedAt()
  18172. case sopnode.FieldUpdatedAt:
  18173. return m.UpdatedAt()
  18174. case sopnode.FieldStatus:
  18175. return m.Status()
  18176. case sopnode.FieldDeletedAt:
  18177. return m.DeletedAt()
  18178. case sopnode.FieldStageID:
  18179. return m.StageID()
  18180. case sopnode.FieldParentID:
  18181. return m.ParentID()
  18182. case sopnode.FieldName:
  18183. return m.Name()
  18184. case sopnode.FieldConditionType:
  18185. return m.ConditionType()
  18186. case sopnode.FieldConditionList:
  18187. return m.ConditionList()
  18188. case sopnode.FieldNoReplyCondition:
  18189. return m.NoReplyCondition()
  18190. case sopnode.FieldNoReplyUnit:
  18191. return m.NoReplyUnit()
  18192. case sopnode.FieldActionMessage:
  18193. return m.ActionMessage()
  18194. case sopnode.FieldActionLabelAdd:
  18195. return m.ActionLabelAdd()
  18196. case sopnode.FieldActionLabelDel:
  18197. return m.ActionLabelDel()
  18198. case sopnode.FieldActionForward:
  18199. return m.ActionForward()
  18200. }
  18201. return nil, false
  18202. }
  18203. // OldField returns the old value of the field from the database. An error is
  18204. // returned if the mutation operation is not UpdateOne, or the query to the
  18205. // database failed.
  18206. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18207. switch name {
  18208. case sopnode.FieldCreatedAt:
  18209. return m.OldCreatedAt(ctx)
  18210. case sopnode.FieldUpdatedAt:
  18211. return m.OldUpdatedAt(ctx)
  18212. case sopnode.FieldStatus:
  18213. return m.OldStatus(ctx)
  18214. case sopnode.FieldDeletedAt:
  18215. return m.OldDeletedAt(ctx)
  18216. case sopnode.FieldStageID:
  18217. return m.OldStageID(ctx)
  18218. case sopnode.FieldParentID:
  18219. return m.OldParentID(ctx)
  18220. case sopnode.FieldName:
  18221. return m.OldName(ctx)
  18222. case sopnode.FieldConditionType:
  18223. return m.OldConditionType(ctx)
  18224. case sopnode.FieldConditionList:
  18225. return m.OldConditionList(ctx)
  18226. case sopnode.FieldNoReplyCondition:
  18227. return m.OldNoReplyCondition(ctx)
  18228. case sopnode.FieldNoReplyUnit:
  18229. return m.OldNoReplyUnit(ctx)
  18230. case sopnode.FieldActionMessage:
  18231. return m.OldActionMessage(ctx)
  18232. case sopnode.FieldActionLabelAdd:
  18233. return m.OldActionLabelAdd(ctx)
  18234. case sopnode.FieldActionLabelDel:
  18235. return m.OldActionLabelDel(ctx)
  18236. case sopnode.FieldActionForward:
  18237. return m.OldActionForward(ctx)
  18238. }
  18239. return nil, fmt.Errorf("unknown SopNode field %s", name)
  18240. }
  18241. // SetField sets the value of a field with the given name. It returns an error if
  18242. // the field is not defined in the schema, or if the type mismatched the field
  18243. // type.
  18244. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  18245. switch name {
  18246. case sopnode.FieldCreatedAt:
  18247. v, ok := value.(time.Time)
  18248. if !ok {
  18249. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18250. }
  18251. m.SetCreatedAt(v)
  18252. return nil
  18253. case sopnode.FieldUpdatedAt:
  18254. v, ok := value.(time.Time)
  18255. if !ok {
  18256. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18257. }
  18258. m.SetUpdatedAt(v)
  18259. return nil
  18260. case sopnode.FieldStatus:
  18261. v, ok := value.(uint8)
  18262. if !ok {
  18263. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18264. }
  18265. m.SetStatus(v)
  18266. return nil
  18267. case sopnode.FieldDeletedAt:
  18268. v, ok := value.(time.Time)
  18269. if !ok {
  18270. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18271. }
  18272. m.SetDeletedAt(v)
  18273. return nil
  18274. case sopnode.FieldStageID:
  18275. v, ok := value.(uint64)
  18276. if !ok {
  18277. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18278. }
  18279. m.SetStageID(v)
  18280. return nil
  18281. case sopnode.FieldParentID:
  18282. v, ok := value.(uint64)
  18283. if !ok {
  18284. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18285. }
  18286. m.SetParentID(v)
  18287. return nil
  18288. case sopnode.FieldName:
  18289. v, ok := value.(string)
  18290. if !ok {
  18291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18292. }
  18293. m.SetName(v)
  18294. return nil
  18295. case sopnode.FieldConditionType:
  18296. v, ok := value.(int)
  18297. if !ok {
  18298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18299. }
  18300. m.SetConditionType(v)
  18301. return nil
  18302. case sopnode.FieldConditionList:
  18303. v, ok := value.([]string)
  18304. if !ok {
  18305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18306. }
  18307. m.SetConditionList(v)
  18308. return nil
  18309. case sopnode.FieldNoReplyCondition:
  18310. v, ok := value.(uint64)
  18311. if !ok {
  18312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18313. }
  18314. m.SetNoReplyCondition(v)
  18315. return nil
  18316. case sopnode.FieldNoReplyUnit:
  18317. v, ok := value.(string)
  18318. if !ok {
  18319. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18320. }
  18321. m.SetNoReplyUnit(v)
  18322. return nil
  18323. case sopnode.FieldActionMessage:
  18324. v, ok := value.([]custom_types.Action)
  18325. if !ok {
  18326. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18327. }
  18328. m.SetActionMessage(v)
  18329. return nil
  18330. case sopnode.FieldActionLabelAdd:
  18331. v, ok := value.([]uint64)
  18332. if !ok {
  18333. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18334. }
  18335. m.SetActionLabelAdd(v)
  18336. return nil
  18337. case sopnode.FieldActionLabelDel:
  18338. v, ok := value.([]uint64)
  18339. if !ok {
  18340. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18341. }
  18342. m.SetActionLabelDel(v)
  18343. return nil
  18344. case sopnode.FieldActionForward:
  18345. v, ok := value.(*custom_types.ActionForward)
  18346. if !ok {
  18347. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18348. }
  18349. m.SetActionForward(v)
  18350. return nil
  18351. }
  18352. return fmt.Errorf("unknown SopNode field %s", name)
  18353. }
  18354. // AddedFields returns all numeric fields that were incremented/decremented during
  18355. // this mutation.
  18356. func (m *SopNodeMutation) AddedFields() []string {
  18357. var fields []string
  18358. if m.addstatus != nil {
  18359. fields = append(fields, sopnode.FieldStatus)
  18360. }
  18361. if m.addparent_id != nil {
  18362. fields = append(fields, sopnode.FieldParentID)
  18363. }
  18364. if m.addcondition_type != nil {
  18365. fields = append(fields, sopnode.FieldConditionType)
  18366. }
  18367. if m.addno_reply_condition != nil {
  18368. fields = append(fields, sopnode.FieldNoReplyCondition)
  18369. }
  18370. return fields
  18371. }
  18372. // AddedField returns the numeric value that was incremented/decremented on a field
  18373. // with the given name. The second boolean return value indicates that this field
  18374. // was not set, or was not defined in the schema.
  18375. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  18376. switch name {
  18377. case sopnode.FieldStatus:
  18378. return m.AddedStatus()
  18379. case sopnode.FieldParentID:
  18380. return m.AddedParentID()
  18381. case sopnode.FieldConditionType:
  18382. return m.AddedConditionType()
  18383. case sopnode.FieldNoReplyCondition:
  18384. return m.AddedNoReplyCondition()
  18385. }
  18386. return nil, false
  18387. }
  18388. // AddField adds the value to the field with the given name. It returns an error if
  18389. // the field is not defined in the schema, or if the type mismatched the field
  18390. // type.
  18391. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  18392. switch name {
  18393. case sopnode.FieldStatus:
  18394. v, ok := value.(int8)
  18395. if !ok {
  18396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18397. }
  18398. m.AddStatus(v)
  18399. return nil
  18400. case sopnode.FieldParentID:
  18401. v, ok := value.(int64)
  18402. if !ok {
  18403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18404. }
  18405. m.AddParentID(v)
  18406. return nil
  18407. case sopnode.FieldConditionType:
  18408. v, ok := value.(int)
  18409. if !ok {
  18410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18411. }
  18412. m.AddConditionType(v)
  18413. return nil
  18414. case sopnode.FieldNoReplyCondition:
  18415. v, ok := value.(int64)
  18416. if !ok {
  18417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18418. }
  18419. m.AddNoReplyCondition(v)
  18420. return nil
  18421. }
  18422. return fmt.Errorf("unknown SopNode numeric field %s", name)
  18423. }
  18424. // ClearedFields returns all nullable fields that were cleared during this
  18425. // mutation.
  18426. func (m *SopNodeMutation) ClearedFields() []string {
  18427. var fields []string
  18428. if m.FieldCleared(sopnode.FieldStatus) {
  18429. fields = append(fields, sopnode.FieldStatus)
  18430. }
  18431. if m.FieldCleared(sopnode.FieldDeletedAt) {
  18432. fields = append(fields, sopnode.FieldDeletedAt)
  18433. }
  18434. if m.FieldCleared(sopnode.FieldConditionList) {
  18435. fields = append(fields, sopnode.FieldConditionList)
  18436. }
  18437. if m.FieldCleared(sopnode.FieldActionMessage) {
  18438. fields = append(fields, sopnode.FieldActionMessage)
  18439. }
  18440. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  18441. fields = append(fields, sopnode.FieldActionLabelAdd)
  18442. }
  18443. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  18444. fields = append(fields, sopnode.FieldActionLabelDel)
  18445. }
  18446. if m.FieldCleared(sopnode.FieldActionForward) {
  18447. fields = append(fields, sopnode.FieldActionForward)
  18448. }
  18449. return fields
  18450. }
  18451. // FieldCleared returns a boolean indicating if a field with the given name was
  18452. // cleared in this mutation.
  18453. func (m *SopNodeMutation) FieldCleared(name string) bool {
  18454. _, ok := m.clearedFields[name]
  18455. return ok
  18456. }
  18457. // ClearField clears the value of the field with the given name. It returns an
  18458. // error if the field is not defined in the schema.
  18459. func (m *SopNodeMutation) ClearField(name string) error {
  18460. switch name {
  18461. case sopnode.FieldStatus:
  18462. m.ClearStatus()
  18463. return nil
  18464. case sopnode.FieldDeletedAt:
  18465. m.ClearDeletedAt()
  18466. return nil
  18467. case sopnode.FieldConditionList:
  18468. m.ClearConditionList()
  18469. return nil
  18470. case sopnode.FieldActionMessage:
  18471. m.ClearActionMessage()
  18472. return nil
  18473. case sopnode.FieldActionLabelAdd:
  18474. m.ClearActionLabelAdd()
  18475. return nil
  18476. case sopnode.FieldActionLabelDel:
  18477. m.ClearActionLabelDel()
  18478. return nil
  18479. case sopnode.FieldActionForward:
  18480. m.ClearActionForward()
  18481. return nil
  18482. }
  18483. return fmt.Errorf("unknown SopNode nullable field %s", name)
  18484. }
  18485. // ResetField resets all changes in the mutation for the field with the given name.
  18486. // It returns an error if the field is not defined in the schema.
  18487. func (m *SopNodeMutation) ResetField(name string) error {
  18488. switch name {
  18489. case sopnode.FieldCreatedAt:
  18490. m.ResetCreatedAt()
  18491. return nil
  18492. case sopnode.FieldUpdatedAt:
  18493. m.ResetUpdatedAt()
  18494. return nil
  18495. case sopnode.FieldStatus:
  18496. m.ResetStatus()
  18497. return nil
  18498. case sopnode.FieldDeletedAt:
  18499. m.ResetDeletedAt()
  18500. return nil
  18501. case sopnode.FieldStageID:
  18502. m.ResetStageID()
  18503. return nil
  18504. case sopnode.FieldParentID:
  18505. m.ResetParentID()
  18506. return nil
  18507. case sopnode.FieldName:
  18508. m.ResetName()
  18509. return nil
  18510. case sopnode.FieldConditionType:
  18511. m.ResetConditionType()
  18512. return nil
  18513. case sopnode.FieldConditionList:
  18514. m.ResetConditionList()
  18515. return nil
  18516. case sopnode.FieldNoReplyCondition:
  18517. m.ResetNoReplyCondition()
  18518. return nil
  18519. case sopnode.FieldNoReplyUnit:
  18520. m.ResetNoReplyUnit()
  18521. return nil
  18522. case sopnode.FieldActionMessage:
  18523. m.ResetActionMessage()
  18524. return nil
  18525. case sopnode.FieldActionLabelAdd:
  18526. m.ResetActionLabelAdd()
  18527. return nil
  18528. case sopnode.FieldActionLabelDel:
  18529. m.ResetActionLabelDel()
  18530. return nil
  18531. case sopnode.FieldActionForward:
  18532. m.ResetActionForward()
  18533. return nil
  18534. }
  18535. return fmt.Errorf("unknown SopNode field %s", name)
  18536. }
  18537. // AddedEdges returns all edge names that were set/added in this mutation.
  18538. func (m *SopNodeMutation) AddedEdges() []string {
  18539. edges := make([]string, 0, 2)
  18540. if m.sop_stage != nil {
  18541. edges = append(edges, sopnode.EdgeSopStage)
  18542. }
  18543. if m.node_messages != nil {
  18544. edges = append(edges, sopnode.EdgeNodeMessages)
  18545. }
  18546. return edges
  18547. }
  18548. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18549. // name in this mutation.
  18550. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  18551. switch name {
  18552. case sopnode.EdgeSopStage:
  18553. if id := m.sop_stage; id != nil {
  18554. return []ent.Value{*id}
  18555. }
  18556. case sopnode.EdgeNodeMessages:
  18557. ids := make([]ent.Value, 0, len(m.node_messages))
  18558. for id := range m.node_messages {
  18559. ids = append(ids, id)
  18560. }
  18561. return ids
  18562. }
  18563. return nil
  18564. }
  18565. // RemovedEdges returns all edge names that were removed in this mutation.
  18566. func (m *SopNodeMutation) RemovedEdges() []string {
  18567. edges := make([]string, 0, 2)
  18568. if m.removednode_messages != nil {
  18569. edges = append(edges, sopnode.EdgeNodeMessages)
  18570. }
  18571. return edges
  18572. }
  18573. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18574. // the given name in this mutation.
  18575. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  18576. switch name {
  18577. case sopnode.EdgeNodeMessages:
  18578. ids := make([]ent.Value, 0, len(m.removednode_messages))
  18579. for id := range m.removednode_messages {
  18580. ids = append(ids, id)
  18581. }
  18582. return ids
  18583. }
  18584. return nil
  18585. }
  18586. // ClearedEdges returns all edge names that were cleared in this mutation.
  18587. func (m *SopNodeMutation) ClearedEdges() []string {
  18588. edges := make([]string, 0, 2)
  18589. if m.clearedsop_stage {
  18590. edges = append(edges, sopnode.EdgeSopStage)
  18591. }
  18592. if m.clearednode_messages {
  18593. edges = append(edges, sopnode.EdgeNodeMessages)
  18594. }
  18595. return edges
  18596. }
  18597. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18598. // was cleared in this mutation.
  18599. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  18600. switch name {
  18601. case sopnode.EdgeSopStage:
  18602. return m.clearedsop_stage
  18603. case sopnode.EdgeNodeMessages:
  18604. return m.clearednode_messages
  18605. }
  18606. return false
  18607. }
  18608. // ClearEdge clears the value of the edge with the given name. It returns an error
  18609. // if that edge is not defined in the schema.
  18610. func (m *SopNodeMutation) ClearEdge(name string) error {
  18611. switch name {
  18612. case sopnode.EdgeSopStage:
  18613. m.ClearSopStage()
  18614. return nil
  18615. }
  18616. return fmt.Errorf("unknown SopNode unique edge %s", name)
  18617. }
  18618. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18619. // It returns an error if the edge is not defined in the schema.
  18620. func (m *SopNodeMutation) ResetEdge(name string) error {
  18621. switch name {
  18622. case sopnode.EdgeSopStage:
  18623. m.ResetSopStage()
  18624. return nil
  18625. case sopnode.EdgeNodeMessages:
  18626. m.ResetNodeMessages()
  18627. return nil
  18628. }
  18629. return fmt.Errorf("unknown SopNode edge %s", name)
  18630. }
  18631. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  18632. type SopStageMutation struct {
  18633. config
  18634. op Op
  18635. typ string
  18636. id *uint64
  18637. created_at *time.Time
  18638. updated_at *time.Time
  18639. status *uint8
  18640. addstatus *int8
  18641. deleted_at *time.Time
  18642. name *string
  18643. condition_type *int
  18644. addcondition_type *int
  18645. condition_operator *int
  18646. addcondition_operator *int
  18647. condition_list *[]custom_types.Condition
  18648. appendcondition_list []custom_types.Condition
  18649. action_message *[]custom_types.Action
  18650. appendaction_message []custom_types.Action
  18651. action_label_add *[]uint64
  18652. appendaction_label_add []uint64
  18653. action_label_del *[]uint64
  18654. appendaction_label_del []uint64
  18655. action_forward **custom_types.ActionForward
  18656. index_sort *int
  18657. addindex_sort *int
  18658. clearedFields map[string]struct{}
  18659. sop_task *uint64
  18660. clearedsop_task bool
  18661. stage_nodes map[uint64]struct{}
  18662. removedstage_nodes map[uint64]struct{}
  18663. clearedstage_nodes bool
  18664. stage_messages map[uint64]struct{}
  18665. removedstage_messages map[uint64]struct{}
  18666. clearedstage_messages bool
  18667. done bool
  18668. oldValue func(context.Context) (*SopStage, error)
  18669. predicates []predicate.SopStage
  18670. }
  18671. var _ ent.Mutation = (*SopStageMutation)(nil)
  18672. // sopstageOption allows management of the mutation configuration using functional options.
  18673. type sopstageOption func(*SopStageMutation)
  18674. // newSopStageMutation creates new mutation for the SopStage entity.
  18675. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  18676. m := &SopStageMutation{
  18677. config: c,
  18678. op: op,
  18679. typ: TypeSopStage,
  18680. clearedFields: make(map[string]struct{}),
  18681. }
  18682. for _, opt := range opts {
  18683. opt(m)
  18684. }
  18685. return m
  18686. }
  18687. // withSopStageID sets the ID field of the mutation.
  18688. func withSopStageID(id uint64) sopstageOption {
  18689. return func(m *SopStageMutation) {
  18690. var (
  18691. err error
  18692. once sync.Once
  18693. value *SopStage
  18694. )
  18695. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  18696. once.Do(func() {
  18697. if m.done {
  18698. err = errors.New("querying old values post mutation is not allowed")
  18699. } else {
  18700. value, err = m.Client().SopStage.Get(ctx, id)
  18701. }
  18702. })
  18703. return value, err
  18704. }
  18705. m.id = &id
  18706. }
  18707. }
  18708. // withSopStage sets the old SopStage of the mutation.
  18709. func withSopStage(node *SopStage) sopstageOption {
  18710. return func(m *SopStageMutation) {
  18711. m.oldValue = func(context.Context) (*SopStage, error) {
  18712. return node, nil
  18713. }
  18714. m.id = &node.ID
  18715. }
  18716. }
  18717. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18718. // executed in a transaction (ent.Tx), a transactional client is returned.
  18719. func (m SopStageMutation) Client() *Client {
  18720. client := &Client{config: m.config}
  18721. client.init()
  18722. return client
  18723. }
  18724. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18725. // it returns an error otherwise.
  18726. func (m SopStageMutation) Tx() (*Tx, error) {
  18727. if _, ok := m.driver.(*txDriver); !ok {
  18728. return nil, errors.New("ent: mutation is not running in a transaction")
  18729. }
  18730. tx := &Tx{config: m.config}
  18731. tx.init()
  18732. return tx, nil
  18733. }
  18734. // SetID sets the value of the id field. Note that this
  18735. // operation is only accepted on creation of SopStage entities.
  18736. func (m *SopStageMutation) SetID(id uint64) {
  18737. m.id = &id
  18738. }
  18739. // ID returns the ID value in the mutation. Note that the ID is only available
  18740. // if it was provided to the builder or after it was returned from the database.
  18741. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  18742. if m.id == nil {
  18743. return
  18744. }
  18745. return *m.id, true
  18746. }
  18747. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18748. // That means, if the mutation is applied within a transaction with an isolation level such
  18749. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18750. // or updated by the mutation.
  18751. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  18752. switch {
  18753. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18754. id, exists := m.ID()
  18755. if exists {
  18756. return []uint64{id}, nil
  18757. }
  18758. fallthrough
  18759. case m.op.Is(OpUpdate | OpDelete):
  18760. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  18761. default:
  18762. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18763. }
  18764. }
  18765. // SetCreatedAt sets the "created_at" field.
  18766. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  18767. m.created_at = &t
  18768. }
  18769. // CreatedAt returns the value of the "created_at" field in the mutation.
  18770. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  18771. v := m.created_at
  18772. if v == nil {
  18773. return
  18774. }
  18775. return *v, true
  18776. }
  18777. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  18778. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18780. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18781. if !m.op.Is(OpUpdateOne) {
  18782. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18783. }
  18784. if m.id == nil || m.oldValue == nil {
  18785. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18786. }
  18787. oldValue, err := m.oldValue(ctx)
  18788. if err != nil {
  18789. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18790. }
  18791. return oldValue.CreatedAt, nil
  18792. }
  18793. // ResetCreatedAt resets all changes to the "created_at" field.
  18794. func (m *SopStageMutation) ResetCreatedAt() {
  18795. m.created_at = nil
  18796. }
  18797. // SetUpdatedAt sets the "updated_at" field.
  18798. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  18799. m.updated_at = &t
  18800. }
  18801. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18802. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  18803. v := m.updated_at
  18804. if v == nil {
  18805. return
  18806. }
  18807. return *v, true
  18808. }
  18809. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  18810. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18812. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18813. if !m.op.Is(OpUpdateOne) {
  18814. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18815. }
  18816. if m.id == nil || m.oldValue == nil {
  18817. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18818. }
  18819. oldValue, err := m.oldValue(ctx)
  18820. if err != nil {
  18821. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18822. }
  18823. return oldValue.UpdatedAt, nil
  18824. }
  18825. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18826. func (m *SopStageMutation) ResetUpdatedAt() {
  18827. m.updated_at = nil
  18828. }
  18829. // SetStatus sets the "status" field.
  18830. func (m *SopStageMutation) SetStatus(u uint8) {
  18831. m.status = &u
  18832. m.addstatus = nil
  18833. }
  18834. // Status returns the value of the "status" field in the mutation.
  18835. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  18836. v := m.status
  18837. if v == nil {
  18838. return
  18839. }
  18840. return *v, true
  18841. }
  18842. // OldStatus returns the old "status" field's value of the SopStage entity.
  18843. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18845. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18846. if !m.op.Is(OpUpdateOne) {
  18847. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18848. }
  18849. if m.id == nil || m.oldValue == nil {
  18850. return v, errors.New("OldStatus requires an ID field in the mutation")
  18851. }
  18852. oldValue, err := m.oldValue(ctx)
  18853. if err != nil {
  18854. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18855. }
  18856. return oldValue.Status, nil
  18857. }
  18858. // AddStatus adds u to the "status" field.
  18859. func (m *SopStageMutation) AddStatus(u int8) {
  18860. if m.addstatus != nil {
  18861. *m.addstatus += u
  18862. } else {
  18863. m.addstatus = &u
  18864. }
  18865. }
  18866. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18867. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  18868. v := m.addstatus
  18869. if v == nil {
  18870. return
  18871. }
  18872. return *v, true
  18873. }
  18874. // ClearStatus clears the value of the "status" field.
  18875. func (m *SopStageMutation) ClearStatus() {
  18876. m.status = nil
  18877. m.addstatus = nil
  18878. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  18879. }
  18880. // StatusCleared returns if the "status" field was cleared in this mutation.
  18881. func (m *SopStageMutation) StatusCleared() bool {
  18882. _, ok := m.clearedFields[sopstage.FieldStatus]
  18883. return ok
  18884. }
  18885. // ResetStatus resets all changes to the "status" field.
  18886. func (m *SopStageMutation) ResetStatus() {
  18887. m.status = nil
  18888. m.addstatus = nil
  18889. delete(m.clearedFields, sopstage.FieldStatus)
  18890. }
  18891. // SetDeletedAt sets the "deleted_at" field.
  18892. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  18893. m.deleted_at = &t
  18894. }
  18895. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18896. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  18897. v := m.deleted_at
  18898. if v == nil {
  18899. return
  18900. }
  18901. return *v, true
  18902. }
  18903. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  18904. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18906. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18907. if !m.op.Is(OpUpdateOne) {
  18908. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18909. }
  18910. if m.id == nil || m.oldValue == nil {
  18911. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18912. }
  18913. oldValue, err := m.oldValue(ctx)
  18914. if err != nil {
  18915. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18916. }
  18917. return oldValue.DeletedAt, nil
  18918. }
  18919. // ClearDeletedAt clears the value of the "deleted_at" field.
  18920. func (m *SopStageMutation) ClearDeletedAt() {
  18921. m.deleted_at = nil
  18922. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  18923. }
  18924. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18925. func (m *SopStageMutation) DeletedAtCleared() bool {
  18926. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  18927. return ok
  18928. }
  18929. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18930. func (m *SopStageMutation) ResetDeletedAt() {
  18931. m.deleted_at = nil
  18932. delete(m.clearedFields, sopstage.FieldDeletedAt)
  18933. }
  18934. // SetTaskID sets the "task_id" field.
  18935. func (m *SopStageMutation) SetTaskID(u uint64) {
  18936. m.sop_task = &u
  18937. }
  18938. // TaskID returns the value of the "task_id" field in the mutation.
  18939. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  18940. v := m.sop_task
  18941. if v == nil {
  18942. return
  18943. }
  18944. return *v, true
  18945. }
  18946. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  18947. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18949. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  18950. if !m.op.Is(OpUpdateOne) {
  18951. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  18952. }
  18953. if m.id == nil || m.oldValue == nil {
  18954. return v, errors.New("OldTaskID requires an ID field in the mutation")
  18955. }
  18956. oldValue, err := m.oldValue(ctx)
  18957. if err != nil {
  18958. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  18959. }
  18960. return oldValue.TaskID, nil
  18961. }
  18962. // ResetTaskID resets all changes to the "task_id" field.
  18963. func (m *SopStageMutation) ResetTaskID() {
  18964. m.sop_task = nil
  18965. }
  18966. // SetName sets the "name" field.
  18967. func (m *SopStageMutation) SetName(s string) {
  18968. m.name = &s
  18969. }
  18970. // Name returns the value of the "name" field in the mutation.
  18971. func (m *SopStageMutation) Name() (r string, exists bool) {
  18972. v := m.name
  18973. if v == nil {
  18974. return
  18975. }
  18976. return *v, true
  18977. }
  18978. // OldName returns the old "name" field's value of the SopStage entity.
  18979. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  18980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18981. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  18982. if !m.op.Is(OpUpdateOne) {
  18983. return v, errors.New("OldName is only allowed on UpdateOne operations")
  18984. }
  18985. if m.id == nil || m.oldValue == nil {
  18986. return v, errors.New("OldName requires an ID field in the mutation")
  18987. }
  18988. oldValue, err := m.oldValue(ctx)
  18989. if err != nil {
  18990. return v, fmt.Errorf("querying old value for OldName: %w", err)
  18991. }
  18992. return oldValue.Name, nil
  18993. }
  18994. // ResetName resets all changes to the "name" field.
  18995. func (m *SopStageMutation) ResetName() {
  18996. m.name = nil
  18997. }
  18998. // SetConditionType sets the "condition_type" field.
  18999. func (m *SopStageMutation) SetConditionType(i int) {
  19000. m.condition_type = &i
  19001. m.addcondition_type = nil
  19002. }
  19003. // ConditionType returns the value of the "condition_type" field in the mutation.
  19004. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  19005. v := m.condition_type
  19006. if v == nil {
  19007. return
  19008. }
  19009. return *v, true
  19010. }
  19011. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  19012. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19013. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19014. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  19015. if !m.op.Is(OpUpdateOne) {
  19016. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  19017. }
  19018. if m.id == nil || m.oldValue == nil {
  19019. return v, errors.New("OldConditionType requires an ID field in the mutation")
  19020. }
  19021. oldValue, err := m.oldValue(ctx)
  19022. if err != nil {
  19023. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  19024. }
  19025. return oldValue.ConditionType, nil
  19026. }
  19027. // AddConditionType adds i to the "condition_type" field.
  19028. func (m *SopStageMutation) AddConditionType(i int) {
  19029. if m.addcondition_type != nil {
  19030. *m.addcondition_type += i
  19031. } else {
  19032. m.addcondition_type = &i
  19033. }
  19034. }
  19035. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  19036. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  19037. v := m.addcondition_type
  19038. if v == nil {
  19039. return
  19040. }
  19041. return *v, true
  19042. }
  19043. // ResetConditionType resets all changes to the "condition_type" field.
  19044. func (m *SopStageMutation) ResetConditionType() {
  19045. m.condition_type = nil
  19046. m.addcondition_type = nil
  19047. }
  19048. // SetConditionOperator sets the "condition_operator" field.
  19049. func (m *SopStageMutation) SetConditionOperator(i int) {
  19050. m.condition_operator = &i
  19051. m.addcondition_operator = nil
  19052. }
  19053. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  19054. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  19055. v := m.condition_operator
  19056. if v == nil {
  19057. return
  19058. }
  19059. return *v, true
  19060. }
  19061. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  19062. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19064. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  19065. if !m.op.Is(OpUpdateOne) {
  19066. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  19067. }
  19068. if m.id == nil || m.oldValue == nil {
  19069. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  19070. }
  19071. oldValue, err := m.oldValue(ctx)
  19072. if err != nil {
  19073. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  19074. }
  19075. return oldValue.ConditionOperator, nil
  19076. }
  19077. // AddConditionOperator adds i to the "condition_operator" field.
  19078. func (m *SopStageMutation) AddConditionOperator(i int) {
  19079. if m.addcondition_operator != nil {
  19080. *m.addcondition_operator += i
  19081. } else {
  19082. m.addcondition_operator = &i
  19083. }
  19084. }
  19085. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  19086. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  19087. v := m.addcondition_operator
  19088. if v == nil {
  19089. return
  19090. }
  19091. return *v, true
  19092. }
  19093. // ResetConditionOperator resets all changes to the "condition_operator" field.
  19094. func (m *SopStageMutation) ResetConditionOperator() {
  19095. m.condition_operator = nil
  19096. m.addcondition_operator = nil
  19097. }
  19098. // SetConditionList sets the "condition_list" field.
  19099. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  19100. m.condition_list = &ct
  19101. m.appendcondition_list = nil
  19102. }
  19103. // ConditionList returns the value of the "condition_list" field in the mutation.
  19104. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  19105. v := m.condition_list
  19106. if v == nil {
  19107. return
  19108. }
  19109. return *v, true
  19110. }
  19111. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  19112. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19113. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19114. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  19115. if !m.op.Is(OpUpdateOne) {
  19116. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  19117. }
  19118. if m.id == nil || m.oldValue == nil {
  19119. return v, errors.New("OldConditionList requires an ID field in the mutation")
  19120. }
  19121. oldValue, err := m.oldValue(ctx)
  19122. if err != nil {
  19123. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  19124. }
  19125. return oldValue.ConditionList, nil
  19126. }
  19127. // AppendConditionList adds ct to the "condition_list" field.
  19128. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  19129. m.appendcondition_list = append(m.appendcondition_list, ct...)
  19130. }
  19131. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  19132. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  19133. if len(m.appendcondition_list) == 0 {
  19134. return nil, false
  19135. }
  19136. return m.appendcondition_list, true
  19137. }
  19138. // ResetConditionList resets all changes to the "condition_list" field.
  19139. func (m *SopStageMutation) ResetConditionList() {
  19140. m.condition_list = nil
  19141. m.appendcondition_list = nil
  19142. }
  19143. // SetActionMessage sets the "action_message" field.
  19144. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  19145. m.action_message = &ct
  19146. m.appendaction_message = nil
  19147. }
  19148. // ActionMessage returns the value of the "action_message" field in the mutation.
  19149. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  19150. v := m.action_message
  19151. if v == nil {
  19152. return
  19153. }
  19154. return *v, true
  19155. }
  19156. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  19157. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19159. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  19160. if !m.op.Is(OpUpdateOne) {
  19161. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  19162. }
  19163. if m.id == nil || m.oldValue == nil {
  19164. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  19165. }
  19166. oldValue, err := m.oldValue(ctx)
  19167. if err != nil {
  19168. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  19169. }
  19170. return oldValue.ActionMessage, nil
  19171. }
  19172. // AppendActionMessage adds ct to the "action_message" field.
  19173. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  19174. m.appendaction_message = append(m.appendaction_message, ct...)
  19175. }
  19176. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  19177. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  19178. if len(m.appendaction_message) == 0 {
  19179. return nil, false
  19180. }
  19181. return m.appendaction_message, true
  19182. }
  19183. // ClearActionMessage clears the value of the "action_message" field.
  19184. func (m *SopStageMutation) ClearActionMessage() {
  19185. m.action_message = nil
  19186. m.appendaction_message = nil
  19187. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  19188. }
  19189. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  19190. func (m *SopStageMutation) ActionMessageCleared() bool {
  19191. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  19192. return ok
  19193. }
  19194. // ResetActionMessage resets all changes to the "action_message" field.
  19195. func (m *SopStageMutation) ResetActionMessage() {
  19196. m.action_message = nil
  19197. m.appendaction_message = nil
  19198. delete(m.clearedFields, sopstage.FieldActionMessage)
  19199. }
  19200. // SetActionLabelAdd sets the "action_label_add" field.
  19201. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  19202. m.action_label_add = &u
  19203. m.appendaction_label_add = nil
  19204. }
  19205. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  19206. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  19207. v := m.action_label_add
  19208. if v == nil {
  19209. return
  19210. }
  19211. return *v, true
  19212. }
  19213. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  19214. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19215. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19216. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  19217. if !m.op.Is(OpUpdateOne) {
  19218. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  19219. }
  19220. if m.id == nil || m.oldValue == nil {
  19221. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  19222. }
  19223. oldValue, err := m.oldValue(ctx)
  19224. if err != nil {
  19225. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  19226. }
  19227. return oldValue.ActionLabelAdd, nil
  19228. }
  19229. // AppendActionLabelAdd adds u to the "action_label_add" field.
  19230. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  19231. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  19232. }
  19233. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  19234. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  19235. if len(m.appendaction_label_add) == 0 {
  19236. return nil, false
  19237. }
  19238. return m.appendaction_label_add, true
  19239. }
  19240. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  19241. func (m *SopStageMutation) ClearActionLabelAdd() {
  19242. m.action_label_add = nil
  19243. m.appendaction_label_add = nil
  19244. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  19245. }
  19246. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  19247. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  19248. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  19249. return ok
  19250. }
  19251. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  19252. func (m *SopStageMutation) ResetActionLabelAdd() {
  19253. m.action_label_add = nil
  19254. m.appendaction_label_add = nil
  19255. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  19256. }
  19257. // SetActionLabelDel sets the "action_label_del" field.
  19258. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  19259. m.action_label_del = &u
  19260. m.appendaction_label_del = nil
  19261. }
  19262. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  19263. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  19264. v := m.action_label_del
  19265. if v == nil {
  19266. return
  19267. }
  19268. return *v, true
  19269. }
  19270. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  19271. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19272. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19273. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  19274. if !m.op.Is(OpUpdateOne) {
  19275. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  19276. }
  19277. if m.id == nil || m.oldValue == nil {
  19278. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  19279. }
  19280. oldValue, err := m.oldValue(ctx)
  19281. if err != nil {
  19282. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  19283. }
  19284. return oldValue.ActionLabelDel, nil
  19285. }
  19286. // AppendActionLabelDel adds u to the "action_label_del" field.
  19287. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  19288. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  19289. }
  19290. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  19291. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  19292. if len(m.appendaction_label_del) == 0 {
  19293. return nil, false
  19294. }
  19295. return m.appendaction_label_del, true
  19296. }
  19297. // ClearActionLabelDel clears the value of the "action_label_del" field.
  19298. func (m *SopStageMutation) ClearActionLabelDel() {
  19299. m.action_label_del = nil
  19300. m.appendaction_label_del = nil
  19301. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  19302. }
  19303. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  19304. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  19305. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  19306. return ok
  19307. }
  19308. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  19309. func (m *SopStageMutation) ResetActionLabelDel() {
  19310. m.action_label_del = nil
  19311. m.appendaction_label_del = nil
  19312. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  19313. }
  19314. // SetActionForward sets the "action_forward" field.
  19315. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  19316. m.action_forward = &ctf
  19317. }
  19318. // ActionForward returns the value of the "action_forward" field in the mutation.
  19319. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  19320. v := m.action_forward
  19321. if v == nil {
  19322. return
  19323. }
  19324. return *v, true
  19325. }
  19326. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  19327. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19329. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  19330. if !m.op.Is(OpUpdateOne) {
  19331. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  19332. }
  19333. if m.id == nil || m.oldValue == nil {
  19334. return v, errors.New("OldActionForward requires an ID field in the mutation")
  19335. }
  19336. oldValue, err := m.oldValue(ctx)
  19337. if err != nil {
  19338. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  19339. }
  19340. return oldValue.ActionForward, nil
  19341. }
  19342. // ClearActionForward clears the value of the "action_forward" field.
  19343. func (m *SopStageMutation) ClearActionForward() {
  19344. m.action_forward = nil
  19345. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  19346. }
  19347. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  19348. func (m *SopStageMutation) ActionForwardCleared() bool {
  19349. _, ok := m.clearedFields[sopstage.FieldActionForward]
  19350. return ok
  19351. }
  19352. // ResetActionForward resets all changes to the "action_forward" field.
  19353. func (m *SopStageMutation) ResetActionForward() {
  19354. m.action_forward = nil
  19355. delete(m.clearedFields, sopstage.FieldActionForward)
  19356. }
  19357. // SetIndexSort sets the "index_sort" field.
  19358. func (m *SopStageMutation) SetIndexSort(i int) {
  19359. m.index_sort = &i
  19360. m.addindex_sort = nil
  19361. }
  19362. // IndexSort returns the value of the "index_sort" field in the mutation.
  19363. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  19364. v := m.index_sort
  19365. if v == nil {
  19366. return
  19367. }
  19368. return *v, true
  19369. }
  19370. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  19371. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  19372. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19373. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  19374. if !m.op.Is(OpUpdateOne) {
  19375. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  19376. }
  19377. if m.id == nil || m.oldValue == nil {
  19378. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  19379. }
  19380. oldValue, err := m.oldValue(ctx)
  19381. if err != nil {
  19382. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  19383. }
  19384. return oldValue.IndexSort, nil
  19385. }
  19386. // AddIndexSort adds i to the "index_sort" field.
  19387. func (m *SopStageMutation) AddIndexSort(i int) {
  19388. if m.addindex_sort != nil {
  19389. *m.addindex_sort += i
  19390. } else {
  19391. m.addindex_sort = &i
  19392. }
  19393. }
  19394. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  19395. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  19396. v := m.addindex_sort
  19397. if v == nil {
  19398. return
  19399. }
  19400. return *v, true
  19401. }
  19402. // ClearIndexSort clears the value of the "index_sort" field.
  19403. func (m *SopStageMutation) ClearIndexSort() {
  19404. m.index_sort = nil
  19405. m.addindex_sort = nil
  19406. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  19407. }
  19408. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  19409. func (m *SopStageMutation) IndexSortCleared() bool {
  19410. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  19411. return ok
  19412. }
  19413. // ResetIndexSort resets all changes to the "index_sort" field.
  19414. func (m *SopStageMutation) ResetIndexSort() {
  19415. m.index_sort = nil
  19416. m.addindex_sort = nil
  19417. delete(m.clearedFields, sopstage.FieldIndexSort)
  19418. }
  19419. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  19420. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  19421. m.sop_task = &id
  19422. }
  19423. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  19424. func (m *SopStageMutation) ClearSopTask() {
  19425. m.clearedsop_task = true
  19426. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  19427. }
  19428. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  19429. func (m *SopStageMutation) SopTaskCleared() bool {
  19430. return m.clearedsop_task
  19431. }
  19432. // SopTaskID returns the "sop_task" edge ID in the mutation.
  19433. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  19434. if m.sop_task != nil {
  19435. return *m.sop_task, true
  19436. }
  19437. return
  19438. }
  19439. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  19440. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  19441. // SopTaskID instead. It exists only for internal usage by the builders.
  19442. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  19443. if id := m.sop_task; id != nil {
  19444. ids = append(ids, *id)
  19445. }
  19446. return
  19447. }
  19448. // ResetSopTask resets all changes to the "sop_task" edge.
  19449. func (m *SopStageMutation) ResetSopTask() {
  19450. m.sop_task = nil
  19451. m.clearedsop_task = false
  19452. }
  19453. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  19454. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  19455. if m.stage_nodes == nil {
  19456. m.stage_nodes = make(map[uint64]struct{})
  19457. }
  19458. for i := range ids {
  19459. m.stage_nodes[ids[i]] = struct{}{}
  19460. }
  19461. }
  19462. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  19463. func (m *SopStageMutation) ClearStageNodes() {
  19464. m.clearedstage_nodes = true
  19465. }
  19466. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  19467. func (m *SopStageMutation) StageNodesCleared() bool {
  19468. return m.clearedstage_nodes
  19469. }
  19470. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  19471. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  19472. if m.removedstage_nodes == nil {
  19473. m.removedstage_nodes = make(map[uint64]struct{})
  19474. }
  19475. for i := range ids {
  19476. delete(m.stage_nodes, ids[i])
  19477. m.removedstage_nodes[ids[i]] = struct{}{}
  19478. }
  19479. }
  19480. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  19481. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  19482. for id := range m.removedstage_nodes {
  19483. ids = append(ids, id)
  19484. }
  19485. return
  19486. }
  19487. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  19488. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  19489. for id := range m.stage_nodes {
  19490. ids = append(ids, id)
  19491. }
  19492. return
  19493. }
  19494. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  19495. func (m *SopStageMutation) ResetStageNodes() {
  19496. m.stage_nodes = nil
  19497. m.clearedstage_nodes = false
  19498. m.removedstage_nodes = nil
  19499. }
  19500. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  19501. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  19502. if m.stage_messages == nil {
  19503. m.stage_messages = make(map[uint64]struct{})
  19504. }
  19505. for i := range ids {
  19506. m.stage_messages[ids[i]] = struct{}{}
  19507. }
  19508. }
  19509. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  19510. func (m *SopStageMutation) ClearStageMessages() {
  19511. m.clearedstage_messages = true
  19512. }
  19513. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  19514. func (m *SopStageMutation) StageMessagesCleared() bool {
  19515. return m.clearedstage_messages
  19516. }
  19517. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  19518. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  19519. if m.removedstage_messages == nil {
  19520. m.removedstage_messages = make(map[uint64]struct{})
  19521. }
  19522. for i := range ids {
  19523. delete(m.stage_messages, ids[i])
  19524. m.removedstage_messages[ids[i]] = struct{}{}
  19525. }
  19526. }
  19527. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  19528. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  19529. for id := range m.removedstage_messages {
  19530. ids = append(ids, id)
  19531. }
  19532. return
  19533. }
  19534. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  19535. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  19536. for id := range m.stage_messages {
  19537. ids = append(ids, id)
  19538. }
  19539. return
  19540. }
  19541. // ResetStageMessages resets all changes to the "stage_messages" edge.
  19542. func (m *SopStageMutation) ResetStageMessages() {
  19543. m.stage_messages = nil
  19544. m.clearedstage_messages = false
  19545. m.removedstage_messages = nil
  19546. }
  19547. // Where appends a list predicates to the SopStageMutation builder.
  19548. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  19549. m.predicates = append(m.predicates, ps...)
  19550. }
  19551. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  19552. // users can use type-assertion to append predicates that do not depend on any generated package.
  19553. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  19554. p := make([]predicate.SopStage, len(ps))
  19555. for i := range ps {
  19556. p[i] = ps[i]
  19557. }
  19558. m.Where(p...)
  19559. }
  19560. // Op returns the operation name.
  19561. func (m *SopStageMutation) Op() Op {
  19562. return m.op
  19563. }
  19564. // SetOp allows setting the mutation operation.
  19565. func (m *SopStageMutation) SetOp(op Op) {
  19566. m.op = op
  19567. }
  19568. // Type returns the node type of this mutation (SopStage).
  19569. func (m *SopStageMutation) Type() string {
  19570. return m.typ
  19571. }
  19572. // Fields returns all fields that were changed during this mutation. Note that in
  19573. // order to get all numeric fields that were incremented/decremented, call
  19574. // AddedFields().
  19575. func (m *SopStageMutation) Fields() []string {
  19576. fields := make([]string, 0, 14)
  19577. if m.created_at != nil {
  19578. fields = append(fields, sopstage.FieldCreatedAt)
  19579. }
  19580. if m.updated_at != nil {
  19581. fields = append(fields, sopstage.FieldUpdatedAt)
  19582. }
  19583. if m.status != nil {
  19584. fields = append(fields, sopstage.FieldStatus)
  19585. }
  19586. if m.deleted_at != nil {
  19587. fields = append(fields, sopstage.FieldDeletedAt)
  19588. }
  19589. if m.sop_task != nil {
  19590. fields = append(fields, sopstage.FieldTaskID)
  19591. }
  19592. if m.name != nil {
  19593. fields = append(fields, sopstage.FieldName)
  19594. }
  19595. if m.condition_type != nil {
  19596. fields = append(fields, sopstage.FieldConditionType)
  19597. }
  19598. if m.condition_operator != nil {
  19599. fields = append(fields, sopstage.FieldConditionOperator)
  19600. }
  19601. if m.condition_list != nil {
  19602. fields = append(fields, sopstage.FieldConditionList)
  19603. }
  19604. if m.action_message != nil {
  19605. fields = append(fields, sopstage.FieldActionMessage)
  19606. }
  19607. if m.action_label_add != nil {
  19608. fields = append(fields, sopstage.FieldActionLabelAdd)
  19609. }
  19610. if m.action_label_del != nil {
  19611. fields = append(fields, sopstage.FieldActionLabelDel)
  19612. }
  19613. if m.action_forward != nil {
  19614. fields = append(fields, sopstage.FieldActionForward)
  19615. }
  19616. if m.index_sort != nil {
  19617. fields = append(fields, sopstage.FieldIndexSort)
  19618. }
  19619. return fields
  19620. }
  19621. // Field returns the value of a field with the given name. The second boolean
  19622. // return value indicates that this field was not set, or was not defined in the
  19623. // schema.
  19624. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  19625. switch name {
  19626. case sopstage.FieldCreatedAt:
  19627. return m.CreatedAt()
  19628. case sopstage.FieldUpdatedAt:
  19629. return m.UpdatedAt()
  19630. case sopstage.FieldStatus:
  19631. return m.Status()
  19632. case sopstage.FieldDeletedAt:
  19633. return m.DeletedAt()
  19634. case sopstage.FieldTaskID:
  19635. return m.TaskID()
  19636. case sopstage.FieldName:
  19637. return m.Name()
  19638. case sopstage.FieldConditionType:
  19639. return m.ConditionType()
  19640. case sopstage.FieldConditionOperator:
  19641. return m.ConditionOperator()
  19642. case sopstage.FieldConditionList:
  19643. return m.ConditionList()
  19644. case sopstage.FieldActionMessage:
  19645. return m.ActionMessage()
  19646. case sopstage.FieldActionLabelAdd:
  19647. return m.ActionLabelAdd()
  19648. case sopstage.FieldActionLabelDel:
  19649. return m.ActionLabelDel()
  19650. case sopstage.FieldActionForward:
  19651. return m.ActionForward()
  19652. case sopstage.FieldIndexSort:
  19653. return m.IndexSort()
  19654. }
  19655. return nil, false
  19656. }
  19657. // OldField returns the old value of the field from the database. An error is
  19658. // returned if the mutation operation is not UpdateOne, or the query to the
  19659. // database failed.
  19660. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19661. switch name {
  19662. case sopstage.FieldCreatedAt:
  19663. return m.OldCreatedAt(ctx)
  19664. case sopstage.FieldUpdatedAt:
  19665. return m.OldUpdatedAt(ctx)
  19666. case sopstage.FieldStatus:
  19667. return m.OldStatus(ctx)
  19668. case sopstage.FieldDeletedAt:
  19669. return m.OldDeletedAt(ctx)
  19670. case sopstage.FieldTaskID:
  19671. return m.OldTaskID(ctx)
  19672. case sopstage.FieldName:
  19673. return m.OldName(ctx)
  19674. case sopstage.FieldConditionType:
  19675. return m.OldConditionType(ctx)
  19676. case sopstage.FieldConditionOperator:
  19677. return m.OldConditionOperator(ctx)
  19678. case sopstage.FieldConditionList:
  19679. return m.OldConditionList(ctx)
  19680. case sopstage.FieldActionMessage:
  19681. return m.OldActionMessage(ctx)
  19682. case sopstage.FieldActionLabelAdd:
  19683. return m.OldActionLabelAdd(ctx)
  19684. case sopstage.FieldActionLabelDel:
  19685. return m.OldActionLabelDel(ctx)
  19686. case sopstage.FieldActionForward:
  19687. return m.OldActionForward(ctx)
  19688. case sopstage.FieldIndexSort:
  19689. return m.OldIndexSort(ctx)
  19690. }
  19691. return nil, fmt.Errorf("unknown SopStage field %s", name)
  19692. }
  19693. // SetField sets the value of a field with the given name. It returns an error if
  19694. // the field is not defined in the schema, or if the type mismatched the field
  19695. // type.
  19696. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  19697. switch name {
  19698. case sopstage.FieldCreatedAt:
  19699. v, ok := value.(time.Time)
  19700. if !ok {
  19701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19702. }
  19703. m.SetCreatedAt(v)
  19704. return nil
  19705. case sopstage.FieldUpdatedAt:
  19706. v, ok := value.(time.Time)
  19707. if !ok {
  19708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19709. }
  19710. m.SetUpdatedAt(v)
  19711. return nil
  19712. case sopstage.FieldStatus:
  19713. v, ok := value.(uint8)
  19714. if !ok {
  19715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19716. }
  19717. m.SetStatus(v)
  19718. return nil
  19719. case sopstage.FieldDeletedAt:
  19720. v, ok := value.(time.Time)
  19721. if !ok {
  19722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19723. }
  19724. m.SetDeletedAt(v)
  19725. return nil
  19726. case sopstage.FieldTaskID:
  19727. v, ok := value.(uint64)
  19728. if !ok {
  19729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19730. }
  19731. m.SetTaskID(v)
  19732. return nil
  19733. case sopstage.FieldName:
  19734. v, ok := value.(string)
  19735. if !ok {
  19736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19737. }
  19738. m.SetName(v)
  19739. return nil
  19740. case sopstage.FieldConditionType:
  19741. v, ok := value.(int)
  19742. if !ok {
  19743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19744. }
  19745. m.SetConditionType(v)
  19746. return nil
  19747. case sopstage.FieldConditionOperator:
  19748. v, ok := value.(int)
  19749. if !ok {
  19750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19751. }
  19752. m.SetConditionOperator(v)
  19753. return nil
  19754. case sopstage.FieldConditionList:
  19755. v, ok := value.([]custom_types.Condition)
  19756. if !ok {
  19757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19758. }
  19759. m.SetConditionList(v)
  19760. return nil
  19761. case sopstage.FieldActionMessage:
  19762. v, ok := value.([]custom_types.Action)
  19763. if !ok {
  19764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19765. }
  19766. m.SetActionMessage(v)
  19767. return nil
  19768. case sopstage.FieldActionLabelAdd:
  19769. v, ok := value.([]uint64)
  19770. if !ok {
  19771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19772. }
  19773. m.SetActionLabelAdd(v)
  19774. return nil
  19775. case sopstage.FieldActionLabelDel:
  19776. v, ok := value.([]uint64)
  19777. if !ok {
  19778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19779. }
  19780. m.SetActionLabelDel(v)
  19781. return nil
  19782. case sopstage.FieldActionForward:
  19783. v, ok := value.(*custom_types.ActionForward)
  19784. if !ok {
  19785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19786. }
  19787. m.SetActionForward(v)
  19788. return nil
  19789. case sopstage.FieldIndexSort:
  19790. v, ok := value.(int)
  19791. if !ok {
  19792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19793. }
  19794. m.SetIndexSort(v)
  19795. return nil
  19796. }
  19797. return fmt.Errorf("unknown SopStage field %s", name)
  19798. }
  19799. // AddedFields returns all numeric fields that were incremented/decremented during
  19800. // this mutation.
  19801. func (m *SopStageMutation) AddedFields() []string {
  19802. var fields []string
  19803. if m.addstatus != nil {
  19804. fields = append(fields, sopstage.FieldStatus)
  19805. }
  19806. if m.addcondition_type != nil {
  19807. fields = append(fields, sopstage.FieldConditionType)
  19808. }
  19809. if m.addcondition_operator != nil {
  19810. fields = append(fields, sopstage.FieldConditionOperator)
  19811. }
  19812. if m.addindex_sort != nil {
  19813. fields = append(fields, sopstage.FieldIndexSort)
  19814. }
  19815. return fields
  19816. }
  19817. // AddedField returns the numeric value that was incremented/decremented on a field
  19818. // with the given name. The second boolean return value indicates that this field
  19819. // was not set, or was not defined in the schema.
  19820. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  19821. switch name {
  19822. case sopstage.FieldStatus:
  19823. return m.AddedStatus()
  19824. case sopstage.FieldConditionType:
  19825. return m.AddedConditionType()
  19826. case sopstage.FieldConditionOperator:
  19827. return m.AddedConditionOperator()
  19828. case sopstage.FieldIndexSort:
  19829. return m.AddedIndexSort()
  19830. }
  19831. return nil, false
  19832. }
  19833. // AddField adds the value to the field with the given name. It returns an error if
  19834. // the field is not defined in the schema, or if the type mismatched the field
  19835. // type.
  19836. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  19837. switch name {
  19838. case sopstage.FieldStatus:
  19839. v, ok := value.(int8)
  19840. if !ok {
  19841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19842. }
  19843. m.AddStatus(v)
  19844. return nil
  19845. case sopstage.FieldConditionType:
  19846. v, ok := value.(int)
  19847. if !ok {
  19848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19849. }
  19850. m.AddConditionType(v)
  19851. return nil
  19852. case sopstage.FieldConditionOperator:
  19853. v, ok := value.(int)
  19854. if !ok {
  19855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19856. }
  19857. m.AddConditionOperator(v)
  19858. return nil
  19859. case sopstage.FieldIndexSort:
  19860. v, ok := value.(int)
  19861. if !ok {
  19862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19863. }
  19864. m.AddIndexSort(v)
  19865. return nil
  19866. }
  19867. return fmt.Errorf("unknown SopStage numeric field %s", name)
  19868. }
  19869. // ClearedFields returns all nullable fields that were cleared during this
  19870. // mutation.
  19871. func (m *SopStageMutation) ClearedFields() []string {
  19872. var fields []string
  19873. if m.FieldCleared(sopstage.FieldStatus) {
  19874. fields = append(fields, sopstage.FieldStatus)
  19875. }
  19876. if m.FieldCleared(sopstage.FieldDeletedAt) {
  19877. fields = append(fields, sopstage.FieldDeletedAt)
  19878. }
  19879. if m.FieldCleared(sopstage.FieldActionMessage) {
  19880. fields = append(fields, sopstage.FieldActionMessage)
  19881. }
  19882. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  19883. fields = append(fields, sopstage.FieldActionLabelAdd)
  19884. }
  19885. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  19886. fields = append(fields, sopstage.FieldActionLabelDel)
  19887. }
  19888. if m.FieldCleared(sopstage.FieldActionForward) {
  19889. fields = append(fields, sopstage.FieldActionForward)
  19890. }
  19891. if m.FieldCleared(sopstage.FieldIndexSort) {
  19892. fields = append(fields, sopstage.FieldIndexSort)
  19893. }
  19894. return fields
  19895. }
  19896. // FieldCleared returns a boolean indicating if a field with the given name was
  19897. // cleared in this mutation.
  19898. func (m *SopStageMutation) FieldCleared(name string) bool {
  19899. _, ok := m.clearedFields[name]
  19900. return ok
  19901. }
  19902. // ClearField clears the value of the field with the given name. It returns an
  19903. // error if the field is not defined in the schema.
  19904. func (m *SopStageMutation) ClearField(name string) error {
  19905. switch name {
  19906. case sopstage.FieldStatus:
  19907. m.ClearStatus()
  19908. return nil
  19909. case sopstage.FieldDeletedAt:
  19910. m.ClearDeletedAt()
  19911. return nil
  19912. case sopstage.FieldActionMessage:
  19913. m.ClearActionMessage()
  19914. return nil
  19915. case sopstage.FieldActionLabelAdd:
  19916. m.ClearActionLabelAdd()
  19917. return nil
  19918. case sopstage.FieldActionLabelDel:
  19919. m.ClearActionLabelDel()
  19920. return nil
  19921. case sopstage.FieldActionForward:
  19922. m.ClearActionForward()
  19923. return nil
  19924. case sopstage.FieldIndexSort:
  19925. m.ClearIndexSort()
  19926. return nil
  19927. }
  19928. return fmt.Errorf("unknown SopStage nullable field %s", name)
  19929. }
  19930. // ResetField resets all changes in the mutation for the field with the given name.
  19931. // It returns an error if the field is not defined in the schema.
  19932. func (m *SopStageMutation) ResetField(name string) error {
  19933. switch name {
  19934. case sopstage.FieldCreatedAt:
  19935. m.ResetCreatedAt()
  19936. return nil
  19937. case sopstage.FieldUpdatedAt:
  19938. m.ResetUpdatedAt()
  19939. return nil
  19940. case sopstage.FieldStatus:
  19941. m.ResetStatus()
  19942. return nil
  19943. case sopstage.FieldDeletedAt:
  19944. m.ResetDeletedAt()
  19945. return nil
  19946. case sopstage.FieldTaskID:
  19947. m.ResetTaskID()
  19948. return nil
  19949. case sopstage.FieldName:
  19950. m.ResetName()
  19951. return nil
  19952. case sopstage.FieldConditionType:
  19953. m.ResetConditionType()
  19954. return nil
  19955. case sopstage.FieldConditionOperator:
  19956. m.ResetConditionOperator()
  19957. return nil
  19958. case sopstage.FieldConditionList:
  19959. m.ResetConditionList()
  19960. return nil
  19961. case sopstage.FieldActionMessage:
  19962. m.ResetActionMessage()
  19963. return nil
  19964. case sopstage.FieldActionLabelAdd:
  19965. m.ResetActionLabelAdd()
  19966. return nil
  19967. case sopstage.FieldActionLabelDel:
  19968. m.ResetActionLabelDel()
  19969. return nil
  19970. case sopstage.FieldActionForward:
  19971. m.ResetActionForward()
  19972. return nil
  19973. case sopstage.FieldIndexSort:
  19974. m.ResetIndexSort()
  19975. return nil
  19976. }
  19977. return fmt.Errorf("unknown SopStage field %s", name)
  19978. }
  19979. // AddedEdges returns all edge names that were set/added in this mutation.
  19980. func (m *SopStageMutation) AddedEdges() []string {
  19981. edges := make([]string, 0, 3)
  19982. if m.sop_task != nil {
  19983. edges = append(edges, sopstage.EdgeSopTask)
  19984. }
  19985. if m.stage_nodes != nil {
  19986. edges = append(edges, sopstage.EdgeStageNodes)
  19987. }
  19988. if m.stage_messages != nil {
  19989. edges = append(edges, sopstage.EdgeStageMessages)
  19990. }
  19991. return edges
  19992. }
  19993. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19994. // name in this mutation.
  19995. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  19996. switch name {
  19997. case sopstage.EdgeSopTask:
  19998. if id := m.sop_task; id != nil {
  19999. return []ent.Value{*id}
  20000. }
  20001. case sopstage.EdgeStageNodes:
  20002. ids := make([]ent.Value, 0, len(m.stage_nodes))
  20003. for id := range m.stage_nodes {
  20004. ids = append(ids, id)
  20005. }
  20006. return ids
  20007. case sopstage.EdgeStageMessages:
  20008. ids := make([]ent.Value, 0, len(m.stage_messages))
  20009. for id := range m.stage_messages {
  20010. ids = append(ids, id)
  20011. }
  20012. return ids
  20013. }
  20014. return nil
  20015. }
  20016. // RemovedEdges returns all edge names that were removed in this mutation.
  20017. func (m *SopStageMutation) RemovedEdges() []string {
  20018. edges := make([]string, 0, 3)
  20019. if m.removedstage_nodes != nil {
  20020. edges = append(edges, sopstage.EdgeStageNodes)
  20021. }
  20022. if m.removedstage_messages != nil {
  20023. edges = append(edges, sopstage.EdgeStageMessages)
  20024. }
  20025. return edges
  20026. }
  20027. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20028. // the given name in this mutation.
  20029. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  20030. switch name {
  20031. case sopstage.EdgeStageNodes:
  20032. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  20033. for id := range m.removedstage_nodes {
  20034. ids = append(ids, id)
  20035. }
  20036. return ids
  20037. case sopstage.EdgeStageMessages:
  20038. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  20039. for id := range m.removedstage_messages {
  20040. ids = append(ids, id)
  20041. }
  20042. return ids
  20043. }
  20044. return nil
  20045. }
  20046. // ClearedEdges returns all edge names that were cleared in this mutation.
  20047. func (m *SopStageMutation) ClearedEdges() []string {
  20048. edges := make([]string, 0, 3)
  20049. if m.clearedsop_task {
  20050. edges = append(edges, sopstage.EdgeSopTask)
  20051. }
  20052. if m.clearedstage_nodes {
  20053. edges = append(edges, sopstage.EdgeStageNodes)
  20054. }
  20055. if m.clearedstage_messages {
  20056. edges = append(edges, sopstage.EdgeStageMessages)
  20057. }
  20058. return edges
  20059. }
  20060. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20061. // was cleared in this mutation.
  20062. func (m *SopStageMutation) EdgeCleared(name string) bool {
  20063. switch name {
  20064. case sopstage.EdgeSopTask:
  20065. return m.clearedsop_task
  20066. case sopstage.EdgeStageNodes:
  20067. return m.clearedstage_nodes
  20068. case sopstage.EdgeStageMessages:
  20069. return m.clearedstage_messages
  20070. }
  20071. return false
  20072. }
  20073. // ClearEdge clears the value of the edge with the given name. It returns an error
  20074. // if that edge is not defined in the schema.
  20075. func (m *SopStageMutation) ClearEdge(name string) error {
  20076. switch name {
  20077. case sopstage.EdgeSopTask:
  20078. m.ClearSopTask()
  20079. return nil
  20080. }
  20081. return fmt.Errorf("unknown SopStage unique edge %s", name)
  20082. }
  20083. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20084. // It returns an error if the edge is not defined in the schema.
  20085. func (m *SopStageMutation) ResetEdge(name string) error {
  20086. switch name {
  20087. case sopstage.EdgeSopTask:
  20088. m.ResetSopTask()
  20089. return nil
  20090. case sopstage.EdgeStageNodes:
  20091. m.ResetStageNodes()
  20092. return nil
  20093. case sopstage.EdgeStageMessages:
  20094. m.ResetStageMessages()
  20095. return nil
  20096. }
  20097. return fmt.Errorf("unknown SopStage edge %s", name)
  20098. }
  20099. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  20100. type SopTaskMutation struct {
  20101. config
  20102. op Op
  20103. typ string
  20104. id *uint64
  20105. created_at *time.Time
  20106. updated_at *time.Time
  20107. status *uint8
  20108. addstatus *int8
  20109. deleted_at *time.Time
  20110. name *string
  20111. bot_wxid_list *[]string
  20112. appendbot_wxid_list []string
  20113. _type *int
  20114. add_type *int
  20115. plan_start_time *time.Time
  20116. plan_end_time *time.Time
  20117. creator_id *string
  20118. organization_id *uint64
  20119. addorganization_id *int64
  20120. token *[]string
  20121. appendtoken []string
  20122. clearedFields map[string]struct{}
  20123. task_stages map[uint64]struct{}
  20124. removedtask_stages map[uint64]struct{}
  20125. clearedtask_stages bool
  20126. done bool
  20127. oldValue func(context.Context) (*SopTask, error)
  20128. predicates []predicate.SopTask
  20129. }
  20130. var _ ent.Mutation = (*SopTaskMutation)(nil)
  20131. // soptaskOption allows management of the mutation configuration using functional options.
  20132. type soptaskOption func(*SopTaskMutation)
  20133. // newSopTaskMutation creates new mutation for the SopTask entity.
  20134. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  20135. m := &SopTaskMutation{
  20136. config: c,
  20137. op: op,
  20138. typ: TypeSopTask,
  20139. clearedFields: make(map[string]struct{}),
  20140. }
  20141. for _, opt := range opts {
  20142. opt(m)
  20143. }
  20144. return m
  20145. }
  20146. // withSopTaskID sets the ID field of the mutation.
  20147. func withSopTaskID(id uint64) soptaskOption {
  20148. return func(m *SopTaskMutation) {
  20149. var (
  20150. err error
  20151. once sync.Once
  20152. value *SopTask
  20153. )
  20154. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  20155. once.Do(func() {
  20156. if m.done {
  20157. err = errors.New("querying old values post mutation is not allowed")
  20158. } else {
  20159. value, err = m.Client().SopTask.Get(ctx, id)
  20160. }
  20161. })
  20162. return value, err
  20163. }
  20164. m.id = &id
  20165. }
  20166. }
  20167. // withSopTask sets the old SopTask of the mutation.
  20168. func withSopTask(node *SopTask) soptaskOption {
  20169. return func(m *SopTaskMutation) {
  20170. m.oldValue = func(context.Context) (*SopTask, error) {
  20171. return node, nil
  20172. }
  20173. m.id = &node.ID
  20174. }
  20175. }
  20176. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20177. // executed in a transaction (ent.Tx), a transactional client is returned.
  20178. func (m SopTaskMutation) Client() *Client {
  20179. client := &Client{config: m.config}
  20180. client.init()
  20181. return client
  20182. }
  20183. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20184. // it returns an error otherwise.
  20185. func (m SopTaskMutation) Tx() (*Tx, error) {
  20186. if _, ok := m.driver.(*txDriver); !ok {
  20187. return nil, errors.New("ent: mutation is not running in a transaction")
  20188. }
  20189. tx := &Tx{config: m.config}
  20190. tx.init()
  20191. return tx, nil
  20192. }
  20193. // SetID sets the value of the id field. Note that this
  20194. // operation is only accepted on creation of SopTask entities.
  20195. func (m *SopTaskMutation) SetID(id uint64) {
  20196. m.id = &id
  20197. }
  20198. // ID returns the ID value in the mutation. Note that the ID is only available
  20199. // if it was provided to the builder or after it was returned from the database.
  20200. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  20201. if m.id == nil {
  20202. return
  20203. }
  20204. return *m.id, true
  20205. }
  20206. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20207. // That means, if the mutation is applied within a transaction with an isolation level such
  20208. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20209. // or updated by the mutation.
  20210. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  20211. switch {
  20212. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20213. id, exists := m.ID()
  20214. if exists {
  20215. return []uint64{id}, nil
  20216. }
  20217. fallthrough
  20218. case m.op.Is(OpUpdate | OpDelete):
  20219. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  20220. default:
  20221. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20222. }
  20223. }
  20224. // SetCreatedAt sets the "created_at" field.
  20225. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  20226. m.created_at = &t
  20227. }
  20228. // CreatedAt returns the value of the "created_at" field in the mutation.
  20229. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  20230. v := m.created_at
  20231. if v == nil {
  20232. return
  20233. }
  20234. return *v, true
  20235. }
  20236. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  20237. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20239. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20240. if !m.op.Is(OpUpdateOne) {
  20241. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20242. }
  20243. if m.id == nil || m.oldValue == nil {
  20244. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20245. }
  20246. oldValue, err := m.oldValue(ctx)
  20247. if err != nil {
  20248. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20249. }
  20250. return oldValue.CreatedAt, nil
  20251. }
  20252. // ResetCreatedAt resets all changes to the "created_at" field.
  20253. func (m *SopTaskMutation) ResetCreatedAt() {
  20254. m.created_at = nil
  20255. }
  20256. // SetUpdatedAt sets the "updated_at" field.
  20257. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  20258. m.updated_at = &t
  20259. }
  20260. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20261. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  20262. v := m.updated_at
  20263. if v == nil {
  20264. return
  20265. }
  20266. return *v, true
  20267. }
  20268. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  20269. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20271. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20272. if !m.op.Is(OpUpdateOne) {
  20273. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20274. }
  20275. if m.id == nil || m.oldValue == nil {
  20276. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20277. }
  20278. oldValue, err := m.oldValue(ctx)
  20279. if err != nil {
  20280. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20281. }
  20282. return oldValue.UpdatedAt, nil
  20283. }
  20284. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20285. func (m *SopTaskMutation) ResetUpdatedAt() {
  20286. m.updated_at = nil
  20287. }
  20288. // SetStatus sets the "status" field.
  20289. func (m *SopTaskMutation) SetStatus(u uint8) {
  20290. m.status = &u
  20291. m.addstatus = nil
  20292. }
  20293. // Status returns the value of the "status" field in the mutation.
  20294. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  20295. v := m.status
  20296. if v == nil {
  20297. return
  20298. }
  20299. return *v, true
  20300. }
  20301. // OldStatus returns the old "status" field's value of the SopTask entity.
  20302. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20304. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20305. if !m.op.Is(OpUpdateOne) {
  20306. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20307. }
  20308. if m.id == nil || m.oldValue == nil {
  20309. return v, errors.New("OldStatus requires an ID field in the mutation")
  20310. }
  20311. oldValue, err := m.oldValue(ctx)
  20312. if err != nil {
  20313. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20314. }
  20315. return oldValue.Status, nil
  20316. }
  20317. // AddStatus adds u to the "status" field.
  20318. func (m *SopTaskMutation) AddStatus(u int8) {
  20319. if m.addstatus != nil {
  20320. *m.addstatus += u
  20321. } else {
  20322. m.addstatus = &u
  20323. }
  20324. }
  20325. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20326. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  20327. v := m.addstatus
  20328. if v == nil {
  20329. return
  20330. }
  20331. return *v, true
  20332. }
  20333. // ClearStatus clears the value of the "status" field.
  20334. func (m *SopTaskMutation) ClearStatus() {
  20335. m.status = nil
  20336. m.addstatus = nil
  20337. m.clearedFields[soptask.FieldStatus] = struct{}{}
  20338. }
  20339. // StatusCleared returns if the "status" field was cleared in this mutation.
  20340. func (m *SopTaskMutation) StatusCleared() bool {
  20341. _, ok := m.clearedFields[soptask.FieldStatus]
  20342. return ok
  20343. }
  20344. // ResetStatus resets all changes to the "status" field.
  20345. func (m *SopTaskMutation) ResetStatus() {
  20346. m.status = nil
  20347. m.addstatus = nil
  20348. delete(m.clearedFields, soptask.FieldStatus)
  20349. }
  20350. // SetDeletedAt sets the "deleted_at" field.
  20351. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  20352. m.deleted_at = &t
  20353. }
  20354. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20355. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  20356. v := m.deleted_at
  20357. if v == nil {
  20358. return
  20359. }
  20360. return *v, true
  20361. }
  20362. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  20363. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20365. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20366. if !m.op.Is(OpUpdateOne) {
  20367. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20368. }
  20369. if m.id == nil || m.oldValue == nil {
  20370. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20371. }
  20372. oldValue, err := m.oldValue(ctx)
  20373. if err != nil {
  20374. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20375. }
  20376. return oldValue.DeletedAt, nil
  20377. }
  20378. // ClearDeletedAt clears the value of the "deleted_at" field.
  20379. func (m *SopTaskMutation) ClearDeletedAt() {
  20380. m.deleted_at = nil
  20381. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  20382. }
  20383. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20384. func (m *SopTaskMutation) DeletedAtCleared() bool {
  20385. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  20386. return ok
  20387. }
  20388. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20389. func (m *SopTaskMutation) ResetDeletedAt() {
  20390. m.deleted_at = nil
  20391. delete(m.clearedFields, soptask.FieldDeletedAt)
  20392. }
  20393. // SetName sets the "name" field.
  20394. func (m *SopTaskMutation) SetName(s string) {
  20395. m.name = &s
  20396. }
  20397. // Name returns the value of the "name" field in the mutation.
  20398. func (m *SopTaskMutation) Name() (r string, exists bool) {
  20399. v := m.name
  20400. if v == nil {
  20401. return
  20402. }
  20403. return *v, true
  20404. }
  20405. // OldName returns the old "name" field's value of the SopTask entity.
  20406. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20408. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  20409. if !m.op.Is(OpUpdateOne) {
  20410. return v, errors.New("OldName is only allowed on UpdateOne operations")
  20411. }
  20412. if m.id == nil || m.oldValue == nil {
  20413. return v, errors.New("OldName requires an ID field in the mutation")
  20414. }
  20415. oldValue, err := m.oldValue(ctx)
  20416. if err != nil {
  20417. return v, fmt.Errorf("querying old value for OldName: %w", err)
  20418. }
  20419. return oldValue.Name, nil
  20420. }
  20421. // ResetName resets all changes to the "name" field.
  20422. func (m *SopTaskMutation) ResetName() {
  20423. m.name = nil
  20424. }
  20425. // SetBotWxidList sets the "bot_wxid_list" field.
  20426. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  20427. m.bot_wxid_list = &s
  20428. m.appendbot_wxid_list = nil
  20429. }
  20430. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  20431. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  20432. v := m.bot_wxid_list
  20433. if v == nil {
  20434. return
  20435. }
  20436. return *v, true
  20437. }
  20438. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  20439. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20440. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20441. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  20442. if !m.op.Is(OpUpdateOne) {
  20443. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  20444. }
  20445. if m.id == nil || m.oldValue == nil {
  20446. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  20447. }
  20448. oldValue, err := m.oldValue(ctx)
  20449. if err != nil {
  20450. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  20451. }
  20452. return oldValue.BotWxidList, nil
  20453. }
  20454. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  20455. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  20456. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  20457. }
  20458. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  20459. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  20460. if len(m.appendbot_wxid_list) == 0 {
  20461. return nil, false
  20462. }
  20463. return m.appendbot_wxid_list, true
  20464. }
  20465. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  20466. func (m *SopTaskMutation) ClearBotWxidList() {
  20467. m.bot_wxid_list = nil
  20468. m.appendbot_wxid_list = nil
  20469. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  20470. }
  20471. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  20472. func (m *SopTaskMutation) BotWxidListCleared() bool {
  20473. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  20474. return ok
  20475. }
  20476. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  20477. func (m *SopTaskMutation) ResetBotWxidList() {
  20478. m.bot_wxid_list = nil
  20479. m.appendbot_wxid_list = nil
  20480. delete(m.clearedFields, soptask.FieldBotWxidList)
  20481. }
  20482. // SetType sets the "type" field.
  20483. func (m *SopTaskMutation) SetType(i int) {
  20484. m._type = &i
  20485. m.add_type = nil
  20486. }
  20487. // GetType returns the value of the "type" field in the mutation.
  20488. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  20489. v := m._type
  20490. if v == nil {
  20491. return
  20492. }
  20493. return *v, true
  20494. }
  20495. // OldType returns the old "type" field's value of the SopTask entity.
  20496. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20497. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20498. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  20499. if !m.op.Is(OpUpdateOne) {
  20500. return v, errors.New("OldType is only allowed on UpdateOne operations")
  20501. }
  20502. if m.id == nil || m.oldValue == nil {
  20503. return v, errors.New("OldType requires an ID field in the mutation")
  20504. }
  20505. oldValue, err := m.oldValue(ctx)
  20506. if err != nil {
  20507. return v, fmt.Errorf("querying old value for OldType: %w", err)
  20508. }
  20509. return oldValue.Type, nil
  20510. }
  20511. // AddType adds i to the "type" field.
  20512. func (m *SopTaskMutation) AddType(i int) {
  20513. if m.add_type != nil {
  20514. *m.add_type += i
  20515. } else {
  20516. m.add_type = &i
  20517. }
  20518. }
  20519. // AddedType returns the value that was added to the "type" field in this mutation.
  20520. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  20521. v := m.add_type
  20522. if v == nil {
  20523. return
  20524. }
  20525. return *v, true
  20526. }
  20527. // ResetType resets all changes to the "type" field.
  20528. func (m *SopTaskMutation) ResetType() {
  20529. m._type = nil
  20530. m.add_type = nil
  20531. }
  20532. // SetPlanStartTime sets the "plan_start_time" field.
  20533. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  20534. m.plan_start_time = &t
  20535. }
  20536. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  20537. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  20538. v := m.plan_start_time
  20539. if v == nil {
  20540. return
  20541. }
  20542. return *v, true
  20543. }
  20544. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  20545. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20546. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20547. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  20548. if !m.op.Is(OpUpdateOne) {
  20549. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  20550. }
  20551. if m.id == nil || m.oldValue == nil {
  20552. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  20553. }
  20554. oldValue, err := m.oldValue(ctx)
  20555. if err != nil {
  20556. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  20557. }
  20558. return oldValue.PlanStartTime, nil
  20559. }
  20560. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  20561. func (m *SopTaskMutation) ClearPlanStartTime() {
  20562. m.plan_start_time = nil
  20563. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  20564. }
  20565. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  20566. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  20567. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  20568. return ok
  20569. }
  20570. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  20571. func (m *SopTaskMutation) ResetPlanStartTime() {
  20572. m.plan_start_time = nil
  20573. delete(m.clearedFields, soptask.FieldPlanStartTime)
  20574. }
  20575. // SetPlanEndTime sets the "plan_end_time" field.
  20576. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  20577. m.plan_end_time = &t
  20578. }
  20579. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  20580. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  20581. v := m.plan_end_time
  20582. if v == nil {
  20583. return
  20584. }
  20585. return *v, true
  20586. }
  20587. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  20588. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20590. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  20591. if !m.op.Is(OpUpdateOne) {
  20592. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  20593. }
  20594. if m.id == nil || m.oldValue == nil {
  20595. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  20596. }
  20597. oldValue, err := m.oldValue(ctx)
  20598. if err != nil {
  20599. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  20600. }
  20601. return oldValue.PlanEndTime, nil
  20602. }
  20603. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  20604. func (m *SopTaskMutation) ClearPlanEndTime() {
  20605. m.plan_end_time = nil
  20606. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  20607. }
  20608. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  20609. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  20610. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  20611. return ok
  20612. }
  20613. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  20614. func (m *SopTaskMutation) ResetPlanEndTime() {
  20615. m.plan_end_time = nil
  20616. delete(m.clearedFields, soptask.FieldPlanEndTime)
  20617. }
  20618. // SetCreatorID sets the "creator_id" field.
  20619. func (m *SopTaskMutation) SetCreatorID(s string) {
  20620. m.creator_id = &s
  20621. }
  20622. // CreatorID returns the value of the "creator_id" field in the mutation.
  20623. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  20624. v := m.creator_id
  20625. if v == nil {
  20626. return
  20627. }
  20628. return *v, true
  20629. }
  20630. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  20631. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20633. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  20634. if !m.op.Is(OpUpdateOne) {
  20635. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  20636. }
  20637. if m.id == nil || m.oldValue == nil {
  20638. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  20639. }
  20640. oldValue, err := m.oldValue(ctx)
  20641. if err != nil {
  20642. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  20643. }
  20644. return oldValue.CreatorID, nil
  20645. }
  20646. // ClearCreatorID clears the value of the "creator_id" field.
  20647. func (m *SopTaskMutation) ClearCreatorID() {
  20648. m.creator_id = nil
  20649. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  20650. }
  20651. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  20652. func (m *SopTaskMutation) CreatorIDCleared() bool {
  20653. _, ok := m.clearedFields[soptask.FieldCreatorID]
  20654. return ok
  20655. }
  20656. // ResetCreatorID resets all changes to the "creator_id" field.
  20657. func (m *SopTaskMutation) ResetCreatorID() {
  20658. m.creator_id = nil
  20659. delete(m.clearedFields, soptask.FieldCreatorID)
  20660. }
  20661. // SetOrganizationID sets the "organization_id" field.
  20662. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  20663. m.organization_id = &u
  20664. m.addorganization_id = nil
  20665. }
  20666. // OrganizationID returns the value of the "organization_id" field in the mutation.
  20667. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  20668. v := m.organization_id
  20669. if v == nil {
  20670. return
  20671. }
  20672. return *v, true
  20673. }
  20674. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  20675. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20677. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  20678. if !m.op.Is(OpUpdateOne) {
  20679. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  20680. }
  20681. if m.id == nil || m.oldValue == nil {
  20682. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  20683. }
  20684. oldValue, err := m.oldValue(ctx)
  20685. if err != nil {
  20686. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  20687. }
  20688. return oldValue.OrganizationID, nil
  20689. }
  20690. // AddOrganizationID adds u to the "organization_id" field.
  20691. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  20692. if m.addorganization_id != nil {
  20693. *m.addorganization_id += u
  20694. } else {
  20695. m.addorganization_id = &u
  20696. }
  20697. }
  20698. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  20699. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  20700. v := m.addorganization_id
  20701. if v == nil {
  20702. return
  20703. }
  20704. return *v, true
  20705. }
  20706. // ClearOrganizationID clears the value of the "organization_id" field.
  20707. func (m *SopTaskMutation) ClearOrganizationID() {
  20708. m.organization_id = nil
  20709. m.addorganization_id = nil
  20710. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  20711. }
  20712. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  20713. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  20714. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  20715. return ok
  20716. }
  20717. // ResetOrganizationID resets all changes to the "organization_id" field.
  20718. func (m *SopTaskMutation) ResetOrganizationID() {
  20719. m.organization_id = nil
  20720. m.addorganization_id = nil
  20721. delete(m.clearedFields, soptask.FieldOrganizationID)
  20722. }
  20723. // SetToken sets the "token" field.
  20724. func (m *SopTaskMutation) SetToken(s []string) {
  20725. m.token = &s
  20726. m.appendtoken = nil
  20727. }
  20728. // Token returns the value of the "token" field in the mutation.
  20729. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  20730. v := m.token
  20731. if v == nil {
  20732. return
  20733. }
  20734. return *v, true
  20735. }
  20736. // OldToken returns the old "token" field's value of the SopTask entity.
  20737. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  20738. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20739. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  20740. if !m.op.Is(OpUpdateOne) {
  20741. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  20742. }
  20743. if m.id == nil || m.oldValue == nil {
  20744. return v, errors.New("OldToken requires an ID field in the mutation")
  20745. }
  20746. oldValue, err := m.oldValue(ctx)
  20747. if err != nil {
  20748. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  20749. }
  20750. return oldValue.Token, nil
  20751. }
  20752. // AppendToken adds s to the "token" field.
  20753. func (m *SopTaskMutation) AppendToken(s []string) {
  20754. m.appendtoken = append(m.appendtoken, s...)
  20755. }
  20756. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  20757. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  20758. if len(m.appendtoken) == 0 {
  20759. return nil, false
  20760. }
  20761. return m.appendtoken, true
  20762. }
  20763. // ClearToken clears the value of the "token" field.
  20764. func (m *SopTaskMutation) ClearToken() {
  20765. m.token = nil
  20766. m.appendtoken = nil
  20767. m.clearedFields[soptask.FieldToken] = struct{}{}
  20768. }
  20769. // TokenCleared returns if the "token" field was cleared in this mutation.
  20770. func (m *SopTaskMutation) TokenCleared() bool {
  20771. _, ok := m.clearedFields[soptask.FieldToken]
  20772. return ok
  20773. }
  20774. // ResetToken resets all changes to the "token" field.
  20775. func (m *SopTaskMutation) ResetToken() {
  20776. m.token = nil
  20777. m.appendtoken = nil
  20778. delete(m.clearedFields, soptask.FieldToken)
  20779. }
  20780. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  20781. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  20782. if m.task_stages == nil {
  20783. m.task_stages = make(map[uint64]struct{})
  20784. }
  20785. for i := range ids {
  20786. m.task_stages[ids[i]] = struct{}{}
  20787. }
  20788. }
  20789. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  20790. func (m *SopTaskMutation) ClearTaskStages() {
  20791. m.clearedtask_stages = true
  20792. }
  20793. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  20794. func (m *SopTaskMutation) TaskStagesCleared() bool {
  20795. return m.clearedtask_stages
  20796. }
  20797. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  20798. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  20799. if m.removedtask_stages == nil {
  20800. m.removedtask_stages = make(map[uint64]struct{})
  20801. }
  20802. for i := range ids {
  20803. delete(m.task_stages, ids[i])
  20804. m.removedtask_stages[ids[i]] = struct{}{}
  20805. }
  20806. }
  20807. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  20808. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  20809. for id := range m.removedtask_stages {
  20810. ids = append(ids, id)
  20811. }
  20812. return
  20813. }
  20814. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  20815. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  20816. for id := range m.task_stages {
  20817. ids = append(ids, id)
  20818. }
  20819. return
  20820. }
  20821. // ResetTaskStages resets all changes to the "task_stages" edge.
  20822. func (m *SopTaskMutation) ResetTaskStages() {
  20823. m.task_stages = nil
  20824. m.clearedtask_stages = false
  20825. m.removedtask_stages = nil
  20826. }
  20827. // Where appends a list predicates to the SopTaskMutation builder.
  20828. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  20829. m.predicates = append(m.predicates, ps...)
  20830. }
  20831. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  20832. // users can use type-assertion to append predicates that do not depend on any generated package.
  20833. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  20834. p := make([]predicate.SopTask, len(ps))
  20835. for i := range ps {
  20836. p[i] = ps[i]
  20837. }
  20838. m.Where(p...)
  20839. }
  20840. // Op returns the operation name.
  20841. func (m *SopTaskMutation) Op() Op {
  20842. return m.op
  20843. }
  20844. // SetOp allows setting the mutation operation.
  20845. func (m *SopTaskMutation) SetOp(op Op) {
  20846. m.op = op
  20847. }
  20848. // Type returns the node type of this mutation (SopTask).
  20849. func (m *SopTaskMutation) Type() string {
  20850. return m.typ
  20851. }
  20852. // Fields returns all fields that were changed during this mutation. Note that in
  20853. // order to get all numeric fields that were incremented/decremented, call
  20854. // AddedFields().
  20855. func (m *SopTaskMutation) Fields() []string {
  20856. fields := make([]string, 0, 12)
  20857. if m.created_at != nil {
  20858. fields = append(fields, soptask.FieldCreatedAt)
  20859. }
  20860. if m.updated_at != nil {
  20861. fields = append(fields, soptask.FieldUpdatedAt)
  20862. }
  20863. if m.status != nil {
  20864. fields = append(fields, soptask.FieldStatus)
  20865. }
  20866. if m.deleted_at != nil {
  20867. fields = append(fields, soptask.FieldDeletedAt)
  20868. }
  20869. if m.name != nil {
  20870. fields = append(fields, soptask.FieldName)
  20871. }
  20872. if m.bot_wxid_list != nil {
  20873. fields = append(fields, soptask.FieldBotWxidList)
  20874. }
  20875. if m._type != nil {
  20876. fields = append(fields, soptask.FieldType)
  20877. }
  20878. if m.plan_start_time != nil {
  20879. fields = append(fields, soptask.FieldPlanStartTime)
  20880. }
  20881. if m.plan_end_time != nil {
  20882. fields = append(fields, soptask.FieldPlanEndTime)
  20883. }
  20884. if m.creator_id != nil {
  20885. fields = append(fields, soptask.FieldCreatorID)
  20886. }
  20887. if m.organization_id != nil {
  20888. fields = append(fields, soptask.FieldOrganizationID)
  20889. }
  20890. if m.token != nil {
  20891. fields = append(fields, soptask.FieldToken)
  20892. }
  20893. return fields
  20894. }
  20895. // Field returns the value of a field with the given name. The second boolean
  20896. // return value indicates that this field was not set, or was not defined in the
  20897. // schema.
  20898. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  20899. switch name {
  20900. case soptask.FieldCreatedAt:
  20901. return m.CreatedAt()
  20902. case soptask.FieldUpdatedAt:
  20903. return m.UpdatedAt()
  20904. case soptask.FieldStatus:
  20905. return m.Status()
  20906. case soptask.FieldDeletedAt:
  20907. return m.DeletedAt()
  20908. case soptask.FieldName:
  20909. return m.Name()
  20910. case soptask.FieldBotWxidList:
  20911. return m.BotWxidList()
  20912. case soptask.FieldType:
  20913. return m.GetType()
  20914. case soptask.FieldPlanStartTime:
  20915. return m.PlanStartTime()
  20916. case soptask.FieldPlanEndTime:
  20917. return m.PlanEndTime()
  20918. case soptask.FieldCreatorID:
  20919. return m.CreatorID()
  20920. case soptask.FieldOrganizationID:
  20921. return m.OrganizationID()
  20922. case soptask.FieldToken:
  20923. return m.Token()
  20924. }
  20925. return nil, false
  20926. }
  20927. // OldField returns the old value of the field from the database. An error is
  20928. // returned if the mutation operation is not UpdateOne, or the query to the
  20929. // database failed.
  20930. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20931. switch name {
  20932. case soptask.FieldCreatedAt:
  20933. return m.OldCreatedAt(ctx)
  20934. case soptask.FieldUpdatedAt:
  20935. return m.OldUpdatedAt(ctx)
  20936. case soptask.FieldStatus:
  20937. return m.OldStatus(ctx)
  20938. case soptask.FieldDeletedAt:
  20939. return m.OldDeletedAt(ctx)
  20940. case soptask.FieldName:
  20941. return m.OldName(ctx)
  20942. case soptask.FieldBotWxidList:
  20943. return m.OldBotWxidList(ctx)
  20944. case soptask.FieldType:
  20945. return m.OldType(ctx)
  20946. case soptask.FieldPlanStartTime:
  20947. return m.OldPlanStartTime(ctx)
  20948. case soptask.FieldPlanEndTime:
  20949. return m.OldPlanEndTime(ctx)
  20950. case soptask.FieldCreatorID:
  20951. return m.OldCreatorID(ctx)
  20952. case soptask.FieldOrganizationID:
  20953. return m.OldOrganizationID(ctx)
  20954. case soptask.FieldToken:
  20955. return m.OldToken(ctx)
  20956. }
  20957. return nil, fmt.Errorf("unknown SopTask field %s", name)
  20958. }
  20959. // SetField sets the value of a field with the given name. It returns an error if
  20960. // the field is not defined in the schema, or if the type mismatched the field
  20961. // type.
  20962. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  20963. switch name {
  20964. case soptask.FieldCreatedAt:
  20965. v, ok := value.(time.Time)
  20966. if !ok {
  20967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20968. }
  20969. m.SetCreatedAt(v)
  20970. return nil
  20971. case soptask.FieldUpdatedAt:
  20972. v, ok := value.(time.Time)
  20973. if !ok {
  20974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20975. }
  20976. m.SetUpdatedAt(v)
  20977. return nil
  20978. case soptask.FieldStatus:
  20979. v, ok := value.(uint8)
  20980. if !ok {
  20981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20982. }
  20983. m.SetStatus(v)
  20984. return nil
  20985. case soptask.FieldDeletedAt:
  20986. v, ok := value.(time.Time)
  20987. if !ok {
  20988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20989. }
  20990. m.SetDeletedAt(v)
  20991. return nil
  20992. case soptask.FieldName:
  20993. v, ok := value.(string)
  20994. if !ok {
  20995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20996. }
  20997. m.SetName(v)
  20998. return nil
  20999. case soptask.FieldBotWxidList:
  21000. v, ok := value.([]string)
  21001. if !ok {
  21002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21003. }
  21004. m.SetBotWxidList(v)
  21005. return nil
  21006. case soptask.FieldType:
  21007. v, ok := value.(int)
  21008. if !ok {
  21009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21010. }
  21011. m.SetType(v)
  21012. return nil
  21013. case soptask.FieldPlanStartTime:
  21014. v, ok := value.(time.Time)
  21015. if !ok {
  21016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21017. }
  21018. m.SetPlanStartTime(v)
  21019. return nil
  21020. case soptask.FieldPlanEndTime:
  21021. v, ok := value.(time.Time)
  21022. if !ok {
  21023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21024. }
  21025. m.SetPlanEndTime(v)
  21026. return nil
  21027. case soptask.FieldCreatorID:
  21028. v, ok := value.(string)
  21029. if !ok {
  21030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21031. }
  21032. m.SetCreatorID(v)
  21033. return nil
  21034. case soptask.FieldOrganizationID:
  21035. v, ok := value.(uint64)
  21036. if !ok {
  21037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21038. }
  21039. m.SetOrganizationID(v)
  21040. return nil
  21041. case soptask.FieldToken:
  21042. v, ok := value.([]string)
  21043. if !ok {
  21044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21045. }
  21046. m.SetToken(v)
  21047. return nil
  21048. }
  21049. return fmt.Errorf("unknown SopTask field %s", name)
  21050. }
  21051. // AddedFields returns all numeric fields that were incremented/decremented during
  21052. // this mutation.
  21053. func (m *SopTaskMutation) AddedFields() []string {
  21054. var fields []string
  21055. if m.addstatus != nil {
  21056. fields = append(fields, soptask.FieldStatus)
  21057. }
  21058. if m.add_type != nil {
  21059. fields = append(fields, soptask.FieldType)
  21060. }
  21061. if m.addorganization_id != nil {
  21062. fields = append(fields, soptask.FieldOrganizationID)
  21063. }
  21064. return fields
  21065. }
  21066. // AddedField returns the numeric value that was incremented/decremented on a field
  21067. // with the given name. The second boolean return value indicates that this field
  21068. // was not set, or was not defined in the schema.
  21069. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  21070. switch name {
  21071. case soptask.FieldStatus:
  21072. return m.AddedStatus()
  21073. case soptask.FieldType:
  21074. return m.AddedType()
  21075. case soptask.FieldOrganizationID:
  21076. return m.AddedOrganizationID()
  21077. }
  21078. return nil, false
  21079. }
  21080. // AddField adds the value to the field with the given name. It returns an error if
  21081. // the field is not defined in the schema, or if the type mismatched the field
  21082. // type.
  21083. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  21084. switch name {
  21085. case soptask.FieldStatus:
  21086. v, ok := value.(int8)
  21087. if !ok {
  21088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21089. }
  21090. m.AddStatus(v)
  21091. return nil
  21092. case soptask.FieldType:
  21093. v, ok := value.(int)
  21094. if !ok {
  21095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21096. }
  21097. m.AddType(v)
  21098. return nil
  21099. case soptask.FieldOrganizationID:
  21100. v, ok := value.(int64)
  21101. if !ok {
  21102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21103. }
  21104. m.AddOrganizationID(v)
  21105. return nil
  21106. }
  21107. return fmt.Errorf("unknown SopTask numeric field %s", name)
  21108. }
  21109. // ClearedFields returns all nullable fields that were cleared during this
  21110. // mutation.
  21111. func (m *SopTaskMutation) ClearedFields() []string {
  21112. var fields []string
  21113. if m.FieldCleared(soptask.FieldStatus) {
  21114. fields = append(fields, soptask.FieldStatus)
  21115. }
  21116. if m.FieldCleared(soptask.FieldDeletedAt) {
  21117. fields = append(fields, soptask.FieldDeletedAt)
  21118. }
  21119. if m.FieldCleared(soptask.FieldBotWxidList) {
  21120. fields = append(fields, soptask.FieldBotWxidList)
  21121. }
  21122. if m.FieldCleared(soptask.FieldPlanStartTime) {
  21123. fields = append(fields, soptask.FieldPlanStartTime)
  21124. }
  21125. if m.FieldCleared(soptask.FieldPlanEndTime) {
  21126. fields = append(fields, soptask.FieldPlanEndTime)
  21127. }
  21128. if m.FieldCleared(soptask.FieldCreatorID) {
  21129. fields = append(fields, soptask.FieldCreatorID)
  21130. }
  21131. if m.FieldCleared(soptask.FieldOrganizationID) {
  21132. fields = append(fields, soptask.FieldOrganizationID)
  21133. }
  21134. if m.FieldCleared(soptask.FieldToken) {
  21135. fields = append(fields, soptask.FieldToken)
  21136. }
  21137. return fields
  21138. }
  21139. // FieldCleared returns a boolean indicating if a field with the given name was
  21140. // cleared in this mutation.
  21141. func (m *SopTaskMutation) FieldCleared(name string) bool {
  21142. _, ok := m.clearedFields[name]
  21143. return ok
  21144. }
  21145. // ClearField clears the value of the field with the given name. It returns an
  21146. // error if the field is not defined in the schema.
  21147. func (m *SopTaskMutation) ClearField(name string) error {
  21148. switch name {
  21149. case soptask.FieldStatus:
  21150. m.ClearStatus()
  21151. return nil
  21152. case soptask.FieldDeletedAt:
  21153. m.ClearDeletedAt()
  21154. return nil
  21155. case soptask.FieldBotWxidList:
  21156. m.ClearBotWxidList()
  21157. return nil
  21158. case soptask.FieldPlanStartTime:
  21159. m.ClearPlanStartTime()
  21160. return nil
  21161. case soptask.FieldPlanEndTime:
  21162. m.ClearPlanEndTime()
  21163. return nil
  21164. case soptask.FieldCreatorID:
  21165. m.ClearCreatorID()
  21166. return nil
  21167. case soptask.FieldOrganizationID:
  21168. m.ClearOrganizationID()
  21169. return nil
  21170. case soptask.FieldToken:
  21171. m.ClearToken()
  21172. return nil
  21173. }
  21174. return fmt.Errorf("unknown SopTask nullable field %s", name)
  21175. }
  21176. // ResetField resets all changes in the mutation for the field with the given name.
  21177. // It returns an error if the field is not defined in the schema.
  21178. func (m *SopTaskMutation) ResetField(name string) error {
  21179. switch name {
  21180. case soptask.FieldCreatedAt:
  21181. m.ResetCreatedAt()
  21182. return nil
  21183. case soptask.FieldUpdatedAt:
  21184. m.ResetUpdatedAt()
  21185. return nil
  21186. case soptask.FieldStatus:
  21187. m.ResetStatus()
  21188. return nil
  21189. case soptask.FieldDeletedAt:
  21190. m.ResetDeletedAt()
  21191. return nil
  21192. case soptask.FieldName:
  21193. m.ResetName()
  21194. return nil
  21195. case soptask.FieldBotWxidList:
  21196. m.ResetBotWxidList()
  21197. return nil
  21198. case soptask.FieldType:
  21199. m.ResetType()
  21200. return nil
  21201. case soptask.FieldPlanStartTime:
  21202. m.ResetPlanStartTime()
  21203. return nil
  21204. case soptask.FieldPlanEndTime:
  21205. m.ResetPlanEndTime()
  21206. return nil
  21207. case soptask.FieldCreatorID:
  21208. m.ResetCreatorID()
  21209. return nil
  21210. case soptask.FieldOrganizationID:
  21211. m.ResetOrganizationID()
  21212. return nil
  21213. case soptask.FieldToken:
  21214. m.ResetToken()
  21215. return nil
  21216. }
  21217. return fmt.Errorf("unknown SopTask field %s", name)
  21218. }
  21219. // AddedEdges returns all edge names that were set/added in this mutation.
  21220. func (m *SopTaskMutation) AddedEdges() []string {
  21221. edges := make([]string, 0, 1)
  21222. if m.task_stages != nil {
  21223. edges = append(edges, soptask.EdgeTaskStages)
  21224. }
  21225. return edges
  21226. }
  21227. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21228. // name in this mutation.
  21229. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  21230. switch name {
  21231. case soptask.EdgeTaskStages:
  21232. ids := make([]ent.Value, 0, len(m.task_stages))
  21233. for id := range m.task_stages {
  21234. ids = append(ids, id)
  21235. }
  21236. return ids
  21237. }
  21238. return nil
  21239. }
  21240. // RemovedEdges returns all edge names that were removed in this mutation.
  21241. func (m *SopTaskMutation) RemovedEdges() []string {
  21242. edges := make([]string, 0, 1)
  21243. if m.removedtask_stages != nil {
  21244. edges = append(edges, soptask.EdgeTaskStages)
  21245. }
  21246. return edges
  21247. }
  21248. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21249. // the given name in this mutation.
  21250. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  21251. switch name {
  21252. case soptask.EdgeTaskStages:
  21253. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  21254. for id := range m.removedtask_stages {
  21255. ids = append(ids, id)
  21256. }
  21257. return ids
  21258. }
  21259. return nil
  21260. }
  21261. // ClearedEdges returns all edge names that were cleared in this mutation.
  21262. func (m *SopTaskMutation) ClearedEdges() []string {
  21263. edges := make([]string, 0, 1)
  21264. if m.clearedtask_stages {
  21265. edges = append(edges, soptask.EdgeTaskStages)
  21266. }
  21267. return edges
  21268. }
  21269. // EdgeCleared returns a boolean which indicates if the edge with the given name
  21270. // was cleared in this mutation.
  21271. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  21272. switch name {
  21273. case soptask.EdgeTaskStages:
  21274. return m.clearedtask_stages
  21275. }
  21276. return false
  21277. }
  21278. // ClearEdge clears the value of the edge with the given name. It returns an error
  21279. // if that edge is not defined in the schema.
  21280. func (m *SopTaskMutation) ClearEdge(name string) error {
  21281. switch name {
  21282. }
  21283. return fmt.Errorf("unknown SopTask unique edge %s", name)
  21284. }
  21285. // ResetEdge resets all changes to the edge with the given name in this mutation.
  21286. // It returns an error if the edge is not defined in the schema.
  21287. func (m *SopTaskMutation) ResetEdge(name string) error {
  21288. switch name {
  21289. case soptask.EdgeTaskStages:
  21290. m.ResetTaskStages()
  21291. return nil
  21292. }
  21293. return fmt.Errorf("unknown SopTask edge %s", name)
  21294. }
  21295. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  21296. type TokenMutation struct {
  21297. config
  21298. op Op
  21299. typ string
  21300. id *uint64
  21301. created_at *time.Time
  21302. updated_at *time.Time
  21303. deleted_at *time.Time
  21304. expire_at *time.Time
  21305. token *string
  21306. mac *string
  21307. organization_id *uint64
  21308. addorganization_id *int64
  21309. custom_agent_base *string
  21310. custom_agent_key *string
  21311. openai_base *string
  21312. openai_key *string
  21313. clearedFields map[string]struct{}
  21314. agent *uint64
  21315. clearedagent bool
  21316. done bool
  21317. oldValue func(context.Context) (*Token, error)
  21318. predicates []predicate.Token
  21319. }
  21320. var _ ent.Mutation = (*TokenMutation)(nil)
  21321. // tokenOption allows management of the mutation configuration using functional options.
  21322. type tokenOption func(*TokenMutation)
  21323. // newTokenMutation creates new mutation for the Token entity.
  21324. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  21325. m := &TokenMutation{
  21326. config: c,
  21327. op: op,
  21328. typ: TypeToken,
  21329. clearedFields: make(map[string]struct{}),
  21330. }
  21331. for _, opt := range opts {
  21332. opt(m)
  21333. }
  21334. return m
  21335. }
  21336. // withTokenID sets the ID field of the mutation.
  21337. func withTokenID(id uint64) tokenOption {
  21338. return func(m *TokenMutation) {
  21339. var (
  21340. err error
  21341. once sync.Once
  21342. value *Token
  21343. )
  21344. m.oldValue = func(ctx context.Context) (*Token, error) {
  21345. once.Do(func() {
  21346. if m.done {
  21347. err = errors.New("querying old values post mutation is not allowed")
  21348. } else {
  21349. value, err = m.Client().Token.Get(ctx, id)
  21350. }
  21351. })
  21352. return value, err
  21353. }
  21354. m.id = &id
  21355. }
  21356. }
  21357. // withToken sets the old Token of the mutation.
  21358. func withToken(node *Token) tokenOption {
  21359. return func(m *TokenMutation) {
  21360. m.oldValue = func(context.Context) (*Token, error) {
  21361. return node, nil
  21362. }
  21363. m.id = &node.ID
  21364. }
  21365. }
  21366. // Client returns a new `ent.Client` from the mutation. If the mutation was
  21367. // executed in a transaction (ent.Tx), a transactional client is returned.
  21368. func (m TokenMutation) Client() *Client {
  21369. client := &Client{config: m.config}
  21370. client.init()
  21371. return client
  21372. }
  21373. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  21374. // it returns an error otherwise.
  21375. func (m TokenMutation) Tx() (*Tx, error) {
  21376. if _, ok := m.driver.(*txDriver); !ok {
  21377. return nil, errors.New("ent: mutation is not running in a transaction")
  21378. }
  21379. tx := &Tx{config: m.config}
  21380. tx.init()
  21381. return tx, nil
  21382. }
  21383. // SetID sets the value of the id field. Note that this
  21384. // operation is only accepted on creation of Token entities.
  21385. func (m *TokenMutation) SetID(id uint64) {
  21386. m.id = &id
  21387. }
  21388. // ID returns the ID value in the mutation. Note that the ID is only available
  21389. // if it was provided to the builder or after it was returned from the database.
  21390. func (m *TokenMutation) ID() (id uint64, exists bool) {
  21391. if m.id == nil {
  21392. return
  21393. }
  21394. return *m.id, true
  21395. }
  21396. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  21397. // That means, if the mutation is applied within a transaction with an isolation level such
  21398. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  21399. // or updated by the mutation.
  21400. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  21401. switch {
  21402. case m.op.Is(OpUpdateOne | OpDeleteOne):
  21403. id, exists := m.ID()
  21404. if exists {
  21405. return []uint64{id}, nil
  21406. }
  21407. fallthrough
  21408. case m.op.Is(OpUpdate | OpDelete):
  21409. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  21410. default:
  21411. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  21412. }
  21413. }
  21414. // SetCreatedAt sets the "created_at" field.
  21415. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  21416. m.created_at = &t
  21417. }
  21418. // CreatedAt returns the value of the "created_at" field in the mutation.
  21419. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  21420. v := m.created_at
  21421. if v == nil {
  21422. return
  21423. }
  21424. return *v, true
  21425. }
  21426. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  21427. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21429. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  21430. if !m.op.Is(OpUpdateOne) {
  21431. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  21432. }
  21433. if m.id == nil || m.oldValue == nil {
  21434. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  21435. }
  21436. oldValue, err := m.oldValue(ctx)
  21437. if err != nil {
  21438. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  21439. }
  21440. return oldValue.CreatedAt, nil
  21441. }
  21442. // ResetCreatedAt resets all changes to the "created_at" field.
  21443. func (m *TokenMutation) ResetCreatedAt() {
  21444. m.created_at = nil
  21445. }
  21446. // SetUpdatedAt sets the "updated_at" field.
  21447. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  21448. m.updated_at = &t
  21449. }
  21450. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  21451. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  21452. v := m.updated_at
  21453. if v == nil {
  21454. return
  21455. }
  21456. return *v, true
  21457. }
  21458. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  21459. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21460. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21461. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  21462. if !m.op.Is(OpUpdateOne) {
  21463. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  21464. }
  21465. if m.id == nil || m.oldValue == nil {
  21466. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  21467. }
  21468. oldValue, err := m.oldValue(ctx)
  21469. if err != nil {
  21470. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  21471. }
  21472. return oldValue.UpdatedAt, nil
  21473. }
  21474. // ResetUpdatedAt resets all changes to the "updated_at" field.
  21475. func (m *TokenMutation) ResetUpdatedAt() {
  21476. m.updated_at = nil
  21477. }
  21478. // SetDeletedAt sets the "deleted_at" field.
  21479. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  21480. m.deleted_at = &t
  21481. }
  21482. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  21483. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  21484. v := m.deleted_at
  21485. if v == nil {
  21486. return
  21487. }
  21488. return *v, true
  21489. }
  21490. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  21491. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21492. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21493. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  21494. if !m.op.Is(OpUpdateOne) {
  21495. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  21496. }
  21497. if m.id == nil || m.oldValue == nil {
  21498. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  21499. }
  21500. oldValue, err := m.oldValue(ctx)
  21501. if err != nil {
  21502. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  21503. }
  21504. return oldValue.DeletedAt, nil
  21505. }
  21506. // ClearDeletedAt clears the value of the "deleted_at" field.
  21507. func (m *TokenMutation) ClearDeletedAt() {
  21508. m.deleted_at = nil
  21509. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  21510. }
  21511. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21512. func (m *TokenMutation) DeletedAtCleared() bool {
  21513. _, ok := m.clearedFields[token.FieldDeletedAt]
  21514. return ok
  21515. }
  21516. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21517. func (m *TokenMutation) ResetDeletedAt() {
  21518. m.deleted_at = nil
  21519. delete(m.clearedFields, token.FieldDeletedAt)
  21520. }
  21521. // SetExpireAt sets the "expire_at" field.
  21522. func (m *TokenMutation) SetExpireAt(t time.Time) {
  21523. m.expire_at = &t
  21524. }
  21525. // ExpireAt returns the value of the "expire_at" field in the mutation.
  21526. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  21527. v := m.expire_at
  21528. if v == nil {
  21529. return
  21530. }
  21531. return *v, true
  21532. }
  21533. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  21534. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21536. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  21537. if !m.op.Is(OpUpdateOne) {
  21538. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  21539. }
  21540. if m.id == nil || m.oldValue == nil {
  21541. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  21542. }
  21543. oldValue, err := m.oldValue(ctx)
  21544. if err != nil {
  21545. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  21546. }
  21547. return oldValue.ExpireAt, nil
  21548. }
  21549. // ClearExpireAt clears the value of the "expire_at" field.
  21550. func (m *TokenMutation) ClearExpireAt() {
  21551. m.expire_at = nil
  21552. m.clearedFields[token.FieldExpireAt] = struct{}{}
  21553. }
  21554. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  21555. func (m *TokenMutation) ExpireAtCleared() bool {
  21556. _, ok := m.clearedFields[token.FieldExpireAt]
  21557. return ok
  21558. }
  21559. // ResetExpireAt resets all changes to the "expire_at" field.
  21560. func (m *TokenMutation) ResetExpireAt() {
  21561. m.expire_at = nil
  21562. delete(m.clearedFields, token.FieldExpireAt)
  21563. }
  21564. // SetToken sets the "token" field.
  21565. func (m *TokenMutation) SetToken(s string) {
  21566. m.token = &s
  21567. }
  21568. // Token returns the value of the "token" field in the mutation.
  21569. func (m *TokenMutation) Token() (r string, exists bool) {
  21570. v := m.token
  21571. if v == nil {
  21572. return
  21573. }
  21574. return *v, true
  21575. }
  21576. // OldToken returns the old "token" field's value of the Token entity.
  21577. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21579. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  21580. if !m.op.Is(OpUpdateOne) {
  21581. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  21582. }
  21583. if m.id == nil || m.oldValue == nil {
  21584. return v, errors.New("OldToken requires an ID field in the mutation")
  21585. }
  21586. oldValue, err := m.oldValue(ctx)
  21587. if err != nil {
  21588. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  21589. }
  21590. return oldValue.Token, nil
  21591. }
  21592. // ClearToken clears the value of the "token" field.
  21593. func (m *TokenMutation) ClearToken() {
  21594. m.token = nil
  21595. m.clearedFields[token.FieldToken] = struct{}{}
  21596. }
  21597. // TokenCleared returns if the "token" field was cleared in this mutation.
  21598. func (m *TokenMutation) TokenCleared() bool {
  21599. _, ok := m.clearedFields[token.FieldToken]
  21600. return ok
  21601. }
  21602. // ResetToken resets all changes to the "token" field.
  21603. func (m *TokenMutation) ResetToken() {
  21604. m.token = nil
  21605. delete(m.clearedFields, token.FieldToken)
  21606. }
  21607. // SetMAC sets the "mac" field.
  21608. func (m *TokenMutation) SetMAC(s string) {
  21609. m.mac = &s
  21610. }
  21611. // MAC returns the value of the "mac" field in the mutation.
  21612. func (m *TokenMutation) MAC() (r string, exists bool) {
  21613. v := m.mac
  21614. if v == nil {
  21615. return
  21616. }
  21617. return *v, true
  21618. }
  21619. // OldMAC returns the old "mac" field's value of the Token entity.
  21620. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21622. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  21623. if !m.op.Is(OpUpdateOne) {
  21624. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  21625. }
  21626. if m.id == nil || m.oldValue == nil {
  21627. return v, errors.New("OldMAC requires an ID field in the mutation")
  21628. }
  21629. oldValue, err := m.oldValue(ctx)
  21630. if err != nil {
  21631. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  21632. }
  21633. return oldValue.MAC, nil
  21634. }
  21635. // ClearMAC clears the value of the "mac" field.
  21636. func (m *TokenMutation) ClearMAC() {
  21637. m.mac = nil
  21638. m.clearedFields[token.FieldMAC] = struct{}{}
  21639. }
  21640. // MACCleared returns if the "mac" field was cleared in this mutation.
  21641. func (m *TokenMutation) MACCleared() bool {
  21642. _, ok := m.clearedFields[token.FieldMAC]
  21643. return ok
  21644. }
  21645. // ResetMAC resets all changes to the "mac" field.
  21646. func (m *TokenMutation) ResetMAC() {
  21647. m.mac = nil
  21648. delete(m.clearedFields, token.FieldMAC)
  21649. }
  21650. // SetOrganizationID sets the "organization_id" field.
  21651. func (m *TokenMutation) SetOrganizationID(u uint64) {
  21652. m.organization_id = &u
  21653. m.addorganization_id = nil
  21654. }
  21655. // OrganizationID returns the value of the "organization_id" field in the mutation.
  21656. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  21657. v := m.organization_id
  21658. if v == nil {
  21659. return
  21660. }
  21661. return *v, true
  21662. }
  21663. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  21664. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21666. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  21667. if !m.op.Is(OpUpdateOne) {
  21668. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  21669. }
  21670. if m.id == nil || m.oldValue == nil {
  21671. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  21672. }
  21673. oldValue, err := m.oldValue(ctx)
  21674. if err != nil {
  21675. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  21676. }
  21677. return oldValue.OrganizationID, nil
  21678. }
  21679. // AddOrganizationID adds u to the "organization_id" field.
  21680. func (m *TokenMutation) AddOrganizationID(u int64) {
  21681. if m.addorganization_id != nil {
  21682. *m.addorganization_id += u
  21683. } else {
  21684. m.addorganization_id = &u
  21685. }
  21686. }
  21687. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  21688. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  21689. v := m.addorganization_id
  21690. if v == nil {
  21691. return
  21692. }
  21693. return *v, true
  21694. }
  21695. // ResetOrganizationID resets all changes to the "organization_id" field.
  21696. func (m *TokenMutation) ResetOrganizationID() {
  21697. m.organization_id = nil
  21698. m.addorganization_id = nil
  21699. }
  21700. // SetAgentID sets the "agent_id" field.
  21701. func (m *TokenMutation) SetAgentID(u uint64) {
  21702. m.agent = &u
  21703. }
  21704. // AgentID returns the value of the "agent_id" field in the mutation.
  21705. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  21706. v := m.agent
  21707. if v == nil {
  21708. return
  21709. }
  21710. return *v, true
  21711. }
  21712. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  21713. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21715. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  21716. if !m.op.Is(OpUpdateOne) {
  21717. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  21718. }
  21719. if m.id == nil || m.oldValue == nil {
  21720. return v, errors.New("OldAgentID requires an ID field in the mutation")
  21721. }
  21722. oldValue, err := m.oldValue(ctx)
  21723. if err != nil {
  21724. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  21725. }
  21726. return oldValue.AgentID, nil
  21727. }
  21728. // ResetAgentID resets all changes to the "agent_id" field.
  21729. func (m *TokenMutation) ResetAgentID() {
  21730. m.agent = nil
  21731. }
  21732. // SetCustomAgentBase sets the "custom_agent_base" field.
  21733. func (m *TokenMutation) SetCustomAgentBase(s string) {
  21734. m.custom_agent_base = &s
  21735. }
  21736. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  21737. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  21738. v := m.custom_agent_base
  21739. if v == nil {
  21740. return
  21741. }
  21742. return *v, true
  21743. }
  21744. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  21745. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21747. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  21748. if !m.op.Is(OpUpdateOne) {
  21749. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  21750. }
  21751. if m.id == nil || m.oldValue == nil {
  21752. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  21753. }
  21754. oldValue, err := m.oldValue(ctx)
  21755. if err != nil {
  21756. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  21757. }
  21758. return oldValue.CustomAgentBase, nil
  21759. }
  21760. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  21761. func (m *TokenMutation) ClearCustomAgentBase() {
  21762. m.custom_agent_base = nil
  21763. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  21764. }
  21765. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  21766. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  21767. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  21768. return ok
  21769. }
  21770. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  21771. func (m *TokenMutation) ResetCustomAgentBase() {
  21772. m.custom_agent_base = nil
  21773. delete(m.clearedFields, token.FieldCustomAgentBase)
  21774. }
  21775. // SetCustomAgentKey sets the "custom_agent_key" field.
  21776. func (m *TokenMutation) SetCustomAgentKey(s string) {
  21777. m.custom_agent_key = &s
  21778. }
  21779. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  21780. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  21781. v := m.custom_agent_key
  21782. if v == nil {
  21783. return
  21784. }
  21785. return *v, true
  21786. }
  21787. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  21788. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21789. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21790. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  21791. if !m.op.Is(OpUpdateOne) {
  21792. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  21793. }
  21794. if m.id == nil || m.oldValue == nil {
  21795. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  21796. }
  21797. oldValue, err := m.oldValue(ctx)
  21798. if err != nil {
  21799. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  21800. }
  21801. return oldValue.CustomAgentKey, nil
  21802. }
  21803. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  21804. func (m *TokenMutation) ClearCustomAgentKey() {
  21805. m.custom_agent_key = nil
  21806. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  21807. }
  21808. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  21809. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  21810. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  21811. return ok
  21812. }
  21813. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  21814. func (m *TokenMutation) ResetCustomAgentKey() {
  21815. m.custom_agent_key = nil
  21816. delete(m.clearedFields, token.FieldCustomAgentKey)
  21817. }
  21818. // SetOpenaiBase sets the "openai_base" field.
  21819. func (m *TokenMutation) SetOpenaiBase(s string) {
  21820. m.openai_base = &s
  21821. }
  21822. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  21823. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  21824. v := m.openai_base
  21825. if v == nil {
  21826. return
  21827. }
  21828. return *v, true
  21829. }
  21830. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  21831. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21832. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21833. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  21834. if !m.op.Is(OpUpdateOne) {
  21835. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  21836. }
  21837. if m.id == nil || m.oldValue == nil {
  21838. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  21839. }
  21840. oldValue, err := m.oldValue(ctx)
  21841. if err != nil {
  21842. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  21843. }
  21844. return oldValue.OpenaiBase, nil
  21845. }
  21846. // ClearOpenaiBase clears the value of the "openai_base" field.
  21847. func (m *TokenMutation) ClearOpenaiBase() {
  21848. m.openai_base = nil
  21849. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  21850. }
  21851. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  21852. func (m *TokenMutation) OpenaiBaseCleared() bool {
  21853. _, ok := m.clearedFields[token.FieldOpenaiBase]
  21854. return ok
  21855. }
  21856. // ResetOpenaiBase resets all changes to the "openai_base" field.
  21857. func (m *TokenMutation) ResetOpenaiBase() {
  21858. m.openai_base = nil
  21859. delete(m.clearedFields, token.FieldOpenaiBase)
  21860. }
  21861. // SetOpenaiKey sets the "openai_key" field.
  21862. func (m *TokenMutation) SetOpenaiKey(s string) {
  21863. m.openai_key = &s
  21864. }
  21865. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  21866. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  21867. v := m.openai_key
  21868. if v == nil {
  21869. return
  21870. }
  21871. return *v, true
  21872. }
  21873. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  21874. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  21875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21876. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  21877. if !m.op.Is(OpUpdateOne) {
  21878. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  21879. }
  21880. if m.id == nil || m.oldValue == nil {
  21881. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  21882. }
  21883. oldValue, err := m.oldValue(ctx)
  21884. if err != nil {
  21885. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  21886. }
  21887. return oldValue.OpenaiKey, nil
  21888. }
  21889. // ClearOpenaiKey clears the value of the "openai_key" field.
  21890. func (m *TokenMutation) ClearOpenaiKey() {
  21891. m.openai_key = nil
  21892. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  21893. }
  21894. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  21895. func (m *TokenMutation) OpenaiKeyCleared() bool {
  21896. _, ok := m.clearedFields[token.FieldOpenaiKey]
  21897. return ok
  21898. }
  21899. // ResetOpenaiKey resets all changes to the "openai_key" field.
  21900. func (m *TokenMutation) ResetOpenaiKey() {
  21901. m.openai_key = nil
  21902. delete(m.clearedFields, token.FieldOpenaiKey)
  21903. }
  21904. // ClearAgent clears the "agent" edge to the Agent entity.
  21905. func (m *TokenMutation) ClearAgent() {
  21906. m.clearedagent = true
  21907. m.clearedFields[token.FieldAgentID] = struct{}{}
  21908. }
  21909. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  21910. func (m *TokenMutation) AgentCleared() bool {
  21911. return m.clearedagent
  21912. }
  21913. // AgentIDs returns the "agent" edge IDs in the mutation.
  21914. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21915. // AgentID instead. It exists only for internal usage by the builders.
  21916. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  21917. if id := m.agent; id != nil {
  21918. ids = append(ids, *id)
  21919. }
  21920. return
  21921. }
  21922. // ResetAgent resets all changes to the "agent" edge.
  21923. func (m *TokenMutation) ResetAgent() {
  21924. m.agent = nil
  21925. m.clearedagent = false
  21926. }
  21927. // Where appends a list predicates to the TokenMutation builder.
  21928. func (m *TokenMutation) Where(ps ...predicate.Token) {
  21929. m.predicates = append(m.predicates, ps...)
  21930. }
  21931. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  21932. // users can use type-assertion to append predicates that do not depend on any generated package.
  21933. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  21934. p := make([]predicate.Token, len(ps))
  21935. for i := range ps {
  21936. p[i] = ps[i]
  21937. }
  21938. m.Where(p...)
  21939. }
  21940. // Op returns the operation name.
  21941. func (m *TokenMutation) Op() Op {
  21942. return m.op
  21943. }
  21944. // SetOp allows setting the mutation operation.
  21945. func (m *TokenMutation) SetOp(op Op) {
  21946. m.op = op
  21947. }
  21948. // Type returns the node type of this mutation (Token).
  21949. func (m *TokenMutation) Type() string {
  21950. return m.typ
  21951. }
  21952. // Fields returns all fields that were changed during this mutation. Note that in
  21953. // order to get all numeric fields that were incremented/decremented, call
  21954. // AddedFields().
  21955. func (m *TokenMutation) Fields() []string {
  21956. fields := make([]string, 0, 12)
  21957. if m.created_at != nil {
  21958. fields = append(fields, token.FieldCreatedAt)
  21959. }
  21960. if m.updated_at != nil {
  21961. fields = append(fields, token.FieldUpdatedAt)
  21962. }
  21963. if m.deleted_at != nil {
  21964. fields = append(fields, token.FieldDeletedAt)
  21965. }
  21966. if m.expire_at != nil {
  21967. fields = append(fields, token.FieldExpireAt)
  21968. }
  21969. if m.token != nil {
  21970. fields = append(fields, token.FieldToken)
  21971. }
  21972. if m.mac != nil {
  21973. fields = append(fields, token.FieldMAC)
  21974. }
  21975. if m.organization_id != nil {
  21976. fields = append(fields, token.FieldOrganizationID)
  21977. }
  21978. if m.agent != nil {
  21979. fields = append(fields, token.FieldAgentID)
  21980. }
  21981. if m.custom_agent_base != nil {
  21982. fields = append(fields, token.FieldCustomAgentBase)
  21983. }
  21984. if m.custom_agent_key != nil {
  21985. fields = append(fields, token.FieldCustomAgentKey)
  21986. }
  21987. if m.openai_base != nil {
  21988. fields = append(fields, token.FieldOpenaiBase)
  21989. }
  21990. if m.openai_key != nil {
  21991. fields = append(fields, token.FieldOpenaiKey)
  21992. }
  21993. return fields
  21994. }
  21995. // Field returns the value of a field with the given name. The second boolean
  21996. // return value indicates that this field was not set, or was not defined in the
  21997. // schema.
  21998. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  21999. switch name {
  22000. case token.FieldCreatedAt:
  22001. return m.CreatedAt()
  22002. case token.FieldUpdatedAt:
  22003. return m.UpdatedAt()
  22004. case token.FieldDeletedAt:
  22005. return m.DeletedAt()
  22006. case token.FieldExpireAt:
  22007. return m.ExpireAt()
  22008. case token.FieldToken:
  22009. return m.Token()
  22010. case token.FieldMAC:
  22011. return m.MAC()
  22012. case token.FieldOrganizationID:
  22013. return m.OrganizationID()
  22014. case token.FieldAgentID:
  22015. return m.AgentID()
  22016. case token.FieldCustomAgentBase:
  22017. return m.CustomAgentBase()
  22018. case token.FieldCustomAgentKey:
  22019. return m.CustomAgentKey()
  22020. case token.FieldOpenaiBase:
  22021. return m.OpenaiBase()
  22022. case token.FieldOpenaiKey:
  22023. return m.OpenaiKey()
  22024. }
  22025. return nil, false
  22026. }
  22027. // OldField returns the old value of the field from the database. An error is
  22028. // returned if the mutation operation is not UpdateOne, or the query to the
  22029. // database failed.
  22030. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22031. switch name {
  22032. case token.FieldCreatedAt:
  22033. return m.OldCreatedAt(ctx)
  22034. case token.FieldUpdatedAt:
  22035. return m.OldUpdatedAt(ctx)
  22036. case token.FieldDeletedAt:
  22037. return m.OldDeletedAt(ctx)
  22038. case token.FieldExpireAt:
  22039. return m.OldExpireAt(ctx)
  22040. case token.FieldToken:
  22041. return m.OldToken(ctx)
  22042. case token.FieldMAC:
  22043. return m.OldMAC(ctx)
  22044. case token.FieldOrganizationID:
  22045. return m.OldOrganizationID(ctx)
  22046. case token.FieldAgentID:
  22047. return m.OldAgentID(ctx)
  22048. case token.FieldCustomAgentBase:
  22049. return m.OldCustomAgentBase(ctx)
  22050. case token.FieldCustomAgentKey:
  22051. return m.OldCustomAgentKey(ctx)
  22052. case token.FieldOpenaiBase:
  22053. return m.OldOpenaiBase(ctx)
  22054. case token.FieldOpenaiKey:
  22055. return m.OldOpenaiKey(ctx)
  22056. }
  22057. return nil, fmt.Errorf("unknown Token field %s", name)
  22058. }
  22059. // SetField sets the value of a field with the given name. It returns an error if
  22060. // the field is not defined in the schema, or if the type mismatched the field
  22061. // type.
  22062. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  22063. switch name {
  22064. case token.FieldCreatedAt:
  22065. v, ok := value.(time.Time)
  22066. if !ok {
  22067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22068. }
  22069. m.SetCreatedAt(v)
  22070. return nil
  22071. case token.FieldUpdatedAt:
  22072. v, ok := value.(time.Time)
  22073. if !ok {
  22074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22075. }
  22076. m.SetUpdatedAt(v)
  22077. return nil
  22078. case token.FieldDeletedAt:
  22079. v, ok := value.(time.Time)
  22080. if !ok {
  22081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22082. }
  22083. m.SetDeletedAt(v)
  22084. return nil
  22085. case token.FieldExpireAt:
  22086. v, ok := value.(time.Time)
  22087. if !ok {
  22088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22089. }
  22090. m.SetExpireAt(v)
  22091. return nil
  22092. case token.FieldToken:
  22093. v, ok := value.(string)
  22094. if !ok {
  22095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22096. }
  22097. m.SetToken(v)
  22098. return nil
  22099. case token.FieldMAC:
  22100. v, ok := value.(string)
  22101. if !ok {
  22102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22103. }
  22104. m.SetMAC(v)
  22105. return nil
  22106. case token.FieldOrganizationID:
  22107. v, ok := value.(uint64)
  22108. if !ok {
  22109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22110. }
  22111. m.SetOrganizationID(v)
  22112. return nil
  22113. case token.FieldAgentID:
  22114. v, ok := value.(uint64)
  22115. if !ok {
  22116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22117. }
  22118. m.SetAgentID(v)
  22119. return nil
  22120. case token.FieldCustomAgentBase:
  22121. v, ok := value.(string)
  22122. if !ok {
  22123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22124. }
  22125. m.SetCustomAgentBase(v)
  22126. return nil
  22127. case token.FieldCustomAgentKey:
  22128. v, ok := value.(string)
  22129. if !ok {
  22130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22131. }
  22132. m.SetCustomAgentKey(v)
  22133. return nil
  22134. case token.FieldOpenaiBase:
  22135. v, ok := value.(string)
  22136. if !ok {
  22137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22138. }
  22139. m.SetOpenaiBase(v)
  22140. return nil
  22141. case token.FieldOpenaiKey:
  22142. v, ok := value.(string)
  22143. if !ok {
  22144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22145. }
  22146. m.SetOpenaiKey(v)
  22147. return nil
  22148. }
  22149. return fmt.Errorf("unknown Token field %s", name)
  22150. }
  22151. // AddedFields returns all numeric fields that were incremented/decremented during
  22152. // this mutation.
  22153. func (m *TokenMutation) AddedFields() []string {
  22154. var fields []string
  22155. if m.addorganization_id != nil {
  22156. fields = append(fields, token.FieldOrganizationID)
  22157. }
  22158. return fields
  22159. }
  22160. // AddedField returns the numeric value that was incremented/decremented on a field
  22161. // with the given name. The second boolean return value indicates that this field
  22162. // was not set, or was not defined in the schema.
  22163. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  22164. switch name {
  22165. case token.FieldOrganizationID:
  22166. return m.AddedOrganizationID()
  22167. }
  22168. return nil, false
  22169. }
  22170. // AddField adds the value to the field with the given name. It returns an error if
  22171. // the field is not defined in the schema, or if the type mismatched the field
  22172. // type.
  22173. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  22174. switch name {
  22175. case token.FieldOrganizationID:
  22176. v, ok := value.(int64)
  22177. if !ok {
  22178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22179. }
  22180. m.AddOrganizationID(v)
  22181. return nil
  22182. }
  22183. return fmt.Errorf("unknown Token numeric field %s", name)
  22184. }
  22185. // ClearedFields returns all nullable fields that were cleared during this
  22186. // mutation.
  22187. func (m *TokenMutation) ClearedFields() []string {
  22188. var fields []string
  22189. if m.FieldCleared(token.FieldDeletedAt) {
  22190. fields = append(fields, token.FieldDeletedAt)
  22191. }
  22192. if m.FieldCleared(token.FieldExpireAt) {
  22193. fields = append(fields, token.FieldExpireAt)
  22194. }
  22195. if m.FieldCleared(token.FieldToken) {
  22196. fields = append(fields, token.FieldToken)
  22197. }
  22198. if m.FieldCleared(token.FieldMAC) {
  22199. fields = append(fields, token.FieldMAC)
  22200. }
  22201. if m.FieldCleared(token.FieldCustomAgentBase) {
  22202. fields = append(fields, token.FieldCustomAgentBase)
  22203. }
  22204. if m.FieldCleared(token.FieldCustomAgentKey) {
  22205. fields = append(fields, token.FieldCustomAgentKey)
  22206. }
  22207. if m.FieldCleared(token.FieldOpenaiBase) {
  22208. fields = append(fields, token.FieldOpenaiBase)
  22209. }
  22210. if m.FieldCleared(token.FieldOpenaiKey) {
  22211. fields = append(fields, token.FieldOpenaiKey)
  22212. }
  22213. return fields
  22214. }
  22215. // FieldCleared returns a boolean indicating if a field with the given name was
  22216. // cleared in this mutation.
  22217. func (m *TokenMutation) FieldCleared(name string) bool {
  22218. _, ok := m.clearedFields[name]
  22219. return ok
  22220. }
  22221. // ClearField clears the value of the field with the given name. It returns an
  22222. // error if the field is not defined in the schema.
  22223. func (m *TokenMutation) ClearField(name string) error {
  22224. switch name {
  22225. case token.FieldDeletedAt:
  22226. m.ClearDeletedAt()
  22227. return nil
  22228. case token.FieldExpireAt:
  22229. m.ClearExpireAt()
  22230. return nil
  22231. case token.FieldToken:
  22232. m.ClearToken()
  22233. return nil
  22234. case token.FieldMAC:
  22235. m.ClearMAC()
  22236. return nil
  22237. case token.FieldCustomAgentBase:
  22238. m.ClearCustomAgentBase()
  22239. return nil
  22240. case token.FieldCustomAgentKey:
  22241. m.ClearCustomAgentKey()
  22242. return nil
  22243. case token.FieldOpenaiBase:
  22244. m.ClearOpenaiBase()
  22245. return nil
  22246. case token.FieldOpenaiKey:
  22247. m.ClearOpenaiKey()
  22248. return nil
  22249. }
  22250. return fmt.Errorf("unknown Token nullable field %s", name)
  22251. }
  22252. // ResetField resets all changes in the mutation for the field with the given name.
  22253. // It returns an error if the field is not defined in the schema.
  22254. func (m *TokenMutation) ResetField(name string) error {
  22255. switch name {
  22256. case token.FieldCreatedAt:
  22257. m.ResetCreatedAt()
  22258. return nil
  22259. case token.FieldUpdatedAt:
  22260. m.ResetUpdatedAt()
  22261. return nil
  22262. case token.FieldDeletedAt:
  22263. m.ResetDeletedAt()
  22264. return nil
  22265. case token.FieldExpireAt:
  22266. m.ResetExpireAt()
  22267. return nil
  22268. case token.FieldToken:
  22269. m.ResetToken()
  22270. return nil
  22271. case token.FieldMAC:
  22272. m.ResetMAC()
  22273. return nil
  22274. case token.FieldOrganizationID:
  22275. m.ResetOrganizationID()
  22276. return nil
  22277. case token.FieldAgentID:
  22278. m.ResetAgentID()
  22279. return nil
  22280. case token.FieldCustomAgentBase:
  22281. m.ResetCustomAgentBase()
  22282. return nil
  22283. case token.FieldCustomAgentKey:
  22284. m.ResetCustomAgentKey()
  22285. return nil
  22286. case token.FieldOpenaiBase:
  22287. m.ResetOpenaiBase()
  22288. return nil
  22289. case token.FieldOpenaiKey:
  22290. m.ResetOpenaiKey()
  22291. return nil
  22292. }
  22293. return fmt.Errorf("unknown Token field %s", name)
  22294. }
  22295. // AddedEdges returns all edge names that were set/added in this mutation.
  22296. func (m *TokenMutation) AddedEdges() []string {
  22297. edges := make([]string, 0, 1)
  22298. if m.agent != nil {
  22299. edges = append(edges, token.EdgeAgent)
  22300. }
  22301. return edges
  22302. }
  22303. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22304. // name in this mutation.
  22305. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  22306. switch name {
  22307. case token.EdgeAgent:
  22308. if id := m.agent; id != nil {
  22309. return []ent.Value{*id}
  22310. }
  22311. }
  22312. return nil
  22313. }
  22314. // RemovedEdges returns all edge names that were removed in this mutation.
  22315. func (m *TokenMutation) RemovedEdges() []string {
  22316. edges := make([]string, 0, 1)
  22317. return edges
  22318. }
  22319. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22320. // the given name in this mutation.
  22321. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  22322. return nil
  22323. }
  22324. // ClearedEdges returns all edge names that were cleared in this mutation.
  22325. func (m *TokenMutation) ClearedEdges() []string {
  22326. edges := make([]string, 0, 1)
  22327. if m.clearedagent {
  22328. edges = append(edges, token.EdgeAgent)
  22329. }
  22330. return edges
  22331. }
  22332. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22333. // was cleared in this mutation.
  22334. func (m *TokenMutation) EdgeCleared(name string) bool {
  22335. switch name {
  22336. case token.EdgeAgent:
  22337. return m.clearedagent
  22338. }
  22339. return false
  22340. }
  22341. // ClearEdge clears the value of the edge with the given name. It returns an error
  22342. // if that edge is not defined in the schema.
  22343. func (m *TokenMutation) ClearEdge(name string) error {
  22344. switch name {
  22345. case token.EdgeAgent:
  22346. m.ClearAgent()
  22347. return nil
  22348. }
  22349. return fmt.Errorf("unknown Token unique edge %s", name)
  22350. }
  22351. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22352. // It returns an error if the edge is not defined in the schema.
  22353. func (m *TokenMutation) ResetEdge(name string) error {
  22354. switch name {
  22355. case token.EdgeAgent:
  22356. m.ResetAgent()
  22357. return nil
  22358. }
  22359. return fmt.Errorf("unknown Token edge %s", name)
  22360. }
  22361. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  22362. type TutorialMutation struct {
  22363. config
  22364. op Op
  22365. typ string
  22366. id *uint64
  22367. created_at *time.Time
  22368. updated_at *time.Time
  22369. deleted_at *time.Time
  22370. index *int
  22371. addindex *int
  22372. title *string
  22373. content *string
  22374. organization_id *uint64
  22375. addorganization_id *int64
  22376. clearedFields map[string]struct{}
  22377. employee *uint64
  22378. clearedemployee bool
  22379. done bool
  22380. oldValue func(context.Context) (*Tutorial, error)
  22381. predicates []predicate.Tutorial
  22382. }
  22383. var _ ent.Mutation = (*TutorialMutation)(nil)
  22384. // tutorialOption allows management of the mutation configuration using functional options.
  22385. type tutorialOption func(*TutorialMutation)
  22386. // newTutorialMutation creates new mutation for the Tutorial entity.
  22387. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  22388. m := &TutorialMutation{
  22389. config: c,
  22390. op: op,
  22391. typ: TypeTutorial,
  22392. clearedFields: make(map[string]struct{}),
  22393. }
  22394. for _, opt := range opts {
  22395. opt(m)
  22396. }
  22397. return m
  22398. }
  22399. // withTutorialID sets the ID field of the mutation.
  22400. func withTutorialID(id uint64) tutorialOption {
  22401. return func(m *TutorialMutation) {
  22402. var (
  22403. err error
  22404. once sync.Once
  22405. value *Tutorial
  22406. )
  22407. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  22408. once.Do(func() {
  22409. if m.done {
  22410. err = errors.New("querying old values post mutation is not allowed")
  22411. } else {
  22412. value, err = m.Client().Tutorial.Get(ctx, id)
  22413. }
  22414. })
  22415. return value, err
  22416. }
  22417. m.id = &id
  22418. }
  22419. }
  22420. // withTutorial sets the old Tutorial of the mutation.
  22421. func withTutorial(node *Tutorial) tutorialOption {
  22422. return func(m *TutorialMutation) {
  22423. m.oldValue = func(context.Context) (*Tutorial, error) {
  22424. return node, nil
  22425. }
  22426. m.id = &node.ID
  22427. }
  22428. }
  22429. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22430. // executed in a transaction (ent.Tx), a transactional client is returned.
  22431. func (m TutorialMutation) Client() *Client {
  22432. client := &Client{config: m.config}
  22433. client.init()
  22434. return client
  22435. }
  22436. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22437. // it returns an error otherwise.
  22438. func (m TutorialMutation) Tx() (*Tx, error) {
  22439. if _, ok := m.driver.(*txDriver); !ok {
  22440. return nil, errors.New("ent: mutation is not running in a transaction")
  22441. }
  22442. tx := &Tx{config: m.config}
  22443. tx.init()
  22444. return tx, nil
  22445. }
  22446. // SetID sets the value of the id field. Note that this
  22447. // operation is only accepted on creation of Tutorial entities.
  22448. func (m *TutorialMutation) SetID(id uint64) {
  22449. m.id = &id
  22450. }
  22451. // ID returns the ID value in the mutation. Note that the ID is only available
  22452. // if it was provided to the builder or after it was returned from the database.
  22453. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  22454. if m.id == nil {
  22455. return
  22456. }
  22457. return *m.id, true
  22458. }
  22459. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22460. // That means, if the mutation is applied within a transaction with an isolation level such
  22461. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22462. // or updated by the mutation.
  22463. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  22464. switch {
  22465. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22466. id, exists := m.ID()
  22467. if exists {
  22468. return []uint64{id}, nil
  22469. }
  22470. fallthrough
  22471. case m.op.Is(OpUpdate | OpDelete):
  22472. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  22473. default:
  22474. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22475. }
  22476. }
  22477. // SetCreatedAt sets the "created_at" field.
  22478. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  22479. m.created_at = &t
  22480. }
  22481. // CreatedAt returns the value of the "created_at" field in the mutation.
  22482. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  22483. v := m.created_at
  22484. if v == nil {
  22485. return
  22486. }
  22487. return *v, true
  22488. }
  22489. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  22490. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22492. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22493. if !m.op.Is(OpUpdateOne) {
  22494. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22495. }
  22496. if m.id == nil || m.oldValue == nil {
  22497. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22498. }
  22499. oldValue, err := m.oldValue(ctx)
  22500. if err != nil {
  22501. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22502. }
  22503. return oldValue.CreatedAt, nil
  22504. }
  22505. // ResetCreatedAt resets all changes to the "created_at" field.
  22506. func (m *TutorialMutation) ResetCreatedAt() {
  22507. m.created_at = nil
  22508. }
  22509. // SetUpdatedAt sets the "updated_at" field.
  22510. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  22511. m.updated_at = &t
  22512. }
  22513. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22514. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  22515. v := m.updated_at
  22516. if v == nil {
  22517. return
  22518. }
  22519. return *v, true
  22520. }
  22521. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  22522. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22523. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22524. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22525. if !m.op.Is(OpUpdateOne) {
  22526. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22527. }
  22528. if m.id == nil || m.oldValue == nil {
  22529. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22530. }
  22531. oldValue, err := m.oldValue(ctx)
  22532. if err != nil {
  22533. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22534. }
  22535. return oldValue.UpdatedAt, nil
  22536. }
  22537. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22538. func (m *TutorialMutation) ResetUpdatedAt() {
  22539. m.updated_at = nil
  22540. }
  22541. // SetDeletedAt sets the "deleted_at" field.
  22542. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  22543. m.deleted_at = &t
  22544. }
  22545. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22546. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  22547. v := m.deleted_at
  22548. if v == nil {
  22549. return
  22550. }
  22551. return *v, true
  22552. }
  22553. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  22554. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22555. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22556. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22557. if !m.op.Is(OpUpdateOne) {
  22558. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22559. }
  22560. if m.id == nil || m.oldValue == nil {
  22561. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22562. }
  22563. oldValue, err := m.oldValue(ctx)
  22564. if err != nil {
  22565. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22566. }
  22567. return oldValue.DeletedAt, nil
  22568. }
  22569. // ClearDeletedAt clears the value of the "deleted_at" field.
  22570. func (m *TutorialMutation) ClearDeletedAt() {
  22571. m.deleted_at = nil
  22572. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  22573. }
  22574. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22575. func (m *TutorialMutation) DeletedAtCleared() bool {
  22576. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  22577. return ok
  22578. }
  22579. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22580. func (m *TutorialMutation) ResetDeletedAt() {
  22581. m.deleted_at = nil
  22582. delete(m.clearedFields, tutorial.FieldDeletedAt)
  22583. }
  22584. // SetEmployeeID sets the "employee_id" field.
  22585. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  22586. m.employee = &u
  22587. }
  22588. // EmployeeID returns the value of the "employee_id" field in the mutation.
  22589. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  22590. v := m.employee
  22591. if v == nil {
  22592. return
  22593. }
  22594. return *v, true
  22595. }
  22596. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  22597. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22599. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  22600. if !m.op.Is(OpUpdateOne) {
  22601. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  22602. }
  22603. if m.id == nil || m.oldValue == nil {
  22604. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  22605. }
  22606. oldValue, err := m.oldValue(ctx)
  22607. if err != nil {
  22608. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  22609. }
  22610. return oldValue.EmployeeID, nil
  22611. }
  22612. // ResetEmployeeID resets all changes to the "employee_id" field.
  22613. func (m *TutorialMutation) ResetEmployeeID() {
  22614. m.employee = nil
  22615. }
  22616. // SetIndex sets the "index" field.
  22617. func (m *TutorialMutation) SetIndex(i int) {
  22618. m.index = &i
  22619. m.addindex = nil
  22620. }
  22621. // Index returns the value of the "index" field in the mutation.
  22622. func (m *TutorialMutation) Index() (r int, exists bool) {
  22623. v := m.index
  22624. if v == nil {
  22625. return
  22626. }
  22627. return *v, true
  22628. }
  22629. // OldIndex returns the old "index" field's value of the Tutorial entity.
  22630. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22631. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22632. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  22633. if !m.op.Is(OpUpdateOne) {
  22634. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  22635. }
  22636. if m.id == nil || m.oldValue == nil {
  22637. return v, errors.New("OldIndex requires an ID field in the mutation")
  22638. }
  22639. oldValue, err := m.oldValue(ctx)
  22640. if err != nil {
  22641. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  22642. }
  22643. return oldValue.Index, nil
  22644. }
  22645. // AddIndex adds i to the "index" field.
  22646. func (m *TutorialMutation) AddIndex(i int) {
  22647. if m.addindex != nil {
  22648. *m.addindex += i
  22649. } else {
  22650. m.addindex = &i
  22651. }
  22652. }
  22653. // AddedIndex returns the value that was added to the "index" field in this mutation.
  22654. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  22655. v := m.addindex
  22656. if v == nil {
  22657. return
  22658. }
  22659. return *v, true
  22660. }
  22661. // ResetIndex resets all changes to the "index" field.
  22662. func (m *TutorialMutation) ResetIndex() {
  22663. m.index = nil
  22664. m.addindex = nil
  22665. }
  22666. // SetTitle sets the "title" field.
  22667. func (m *TutorialMutation) SetTitle(s string) {
  22668. m.title = &s
  22669. }
  22670. // Title returns the value of the "title" field in the mutation.
  22671. func (m *TutorialMutation) Title() (r string, exists bool) {
  22672. v := m.title
  22673. if v == nil {
  22674. return
  22675. }
  22676. return *v, true
  22677. }
  22678. // OldTitle returns the old "title" field's value of the Tutorial entity.
  22679. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22681. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  22682. if !m.op.Is(OpUpdateOne) {
  22683. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  22684. }
  22685. if m.id == nil || m.oldValue == nil {
  22686. return v, errors.New("OldTitle requires an ID field in the mutation")
  22687. }
  22688. oldValue, err := m.oldValue(ctx)
  22689. if err != nil {
  22690. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  22691. }
  22692. return oldValue.Title, nil
  22693. }
  22694. // ResetTitle resets all changes to the "title" field.
  22695. func (m *TutorialMutation) ResetTitle() {
  22696. m.title = nil
  22697. }
  22698. // SetContent sets the "content" field.
  22699. func (m *TutorialMutation) SetContent(s string) {
  22700. m.content = &s
  22701. }
  22702. // Content returns the value of the "content" field in the mutation.
  22703. func (m *TutorialMutation) Content() (r string, exists bool) {
  22704. v := m.content
  22705. if v == nil {
  22706. return
  22707. }
  22708. return *v, true
  22709. }
  22710. // OldContent returns the old "content" field's value of the Tutorial entity.
  22711. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22713. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  22714. if !m.op.Is(OpUpdateOne) {
  22715. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  22716. }
  22717. if m.id == nil || m.oldValue == nil {
  22718. return v, errors.New("OldContent requires an ID field in the mutation")
  22719. }
  22720. oldValue, err := m.oldValue(ctx)
  22721. if err != nil {
  22722. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  22723. }
  22724. return oldValue.Content, nil
  22725. }
  22726. // ResetContent resets all changes to the "content" field.
  22727. func (m *TutorialMutation) ResetContent() {
  22728. m.content = nil
  22729. }
  22730. // SetOrganizationID sets the "organization_id" field.
  22731. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  22732. m.organization_id = &u
  22733. m.addorganization_id = nil
  22734. }
  22735. // OrganizationID returns the value of the "organization_id" field in the mutation.
  22736. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  22737. v := m.organization_id
  22738. if v == nil {
  22739. return
  22740. }
  22741. return *v, true
  22742. }
  22743. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  22744. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  22745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22746. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  22747. if !m.op.Is(OpUpdateOne) {
  22748. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  22749. }
  22750. if m.id == nil || m.oldValue == nil {
  22751. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  22752. }
  22753. oldValue, err := m.oldValue(ctx)
  22754. if err != nil {
  22755. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  22756. }
  22757. return oldValue.OrganizationID, nil
  22758. }
  22759. // AddOrganizationID adds u to the "organization_id" field.
  22760. func (m *TutorialMutation) AddOrganizationID(u int64) {
  22761. if m.addorganization_id != nil {
  22762. *m.addorganization_id += u
  22763. } else {
  22764. m.addorganization_id = &u
  22765. }
  22766. }
  22767. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  22768. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  22769. v := m.addorganization_id
  22770. if v == nil {
  22771. return
  22772. }
  22773. return *v, true
  22774. }
  22775. // ResetOrganizationID resets all changes to the "organization_id" field.
  22776. func (m *TutorialMutation) ResetOrganizationID() {
  22777. m.organization_id = nil
  22778. m.addorganization_id = nil
  22779. }
  22780. // ClearEmployee clears the "employee" edge to the Employee entity.
  22781. func (m *TutorialMutation) ClearEmployee() {
  22782. m.clearedemployee = true
  22783. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  22784. }
  22785. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  22786. func (m *TutorialMutation) EmployeeCleared() bool {
  22787. return m.clearedemployee
  22788. }
  22789. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  22790. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22791. // EmployeeID instead. It exists only for internal usage by the builders.
  22792. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  22793. if id := m.employee; id != nil {
  22794. ids = append(ids, *id)
  22795. }
  22796. return
  22797. }
  22798. // ResetEmployee resets all changes to the "employee" edge.
  22799. func (m *TutorialMutation) ResetEmployee() {
  22800. m.employee = nil
  22801. m.clearedemployee = false
  22802. }
  22803. // Where appends a list predicates to the TutorialMutation builder.
  22804. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  22805. m.predicates = append(m.predicates, ps...)
  22806. }
  22807. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  22808. // users can use type-assertion to append predicates that do not depend on any generated package.
  22809. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  22810. p := make([]predicate.Tutorial, len(ps))
  22811. for i := range ps {
  22812. p[i] = ps[i]
  22813. }
  22814. m.Where(p...)
  22815. }
  22816. // Op returns the operation name.
  22817. func (m *TutorialMutation) Op() Op {
  22818. return m.op
  22819. }
  22820. // SetOp allows setting the mutation operation.
  22821. func (m *TutorialMutation) SetOp(op Op) {
  22822. m.op = op
  22823. }
  22824. // Type returns the node type of this mutation (Tutorial).
  22825. func (m *TutorialMutation) Type() string {
  22826. return m.typ
  22827. }
  22828. // Fields returns all fields that were changed during this mutation. Note that in
  22829. // order to get all numeric fields that were incremented/decremented, call
  22830. // AddedFields().
  22831. func (m *TutorialMutation) Fields() []string {
  22832. fields := make([]string, 0, 8)
  22833. if m.created_at != nil {
  22834. fields = append(fields, tutorial.FieldCreatedAt)
  22835. }
  22836. if m.updated_at != nil {
  22837. fields = append(fields, tutorial.FieldUpdatedAt)
  22838. }
  22839. if m.deleted_at != nil {
  22840. fields = append(fields, tutorial.FieldDeletedAt)
  22841. }
  22842. if m.employee != nil {
  22843. fields = append(fields, tutorial.FieldEmployeeID)
  22844. }
  22845. if m.index != nil {
  22846. fields = append(fields, tutorial.FieldIndex)
  22847. }
  22848. if m.title != nil {
  22849. fields = append(fields, tutorial.FieldTitle)
  22850. }
  22851. if m.content != nil {
  22852. fields = append(fields, tutorial.FieldContent)
  22853. }
  22854. if m.organization_id != nil {
  22855. fields = append(fields, tutorial.FieldOrganizationID)
  22856. }
  22857. return fields
  22858. }
  22859. // Field returns the value of a field with the given name. The second boolean
  22860. // return value indicates that this field was not set, or was not defined in the
  22861. // schema.
  22862. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  22863. switch name {
  22864. case tutorial.FieldCreatedAt:
  22865. return m.CreatedAt()
  22866. case tutorial.FieldUpdatedAt:
  22867. return m.UpdatedAt()
  22868. case tutorial.FieldDeletedAt:
  22869. return m.DeletedAt()
  22870. case tutorial.FieldEmployeeID:
  22871. return m.EmployeeID()
  22872. case tutorial.FieldIndex:
  22873. return m.Index()
  22874. case tutorial.FieldTitle:
  22875. return m.Title()
  22876. case tutorial.FieldContent:
  22877. return m.Content()
  22878. case tutorial.FieldOrganizationID:
  22879. return m.OrganizationID()
  22880. }
  22881. return nil, false
  22882. }
  22883. // OldField returns the old value of the field from the database. An error is
  22884. // returned if the mutation operation is not UpdateOne, or the query to the
  22885. // database failed.
  22886. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  22887. switch name {
  22888. case tutorial.FieldCreatedAt:
  22889. return m.OldCreatedAt(ctx)
  22890. case tutorial.FieldUpdatedAt:
  22891. return m.OldUpdatedAt(ctx)
  22892. case tutorial.FieldDeletedAt:
  22893. return m.OldDeletedAt(ctx)
  22894. case tutorial.FieldEmployeeID:
  22895. return m.OldEmployeeID(ctx)
  22896. case tutorial.FieldIndex:
  22897. return m.OldIndex(ctx)
  22898. case tutorial.FieldTitle:
  22899. return m.OldTitle(ctx)
  22900. case tutorial.FieldContent:
  22901. return m.OldContent(ctx)
  22902. case tutorial.FieldOrganizationID:
  22903. return m.OldOrganizationID(ctx)
  22904. }
  22905. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  22906. }
  22907. // SetField sets the value of a field with the given name. It returns an error if
  22908. // the field is not defined in the schema, or if the type mismatched the field
  22909. // type.
  22910. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  22911. switch name {
  22912. case tutorial.FieldCreatedAt:
  22913. v, ok := value.(time.Time)
  22914. if !ok {
  22915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22916. }
  22917. m.SetCreatedAt(v)
  22918. return nil
  22919. case tutorial.FieldUpdatedAt:
  22920. v, ok := value.(time.Time)
  22921. if !ok {
  22922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22923. }
  22924. m.SetUpdatedAt(v)
  22925. return nil
  22926. case tutorial.FieldDeletedAt:
  22927. v, ok := value.(time.Time)
  22928. if !ok {
  22929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22930. }
  22931. m.SetDeletedAt(v)
  22932. return nil
  22933. case tutorial.FieldEmployeeID:
  22934. v, ok := value.(uint64)
  22935. if !ok {
  22936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22937. }
  22938. m.SetEmployeeID(v)
  22939. return nil
  22940. case tutorial.FieldIndex:
  22941. v, ok := value.(int)
  22942. if !ok {
  22943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22944. }
  22945. m.SetIndex(v)
  22946. return nil
  22947. case tutorial.FieldTitle:
  22948. v, ok := value.(string)
  22949. if !ok {
  22950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22951. }
  22952. m.SetTitle(v)
  22953. return nil
  22954. case tutorial.FieldContent:
  22955. v, ok := value.(string)
  22956. if !ok {
  22957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22958. }
  22959. m.SetContent(v)
  22960. return nil
  22961. case tutorial.FieldOrganizationID:
  22962. v, ok := value.(uint64)
  22963. if !ok {
  22964. return fmt.Errorf("unexpected type %T for field %s", value, name)
  22965. }
  22966. m.SetOrganizationID(v)
  22967. return nil
  22968. }
  22969. return fmt.Errorf("unknown Tutorial field %s", name)
  22970. }
  22971. // AddedFields returns all numeric fields that were incremented/decremented during
  22972. // this mutation.
  22973. func (m *TutorialMutation) AddedFields() []string {
  22974. var fields []string
  22975. if m.addindex != nil {
  22976. fields = append(fields, tutorial.FieldIndex)
  22977. }
  22978. if m.addorganization_id != nil {
  22979. fields = append(fields, tutorial.FieldOrganizationID)
  22980. }
  22981. return fields
  22982. }
  22983. // AddedField returns the numeric value that was incremented/decremented on a field
  22984. // with the given name. The second boolean return value indicates that this field
  22985. // was not set, or was not defined in the schema.
  22986. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  22987. switch name {
  22988. case tutorial.FieldIndex:
  22989. return m.AddedIndex()
  22990. case tutorial.FieldOrganizationID:
  22991. return m.AddedOrganizationID()
  22992. }
  22993. return nil, false
  22994. }
  22995. // AddField adds the value to the field with the given name. It returns an error if
  22996. // the field is not defined in the schema, or if the type mismatched the field
  22997. // type.
  22998. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  22999. switch name {
  23000. case tutorial.FieldIndex:
  23001. v, ok := value.(int)
  23002. if !ok {
  23003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23004. }
  23005. m.AddIndex(v)
  23006. return nil
  23007. case tutorial.FieldOrganizationID:
  23008. v, ok := value.(int64)
  23009. if !ok {
  23010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23011. }
  23012. m.AddOrganizationID(v)
  23013. return nil
  23014. }
  23015. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  23016. }
  23017. // ClearedFields returns all nullable fields that were cleared during this
  23018. // mutation.
  23019. func (m *TutorialMutation) ClearedFields() []string {
  23020. var fields []string
  23021. if m.FieldCleared(tutorial.FieldDeletedAt) {
  23022. fields = append(fields, tutorial.FieldDeletedAt)
  23023. }
  23024. return fields
  23025. }
  23026. // FieldCleared returns a boolean indicating if a field with the given name was
  23027. // cleared in this mutation.
  23028. func (m *TutorialMutation) FieldCleared(name string) bool {
  23029. _, ok := m.clearedFields[name]
  23030. return ok
  23031. }
  23032. // ClearField clears the value of the field with the given name. It returns an
  23033. // error if the field is not defined in the schema.
  23034. func (m *TutorialMutation) ClearField(name string) error {
  23035. switch name {
  23036. case tutorial.FieldDeletedAt:
  23037. m.ClearDeletedAt()
  23038. return nil
  23039. }
  23040. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  23041. }
  23042. // ResetField resets all changes in the mutation for the field with the given name.
  23043. // It returns an error if the field is not defined in the schema.
  23044. func (m *TutorialMutation) ResetField(name string) error {
  23045. switch name {
  23046. case tutorial.FieldCreatedAt:
  23047. m.ResetCreatedAt()
  23048. return nil
  23049. case tutorial.FieldUpdatedAt:
  23050. m.ResetUpdatedAt()
  23051. return nil
  23052. case tutorial.FieldDeletedAt:
  23053. m.ResetDeletedAt()
  23054. return nil
  23055. case tutorial.FieldEmployeeID:
  23056. m.ResetEmployeeID()
  23057. return nil
  23058. case tutorial.FieldIndex:
  23059. m.ResetIndex()
  23060. return nil
  23061. case tutorial.FieldTitle:
  23062. m.ResetTitle()
  23063. return nil
  23064. case tutorial.FieldContent:
  23065. m.ResetContent()
  23066. return nil
  23067. case tutorial.FieldOrganizationID:
  23068. m.ResetOrganizationID()
  23069. return nil
  23070. }
  23071. return fmt.Errorf("unknown Tutorial field %s", name)
  23072. }
  23073. // AddedEdges returns all edge names that were set/added in this mutation.
  23074. func (m *TutorialMutation) AddedEdges() []string {
  23075. edges := make([]string, 0, 1)
  23076. if m.employee != nil {
  23077. edges = append(edges, tutorial.EdgeEmployee)
  23078. }
  23079. return edges
  23080. }
  23081. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23082. // name in this mutation.
  23083. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  23084. switch name {
  23085. case tutorial.EdgeEmployee:
  23086. if id := m.employee; id != nil {
  23087. return []ent.Value{*id}
  23088. }
  23089. }
  23090. return nil
  23091. }
  23092. // RemovedEdges returns all edge names that were removed in this mutation.
  23093. func (m *TutorialMutation) RemovedEdges() []string {
  23094. edges := make([]string, 0, 1)
  23095. return edges
  23096. }
  23097. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23098. // the given name in this mutation.
  23099. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  23100. return nil
  23101. }
  23102. // ClearedEdges returns all edge names that were cleared in this mutation.
  23103. func (m *TutorialMutation) ClearedEdges() []string {
  23104. edges := make([]string, 0, 1)
  23105. if m.clearedemployee {
  23106. edges = append(edges, tutorial.EdgeEmployee)
  23107. }
  23108. return edges
  23109. }
  23110. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23111. // was cleared in this mutation.
  23112. func (m *TutorialMutation) EdgeCleared(name string) bool {
  23113. switch name {
  23114. case tutorial.EdgeEmployee:
  23115. return m.clearedemployee
  23116. }
  23117. return false
  23118. }
  23119. // ClearEdge clears the value of the edge with the given name. It returns an error
  23120. // if that edge is not defined in the schema.
  23121. func (m *TutorialMutation) ClearEdge(name string) error {
  23122. switch name {
  23123. case tutorial.EdgeEmployee:
  23124. m.ClearEmployee()
  23125. return nil
  23126. }
  23127. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  23128. }
  23129. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23130. // It returns an error if the edge is not defined in the schema.
  23131. func (m *TutorialMutation) ResetEdge(name string) error {
  23132. switch name {
  23133. case tutorial.EdgeEmployee:
  23134. m.ResetEmployee()
  23135. return nil
  23136. }
  23137. return fmt.Errorf("unknown Tutorial edge %s", name)
  23138. }
  23139. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  23140. type UsageDetailMutation struct {
  23141. config
  23142. op Op
  23143. typ string
  23144. id *uint64
  23145. created_at *time.Time
  23146. updated_at *time.Time
  23147. status *uint8
  23148. addstatus *int8
  23149. _type *int
  23150. add_type *int
  23151. bot_id *string
  23152. receiver_id *string
  23153. app *int
  23154. addapp *int
  23155. session_id *uint64
  23156. addsession_id *int64
  23157. request *string
  23158. response *string
  23159. total_tokens *uint64
  23160. addtotal_tokens *int64
  23161. prompt_tokens *uint64
  23162. addprompt_tokens *int64
  23163. completion_tokens *uint64
  23164. addcompletion_tokens *int64
  23165. organization_id *uint64
  23166. addorganization_id *int64
  23167. clearedFields map[string]struct{}
  23168. done bool
  23169. oldValue func(context.Context) (*UsageDetail, error)
  23170. predicates []predicate.UsageDetail
  23171. }
  23172. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  23173. // usagedetailOption allows management of the mutation configuration using functional options.
  23174. type usagedetailOption func(*UsageDetailMutation)
  23175. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  23176. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  23177. m := &UsageDetailMutation{
  23178. config: c,
  23179. op: op,
  23180. typ: TypeUsageDetail,
  23181. clearedFields: make(map[string]struct{}),
  23182. }
  23183. for _, opt := range opts {
  23184. opt(m)
  23185. }
  23186. return m
  23187. }
  23188. // withUsageDetailID sets the ID field of the mutation.
  23189. func withUsageDetailID(id uint64) usagedetailOption {
  23190. return func(m *UsageDetailMutation) {
  23191. var (
  23192. err error
  23193. once sync.Once
  23194. value *UsageDetail
  23195. )
  23196. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  23197. once.Do(func() {
  23198. if m.done {
  23199. err = errors.New("querying old values post mutation is not allowed")
  23200. } else {
  23201. value, err = m.Client().UsageDetail.Get(ctx, id)
  23202. }
  23203. })
  23204. return value, err
  23205. }
  23206. m.id = &id
  23207. }
  23208. }
  23209. // withUsageDetail sets the old UsageDetail of the mutation.
  23210. func withUsageDetail(node *UsageDetail) usagedetailOption {
  23211. return func(m *UsageDetailMutation) {
  23212. m.oldValue = func(context.Context) (*UsageDetail, error) {
  23213. return node, nil
  23214. }
  23215. m.id = &node.ID
  23216. }
  23217. }
  23218. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23219. // executed in a transaction (ent.Tx), a transactional client is returned.
  23220. func (m UsageDetailMutation) Client() *Client {
  23221. client := &Client{config: m.config}
  23222. client.init()
  23223. return client
  23224. }
  23225. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23226. // it returns an error otherwise.
  23227. func (m UsageDetailMutation) Tx() (*Tx, error) {
  23228. if _, ok := m.driver.(*txDriver); !ok {
  23229. return nil, errors.New("ent: mutation is not running in a transaction")
  23230. }
  23231. tx := &Tx{config: m.config}
  23232. tx.init()
  23233. return tx, nil
  23234. }
  23235. // SetID sets the value of the id field. Note that this
  23236. // operation is only accepted on creation of UsageDetail entities.
  23237. func (m *UsageDetailMutation) SetID(id uint64) {
  23238. m.id = &id
  23239. }
  23240. // ID returns the ID value in the mutation. Note that the ID is only available
  23241. // if it was provided to the builder or after it was returned from the database.
  23242. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  23243. if m.id == nil {
  23244. return
  23245. }
  23246. return *m.id, true
  23247. }
  23248. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23249. // That means, if the mutation is applied within a transaction with an isolation level such
  23250. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23251. // or updated by the mutation.
  23252. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  23253. switch {
  23254. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23255. id, exists := m.ID()
  23256. if exists {
  23257. return []uint64{id}, nil
  23258. }
  23259. fallthrough
  23260. case m.op.Is(OpUpdate | OpDelete):
  23261. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  23262. default:
  23263. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23264. }
  23265. }
  23266. // SetCreatedAt sets the "created_at" field.
  23267. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  23268. m.created_at = &t
  23269. }
  23270. // CreatedAt returns the value of the "created_at" field in the mutation.
  23271. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  23272. v := m.created_at
  23273. if v == nil {
  23274. return
  23275. }
  23276. return *v, true
  23277. }
  23278. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  23279. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23281. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23282. if !m.op.Is(OpUpdateOne) {
  23283. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23284. }
  23285. if m.id == nil || m.oldValue == nil {
  23286. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23287. }
  23288. oldValue, err := m.oldValue(ctx)
  23289. if err != nil {
  23290. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23291. }
  23292. return oldValue.CreatedAt, nil
  23293. }
  23294. // ResetCreatedAt resets all changes to the "created_at" field.
  23295. func (m *UsageDetailMutation) ResetCreatedAt() {
  23296. m.created_at = nil
  23297. }
  23298. // SetUpdatedAt sets the "updated_at" field.
  23299. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  23300. m.updated_at = &t
  23301. }
  23302. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23303. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  23304. v := m.updated_at
  23305. if v == nil {
  23306. return
  23307. }
  23308. return *v, true
  23309. }
  23310. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  23311. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23312. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23313. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23314. if !m.op.Is(OpUpdateOne) {
  23315. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23316. }
  23317. if m.id == nil || m.oldValue == nil {
  23318. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23319. }
  23320. oldValue, err := m.oldValue(ctx)
  23321. if err != nil {
  23322. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23323. }
  23324. return oldValue.UpdatedAt, nil
  23325. }
  23326. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23327. func (m *UsageDetailMutation) ResetUpdatedAt() {
  23328. m.updated_at = nil
  23329. }
  23330. // SetStatus sets the "status" field.
  23331. func (m *UsageDetailMutation) SetStatus(u uint8) {
  23332. m.status = &u
  23333. m.addstatus = nil
  23334. }
  23335. // Status returns the value of the "status" field in the mutation.
  23336. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  23337. v := m.status
  23338. if v == nil {
  23339. return
  23340. }
  23341. return *v, true
  23342. }
  23343. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  23344. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23346. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23347. if !m.op.Is(OpUpdateOne) {
  23348. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23349. }
  23350. if m.id == nil || m.oldValue == nil {
  23351. return v, errors.New("OldStatus requires an ID field in the mutation")
  23352. }
  23353. oldValue, err := m.oldValue(ctx)
  23354. if err != nil {
  23355. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23356. }
  23357. return oldValue.Status, nil
  23358. }
  23359. // AddStatus adds u to the "status" field.
  23360. func (m *UsageDetailMutation) AddStatus(u int8) {
  23361. if m.addstatus != nil {
  23362. *m.addstatus += u
  23363. } else {
  23364. m.addstatus = &u
  23365. }
  23366. }
  23367. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23368. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  23369. v := m.addstatus
  23370. if v == nil {
  23371. return
  23372. }
  23373. return *v, true
  23374. }
  23375. // ClearStatus clears the value of the "status" field.
  23376. func (m *UsageDetailMutation) ClearStatus() {
  23377. m.status = nil
  23378. m.addstatus = nil
  23379. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  23380. }
  23381. // StatusCleared returns if the "status" field was cleared in this mutation.
  23382. func (m *UsageDetailMutation) StatusCleared() bool {
  23383. _, ok := m.clearedFields[usagedetail.FieldStatus]
  23384. return ok
  23385. }
  23386. // ResetStatus resets all changes to the "status" field.
  23387. func (m *UsageDetailMutation) ResetStatus() {
  23388. m.status = nil
  23389. m.addstatus = nil
  23390. delete(m.clearedFields, usagedetail.FieldStatus)
  23391. }
  23392. // SetType sets the "type" field.
  23393. func (m *UsageDetailMutation) SetType(i int) {
  23394. m._type = &i
  23395. m.add_type = nil
  23396. }
  23397. // GetType returns the value of the "type" field in the mutation.
  23398. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  23399. v := m._type
  23400. if v == nil {
  23401. return
  23402. }
  23403. return *v, true
  23404. }
  23405. // OldType returns the old "type" field's value of the UsageDetail entity.
  23406. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23408. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  23409. if !m.op.Is(OpUpdateOne) {
  23410. return v, errors.New("OldType is only allowed on UpdateOne operations")
  23411. }
  23412. if m.id == nil || m.oldValue == nil {
  23413. return v, errors.New("OldType requires an ID field in the mutation")
  23414. }
  23415. oldValue, err := m.oldValue(ctx)
  23416. if err != nil {
  23417. return v, fmt.Errorf("querying old value for OldType: %w", err)
  23418. }
  23419. return oldValue.Type, nil
  23420. }
  23421. // AddType adds i to the "type" field.
  23422. func (m *UsageDetailMutation) AddType(i int) {
  23423. if m.add_type != nil {
  23424. *m.add_type += i
  23425. } else {
  23426. m.add_type = &i
  23427. }
  23428. }
  23429. // AddedType returns the value that was added to the "type" field in this mutation.
  23430. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  23431. v := m.add_type
  23432. if v == nil {
  23433. return
  23434. }
  23435. return *v, true
  23436. }
  23437. // ClearType clears the value of the "type" field.
  23438. func (m *UsageDetailMutation) ClearType() {
  23439. m._type = nil
  23440. m.add_type = nil
  23441. m.clearedFields[usagedetail.FieldType] = struct{}{}
  23442. }
  23443. // TypeCleared returns if the "type" field was cleared in this mutation.
  23444. func (m *UsageDetailMutation) TypeCleared() bool {
  23445. _, ok := m.clearedFields[usagedetail.FieldType]
  23446. return ok
  23447. }
  23448. // ResetType resets all changes to the "type" field.
  23449. func (m *UsageDetailMutation) ResetType() {
  23450. m._type = nil
  23451. m.add_type = nil
  23452. delete(m.clearedFields, usagedetail.FieldType)
  23453. }
  23454. // SetBotID sets the "bot_id" field.
  23455. func (m *UsageDetailMutation) SetBotID(s string) {
  23456. m.bot_id = &s
  23457. }
  23458. // BotID returns the value of the "bot_id" field in the mutation.
  23459. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  23460. v := m.bot_id
  23461. if v == nil {
  23462. return
  23463. }
  23464. return *v, true
  23465. }
  23466. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  23467. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23469. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  23470. if !m.op.Is(OpUpdateOne) {
  23471. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  23472. }
  23473. if m.id == nil || m.oldValue == nil {
  23474. return v, errors.New("OldBotID requires an ID field in the mutation")
  23475. }
  23476. oldValue, err := m.oldValue(ctx)
  23477. if err != nil {
  23478. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  23479. }
  23480. return oldValue.BotID, nil
  23481. }
  23482. // ResetBotID resets all changes to the "bot_id" field.
  23483. func (m *UsageDetailMutation) ResetBotID() {
  23484. m.bot_id = nil
  23485. }
  23486. // SetReceiverID sets the "receiver_id" field.
  23487. func (m *UsageDetailMutation) SetReceiverID(s string) {
  23488. m.receiver_id = &s
  23489. }
  23490. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  23491. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  23492. v := m.receiver_id
  23493. if v == nil {
  23494. return
  23495. }
  23496. return *v, true
  23497. }
  23498. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  23499. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23501. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  23502. if !m.op.Is(OpUpdateOne) {
  23503. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  23504. }
  23505. if m.id == nil || m.oldValue == nil {
  23506. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  23507. }
  23508. oldValue, err := m.oldValue(ctx)
  23509. if err != nil {
  23510. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  23511. }
  23512. return oldValue.ReceiverID, nil
  23513. }
  23514. // ResetReceiverID resets all changes to the "receiver_id" field.
  23515. func (m *UsageDetailMutation) ResetReceiverID() {
  23516. m.receiver_id = nil
  23517. }
  23518. // SetApp sets the "app" field.
  23519. func (m *UsageDetailMutation) SetApp(i int) {
  23520. m.app = &i
  23521. m.addapp = nil
  23522. }
  23523. // App returns the value of the "app" field in the mutation.
  23524. func (m *UsageDetailMutation) App() (r int, exists bool) {
  23525. v := m.app
  23526. if v == nil {
  23527. return
  23528. }
  23529. return *v, true
  23530. }
  23531. // OldApp returns the old "app" field's value of the UsageDetail entity.
  23532. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23533. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23534. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  23535. if !m.op.Is(OpUpdateOne) {
  23536. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  23537. }
  23538. if m.id == nil || m.oldValue == nil {
  23539. return v, errors.New("OldApp requires an ID field in the mutation")
  23540. }
  23541. oldValue, err := m.oldValue(ctx)
  23542. if err != nil {
  23543. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  23544. }
  23545. return oldValue.App, nil
  23546. }
  23547. // AddApp adds i to the "app" field.
  23548. func (m *UsageDetailMutation) AddApp(i int) {
  23549. if m.addapp != nil {
  23550. *m.addapp += i
  23551. } else {
  23552. m.addapp = &i
  23553. }
  23554. }
  23555. // AddedApp returns the value that was added to the "app" field in this mutation.
  23556. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  23557. v := m.addapp
  23558. if v == nil {
  23559. return
  23560. }
  23561. return *v, true
  23562. }
  23563. // ClearApp clears the value of the "app" field.
  23564. func (m *UsageDetailMutation) ClearApp() {
  23565. m.app = nil
  23566. m.addapp = nil
  23567. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  23568. }
  23569. // AppCleared returns if the "app" field was cleared in this mutation.
  23570. func (m *UsageDetailMutation) AppCleared() bool {
  23571. _, ok := m.clearedFields[usagedetail.FieldApp]
  23572. return ok
  23573. }
  23574. // ResetApp resets all changes to the "app" field.
  23575. func (m *UsageDetailMutation) ResetApp() {
  23576. m.app = nil
  23577. m.addapp = nil
  23578. delete(m.clearedFields, usagedetail.FieldApp)
  23579. }
  23580. // SetSessionID sets the "session_id" field.
  23581. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  23582. m.session_id = &u
  23583. m.addsession_id = nil
  23584. }
  23585. // SessionID returns the value of the "session_id" field in the mutation.
  23586. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  23587. v := m.session_id
  23588. if v == nil {
  23589. return
  23590. }
  23591. return *v, true
  23592. }
  23593. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  23594. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23595. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23596. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  23597. if !m.op.Is(OpUpdateOne) {
  23598. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  23599. }
  23600. if m.id == nil || m.oldValue == nil {
  23601. return v, errors.New("OldSessionID requires an ID field in the mutation")
  23602. }
  23603. oldValue, err := m.oldValue(ctx)
  23604. if err != nil {
  23605. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  23606. }
  23607. return oldValue.SessionID, nil
  23608. }
  23609. // AddSessionID adds u to the "session_id" field.
  23610. func (m *UsageDetailMutation) AddSessionID(u int64) {
  23611. if m.addsession_id != nil {
  23612. *m.addsession_id += u
  23613. } else {
  23614. m.addsession_id = &u
  23615. }
  23616. }
  23617. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  23618. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  23619. v := m.addsession_id
  23620. if v == nil {
  23621. return
  23622. }
  23623. return *v, true
  23624. }
  23625. // ClearSessionID clears the value of the "session_id" field.
  23626. func (m *UsageDetailMutation) ClearSessionID() {
  23627. m.session_id = nil
  23628. m.addsession_id = nil
  23629. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  23630. }
  23631. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  23632. func (m *UsageDetailMutation) SessionIDCleared() bool {
  23633. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  23634. return ok
  23635. }
  23636. // ResetSessionID resets all changes to the "session_id" field.
  23637. func (m *UsageDetailMutation) ResetSessionID() {
  23638. m.session_id = nil
  23639. m.addsession_id = nil
  23640. delete(m.clearedFields, usagedetail.FieldSessionID)
  23641. }
  23642. // SetRequest sets the "request" field.
  23643. func (m *UsageDetailMutation) SetRequest(s string) {
  23644. m.request = &s
  23645. }
  23646. // Request returns the value of the "request" field in the mutation.
  23647. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  23648. v := m.request
  23649. if v == nil {
  23650. return
  23651. }
  23652. return *v, true
  23653. }
  23654. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  23655. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23656. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23657. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  23658. if !m.op.Is(OpUpdateOne) {
  23659. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  23660. }
  23661. if m.id == nil || m.oldValue == nil {
  23662. return v, errors.New("OldRequest requires an ID field in the mutation")
  23663. }
  23664. oldValue, err := m.oldValue(ctx)
  23665. if err != nil {
  23666. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  23667. }
  23668. return oldValue.Request, nil
  23669. }
  23670. // ResetRequest resets all changes to the "request" field.
  23671. func (m *UsageDetailMutation) ResetRequest() {
  23672. m.request = nil
  23673. }
  23674. // SetResponse sets the "response" field.
  23675. func (m *UsageDetailMutation) SetResponse(s string) {
  23676. m.response = &s
  23677. }
  23678. // Response returns the value of the "response" field in the mutation.
  23679. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  23680. v := m.response
  23681. if v == nil {
  23682. return
  23683. }
  23684. return *v, true
  23685. }
  23686. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  23687. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23689. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  23690. if !m.op.Is(OpUpdateOne) {
  23691. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  23692. }
  23693. if m.id == nil || m.oldValue == nil {
  23694. return v, errors.New("OldResponse requires an ID field in the mutation")
  23695. }
  23696. oldValue, err := m.oldValue(ctx)
  23697. if err != nil {
  23698. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  23699. }
  23700. return oldValue.Response, nil
  23701. }
  23702. // ResetResponse resets all changes to the "response" field.
  23703. func (m *UsageDetailMutation) ResetResponse() {
  23704. m.response = nil
  23705. }
  23706. // SetTotalTokens sets the "total_tokens" field.
  23707. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  23708. m.total_tokens = &u
  23709. m.addtotal_tokens = nil
  23710. }
  23711. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  23712. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  23713. v := m.total_tokens
  23714. if v == nil {
  23715. return
  23716. }
  23717. return *v, true
  23718. }
  23719. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  23720. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23721. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23722. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  23723. if !m.op.Is(OpUpdateOne) {
  23724. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  23725. }
  23726. if m.id == nil || m.oldValue == nil {
  23727. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  23728. }
  23729. oldValue, err := m.oldValue(ctx)
  23730. if err != nil {
  23731. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  23732. }
  23733. return oldValue.TotalTokens, nil
  23734. }
  23735. // AddTotalTokens adds u to the "total_tokens" field.
  23736. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  23737. if m.addtotal_tokens != nil {
  23738. *m.addtotal_tokens += u
  23739. } else {
  23740. m.addtotal_tokens = &u
  23741. }
  23742. }
  23743. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  23744. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  23745. v := m.addtotal_tokens
  23746. if v == nil {
  23747. return
  23748. }
  23749. return *v, true
  23750. }
  23751. // ClearTotalTokens clears the value of the "total_tokens" field.
  23752. func (m *UsageDetailMutation) ClearTotalTokens() {
  23753. m.total_tokens = nil
  23754. m.addtotal_tokens = nil
  23755. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  23756. }
  23757. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  23758. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  23759. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  23760. return ok
  23761. }
  23762. // ResetTotalTokens resets all changes to the "total_tokens" field.
  23763. func (m *UsageDetailMutation) ResetTotalTokens() {
  23764. m.total_tokens = nil
  23765. m.addtotal_tokens = nil
  23766. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  23767. }
  23768. // SetPromptTokens sets the "prompt_tokens" field.
  23769. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  23770. m.prompt_tokens = &u
  23771. m.addprompt_tokens = nil
  23772. }
  23773. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  23774. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  23775. v := m.prompt_tokens
  23776. if v == nil {
  23777. return
  23778. }
  23779. return *v, true
  23780. }
  23781. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  23782. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23784. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  23785. if !m.op.Is(OpUpdateOne) {
  23786. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  23787. }
  23788. if m.id == nil || m.oldValue == nil {
  23789. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  23790. }
  23791. oldValue, err := m.oldValue(ctx)
  23792. if err != nil {
  23793. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  23794. }
  23795. return oldValue.PromptTokens, nil
  23796. }
  23797. // AddPromptTokens adds u to the "prompt_tokens" field.
  23798. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  23799. if m.addprompt_tokens != nil {
  23800. *m.addprompt_tokens += u
  23801. } else {
  23802. m.addprompt_tokens = &u
  23803. }
  23804. }
  23805. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  23806. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  23807. v := m.addprompt_tokens
  23808. if v == nil {
  23809. return
  23810. }
  23811. return *v, true
  23812. }
  23813. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  23814. func (m *UsageDetailMutation) ClearPromptTokens() {
  23815. m.prompt_tokens = nil
  23816. m.addprompt_tokens = nil
  23817. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  23818. }
  23819. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  23820. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  23821. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  23822. return ok
  23823. }
  23824. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  23825. func (m *UsageDetailMutation) ResetPromptTokens() {
  23826. m.prompt_tokens = nil
  23827. m.addprompt_tokens = nil
  23828. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  23829. }
  23830. // SetCompletionTokens sets the "completion_tokens" field.
  23831. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  23832. m.completion_tokens = &u
  23833. m.addcompletion_tokens = nil
  23834. }
  23835. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  23836. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  23837. v := m.completion_tokens
  23838. if v == nil {
  23839. return
  23840. }
  23841. return *v, true
  23842. }
  23843. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  23844. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23845. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23846. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  23847. if !m.op.Is(OpUpdateOne) {
  23848. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  23849. }
  23850. if m.id == nil || m.oldValue == nil {
  23851. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  23852. }
  23853. oldValue, err := m.oldValue(ctx)
  23854. if err != nil {
  23855. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  23856. }
  23857. return oldValue.CompletionTokens, nil
  23858. }
  23859. // AddCompletionTokens adds u to the "completion_tokens" field.
  23860. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  23861. if m.addcompletion_tokens != nil {
  23862. *m.addcompletion_tokens += u
  23863. } else {
  23864. m.addcompletion_tokens = &u
  23865. }
  23866. }
  23867. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  23868. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  23869. v := m.addcompletion_tokens
  23870. if v == nil {
  23871. return
  23872. }
  23873. return *v, true
  23874. }
  23875. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  23876. func (m *UsageDetailMutation) ClearCompletionTokens() {
  23877. m.completion_tokens = nil
  23878. m.addcompletion_tokens = nil
  23879. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  23880. }
  23881. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  23882. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  23883. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  23884. return ok
  23885. }
  23886. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  23887. func (m *UsageDetailMutation) ResetCompletionTokens() {
  23888. m.completion_tokens = nil
  23889. m.addcompletion_tokens = nil
  23890. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  23891. }
  23892. // SetOrganizationID sets the "organization_id" field.
  23893. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  23894. m.organization_id = &u
  23895. m.addorganization_id = nil
  23896. }
  23897. // OrganizationID returns the value of the "organization_id" field in the mutation.
  23898. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  23899. v := m.organization_id
  23900. if v == nil {
  23901. return
  23902. }
  23903. return *v, true
  23904. }
  23905. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  23906. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  23907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23908. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  23909. if !m.op.Is(OpUpdateOne) {
  23910. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  23911. }
  23912. if m.id == nil || m.oldValue == nil {
  23913. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  23914. }
  23915. oldValue, err := m.oldValue(ctx)
  23916. if err != nil {
  23917. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  23918. }
  23919. return oldValue.OrganizationID, nil
  23920. }
  23921. // AddOrganizationID adds u to the "organization_id" field.
  23922. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  23923. if m.addorganization_id != nil {
  23924. *m.addorganization_id += u
  23925. } else {
  23926. m.addorganization_id = &u
  23927. }
  23928. }
  23929. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  23930. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  23931. v := m.addorganization_id
  23932. if v == nil {
  23933. return
  23934. }
  23935. return *v, true
  23936. }
  23937. // ClearOrganizationID clears the value of the "organization_id" field.
  23938. func (m *UsageDetailMutation) ClearOrganizationID() {
  23939. m.organization_id = nil
  23940. m.addorganization_id = nil
  23941. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  23942. }
  23943. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  23944. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  23945. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  23946. return ok
  23947. }
  23948. // ResetOrganizationID resets all changes to the "organization_id" field.
  23949. func (m *UsageDetailMutation) ResetOrganizationID() {
  23950. m.organization_id = nil
  23951. m.addorganization_id = nil
  23952. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  23953. }
  23954. // Where appends a list predicates to the UsageDetailMutation builder.
  23955. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  23956. m.predicates = append(m.predicates, ps...)
  23957. }
  23958. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  23959. // users can use type-assertion to append predicates that do not depend on any generated package.
  23960. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  23961. p := make([]predicate.UsageDetail, len(ps))
  23962. for i := range ps {
  23963. p[i] = ps[i]
  23964. }
  23965. m.Where(p...)
  23966. }
  23967. // Op returns the operation name.
  23968. func (m *UsageDetailMutation) Op() Op {
  23969. return m.op
  23970. }
  23971. // SetOp allows setting the mutation operation.
  23972. func (m *UsageDetailMutation) SetOp(op Op) {
  23973. m.op = op
  23974. }
  23975. // Type returns the node type of this mutation (UsageDetail).
  23976. func (m *UsageDetailMutation) Type() string {
  23977. return m.typ
  23978. }
  23979. // Fields returns all fields that were changed during this mutation. Note that in
  23980. // order to get all numeric fields that were incremented/decremented, call
  23981. // AddedFields().
  23982. func (m *UsageDetailMutation) Fields() []string {
  23983. fields := make([]string, 0, 14)
  23984. if m.created_at != nil {
  23985. fields = append(fields, usagedetail.FieldCreatedAt)
  23986. }
  23987. if m.updated_at != nil {
  23988. fields = append(fields, usagedetail.FieldUpdatedAt)
  23989. }
  23990. if m.status != nil {
  23991. fields = append(fields, usagedetail.FieldStatus)
  23992. }
  23993. if m._type != nil {
  23994. fields = append(fields, usagedetail.FieldType)
  23995. }
  23996. if m.bot_id != nil {
  23997. fields = append(fields, usagedetail.FieldBotID)
  23998. }
  23999. if m.receiver_id != nil {
  24000. fields = append(fields, usagedetail.FieldReceiverID)
  24001. }
  24002. if m.app != nil {
  24003. fields = append(fields, usagedetail.FieldApp)
  24004. }
  24005. if m.session_id != nil {
  24006. fields = append(fields, usagedetail.FieldSessionID)
  24007. }
  24008. if m.request != nil {
  24009. fields = append(fields, usagedetail.FieldRequest)
  24010. }
  24011. if m.response != nil {
  24012. fields = append(fields, usagedetail.FieldResponse)
  24013. }
  24014. if m.total_tokens != nil {
  24015. fields = append(fields, usagedetail.FieldTotalTokens)
  24016. }
  24017. if m.prompt_tokens != nil {
  24018. fields = append(fields, usagedetail.FieldPromptTokens)
  24019. }
  24020. if m.completion_tokens != nil {
  24021. fields = append(fields, usagedetail.FieldCompletionTokens)
  24022. }
  24023. if m.organization_id != nil {
  24024. fields = append(fields, usagedetail.FieldOrganizationID)
  24025. }
  24026. return fields
  24027. }
  24028. // Field returns the value of a field with the given name. The second boolean
  24029. // return value indicates that this field was not set, or was not defined in the
  24030. // schema.
  24031. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  24032. switch name {
  24033. case usagedetail.FieldCreatedAt:
  24034. return m.CreatedAt()
  24035. case usagedetail.FieldUpdatedAt:
  24036. return m.UpdatedAt()
  24037. case usagedetail.FieldStatus:
  24038. return m.Status()
  24039. case usagedetail.FieldType:
  24040. return m.GetType()
  24041. case usagedetail.FieldBotID:
  24042. return m.BotID()
  24043. case usagedetail.FieldReceiverID:
  24044. return m.ReceiverID()
  24045. case usagedetail.FieldApp:
  24046. return m.App()
  24047. case usagedetail.FieldSessionID:
  24048. return m.SessionID()
  24049. case usagedetail.FieldRequest:
  24050. return m.Request()
  24051. case usagedetail.FieldResponse:
  24052. return m.Response()
  24053. case usagedetail.FieldTotalTokens:
  24054. return m.TotalTokens()
  24055. case usagedetail.FieldPromptTokens:
  24056. return m.PromptTokens()
  24057. case usagedetail.FieldCompletionTokens:
  24058. return m.CompletionTokens()
  24059. case usagedetail.FieldOrganizationID:
  24060. return m.OrganizationID()
  24061. }
  24062. return nil, false
  24063. }
  24064. // OldField returns the old value of the field from the database. An error is
  24065. // returned if the mutation operation is not UpdateOne, or the query to the
  24066. // database failed.
  24067. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24068. switch name {
  24069. case usagedetail.FieldCreatedAt:
  24070. return m.OldCreatedAt(ctx)
  24071. case usagedetail.FieldUpdatedAt:
  24072. return m.OldUpdatedAt(ctx)
  24073. case usagedetail.FieldStatus:
  24074. return m.OldStatus(ctx)
  24075. case usagedetail.FieldType:
  24076. return m.OldType(ctx)
  24077. case usagedetail.FieldBotID:
  24078. return m.OldBotID(ctx)
  24079. case usagedetail.FieldReceiverID:
  24080. return m.OldReceiverID(ctx)
  24081. case usagedetail.FieldApp:
  24082. return m.OldApp(ctx)
  24083. case usagedetail.FieldSessionID:
  24084. return m.OldSessionID(ctx)
  24085. case usagedetail.FieldRequest:
  24086. return m.OldRequest(ctx)
  24087. case usagedetail.FieldResponse:
  24088. return m.OldResponse(ctx)
  24089. case usagedetail.FieldTotalTokens:
  24090. return m.OldTotalTokens(ctx)
  24091. case usagedetail.FieldPromptTokens:
  24092. return m.OldPromptTokens(ctx)
  24093. case usagedetail.FieldCompletionTokens:
  24094. return m.OldCompletionTokens(ctx)
  24095. case usagedetail.FieldOrganizationID:
  24096. return m.OldOrganizationID(ctx)
  24097. }
  24098. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  24099. }
  24100. // SetField sets the value of a field with the given name. It returns an error if
  24101. // the field is not defined in the schema, or if the type mismatched the field
  24102. // type.
  24103. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  24104. switch name {
  24105. case usagedetail.FieldCreatedAt:
  24106. v, ok := value.(time.Time)
  24107. if !ok {
  24108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24109. }
  24110. m.SetCreatedAt(v)
  24111. return nil
  24112. case usagedetail.FieldUpdatedAt:
  24113. v, ok := value.(time.Time)
  24114. if !ok {
  24115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24116. }
  24117. m.SetUpdatedAt(v)
  24118. return nil
  24119. case usagedetail.FieldStatus:
  24120. v, ok := value.(uint8)
  24121. if !ok {
  24122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24123. }
  24124. m.SetStatus(v)
  24125. return nil
  24126. case usagedetail.FieldType:
  24127. v, ok := value.(int)
  24128. if !ok {
  24129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24130. }
  24131. m.SetType(v)
  24132. return nil
  24133. case usagedetail.FieldBotID:
  24134. v, ok := value.(string)
  24135. if !ok {
  24136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24137. }
  24138. m.SetBotID(v)
  24139. return nil
  24140. case usagedetail.FieldReceiverID:
  24141. v, ok := value.(string)
  24142. if !ok {
  24143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24144. }
  24145. m.SetReceiverID(v)
  24146. return nil
  24147. case usagedetail.FieldApp:
  24148. v, ok := value.(int)
  24149. if !ok {
  24150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24151. }
  24152. m.SetApp(v)
  24153. return nil
  24154. case usagedetail.FieldSessionID:
  24155. v, ok := value.(uint64)
  24156. if !ok {
  24157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24158. }
  24159. m.SetSessionID(v)
  24160. return nil
  24161. case usagedetail.FieldRequest:
  24162. v, ok := value.(string)
  24163. if !ok {
  24164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24165. }
  24166. m.SetRequest(v)
  24167. return nil
  24168. case usagedetail.FieldResponse:
  24169. v, ok := value.(string)
  24170. if !ok {
  24171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24172. }
  24173. m.SetResponse(v)
  24174. return nil
  24175. case usagedetail.FieldTotalTokens:
  24176. v, ok := value.(uint64)
  24177. if !ok {
  24178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24179. }
  24180. m.SetTotalTokens(v)
  24181. return nil
  24182. case usagedetail.FieldPromptTokens:
  24183. v, ok := value.(uint64)
  24184. if !ok {
  24185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24186. }
  24187. m.SetPromptTokens(v)
  24188. return nil
  24189. case usagedetail.FieldCompletionTokens:
  24190. v, ok := value.(uint64)
  24191. if !ok {
  24192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24193. }
  24194. m.SetCompletionTokens(v)
  24195. return nil
  24196. case usagedetail.FieldOrganizationID:
  24197. v, ok := value.(uint64)
  24198. if !ok {
  24199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24200. }
  24201. m.SetOrganizationID(v)
  24202. return nil
  24203. }
  24204. return fmt.Errorf("unknown UsageDetail field %s", name)
  24205. }
  24206. // AddedFields returns all numeric fields that were incremented/decremented during
  24207. // this mutation.
  24208. func (m *UsageDetailMutation) AddedFields() []string {
  24209. var fields []string
  24210. if m.addstatus != nil {
  24211. fields = append(fields, usagedetail.FieldStatus)
  24212. }
  24213. if m.add_type != nil {
  24214. fields = append(fields, usagedetail.FieldType)
  24215. }
  24216. if m.addapp != nil {
  24217. fields = append(fields, usagedetail.FieldApp)
  24218. }
  24219. if m.addsession_id != nil {
  24220. fields = append(fields, usagedetail.FieldSessionID)
  24221. }
  24222. if m.addtotal_tokens != nil {
  24223. fields = append(fields, usagedetail.FieldTotalTokens)
  24224. }
  24225. if m.addprompt_tokens != nil {
  24226. fields = append(fields, usagedetail.FieldPromptTokens)
  24227. }
  24228. if m.addcompletion_tokens != nil {
  24229. fields = append(fields, usagedetail.FieldCompletionTokens)
  24230. }
  24231. if m.addorganization_id != nil {
  24232. fields = append(fields, usagedetail.FieldOrganizationID)
  24233. }
  24234. return fields
  24235. }
  24236. // AddedField returns the numeric value that was incremented/decremented on a field
  24237. // with the given name. The second boolean return value indicates that this field
  24238. // was not set, or was not defined in the schema.
  24239. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  24240. switch name {
  24241. case usagedetail.FieldStatus:
  24242. return m.AddedStatus()
  24243. case usagedetail.FieldType:
  24244. return m.AddedType()
  24245. case usagedetail.FieldApp:
  24246. return m.AddedApp()
  24247. case usagedetail.FieldSessionID:
  24248. return m.AddedSessionID()
  24249. case usagedetail.FieldTotalTokens:
  24250. return m.AddedTotalTokens()
  24251. case usagedetail.FieldPromptTokens:
  24252. return m.AddedPromptTokens()
  24253. case usagedetail.FieldCompletionTokens:
  24254. return m.AddedCompletionTokens()
  24255. case usagedetail.FieldOrganizationID:
  24256. return m.AddedOrganizationID()
  24257. }
  24258. return nil, false
  24259. }
  24260. // AddField adds the value to the field with the given name. It returns an error if
  24261. // the field is not defined in the schema, or if the type mismatched the field
  24262. // type.
  24263. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  24264. switch name {
  24265. case usagedetail.FieldStatus:
  24266. v, ok := value.(int8)
  24267. if !ok {
  24268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24269. }
  24270. m.AddStatus(v)
  24271. return nil
  24272. case usagedetail.FieldType:
  24273. v, ok := value.(int)
  24274. if !ok {
  24275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24276. }
  24277. m.AddType(v)
  24278. return nil
  24279. case usagedetail.FieldApp:
  24280. v, ok := value.(int)
  24281. if !ok {
  24282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24283. }
  24284. m.AddApp(v)
  24285. return nil
  24286. case usagedetail.FieldSessionID:
  24287. v, ok := value.(int64)
  24288. if !ok {
  24289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24290. }
  24291. m.AddSessionID(v)
  24292. return nil
  24293. case usagedetail.FieldTotalTokens:
  24294. v, ok := value.(int64)
  24295. if !ok {
  24296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24297. }
  24298. m.AddTotalTokens(v)
  24299. return nil
  24300. case usagedetail.FieldPromptTokens:
  24301. v, ok := value.(int64)
  24302. if !ok {
  24303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24304. }
  24305. m.AddPromptTokens(v)
  24306. return nil
  24307. case usagedetail.FieldCompletionTokens:
  24308. v, ok := value.(int64)
  24309. if !ok {
  24310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24311. }
  24312. m.AddCompletionTokens(v)
  24313. return nil
  24314. case usagedetail.FieldOrganizationID:
  24315. v, ok := value.(int64)
  24316. if !ok {
  24317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24318. }
  24319. m.AddOrganizationID(v)
  24320. return nil
  24321. }
  24322. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  24323. }
  24324. // ClearedFields returns all nullable fields that were cleared during this
  24325. // mutation.
  24326. func (m *UsageDetailMutation) ClearedFields() []string {
  24327. var fields []string
  24328. if m.FieldCleared(usagedetail.FieldStatus) {
  24329. fields = append(fields, usagedetail.FieldStatus)
  24330. }
  24331. if m.FieldCleared(usagedetail.FieldType) {
  24332. fields = append(fields, usagedetail.FieldType)
  24333. }
  24334. if m.FieldCleared(usagedetail.FieldApp) {
  24335. fields = append(fields, usagedetail.FieldApp)
  24336. }
  24337. if m.FieldCleared(usagedetail.FieldSessionID) {
  24338. fields = append(fields, usagedetail.FieldSessionID)
  24339. }
  24340. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  24341. fields = append(fields, usagedetail.FieldTotalTokens)
  24342. }
  24343. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  24344. fields = append(fields, usagedetail.FieldPromptTokens)
  24345. }
  24346. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  24347. fields = append(fields, usagedetail.FieldCompletionTokens)
  24348. }
  24349. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  24350. fields = append(fields, usagedetail.FieldOrganizationID)
  24351. }
  24352. return fields
  24353. }
  24354. // FieldCleared returns a boolean indicating if a field with the given name was
  24355. // cleared in this mutation.
  24356. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  24357. _, ok := m.clearedFields[name]
  24358. return ok
  24359. }
  24360. // ClearField clears the value of the field with the given name. It returns an
  24361. // error if the field is not defined in the schema.
  24362. func (m *UsageDetailMutation) ClearField(name string) error {
  24363. switch name {
  24364. case usagedetail.FieldStatus:
  24365. m.ClearStatus()
  24366. return nil
  24367. case usagedetail.FieldType:
  24368. m.ClearType()
  24369. return nil
  24370. case usagedetail.FieldApp:
  24371. m.ClearApp()
  24372. return nil
  24373. case usagedetail.FieldSessionID:
  24374. m.ClearSessionID()
  24375. return nil
  24376. case usagedetail.FieldTotalTokens:
  24377. m.ClearTotalTokens()
  24378. return nil
  24379. case usagedetail.FieldPromptTokens:
  24380. m.ClearPromptTokens()
  24381. return nil
  24382. case usagedetail.FieldCompletionTokens:
  24383. m.ClearCompletionTokens()
  24384. return nil
  24385. case usagedetail.FieldOrganizationID:
  24386. m.ClearOrganizationID()
  24387. return nil
  24388. }
  24389. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  24390. }
  24391. // ResetField resets all changes in the mutation for the field with the given name.
  24392. // It returns an error if the field is not defined in the schema.
  24393. func (m *UsageDetailMutation) ResetField(name string) error {
  24394. switch name {
  24395. case usagedetail.FieldCreatedAt:
  24396. m.ResetCreatedAt()
  24397. return nil
  24398. case usagedetail.FieldUpdatedAt:
  24399. m.ResetUpdatedAt()
  24400. return nil
  24401. case usagedetail.FieldStatus:
  24402. m.ResetStatus()
  24403. return nil
  24404. case usagedetail.FieldType:
  24405. m.ResetType()
  24406. return nil
  24407. case usagedetail.FieldBotID:
  24408. m.ResetBotID()
  24409. return nil
  24410. case usagedetail.FieldReceiverID:
  24411. m.ResetReceiverID()
  24412. return nil
  24413. case usagedetail.FieldApp:
  24414. m.ResetApp()
  24415. return nil
  24416. case usagedetail.FieldSessionID:
  24417. m.ResetSessionID()
  24418. return nil
  24419. case usagedetail.FieldRequest:
  24420. m.ResetRequest()
  24421. return nil
  24422. case usagedetail.FieldResponse:
  24423. m.ResetResponse()
  24424. return nil
  24425. case usagedetail.FieldTotalTokens:
  24426. m.ResetTotalTokens()
  24427. return nil
  24428. case usagedetail.FieldPromptTokens:
  24429. m.ResetPromptTokens()
  24430. return nil
  24431. case usagedetail.FieldCompletionTokens:
  24432. m.ResetCompletionTokens()
  24433. return nil
  24434. case usagedetail.FieldOrganizationID:
  24435. m.ResetOrganizationID()
  24436. return nil
  24437. }
  24438. return fmt.Errorf("unknown UsageDetail field %s", name)
  24439. }
  24440. // AddedEdges returns all edge names that were set/added in this mutation.
  24441. func (m *UsageDetailMutation) AddedEdges() []string {
  24442. edges := make([]string, 0, 0)
  24443. return edges
  24444. }
  24445. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24446. // name in this mutation.
  24447. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  24448. return nil
  24449. }
  24450. // RemovedEdges returns all edge names that were removed in this mutation.
  24451. func (m *UsageDetailMutation) RemovedEdges() []string {
  24452. edges := make([]string, 0, 0)
  24453. return edges
  24454. }
  24455. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24456. // the given name in this mutation.
  24457. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  24458. return nil
  24459. }
  24460. // ClearedEdges returns all edge names that were cleared in this mutation.
  24461. func (m *UsageDetailMutation) ClearedEdges() []string {
  24462. edges := make([]string, 0, 0)
  24463. return edges
  24464. }
  24465. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24466. // was cleared in this mutation.
  24467. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  24468. return false
  24469. }
  24470. // ClearEdge clears the value of the edge with the given name. It returns an error
  24471. // if that edge is not defined in the schema.
  24472. func (m *UsageDetailMutation) ClearEdge(name string) error {
  24473. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  24474. }
  24475. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24476. // It returns an error if the edge is not defined in the schema.
  24477. func (m *UsageDetailMutation) ResetEdge(name string) error {
  24478. return fmt.Errorf("unknown UsageDetail edge %s", name)
  24479. }
  24480. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  24481. type UsageStatisticDayMutation struct {
  24482. config
  24483. op Op
  24484. typ string
  24485. id *uint64
  24486. created_at *time.Time
  24487. updated_at *time.Time
  24488. status *uint8
  24489. addstatus *int8
  24490. deleted_at *time.Time
  24491. addtime *uint64
  24492. addaddtime *int64
  24493. _type *int
  24494. add_type *int
  24495. bot_id *string
  24496. organization_id *uint64
  24497. addorganization_id *int64
  24498. ai_response *uint64
  24499. addai_response *int64
  24500. sop_run *uint64
  24501. addsop_run *int64
  24502. total_friend *uint64
  24503. addtotal_friend *int64
  24504. total_group *uint64
  24505. addtotal_group *int64
  24506. account_balance *uint64
  24507. addaccount_balance *int64
  24508. consume_token *uint64
  24509. addconsume_token *int64
  24510. active_user *uint64
  24511. addactive_user *int64
  24512. new_user *int64
  24513. addnew_user *int64
  24514. label_dist *[]custom_types.LabelDist
  24515. appendlabel_dist []custom_types.LabelDist
  24516. clearedFields map[string]struct{}
  24517. done bool
  24518. oldValue func(context.Context) (*UsageStatisticDay, error)
  24519. predicates []predicate.UsageStatisticDay
  24520. }
  24521. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  24522. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  24523. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  24524. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  24525. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  24526. m := &UsageStatisticDayMutation{
  24527. config: c,
  24528. op: op,
  24529. typ: TypeUsageStatisticDay,
  24530. clearedFields: make(map[string]struct{}),
  24531. }
  24532. for _, opt := range opts {
  24533. opt(m)
  24534. }
  24535. return m
  24536. }
  24537. // withUsageStatisticDayID sets the ID field of the mutation.
  24538. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  24539. return func(m *UsageStatisticDayMutation) {
  24540. var (
  24541. err error
  24542. once sync.Once
  24543. value *UsageStatisticDay
  24544. )
  24545. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  24546. once.Do(func() {
  24547. if m.done {
  24548. err = errors.New("querying old values post mutation is not allowed")
  24549. } else {
  24550. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  24551. }
  24552. })
  24553. return value, err
  24554. }
  24555. m.id = &id
  24556. }
  24557. }
  24558. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  24559. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  24560. return func(m *UsageStatisticDayMutation) {
  24561. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  24562. return node, nil
  24563. }
  24564. m.id = &node.ID
  24565. }
  24566. }
  24567. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24568. // executed in a transaction (ent.Tx), a transactional client is returned.
  24569. func (m UsageStatisticDayMutation) Client() *Client {
  24570. client := &Client{config: m.config}
  24571. client.init()
  24572. return client
  24573. }
  24574. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24575. // it returns an error otherwise.
  24576. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  24577. if _, ok := m.driver.(*txDriver); !ok {
  24578. return nil, errors.New("ent: mutation is not running in a transaction")
  24579. }
  24580. tx := &Tx{config: m.config}
  24581. tx.init()
  24582. return tx, nil
  24583. }
  24584. // SetID sets the value of the id field. Note that this
  24585. // operation is only accepted on creation of UsageStatisticDay entities.
  24586. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  24587. m.id = &id
  24588. }
  24589. // ID returns the ID value in the mutation. Note that the ID is only available
  24590. // if it was provided to the builder or after it was returned from the database.
  24591. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  24592. if m.id == nil {
  24593. return
  24594. }
  24595. return *m.id, true
  24596. }
  24597. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24598. // That means, if the mutation is applied within a transaction with an isolation level such
  24599. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24600. // or updated by the mutation.
  24601. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  24602. switch {
  24603. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24604. id, exists := m.ID()
  24605. if exists {
  24606. return []uint64{id}, nil
  24607. }
  24608. fallthrough
  24609. case m.op.Is(OpUpdate | OpDelete):
  24610. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  24611. default:
  24612. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24613. }
  24614. }
  24615. // SetCreatedAt sets the "created_at" field.
  24616. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  24617. m.created_at = &t
  24618. }
  24619. // CreatedAt returns the value of the "created_at" field in the mutation.
  24620. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  24621. v := m.created_at
  24622. if v == nil {
  24623. return
  24624. }
  24625. return *v, true
  24626. }
  24627. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  24628. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24630. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24631. if !m.op.Is(OpUpdateOne) {
  24632. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24633. }
  24634. if m.id == nil || m.oldValue == nil {
  24635. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24636. }
  24637. oldValue, err := m.oldValue(ctx)
  24638. if err != nil {
  24639. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24640. }
  24641. return oldValue.CreatedAt, nil
  24642. }
  24643. // ResetCreatedAt resets all changes to the "created_at" field.
  24644. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  24645. m.created_at = nil
  24646. }
  24647. // SetUpdatedAt sets the "updated_at" field.
  24648. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  24649. m.updated_at = &t
  24650. }
  24651. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24652. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  24653. v := m.updated_at
  24654. if v == nil {
  24655. return
  24656. }
  24657. return *v, true
  24658. }
  24659. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  24660. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24661. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24662. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24663. if !m.op.Is(OpUpdateOne) {
  24664. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24665. }
  24666. if m.id == nil || m.oldValue == nil {
  24667. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24668. }
  24669. oldValue, err := m.oldValue(ctx)
  24670. if err != nil {
  24671. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24672. }
  24673. return oldValue.UpdatedAt, nil
  24674. }
  24675. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24676. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  24677. m.updated_at = nil
  24678. }
  24679. // SetStatus sets the "status" field.
  24680. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  24681. m.status = &u
  24682. m.addstatus = nil
  24683. }
  24684. // Status returns the value of the "status" field in the mutation.
  24685. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  24686. v := m.status
  24687. if v == nil {
  24688. return
  24689. }
  24690. return *v, true
  24691. }
  24692. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  24693. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24695. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  24696. if !m.op.Is(OpUpdateOne) {
  24697. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  24698. }
  24699. if m.id == nil || m.oldValue == nil {
  24700. return v, errors.New("OldStatus requires an ID field in the mutation")
  24701. }
  24702. oldValue, err := m.oldValue(ctx)
  24703. if err != nil {
  24704. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  24705. }
  24706. return oldValue.Status, nil
  24707. }
  24708. // AddStatus adds u to the "status" field.
  24709. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  24710. if m.addstatus != nil {
  24711. *m.addstatus += u
  24712. } else {
  24713. m.addstatus = &u
  24714. }
  24715. }
  24716. // AddedStatus returns the value that was added to the "status" field in this mutation.
  24717. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  24718. v := m.addstatus
  24719. if v == nil {
  24720. return
  24721. }
  24722. return *v, true
  24723. }
  24724. // ClearStatus clears the value of the "status" field.
  24725. func (m *UsageStatisticDayMutation) ClearStatus() {
  24726. m.status = nil
  24727. m.addstatus = nil
  24728. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  24729. }
  24730. // StatusCleared returns if the "status" field was cleared in this mutation.
  24731. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  24732. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  24733. return ok
  24734. }
  24735. // ResetStatus resets all changes to the "status" field.
  24736. func (m *UsageStatisticDayMutation) ResetStatus() {
  24737. m.status = nil
  24738. m.addstatus = nil
  24739. delete(m.clearedFields, usagestatisticday.FieldStatus)
  24740. }
  24741. // SetDeletedAt sets the "deleted_at" field.
  24742. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  24743. m.deleted_at = &t
  24744. }
  24745. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24746. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  24747. v := m.deleted_at
  24748. if v == nil {
  24749. return
  24750. }
  24751. return *v, true
  24752. }
  24753. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  24754. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24756. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24757. if !m.op.Is(OpUpdateOne) {
  24758. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24759. }
  24760. if m.id == nil || m.oldValue == nil {
  24761. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24762. }
  24763. oldValue, err := m.oldValue(ctx)
  24764. if err != nil {
  24765. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24766. }
  24767. return oldValue.DeletedAt, nil
  24768. }
  24769. // ClearDeletedAt clears the value of the "deleted_at" field.
  24770. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  24771. m.deleted_at = nil
  24772. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  24773. }
  24774. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24775. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  24776. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  24777. return ok
  24778. }
  24779. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24780. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  24781. m.deleted_at = nil
  24782. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  24783. }
  24784. // SetAddtime sets the "addtime" field.
  24785. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  24786. m.addtime = &u
  24787. m.addaddtime = nil
  24788. }
  24789. // Addtime returns the value of the "addtime" field in the mutation.
  24790. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  24791. v := m.addtime
  24792. if v == nil {
  24793. return
  24794. }
  24795. return *v, true
  24796. }
  24797. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  24798. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24799. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24800. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  24801. if !m.op.Is(OpUpdateOne) {
  24802. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  24803. }
  24804. if m.id == nil || m.oldValue == nil {
  24805. return v, errors.New("OldAddtime requires an ID field in the mutation")
  24806. }
  24807. oldValue, err := m.oldValue(ctx)
  24808. if err != nil {
  24809. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  24810. }
  24811. return oldValue.Addtime, nil
  24812. }
  24813. // AddAddtime adds u to the "addtime" field.
  24814. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  24815. if m.addaddtime != nil {
  24816. *m.addaddtime += u
  24817. } else {
  24818. m.addaddtime = &u
  24819. }
  24820. }
  24821. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  24822. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  24823. v := m.addaddtime
  24824. if v == nil {
  24825. return
  24826. }
  24827. return *v, true
  24828. }
  24829. // ResetAddtime resets all changes to the "addtime" field.
  24830. func (m *UsageStatisticDayMutation) ResetAddtime() {
  24831. m.addtime = nil
  24832. m.addaddtime = nil
  24833. }
  24834. // SetType sets the "type" field.
  24835. func (m *UsageStatisticDayMutation) SetType(i int) {
  24836. m._type = &i
  24837. m.add_type = nil
  24838. }
  24839. // GetType returns the value of the "type" field in the mutation.
  24840. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  24841. v := m._type
  24842. if v == nil {
  24843. return
  24844. }
  24845. return *v, true
  24846. }
  24847. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  24848. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24849. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24850. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  24851. if !m.op.Is(OpUpdateOne) {
  24852. return v, errors.New("OldType is only allowed on UpdateOne operations")
  24853. }
  24854. if m.id == nil || m.oldValue == nil {
  24855. return v, errors.New("OldType requires an ID field in the mutation")
  24856. }
  24857. oldValue, err := m.oldValue(ctx)
  24858. if err != nil {
  24859. return v, fmt.Errorf("querying old value for OldType: %w", err)
  24860. }
  24861. return oldValue.Type, nil
  24862. }
  24863. // AddType adds i to the "type" field.
  24864. func (m *UsageStatisticDayMutation) AddType(i int) {
  24865. if m.add_type != nil {
  24866. *m.add_type += i
  24867. } else {
  24868. m.add_type = &i
  24869. }
  24870. }
  24871. // AddedType returns the value that was added to the "type" field in this mutation.
  24872. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  24873. v := m.add_type
  24874. if v == nil {
  24875. return
  24876. }
  24877. return *v, true
  24878. }
  24879. // ResetType resets all changes to the "type" field.
  24880. func (m *UsageStatisticDayMutation) ResetType() {
  24881. m._type = nil
  24882. m.add_type = nil
  24883. }
  24884. // SetBotID sets the "bot_id" field.
  24885. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  24886. m.bot_id = &s
  24887. }
  24888. // BotID returns the value of the "bot_id" field in the mutation.
  24889. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  24890. v := m.bot_id
  24891. if v == nil {
  24892. return
  24893. }
  24894. return *v, true
  24895. }
  24896. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  24897. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24898. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24899. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  24900. if !m.op.Is(OpUpdateOne) {
  24901. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  24902. }
  24903. if m.id == nil || m.oldValue == nil {
  24904. return v, errors.New("OldBotID requires an ID field in the mutation")
  24905. }
  24906. oldValue, err := m.oldValue(ctx)
  24907. if err != nil {
  24908. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  24909. }
  24910. return oldValue.BotID, nil
  24911. }
  24912. // ClearBotID clears the value of the "bot_id" field.
  24913. func (m *UsageStatisticDayMutation) ClearBotID() {
  24914. m.bot_id = nil
  24915. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  24916. }
  24917. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  24918. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  24919. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  24920. return ok
  24921. }
  24922. // ResetBotID resets all changes to the "bot_id" field.
  24923. func (m *UsageStatisticDayMutation) ResetBotID() {
  24924. m.bot_id = nil
  24925. delete(m.clearedFields, usagestatisticday.FieldBotID)
  24926. }
  24927. // SetOrganizationID sets the "organization_id" field.
  24928. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  24929. m.organization_id = &u
  24930. m.addorganization_id = nil
  24931. }
  24932. // OrganizationID returns the value of the "organization_id" field in the mutation.
  24933. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  24934. v := m.organization_id
  24935. if v == nil {
  24936. return
  24937. }
  24938. return *v, true
  24939. }
  24940. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  24941. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  24942. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24943. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  24944. if !m.op.Is(OpUpdateOne) {
  24945. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  24946. }
  24947. if m.id == nil || m.oldValue == nil {
  24948. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  24949. }
  24950. oldValue, err := m.oldValue(ctx)
  24951. if err != nil {
  24952. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  24953. }
  24954. return oldValue.OrganizationID, nil
  24955. }
  24956. // AddOrganizationID adds u to the "organization_id" field.
  24957. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  24958. if m.addorganization_id != nil {
  24959. *m.addorganization_id += u
  24960. } else {
  24961. m.addorganization_id = &u
  24962. }
  24963. }
  24964. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  24965. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  24966. v := m.addorganization_id
  24967. if v == nil {
  24968. return
  24969. }
  24970. return *v, true
  24971. }
  24972. // ClearOrganizationID clears the value of the "organization_id" field.
  24973. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  24974. m.organization_id = nil
  24975. m.addorganization_id = nil
  24976. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  24977. }
  24978. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  24979. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  24980. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  24981. return ok
  24982. }
  24983. // ResetOrganizationID resets all changes to the "organization_id" field.
  24984. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  24985. m.organization_id = nil
  24986. m.addorganization_id = nil
  24987. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  24988. }
  24989. // SetAiResponse sets the "ai_response" field.
  24990. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  24991. m.ai_response = &u
  24992. m.addai_response = nil
  24993. }
  24994. // AiResponse returns the value of the "ai_response" field in the mutation.
  24995. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  24996. v := m.ai_response
  24997. if v == nil {
  24998. return
  24999. }
  25000. return *v, true
  25001. }
  25002. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  25003. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25004. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25005. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  25006. if !m.op.Is(OpUpdateOne) {
  25007. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  25008. }
  25009. if m.id == nil || m.oldValue == nil {
  25010. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  25011. }
  25012. oldValue, err := m.oldValue(ctx)
  25013. if err != nil {
  25014. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  25015. }
  25016. return oldValue.AiResponse, nil
  25017. }
  25018. // AddAiResponse adds u to the "ai_response" field.
  25019. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  25020. if m.addai_response != nil {
  25021. *m.addai_response += u
  25022. } else {
  25023. m.addai_response = &u
  25024. }
  25025. }
  25026. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  25027. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  25028. v := m.addai_response
  25029. if v == nil {
  25030. return
  25031. }
  25032. return *v, true
  25033. }
  25034. // ResetAiResponse resets all changes to the "ai_response" field.
  25035. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  25036. m.ai_response = nil
  25037. m.addai_response = nil
  25038. }
  25039. // SetSopRun sets the "sop_run" field.
  25040. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  25041. m.sop_run = &u
  25042. m.addsop_run = nil
  25043. }
  25044. // SopRun returns the value of the "sop_run" field in the mutation.
  25045. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  25046. v := m.sop_run
  25047. if v == nil {
  25048. return
  25049. }
  25050. return *v, true
  25051. }
  25052. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  25053. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25055. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  25056. if !m.op.Is(OpUpdateOne) {
  25057. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  25058. }
  25059. if m.id == nil || m.oldValue == nil {
  25060. return v, errors.New("OldSopRun requires an ID field in the mutation")
  25061. }
  25062. oldValue, err := m.oldValue(ctx)
  25063. if err != nil {
  25064. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  25065. }
  25066. return oldValue.SopRun, nil
  25067. }
  25068. // AddSopRun adds u to the "sop_run" field.
  25069. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  25070. if m.addsop_run != nil {
  25071. *m.addsop_run += u
  25072. } else {
  25073. m.addsop_run = &u
  25074. }
  25075. }
  25076. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  25077. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  25078. v := m.addsop_run
  25079. if v == nil {
  25080. return
  25081. }
  25082. return *v, true
  25083. }
  25084. // ResetSopRun resets all changes to the "sop_run" field.
  25085. func (m *UsageStatisticDayMutation) ResetSopRun() {
  25086. m.sop_run = nil
  25087. m.addsop_run = nil
  25088. }
  25089. // SetTotalFriend sets the "total_friend" field.
  25090. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  25091. m.total_friend = &u
  25092. m.addtotal_friend = nil
  25093. }
  25094. // TotalFriend returns the value of the "total_friend" field in the mutation.
  25095. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  25096. v := m.total_friend
  25097. if v == nil {
  25098. return
  25099. }
  25100. return *v, true
  25101. }
  25102. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  25103. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25105. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  25106. if !m.op.Is(OpUpdateOne) {
  25107. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  25108. }
  25109. if m.id == nil || m.oldValue == nil {
  25110. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  25111. }
  25112. oldValue, err := m.oldValue(ctx)
  25113. if err != nil {
  25114. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  25115. }
  25116. return oldValue.TotalFriend, nil
  25117. }
  25118. // AddTotalFriend adds u to the "total_friend" field.
  25119. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  25120. if m.addtotal_friend != nil {
  25121. *m.addtotal_friend += u
  25122. } else {
  25123. m.addtotal_friend = &u
  25124. }
  25125. }
  25126. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  25127. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  25128. v := m.addtotal_friend
  25129. if v == nil {
  25130. return
  25131. }
  25132. return *v, true
  25133. }
  25134. // ResetTotalFriend resets all changes to the "total_friend" field.
  25135. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  25136. m.total_friend = nil
  25137. m.addtotal_friend = nil
  25138. }
  25139. // SetTotalGroup sets the "total_group" field.
  25140. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  25141. m.total_group = &u
  25142. m.addtotal_group = nil
  25143. }
  25144. // TotalGroup returns the value of the "total_group" field in the mutation.
  25145. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  25146. v := m.total_group
  25147. if v == nil {
  25148. return
  25149. }
  25150. return *v, true
  25151. }
  25152. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  25153. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25155. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  25156. if !m.op.Is(OpUpdateOne) {
  25157. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  25158. }
  25159. if m.id == nil || m.oldValue == nil {
  25160. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  25161. }
  25162. oldValue, err := m.oldValue(ctx)
  25163. if err != nil {
  25164. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  25165. }
  25166. return oldValue.TotalGroup, nil
  25167. }
  25168. // AddTotalGroup adds u to the "total_group" field.
  25169. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  25170. if m.addtotal_group != nil {
  25171. *m.addtotal_group += u
  25172. } else {
  25173. m.addtotal_group = &u
  25174. }
  25175. }
  25176. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  25177. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  25178. v := m.addtotal_group
  25179. if v == nil {
  25180. return
  25181. }
  25182. return *v, true
  25183. }
  25184. // ResetTotalGroup resets all changes to the "total_group" field.
  25185. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  25186. m.total_group = nil
  25187. m.addtotal_group = nil
  25188. }
  25189. // SetAccountBalance sets the "account_balance" field.
  25190. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  25191. m.account_balance = &u
  25192. m.addaccount_balance = nil
  25193. }
  25194. // AccountBalance returns the value of the "account_balance" field in the mutation.
  25195. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  25196. v := m.account_balance
  25197. if v == nil {
  25198. return
  25199. }
  25200. return *v, true
  25201. }
  25202. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  25203. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25205. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  25206. if !m.op.Is(OpUpdateOne) {
  25207. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  25208. }
  25209. if m.id == nil || m.oldValue == nil {
  25210. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  25211. }
  25212. oldValue, err := m.oldValue(ctx)
  25213. if err != nil {
  25214. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  25215. }
  25216. return oldValue.AccountBalance, nil
  25217. }
  25218. // AddAccountBalance adds u to the "account_balance" field.
  25219. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  25220. if m.addaccount_balance != nil {
  25221. *m.addaccount_balance += u
  25222. } else {
  25223. m.addaccount_balance = &u
  25224. }
  25225. }
  25226. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  25227. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  25228. v := m.addaccount_balance
  25229. if v == nil {
  25230. return
  25231. }
  25232. return *v, true
  25233. }
  25234. // ResetAccountBalance resets all changes to the "account_balance" field.
  25235. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  25236. m.account_balance = nil
  25237. m.addaccount_balance = nil
  25238. }
  25239. // SetConsumeToken sets the "consume_token" field.
  25240. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  25241. m.consume_token = &u
  25242. m.addconsume_token = nil
  25243. }
  25244. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  25245. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  25246. v := m.consume_token
  25247. if v == nil {
  25248. return
  25249. }
  25250. return *v, true
  25251. }
  25252. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  25253. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25255. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  25256. if !m.op.Is(OpUpdateOne) {
  25257. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  25258. }
  25259. if m.id == nil || m.oldValue == nil {
  25260. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  25261. }
  25262. oldValue, err := m.oldValue(ctx)
  25263. if err != nil {
  25264. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  25265. }
  25266. return oldValue.ConsumeToken, nil
  25267. }
  25268. // AddConsumeToken adds u to the "consume_token" field.
  25269. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  25270. if m.addconsume_token != nil {
  25271. *m.addconsume_token += u
  25272. } else {
  25273. m.addconsume_token = &u
  25274. }
  25275. }
  25276. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  25277. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  25278. v := m.addconsume_token
  25279. if v == nil {
  25280. return
  25281. }
  25282. return *v, true
  25283. }
  25284. // ResetConsumeToken resets all changes to the "consume_token" field.
  25285. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  25286. m.consume_token = nil
  25287. m.addconsume_token = nil
  25288. }
  25289. // SetActiveUser sets the "active_user" field.
  25290. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  25291. m.active_user = &u
  25292. m.addactive_user = nil
  25293. }
  25294. // ActiveUser returns the value of the "active_user" field in the mutation.
  25295. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  25296. v := m.active_user
  25297. if v == nil {
  25298. return
  25299. }
  25300. return *v, true
  25301. }
  25302. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  25303. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25305. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  25306. if !m.op.Is(OpUpdateOne) {
  25307. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  25308. }
  25309. if m.id == nil || m.oldValue == nil {
  25310. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  25311. }
  25312. oldValue, err := m.oldValue(ctx)
  25313. if err != nil {
  25314. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  25315. }
  25316. return oldValue.ActiveUser, nil
  25317. }
  25318. // AddActiveUser adds u to the "active_user" field.
  25319. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  25320. if m.addactive_user != nil {
  25321. *m.addactive_user += u
  25322. } else {
  25323. m.addactive_user = &u
  25324. }
  25325. }
  25326. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  25327. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  25328. v := m.addactive_user
  25329. if v == nil {
  25330. return
  25331. }
  25332. return *v, true
  25333. }
  25334. // ResetActiveUser resets all changes to the "active_user" field.
  25335. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  25336. m.active_user = nil
  25337. m.addactive_user = nil
  25338. }
  25339. // SetNewUser sets the "new_user" field.
  25340. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  25341. m.new_user = &i
  25342. m.addnew_user = nil
  25343. }
  25344. // NewUser returns the value of the "new_user" field in the mutation.
  25345. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  25346. v := m.new_user
  25347. if v == nil {
  25348. return
  25349. }
  25350. return *v, true
  25351. }
  25352. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  25353. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25355. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  25356. if !m.op.Is(OpUpdateOne) {
  25357. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  25358. }
  25359. if m.id == nil || m.oldValue == nil {
  25360. return v, errors.New("OldNewUser requires an ID field in the mutation")
  25361. }
  25362. oldValue, err := m.oldValue(ctx)
  25363. if err != nil {
  25364. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  25365. }
  25366. return oldValue.NewUser, nil
  25367. }
  25368. // AddNewUser adds i to the "new_user" field.
  25369. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  25370. if m.addnew_user != nil {
  25371. *m.addnew_user += i
  25372. } else {
  25373. m.addnew_user = &i
  25374. }
  25375. }
  25376. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  25377. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  25378. v := m.addnew_user
  25379. if v == nil {
  25380. return
  25381. }
  25382. return *v, true
  25383. }
  25384. // ResetNewUser resets all changes to the "new_user" field.
  25385. func (m *UsageStatisticDayMutation) ResetNewUser() {
  25386. m.new_user = nil
  25387. m.addnew_user = nil
  25388. }
  25389. // SetLabelDist sets the "label_dist" field.
  25390. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  25391. m.label_dist = &ctd
  25392. m.appendlabel_dist = nil
  25393. }
  25394. // LabelDist returns the value of the "label_dist" field in the mutation.
  25395. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  25396. v := m.label_dist
  25397. if v == nil {
  25398. return
  25399. }
  25400. return *v, true
  25401. }
  25402. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  25403. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  25404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25405. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  25406. if !m.op.Is(OpUpdateOne) {
  25407. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  25408. }
  25409. if m.id == nil || m.oldValue == nil {
  25410. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  25411. }
  25412. oldValue, err := m.oldValue(ctx)
  25413. if err != nil {
  25414. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  25415. }
  25416. return oldValue.LabelDist, nil
  25417. }
  25418. // AppendLabelDist adds ctd to the "label_dist" field.
  25419. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  25420. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  25421. }
  25422. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  25423. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  25424. if len(m.appendlabel_dist) == 0 {
  25425. return nil, false
  25426. }
  25427. return m.appendlabel_dist, true
  25428. }
  25429. // ResetLabelDist resets all changes to the "label_dist" field.
  25430. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  25431. m.label_dist = nil
  25432. m.appendlabel_dist = nil
  25433. }
  25434. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  25435. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  25436. m.predicates = append(m.predicates, ps...)
  25437. }
  25438. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  25439. // users can use type-assertion to append predicates that do not depend on any generated package.
  25440. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  25441. p := make([]predicate.UsageStatisticDay, len(ps))
  25442. for i := range ps {
  25443. p[i] = ps[i]
  25444. }
  25445. m.Where(p...)
  25446. }
  25447. // Op returns the operation name.
  25448. func (m *UsageStatisticDayMutation) Op() Op {
  25449. return m.op
  25450. }
  25451. // SetOp allows setting the mutation operation.
  25452. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  25453. m.op = op
  25454. }
  25455. // Type returns the node type of this mutation (UsageStatisticDay).
  25456. func (m *UsageStatisticDayMutation) Type() string {
  25457. return m.typ
  25458. }
  25459. // Fields returns all fields that were changed during this mutation. Note that in
  25460. // order to get all numeric fields that were incremented/decremented, call
  25461. // AddedFields().
  25462. func (m *UsageStatisticDayMutation) Fields() []string {
  25463. fields := make([]string, 0, 17)
  25464. if m.created_at != nil {
  25465. fields = append(fields, usagestatisticday.FieldCreatedAt)
  25466. }
  25467. if m.updated_at != nil {
  25468. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  25469. }
  25470. if m.status != nil {
  25471. fields = append(fields, usagestatisticday.FieldStatus)
  25472. }
  25473. if m.deleted_at != nil {
  25474. fields = append(fields, usagestatisticday.FieldDeletedAt)
  25475. }
  25476. if m.addtime != nil {
  25477. fields = append(fields, usagestatisticday.FieldAddtime)
  25478. }
  25479. if m._type != nil {
  25480. fields = append(fields, usagestatisticday.FieldType)
  25481. }
  25482. if m.bot_id != nil {
  25483. fields = append(fields, usagestatisticday.FieldBotID)
  25484. }
  25485. if m.organization_id != nil {
  25486. fields = append(fields, usagestatisticday.FieldOrganizationID)
  25487. }
  25488. if m.ai_response != nil {
  25489. fields = append(fields, usagestatisticday.FieldAiResponse)
  25490. }
  25491. if m.sop_run != nil {
  25492. fields = append(fields, usagestatisticday.FieldSopRun)
  25493. }
  25494. if m.total_friend != nil {
  25495. fields = append(fields, usagestatisticday.FieldTotalFriend)
  25496. }
  25497. if m.total_group != nil {
  25498. fields = append(fields, usagestatisticday.FieldTotalGroup)
  25499. }
  25500. if m.account_balance != nil {
  25501. fields = append(fields, usagestatisticday.FieldAccountBalance)
  25502. }
  25503. if m.consume_token != nil {
  25504. fields = append(fields, usagestatisticday.FieldConsumeToken)
  25505. }
  25506. if m.active_user != nil {
  25507. fields = append(fields, usagestatisticday.FieldActiveUser)
  25508. }
  25509. if m.new_user != nil {
  25510. fields = append(fields, usagestatisticday.FieldNewUser)
  25511. }
  25512. if m.label_dist != nil {
  25513. fields = append(fields, usagestatisticday.FieldLabelDist)
  25514. }
  25515. return fields
  25516. }
  25517. // Field returns the value of a field with the given name. The second boolean
  25518. // return value indicates that this field was not set, or was not defined in the
  25519. // schema.
  25520. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  25521. switch name {
  25522. case usagestatisticday.FieldCreatedAt:
  25523. return m.CreatedAt()
  25524. case usagestatisticday.FieldUpdatedAt:
  25525. return m.UpdatedAt()
  25526. case usagestatisticday.FieldStatus:
  25527. return m.Status()
  25528. case usagestatisticday.FieldDeletedAt:
  25529. return m.DeletedAt()
  25530. case usagestatisticday.FieldAddtime:
  25531. return m.Addtime()
  25532. case usagestatisticday.FieldType:
  25533. return m.GetType()
  25534. case usagestatisticday.FieldBotID:
  25535. return m.BotID()
  25536. case usagestatisticday.FieldOrganizationID:
  25537. return m.OrganizationID()
  25538. case usagestatisticday.FieldAiResponse:
  25539. return m.AiResponse()
  25540. case usagestatisticday.FieldSopRun:
  25541. return m.SopRun()
  25542. case usagestatisticday.FieldTotalFriend:
  25543. return m.TotalFriend()
  25544. case usagestatisticday.FieldTotalGroup:
  25545. return m.TotalGroup()
  25546. case usagestatisticday.FieldAccountBalance:
  25547. return m.AccountBalance()
  25548. case usagestatisticday.FieldConsumeToken:
  25549. return m.ConsumeToken()
  25550. case usagestatisticday.FieldActiveUser:
  25551. return m.ActiveUser()
  25552. case usagestatisticday.FieldNewUser:
  25553. return m.NewUser()
  25554. case usagestatisticday.FieldLabelDist:
  25555. return m.LabelDist()
  25556. }
  25557. return nil, false
  25558. }
  25559. // OldField returns the old value of the field from the database. An error is
  25560. // returned if the mutation operation is not UpdateOne, or the query to the
  25561. // database failed.
  25562. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25563. switch name {
  25564. case usagestatisticday.FieldCreatedAt:
  25565. return m.OldCreatedAt(ctx)
  25566. case usagestatisticday.FieldUpdatedAt:
  25567. return m.OldUpdatedAt(ctx)
  25568. case usagestatisticday.FieldStatus:
  25569. return m.OldStatus(ctx)
  25570. case usagestatisticday.FieldDeletedAt:
  25571. return m.OldDeletedAt(ctx)
  25572. case usagestatisticday.FieldAddtime:
  25573. return m.OldAddtime(ctx)
  25574. case usagestatisticday.FieldType:
  25575. return m.OldType(ctx)
  25576. case usagestatisticday.FieldBotID:
  25577. return m.OldBotID(ctx)
  25578. case usagestatisticday.FieldOrganizationID:
  25579. return m.OldOrganizationID(ctx)
  25580. case usagestatisticday.FieldAiResponse:
  25581. return m.OldAiResponse(ctx)
  25582. case usagestatisticday.FieldSopRun:
  25583. return m.OldSopRun(ctx)
  25584. case usagestatisticday.FieldTotalFriend:
  25585. return m.OldTotalFriend(ctx)
  25586. case usagestatisticday.FieldTotalGroup:
  25587. return m.OldTotalGroup(ctx)
  25588. case usagestatisticday.FieldAccountBalance:
  25589. return m.OldAccountBalance(ctx)
  25590. case usagestatisticday.FieldConsumeToken:
  25591. return m.OldConsumeToken(ctx)
  25592. case usagestatisticday.FieldActiveUser:
  25593. return m.OldActiveUser(ctx)
  25594. case usagestatisticday.FieldNewUser:
  25595. return m.OldNewUser(ctx)
  25596. case usagestatisticday.FieldLabelDist:
  25597. return m.OldLabelDist(ctx)
  25598. }
  25599. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  25600. }
  25601. // SetField sets the value of a field with the given name. It returns an error if
  25602. // the field is not defined in the schema, or if the type mismatched the field
  25603. // type.
  25604. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  25605. switch name {
  25606. case usagestatisticday.FieldCreatedAt:
  25607. v, ok := value.(time.Time)
  25608. if !ok {
  25609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25610. }
  25611. m.SetCreatedAt(v)
  25612. return nil
  25613. case usagestatisticday.FieldUpdatedAt:
  25614. v, ok := value.(time.Time)
  25615. if !ok {
  25616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25617. }
  25618. m.SetUpdatedAt(v)
  25619. return nil
  25620. case usagestatisticday.FieldStatus:
  25621. v, ok := value.(uint8)
  25622. if !ok {
  25623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25624. }
  25625. m.SetStatus(v)
  25626. return nil
  25627. case usagestatisticday.FieldDeletedAt:
  25628. v, ok := value.(time.Time)
  25629. if !ok {
  25630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25631. }
  25632. m.SetDeletedAt(v)
  25633. return nil
  25634. case usagestatisticday.FieldAddtime:
  25635. v, ok := value.(uint64)
  25636. if !ok {
  25637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25638. }
  25639. m.SetAddtime(v)
  25640. return nil
  25641. case usagestatisticday.FieldType:
  25642. v, ok := value.(int)
  25643. if !ok {
  25644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25645. }
  25646. m.SetType(v)
  25647. return nil
  25648. case usagestatisticday.FieldBotID:
  25649. v, ok := value.(string)
  25650. if !ok {
  25651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25652. }
  25653. m.SetBotID(v)
  25654. return nil
  25655. case usagestatisticday.FieldOrganizationID:
  25656. v, ok := value.(uint64)
  25657. if !ok {
  25658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25659. }
  25660. m.SetOrganizationID(v)
  25661. return nil
  25662. case usagestatisticday.FieldAiResponse:
  25663. v, ok := value.(uint64)
  25664. if !ok {
  25665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25666. }
  25667. m.SetAiResponse(v)
  25668. return nil
  25669. case usagestatisticday.FieldSopRun:
  25670. v, ok := value.(uint64)
  25671. if !ok {
  25672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25673. }
  25674. m.SetSopRun(v)
  25675. return nil
  25676. case usagestatisticday.FieldTotalFriend:
  25677. v, ok := value.(uint64)
  25678. if !ok {
  25679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25680. }
  25681. m.SetTotalFriend(v)
  25682. return nil
  25683. case usagestatisticday.FieldTotalGroup:
  25684. v, ok := value.(uint64)
  25685. if !ok {
  25686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25687. }
  25688. m.SetTotalGroup(v)
  25689. return nil
  25690. case usagestatisticday.FieldAccountBalance:
  25691. v, ok := value.(uint64)
  25692. if !ok {
  25693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25694. }
  25695. m.SetAccountBalance(v)
  25696. return nil
  25697. case usagestatisticday.FieldConsumeToken:
  25698. v, ok := value.(uint64)
  25699. if !ok {
  25700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25701. }
  25702. m.SetConsumeToken(v)
  25703. return nil
  25704. case usagestatisticday.FieldActiveUser:
  25705. v, ok := value.(uint64)
  25706. if !ok {
  25707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25708. }
  25709. m.SetActiveUser(v)
  25710. return nil
  25711. case usagestatisticday.FieldNewUser:
  25712. v, ok := value.(int64)
  25713. if !ok {
  25714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25715. }
  25716. m.SetNewUser(v)
  25717. return nil
  25718. case usagestatisticday.FieldLabelDist:
  25719. v, ok := value.([]custom_types.LabelDist)
  25720. if !ok {
  25721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25722. }
  25723. m.SetLabelDist(v)
  25724. return nil
  25725. }
  25726. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  25727. }
  25728. // AddedFields returns all numeric fields that were incremented/decremented during
  25729. // this mutation.
  25730. func (m *UsageStatisticDayMutation) AddedFields() []string {
  25731. var fields []string
  25732. if m.addstatus != nil {
  25733. fields = append(fields, usagestatisticday.FieldStatus)
  25734. }
  25735. if m.addaddtime != nil {
  25736. fields = append(fields, usagestatisticday.FieldAddtime)
  25737. }
  25738. if m.add_type != nil {
  25739. fields = append(fields, usagestatisticday.FieldType)
  25740. }
  25741. if m.addorganization_id != nil {
  25742. fields = append(fields, usagestatisticday.FieldOrganizationID)
  25743. }
  25744. if m.addai_response != nil {
  25745. fields = append(fields, usagestatisticday.FieldAiResponse)
  25746. }
  25747. if m.addsop_run != nil {
  25748. fields = append(fields, usagestatisticday.FieldSopRun)
  25749. }
  25750. if m.addtotal_friend != nil {
  25751. fields = append(fields, usagestatisticday.FieldTotalFriend)
  25752. }
  25753. if m.addtotal_group != nil {
  25754. fields = append(fields, usagestatisticday.FieldTotalGroup)
  25755. }
  25756. if m.addaccount_balance != nil {
  25757. fields = append(fields, usagestatisticday.FieldAccountBalance)
  25758. }
  25759. if m.addconsume_token != nil {
  25760. fields = append(fields, usagestatisticday.FieldConsumeToken)
  25761. }
  25762. if m.addactive_user != nil {
  25763. fields = append(fields, usagestatisticday.FieldActiveUser)
  25764. }
  25765. if m.addnew_user != nil {
  25766. fields = append(fields, usagestatisticday.FieldNewUser)
  25767. }
  25768. return fields
  25769. }
  25770. // AddedField returns the numeric value that was incremented/decremented on a field
  25771. // with the given name. The second boolean return value indicates that this field
  25772. // was not set, or was not defined in the schema.
  25773. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  25774. switch name {
  25775. case usagestatisticday.FieldStatus:
  25776. return m.AddedStatus()
  25777. case usagestatisticday.FieldAddtime:
  25778. return m.AddedAddtime()
  25779. case usagestatisticday.FieldType:
  25780. return m.AddedType()
  25781. case usagestatisticday.FieldOrganizationID:
  25782. return m.AddedOrganizationID()
  25783. case usagestatisticday.FieldAiResponse:
  25784. return m.AddedAiResponse()
  25785. case usagestatisticday.FieldSopRun:
  25786. return m.AddedSopRun()
  25787. case usagestatisticday.FieldTotalFriend:
  25788. return m.AddedTotalFriend()
  25789. case usagestatisticday.FieldTotalGroup:
  25790. return m.AddedTotalGroup()
  25791. case usagestatisticday.FieldAccountBalance:
  25792. return m.AddedAccountBalance()
  25793. case usagestatisticday.FieldConsumeToken:
  25794. return m.AddedConsumeToken()
  25795. case usagestatisticday.FieldActiveUser:
  25796. return m.AddedActiveUser()
  25797. case usagestatisticday.FieldNewUser:
  25798. return m.AddedNewUser()
  25799. }
  25800. return nil, false
  25801. }
  25802. // AddField adds the value to the field with the given name. It returns an error if
  25803. // the field is not defined in the schema, or if the type mismatched the field
  25804. // type.
  25805. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  25806. switch name {
  25807. case usagestatisticday.FieldStatus:
  25808. v, ok := value.(int8)
  25809. if !ok {
  25810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25811. }
  25812. m.AddStatus(v)
  25813. return nil
  25814. case usagestatisticday.FieldAddtime:
  25815. v, ok := value.(int64)
  25816. if !ok {
  25817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25818. }
  25819. m.AddAddtime(v)
  25820. return nil
  25821. case usagestatisticday.FieldType:
  25822. v, ok := value.(int)
  25823. if !ok {
  25824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25825. }
  25826. m.AddType(v)
  25827. return nil
  25828. case usagestatisticday.FieldOrganizationID:
  25829. v, ok := value.(int64)
  25830. if !ok {
  25831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25832. }
  25833. m.AddOrganizationID(v)
  25834. return nil
  25835. case usagestatisticday.FieldAiResponse:
  25836. v, ok := value.(int64)
  25837. if !ok {
  25838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25839. }
  25840. m.AddAiResponse(v)
  25841. return nil
  25842. case usagestatisticday.FieldSopRun:
  25843. v, ok := value.(int64)
  25844. if !ok {
  25845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25846. }
  25847. m.AddSopRun(v)
  25848. return nil
  25849. case usagestatisticday.FieldTotalFriend:
  25850. v, ok := value.(int64)
  25851. if !ok {
  25852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25853. }
  25854. m.AddTotalFriend(v)
  25855. return nil
  25856. case usagestatisticday.FieldTotalGroup:
  25857. v, ok := value.(int64)
  25858. if !ok {
  25859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25860. }
  25861. m.AddTotalGroup(v)
  25862. return nil
  25863. case usagestatisticday.FieldAccountBalance:
  25864. v, ok := value.(int64)
  25865. if !ok {
  25866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25867. }
  25868. m.AddAccountBalance(v)
  25869. return nil
  25870. case usagestatisticday.FieldConsumeToken:
  25871. v, ok := value.(int64)
  25872. if !ok {
  25873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25874. }
  25875. m.AddConsumeToken(v)
  25876. return nil
  25877. case usagestatisticday.FieldActiveUser:
  25878. v, ok := value.(int64)
  25879. if !ok {
  25880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25881. }
  25882. m.AddActiveUser(v)
  25883. return nil
  25884. case usagestatisticday.FieldNewUser:
  25885. v, ok := value.(int64)
  25886. if !ok {
  25887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25888. }
  25889. m.AddNewUser(v)
  25890. return nil
  25891. }
  25892. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  25893. }
  25894. // ClearedFields returns all nullable fields that were cleared during this
  25895. // mutation.
  25896. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  25897. var fields []string
  25898. if m.FieldCleared(usagestatisticday.FieldStatus) {
  25899. fields = append(fields, usagestatisticday.FieldStatus)
  25900. }
  25901. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  25902. fields = append(fields, usagestatisticday.FieldDeletedAt)
  25903. }
  25904. if m.FieldCleared(usagestatisticday.FieldBotID) {
  25905. fields = append(fields, usagestatisticday.FieldBotID)
  25906. }
  25907. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  25908. fields = append(fields, usagestatisticday.FieldOrganizationID)
  25909. }
  25910. return fields
  25911. }
  25912. // FieldCleared returns a boolean indicating if a field with the given name was
  25913. // cleared in this mutation.
  25914. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  25915. _, ok := m.clearedFields[name]
  25916. return ok
  25917. }
  25918. // ClearField clears the value of the field with the given name. It returns an
  25919. // error if the field is not defined in the schema.
  25920. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  25921. switch name {
  25922. case usagestatisticday.FieldStatus:
  25923. m.ClearStatus()
  25924. return nil
  25925. case usagestatisticday.FieldDeletedAt:
  25926. m.ClearDeletedAt()
  25927. return nil
  25928. case usagestatisticday.FieldBotID:
  25929. m.ClearBotID()
  25930. return nil
  25931. case usagestatisticday.FieldOrganizationID:
  25932. m.ClearOrganizationID()
  25933. return nil
  25934. }
  25935. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  25936. }
  25937. // ResetField resets all changes in the mutation for the field with the given name.
  25938. // It returns an error if the field is not defined in the schema.
  25939. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  25940. switch name {
  25941. case usagestatisticday.FieldCreatedAt:
  25942. m.ResetCreatedAt()
  25943. return nil
  25944. case usagestatisticday.FieldUpdatedAt:
  25945. m.ResetUpdatedAt()
  25946. return nil
  25947. case usagestatisticday.FieldStatus:
  25948. m.ResetStatus()
  25949. return nil
  25950. case usagestatisticday.FieldDeletedAt:
  25951. m.ResetDeletedAt()
  25952. return nil
  25953. case usagestatisticday.FieldAddtime:
  25954. m.ResetAddtime()
  25955. return nil
  25956. case usagestatisticday.FieldType:
  25957. m.ResetType()
  25958. return nil
  25959. case usagestatisticday.FieldBotID:
  25960. m.ResetBotID()
  25961. return nil
  25962. case usagestatisticday.FieldOrganizationID:
  25963. m.ResetOrganizationID()
  25964. return nil
  25965. case usagestatisticday.FieldAiResponse:
  25966. m.ResetAiResponse()
  25967. return nil
  25968. case usagestatisticday.FieldSopRun:
  25969. m.ResetSopRun()
  25970. return nil
  25971. case usagestatisticday.FieldTotalFriend:
  25972. m.ResetTotalFriend()
  25973. return nil
  25974. case usagestatisticday.FieldTotalGroup:
  25975. m.ResetTotalGroup()
  25976. return nil
  25977. case usagestatisticday.FieldAccountBalance:
  25978. m.ResetAccountBalance()
  25979. return nil
  25980. case usagestatisticday.FieldConsumeToken:
  25981. m.ResetConsumeToken()
  25982. return nil
  25983. case usagestatisticday.FieldActiveUser:
  25984. m.ResetActiveUser()
  25985. return nil
  25986. case usagestatisticday.FieldNewUser:
  25987. m.ResetNewUser()
  25988. return nil
  25989. case usagestatisticday.FieldLabelDist:
  25990. m.ResetLabelDist()
  25991. return nil
  25992. }
  25993. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  25994. }
  25995. // AddedEdges returns all edge names that were set/added in this mutation.
  25996. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  25997. edges := make([]string, 0, 0)
  25998. return edges
  25999. }
  26000. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26001. // name in this mutation.
  26002. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  26003. return nil
  26004. }
  26005. // RemovedEdges returns all edge names that were removed in this mutation.
  26006. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  26007. edges := make([]string, 0, 0)
  26008. return edges
  26009. }
  26010. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26011. // the given name in this mutation.
  26012. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  26013. return nil
  26014. }
  26015. // ClearedEdges returns all edge names that were cleared in this mutation.
  26016. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  26017. edges := make([]string, 0, 0)
  26018. return edges
  26019. }
  26020. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26021. // was cleared in this mutation.
  26022. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  26023. return false
  26024. }
  26025. // ClearEdge clears the value of the edge with the given name. It returns an error
  26026. // if that edge is not defined in the schema.
  26027. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  26028. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  26029. }
  26030. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26031. // It returns an error if the edge is not defined in the schema.
  26032. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  26033. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  26034. }
  26035. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  26036. type UsageStatisticHourMutation struct {
  26037. config
  26038. op Op
  26039. typ string
  26040. id *uint64
  26041. created_at *time.Time
  26042. updated_at *time.Time
  26043. status *uint8
  26044. addstatus *int8
  26045. deleted_at *time.Time
  26046. addtime *uint64
  26047. addaddtime *int64
  26048. _type *int
  26049. add_type *int
  26050. bot_id *string
  26051. organization_id *uint64
  26052. addorganization_id *int64
  26053. ai_response *uint64
  26054. addai_response *int64
  26055. sop_run *uint64
  26056. addsop_run *int64
  26057. total_friend *uint64
  26058. addtotal_friend *int64
  26059. total_group *uint64
  26060. addtotal_group *int64
  26061. account_balance *uint64
  26062. addaccount_balance *int64
  26063. consume_token *uint64
  26064. addconsume_token *int64
  26065. active_user *uint64
  26066. addactive_user *int64
  26067. new_user *int64
  26068. addnew_user *int64
  26069. label_dist *[]custom_types.LabelDist
  26070. appendlabel_dist []custom_types.LabelDist
  26071. clearedFields map[string]struct{}
  26072. done bool
  26073. oldValue func(context.Context) (*UsageStatisticHour, error)
  26074. predicates []predicate.UsageStatisticHour
  26075. }
  26076. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  26077. // usagestatistichourOption allows management of the mutation configuration using functional options.
  26078. type usagestatistichourOption func(*UsageStatisticHourMutation)
  26079. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  26080. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  26081. m := &UsageStatisticHourMutation{
  26082. config: c,
  26083. op: op,
  26084. typ: TypeUsageStatisticHour,
  26085. clearedFields: make(map[string]struct{}),
  26086. }
  26087. for _, opt := range opts {
  26088. opt(m)
  26089. }
  26090. return m
  26091. }
  26092. // withUsageStatisticHourID sets the ID field of the mutation.
  26093. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  26094. return func(m *UsageStatisticHourMutation) {
  26095. var (
  26096. err error
  26097. once sync.Once
  26098. value *UsageStatisticHour
  26099. )
  26100. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  26101. once.Do(func() {
  26102. if m.done {
  26103. err = errors.New("querying old values post mutation is not allowed")
  26104. } else {
  26105. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  26106. }
  26107. })
  26108. return value, err
  26109. }
  26110. m.id = &id
  26111. }
  26112. }
  26113. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  26114. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  26115. return func(m *UsageStatisticHourMutation) {
  26116. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  26117. return node, nil
  26118. }
  26119. m.id = &node.ID
  26120. }
  26121. }
  26122. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26123. // executed in a transaction (ent.Tx), a transactional client is returned.
  26124. func (m UsageStatisticHourMutation) Client() *Client {
  26125. client := &Client{config: m.config}
  26126. client.init()
  26127. return client
  26128. }
  26129. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26130. // it returns an error otherwise.
  26131. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  26132. if _, ok := m.driver.(*txDriver); !ok {
  26133. return nil, errors.New("ent: mutation is not running in a transaction")
  26134. }
  26135. tx := &Tx{config: m.config}
  26136. tx.init()
  26137. return tx, nil
  26138. }
  26139. // SetID sets the value of the id field. Note that this
  26140. // operation is only accepted on creation of UsageStatisticHour entities.
  26141. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  26142. m.id = &id
  26143. }
  26144. // ID returns the ID value in the mutation. Note that the ID is only available
  26145. // if it was provided to the builder or after it was returned from the database.
  26146. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  26147. if m.id == nil {
  26148. return
  26149. }
  26150. return *m.id, true
  26151. }
  26152. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26153. // That means, if the mutation is applied within a transaction with an isolation level such
  26154. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26155. // or updated by the mutation.
  26156. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  26157. switch {
  26158. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26159. id, exists := m.ID()
  26160. if exists {
  26161. return []uint64{id}, nil
  26162. }
  26163. fallthrough
  26164. case m.op.Is(OpUpdate | OpDelete):
  26165. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  26166. default:
  26167. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26168. }
  26169. }
  26170. // SetCreatedAt sets the "created_at" field.
  26171. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  26172. m.created_at = &t
  26173. }
  26174. // CreatedAt returns the value of the "created_at" field in the mutation.
  26175. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  26176. v := m.created_at
  26177. if v == nil {
  26178. return
  26179. }
  26180. return *v, true
  26181. }
  26182. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  26183. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26185. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26186. if !m.op.Is(OpUpdateOne) {
  26187. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26188. }
  26189. if m.id == nil || m.oldValue == nil {
  26190. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26191. }
  26192. oldValue, err := m.oldValue(ctx)
  26193. if err != nil {
  26194. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26195. }
  26196. return oldValue.CreatedAt, nil
  26197. }
  26198. // ResetCreatedAt resets all changes to the "created_at" field.
  26199. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  26200. m.created_at = nil
  26201. }
  26202. // SetUpdatedAt sets the "updated_at" field.
  26203. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  26204. m.updated_at = &t
  26205. }
  26206. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26207. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  26208. v := m.updated_at
  26209. if v == nil {
  26210. return
  26211. }
  26212. return *v, true
  26213. }
  26214. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  26215. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26216. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26217. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26218. if !m.op.Is(OpUpdateOne) {
  26219. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26220. }
  26221. if m.id == nil || m.oldValue == nil {
  26222. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26223. }
  26224. oldValue, err := m.oldValue(ctx)
  26225. if err != nil {
  26226. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26227. }
  26228. return oldValue.UpdatedAt, nil
  26229. }
  26230. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26231. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  26232. m.updated_at = nil
  26233. }
  26234. // SetStatus sets the "status" field.
  26235. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  26236. m.status = &u
  26237. m.addstatus = nil
  26238. }
  26239. // Status returns the value of the "status" field in the mutation.
  26240. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  26241. v := m.status
  26242. if v == nil {
  26243. return
  26244. }
  26245. return *v, true
  26246. }
  26247. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  26248. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26249. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26250. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26251. if !m.op.Is(OpUpdateOne) {
  26252. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26253. }
  26254. if m.id == nil || m.oldValue == nil {
  26255. return v, errors.New("OldStatus requires an ID field in the mutation")
  26256. }
  26257. oldValue, err := m.oldValue(ctx)
  26258. if err != nil {
  26259. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26260. }
  26261. return oldValue.Status, nil
  26262. }
  26263. // AddStatus adds u to the "status" field.
  26264. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  26265. if m.addstatus != nil {
  26266. *m.addstatus += u
  26267. } else {
  26268. m.addstatus = &u
  26269. }
  26270. }
  26271. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26272. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  26273. v := m.addstatus
  26274. if v == nil {
  26275. return
  26276. }
  26277. return *v, true
  26278. }
  26279. // ClearStatus clears the value of the "status" field.
  26280. func (m *UsageStatisticHourMutation) ClearStatus() {
  26281. m.status = nil
  26282. m.addstatus = nil
  26283. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  26284. }
  26285. // StatusCleared returns if the "status" field was cleared in this mutation.
  26286. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  26287. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  26288. return ok
  26289. }
  26290. // ResetStatus resets all changes to the "status" field.
  26291. func (m *UsageStatisticHourMutation) ResetStatus() {
  26292. m.status = nil
  26293. m.addstatus = nil
  26294. delete(m.clearedFields, usagestatistichour.FieldStatus)
  26295. }
  26296. // SetDeletedAt sets the "deleted_at" field.
  26297. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  26298. m.deleted_at = &t
  26299. }
  26300. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26301. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  26302. v := m.deleted_at
  26303. if v == nil {
  26304. return
  26305. }
  26306. return *v, true
  26307. }
  26308. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  26309. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26310. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26311. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26312. if !m.op.Is(OpUpdateOne) {
  26313. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26314. }
  26315. if m.id == nil || m.oldValue == nil {
  26316. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26317. }
  26318. oldValue, err := m.oldValue(ctx)
  26319. if err != nil {
  26320. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26321. }
  26322. return oldValue.DeletedAt, nil
  26323. }
  26324. // ClearDeletedAt clears the value of the "deleted_at" field.
  26325. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  26326. m.deleted_at = nil
  26327. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  26328. }
  26329. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26330. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  26331. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  26332. return ok
  26333. }
  26334. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26335. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  26336. m.deleted_at = nil
  26337. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  26338. }
  26339. // SetAddtime sets the "addtime" field.
  26340. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  26341. m.addtime = &u
  26342. m.addaddtime = nil
  26343. }
  26344. // Addtime returns the value of the "addtime" field in the mutation.
  26345. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  26346. v := m.addtime
  26347. if v == nil {
  26348. return
  26349. }
  26350. return *v, true
  26351. }
  26352. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  26353. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26355. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  26356. if !m.op.Is(OpUpdateOne) {
  26357. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  26358. }
  26359. if m.id == nil || m.oldValue == nil {
  26360. return v, errors.New("OldAddtime requires an ID field in the mutation")
  26361. }
  26362. oldValue, err := m.oldValue(ctx)
  26363. if err != nil {
  26364. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  26365. }
  26366. return oldValue.Addtime, nil
  26367. }
  26368. // AddAddtime adds u to the "addtime" field.
  26369. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  26370. if m.addaddtime != nil {
  26371. *m.addaddtime += u
  26372. } else {
  26373. m.addaddtime = &u
  26374. }
  26375. }
  26376. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  26377. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  26378. v := m.addaddtime
  26379. if v == nil {
  26380. return
  26381. }
  26382. return *v, true
  26383. }
  26384. // ResetAddtime resets all changes to the "addtime" field.
  26385. func (m *UsageStatisticHourMutation) ResetAddtime() {
  26386. m.addtime = nil
  26387. m.addaddtime = nil
  26388. }
  26389. // SetType sets the "type" field.
  26390. func (m *UsageStatisticHourMutation) SetType(i int) {
  26391. m._type = &i
  26392. m.add_type = nil
  26393. }
  26394. // GetType returns the value of the "type" field in the mutation.
  26395. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  26396. v := m._type
  26397. if v == nil {
  26398. return
  26399. }
  26400. return *v, true
  26401. }
  26402. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  26403. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26405. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  26406. if !m.op.Is(OpUpdateOne) {
  26407. return v, errors.New("OldType is only allowed on UpdateOne operations")
  26408. }
  26409. if m.id == nil || m.oldValue == nil {
  26410. return v, errors.New("OldType requires an ID field in the mutation")
  26411. }
  26412. oldValue, err := m.oldValue(ctx)
  26413. if err != nil {
  26414. return v, fmt.Errorf("querying old value for OldType: %w", err)
  26415. }
  26416. return oldValue.Type, nil
  26417. }
  26418. // AddType adds i to the "type" field.
  26419. func (m *UsageStatisticHourMutation) AddType(i int) {
  26420. if m.add_type != nil {
  26421. *m.add_type += i
  26422. } else {
  26423. m.add_type = &i
  26424. }
  26425. }
  26426. // AddedType returns the value that was added to the "type" field in this mutation.
  26427. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  26428. v := m.add_type
  26429. if v == nil {
  26430. return
  26431. }
  26432. return *v, true
  26433. }
  26434. // ResetType resets all changes to the "type" field.
  26435. func (m *UsageStatisticHourMutation) ResetType() {
  26436. m._type = nil
  26437. m.add_type = nil
  26438. }
  26439. // SetBotID sets the "bot_id" field.
  26440. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  26441. m.bot_id = &s
  26442. }
  26443. // BotID returns the value of the "bot_id" field in the mutation.
  26444. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  26445. v := m.bot_id
  26446. if v == nil {
  26447. return
  26448. }
  26449. return *v, true
  26450. }
  26451. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  26452. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26453. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26454. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  26455. if !m.op.Is(OpUpdateOne) {
  26456. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  26457. }
  26458. if m.id == nil || m.oldValue == nil {
  26459. return v, errors.New("OldBotID requires an ID field in the mutation")
  26460. }
  26461. oldValue, err := m.oldValue(ctx)
  26462. if err != nil {
  26463. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  26464. }
  26465. return oldValue.BotID, nil
  26466. }
  26467. // ClearBotID clears the value of the "bot_id" field.
  26468. func (m *UsageStatisticHourMutation) ClearBotID() {
  26469. m.bot_id = nil
  26470. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  26471. }
  26472. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  26473. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  26474. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  26475. return ok
  26476. }
  26477. // ResetBotID resets all changes to the "bot_id" field.
  26478. func (m *UsageStatisticHourMutation) ResetBotID() {
  26479. m.bot_id = nil
  26480. delete(m.clearedFields, usagestatistichour.FieldBotID)
  26481. }
  26482. // SetOrganizationID sets the "organization_id" field.
  26483. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  26484. m.organization_id = &u
  26485. m.addorganization_id = nil
  26486. }
  26487. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26488. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  26489. v := m.organization_id
  26490. if v == nil {
  26491. return
  26492. }
  26493. return *v, true
  26494. }
  26495. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  26496. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26497. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26498. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26499. if !m.op.Is(OpUpdateOne) {
  26500. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26501. }
  26502. if m.id == nil || m.oldValue == nil {
  26503. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26504. }
  26505. oldValue, err := m.oldValue(ctx)
  26506. if err != nil {
  26507. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26508. }
  26509. return oldValue.OrganizationID, nil
  26510. }
  26511. // AddOrganizationID adds u to the "organization_id" field.
  26512. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  26513. if m.addorganization_id != nil {
  26514. *m.addorganization_id += u
  26515. } else {
  26516. m.addorganization_id = &u
  26517. }
  26518. }
  26519. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26520. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  26521. v := m.addorganization_id
  26522. if v == nil {
  26523. return
  26524. }
  26525. return *v, true
  26526. }
  26527. // ClearOrganizationID clears the value of the "organization_id" field.
  26528. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  26529. m.organization_id = nil
  26530. m.addorganization_id = nil
  26531. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  26532. }
  26533. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  26534. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  26535. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  26536. return ok
  26537. }
  26538. // ResetOrganizationID resets all changes to the "organization_id" field.
  26539. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  26540. m.organization_id = nil
  26541. m.addorganization_id = nil
  26542. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  26543. }
  26544. // SetAiResponse sets the "ai_response" field.
  26545. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  26546. m.ai_response = &u
  26547. m.addai_response = nil
  26548. }
  26549. // AiResponse returns the value of the "ai_response" field in the mutation.
  26550. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  26551. v := m.ai_response
  26552. if v == nil {
  26553. return
  26554. }
  26555. return *v, true
  26556. }
  26557. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  26558. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26560. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  26561. if !m.op.Is(OpUpdateOne) {
  26562. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  26563. }
  26564. if m.id == nil || m.oldValue == nil {
  26565. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  26566. }
  26567. oldValue, err := m.oldValue(ctx)
  26568. if err != nil {
  26569. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  26570. }
  26571. return oldValue.AiResponse, nil
  26572. }
  26573. // AddAiResponse adds u to the "ai_response" field.
  26574. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  26575. if m.addai_response != nil {
  26576. *m.addai_response += u
  26577. } else {
  26578. m.addai_response = &u
  26579. }
  26580. }
  26581. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  26582. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  26583. v := m.addai_response
  26584. if v == nil {
  26585. return
  26586. }
  26587. return *v, true
  26588. }
  26589. // ResetAiResponse resets all changes to the "ai_response" field.
  26590. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  26591. m.ai_response = nil
  26592. m.addai_response = nil
  26593. }
  26594. // SetSopRun sets the "sop_run" field.
  26595. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  26596. m.sop_run = &u
  26597. m.addsop_run = nil
  26598. }
  26599. // SopRun returns the value of the "sop_run" field in the mutation.
  26600. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  26601. v := m.sop_run
  26602. if v == nil {
  26603. return
  26604. }
  26605. return *v, true
  26606. }
  26607. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  26608. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26609. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26610. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  26611. if !m.op.Is(OpUpdateOne) {
  26612. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  26613. }
  26614. if m.id == nil || m.oldValue == nil {
  26615. return v, errors.New("OldSopRun requires an ID field in the mutation")
  26616. }
  26617. oldValue, err := m.oldValue(ctx)
  26618. if err != nil {
  26619. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  26620. }
  26621. return oldValue.SopRun, nil
  26622. }
  26623. // AddSopRun adds u to the "sop_run" field.
  26624. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  26625. if m.addsop_run != nil {
  26626. *m.addsop_run += u
  26627. } else {
  26628. m.addsop_run = &u
  26629. }
  26630. }
  26631. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  26632. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  26633. v := m.addsop_run
  26634. if v == nil {
  26635. return
  26636. }
  26637. return *v, true
  26638. }
  26639. // ResetSopRun resets all changes to the "sop_run" field.
  26640. func (m *UsageStatisticHourMutation) ResetSopRun() {
  26641. m.sop_run = nil
  26642. m.addsop_run = nil
  26643. }
  26644. // SetTotalFriend sets the "total_friend" field.
  26645. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  26646. m.total_friend = &u
  26647. m.addtotal_friend = nil
  26648. }
  26649. // TotalFriend returns the value of the "total_friend" field in the mutation.
  26650. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  26651. v := m.total_friend
  26652. if v == nil {
  26653. return
  26654. }
  26655. return *v, true
  26656. }
  26657. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  26658. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26659. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26660. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  26661. if !m.op.Is(OpUpdateOne) {
  26662. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  26663. }
  26664. if m.id == nil || m.oldValue == nil {
  26665. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  26666. }
  26667. oldValue, err := m.oldValue(ctx)
  26668. if err != nil {
  26669. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  26670. }
  26671. return oldValue.TotalFriend, nil
  26672. }
  26673. // AddTotalFriend adds u to the "total_friend" field.
  26674. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  26675. if m.addtotal_friend != nil {
  26676. *m.addtotal_friend += u
  26677. } else {
  26678. m.addtotal_friend = &u
  26679. }
  26680. }
  26681. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  26682. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  26683. v := m.addtotal_friend
  26684. if v == nil {
  26685. return
  26686. }
  26687. return *v, true
  26688. }
  26689. // ResetTotalFriend resets all changes to the "total_friend" field.
  26690. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  26691. m.total_friend = nil
  26692. m.addtotal_friend = nil
  26693. }
  26694. // SetTotalGroup sets the "total_group" field.
  26695. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  26696. m.total_group = &u
  26697. m.addtotal_group = nil
  26698. }
  26699. // TotalGroup returns the value of the "total_group" field in the mutation.
  26700. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  26701. v := m.total_group
  26702. if v == nil {
  26703. return
  26704. }
  26705. return *v, true
  26706. }
  26707. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  26708. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26710. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  26711. if !m.op.Is(OpUpdateOne) {
  26712. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  26713. }
  26714. if m.id == nil || m.oldValue == nil {
  26715. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  26716. }
  26717. oldValue, err := m.oldValue(ctx)
  26718. if err != nil {
  26719. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  26720. }
  26721. return oldValue.TotalGroup, nil
  26722. }
  26723. // AddTotalGroup adds u to the "total_group" field.
  26724. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  26725. if m.addtotal_group != nil {
  26726. *m.addtotal_group += u
  26727. } else {
  26728. m.addtotal_group = &u
  26729. }
  26730. }
  26731. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  26732. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  26733. v := m.addtotal_group
  26734. if v == nil {
  26735. return
  26736. }
  26737. return *v, true
  26738. }
  26739. // ResetTotalGroup resets all changes to the "total_group" field.
  26740. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  26741. m.total_group = nil
  26742. m.addtotal_group = nil
  26743. }
  26744. // SetAccountBalance sets the "account_balance" field.
  26745. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  26746. m.account_balance = &u
  26747. m.addaccount_balance = nil
  26748. }
  26749. // AccountBalance returns the value of the "account_balance" field in the mutation.
  26750. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  26751. v := m.account_balance
  26752. if v == nil {
  26753. return
  26754. }
  26755. return *v, true
  26756. }
  26757. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  26758. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26759. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26760. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  26761. if !m.op.Is(OpUpdateOne) {
  26762. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  26763. }
  26764. if m.id == nil || m.oldValue == nil {
  26765. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  26766. }
  26767. oldValue, err := m.oldValue(ctx)
  26768. if err != nil {
  26769. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  26770. }
  26771. return oldValue.AccountBalance, nil
  26772. }
  26773. // AddAccountBalance adds u to the "account_balance" field.
  26774. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  26775. if m.addaccount_balance != nil {
  26776. *m.addaccount_balance += u
  26777. } else {
  26778. m.addaccount_balance = &u
  26779. }
  26780. }
  26781. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  26782. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  26783. v := m.addaccount_balance
  26784. if v == nil {
  26785. return
  26786. }
  26787. return *v, true
  26788. }
  26789. // ResetAccountBalance resets all changes to the "account_balance" field.
  26790. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  26791. m.account_balance = nil
  26792. m.addaccount_balance = nil
  26793. }
  26794. // SetConsumeToken sets the "consume_token" field.
  26795. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  26796. m.consume_token = &u
  26797. m.addconsume_token = nil
  26798. }
  26799. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  26800. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  26801. v := m.consume_token
  26802. if v == nil {
  26803. return
  26804. }
  26805. return *v, true
  26806. }
  26807. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  26808. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26810. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  26811. if !m.op.Is(OpUpdateOne) {
  26812. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  26813. }
  26814. if m.id == nil || m.oldValue == nil {
  26815. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  26816. }
  26817. oldValue, err := m.oldValue(ctx)
  26818. if err != nil {
  26819. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  26820. }
  26821. return oldValue.ConsumeToken, nil
  26822. }
  26823. // AddConsumeToken adds u to the "consume_token" field.
  26824. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  26825. if m.addconsume_token != nil {
  26826. *m.addconsume_token += u
  26827. } else {
  26828. m.addconsume_token = &u
  26829. }
  26830. }
  26831. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  26832. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  26833. v := m.addconsume_token
  26834. if v == nil {
  26835. return
  26836. }
  26837. return *v, true
  26838. }
  26839. // ResetConsumeToken resets all changes to the "consume_token" field.
  26840. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  26841. m.consume_token = nil
  26842. m.addconsume_token = nil
  26843. }
  26844. // SetActiveUser sets the "active_user" field.
  26845. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  26846. m.active_user = &u
  26847. m.addactive_user = nil
  26848. }
  26849. // ActiveUser returns the value of the "active_user" field in the mutation.
  26850. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  26851. v := m.active_user
  26852. if v == nil {
  26853. return
  26854. }
  26855. return *v, true
  26856. }
  26857. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  26858. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26860. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  26861. if !m.op.Is(OpUpdateOne) {
  26862. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  26863. }
  26864. if m.id == nil || m.oldValue == nil {
  26865. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  26866. }
  26867. oldValue, err := m.oldValue(ctx)
  26868. if err != nil {
  26869. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  26870. }
  26871. return oldValue.ActiveUser, nil
  26872. }
  26873. // AddActiveUser adds u to the "active_user" field.
  26874. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  26875. if m.addactive_user != nil {
  26876. *m.addactive_user += u
  26877. } else {
  26878. m.addactive_user = &u
  26879. }
  26880. }
  26881. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  26882. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  26883. v := m.addactive_user
  26884. if v == nil {
  26885. return
  26886. }
  26887. return *v, true
  26888. }
  26889. // ResetActiveUser resets all changes to the "active_user" field.
  26890. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  26891. m.active_user = nil
  26892. m.addactive_user = nil
  26893. }
  26894. // SetNewUser sets the "new_user" field.
  26895. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  26896. m.new_user = &i
  26897. m.addnew_user = nil
  26898. }
  26899. // NewUser returns the value of the "new_user" field in the mutation.
  26900. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  26901. v := m.new_user
  26902. if v == nil {
  26903. return
  26904. }
  26905. return *v, true
  26906. }
  26907. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  26908. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26910. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  26911. if !m.op.Is(OpUpdateOne) {
  26912. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  26913. }
  26914. if m.id == nil || m.oldValue == nil {
  26915. return v, errors.New("OldNewUser requires an ID field in the mutation")
  26916. }
  26917. oldValue, err := m.oldValue(ctx)
  26918. if err != nil {
  26919. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  26920. }
  26921. return oldValue.NewUser, nil
  26922. }
  26923. // AddNewUser adds i to the "new_user" field.
  26924. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  26925. if m.addnew_user != nil {
  26926. *m.addnew_user += i
  26927. } else {
  26928. m.addnew_user = &i
  26929. }
  26930. }
  26931. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  26932. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  26933. v := m.addnew_user
  26934. if v == nil {
  26935. return
  26936. }
  26937. return *v, true
  26938. }
  26939. // ResetNewUser resets all changes to the "new_user" field.
  26940. func (m *UsageStatisticHourMutation) ResetNewUser() {
  26941. m.new_user = nil
  26942. m.addnew_user = nil
  26943. }
  26944. // SetLabelDist sets the "label_dist" field.
  26945. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  26946. m.label_dist = &ctd
  26947. m.appendlabel_dist = nil
  26948. }
  26949. // LabelDist returns the value of the "label_dist" field in the mutation.
  26950. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  26951. v := m.label_dist
  26952. if v == nil {
  26953. return
  26954. }
  26955. return *v, true
  26956. }
  26957. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  26958. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  26959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26960. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  26961. if !m.op.Is(OpUpdateOne) {
  26962. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  26963. }
  26964. if m.id == nil || m.oldValue == nil {
  26965. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  26966. }
  26967. oldValue, err := m.oldValue(ctx)
  26968. if err != nil {
  26969. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  26970. }
  26971. return oldValue.LabelDist, nil
  26972. }
  26973. // AppendLabelDist adds ctd to the "label_dist" field.
  26974. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  26975. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  26976. }
  26977. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  26978. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  26979. if len(m.appendlabel_dist) == 0 {
  26980. return nil, false
  26981. }
  26982. return m.appendlabel_dist, true
  26983. }
  26984. // ResetLabelDist resets all changes to the "label_dist" field.
  26985. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  26986. m.label_dist = nil
  26987. m.appendlabel_dist = nil
  26988. }
  26989. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  26990. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  26991. m.predicates = append(m.predicates, ps...)
  26992. }
  26993. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  26994. // users can use type-assertion to append predicates that do not depend on any generated package.
  26995. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  26996. p := make([]predicate.UsageStatisticHour, len(ps))
  26997. for i := range ps {
  26998. p[i] = ps[i]
  26999. }
  27000. m.Where(p...)
  27001. }
  27002. // Op returns the operation name.
  27003. func (m *UsageStatisticHourMutation) Op() Op {
  27004. return m.op
  27005. }
  27006. // SetOp allows setting the mutation operation.
  27007. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  27008. m.op = op
  27009. }
  27010. // Type returns the node type of this mutation (UsageStatisticHour).
  27011. func (m *UsageStatisticHourMutation) Type() string {
  27012. return m.typ
  27013. }
  27014. // Fields returns all fields that were changed during this mutation. Note that in
  27015. // order to get all numeric fields that were incremented/decremented, call
  27016. // AddedFields().
  27017. func (m *UsageStatisticHourMutation) Fields() []string {
  27018. fields := make([]string, 0, 17)
  27019. if m.created_at != nil {
  27020. fields = append(fields, usagestatistichour.FieldCreatedAt)
  27021. }
  27022. if m.updated_at != nil {
  27023. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  27024. }
  27025. if m.status != nil {
  27026. fields = append(fields, usagestatistichour.FieldStatus)
  27027. }
  27028. if m.deleted_at != nil {
  27029. fields = append(fields, usagestatistichour.FieldDeletedAt)
  27030. }
  27031. if m.addtime != nil {
  27032. fields = append(fields, usagestatistichour.FieldAddtime)
  27033. }
  27034. if m._type != nil {
  27035. fields = append(fields, usagestatistichour.FieldType)
  27036. }
  27037. if m.bot_id != nil {
  27038. fields = append(fields, usagestatistichour.FieldBotID)
  27039. }
  27040. if m.organization_id != nil {
  27041. fields = append(fields, usagestatistichour.FieldOrganizationID)
  27042. }
  27043. if m.ai_response != nil {
  27044. fields = append(fields, usagestatistichour.FieldAiResponse)
  27045. }
  27046. if m.sop_run != nil {
  27047. fields = append(fields, usagestatistichour.FieldSopRun)
  27048. }
  27049. if m.total_friend != nil {
  27050. fields = append(fields, usagestatistichour.FieldTotalFriend)
  27051. }
  27052. if m.total_group != nil {
  27053. fields = append(fields, usagestatistichour.FieldTotalGroup)
  27054. }
  27055. if m.account_balance != nil {
  27056. fields = append(fields, usagestatistichour.FieldAccountBalance)
  27057. }
  27058. if m.consume_token != nil {
  27059. fields = append(fields, usagestatistichour.FieldConsumeToken)
  27060. }
  27061. if m.active_user != nil {
  27062. fields = append(fields, usagestatistichour.FieldActiveUser)
  27063. }
  27064. if m.new_user != nil {
  27065. fields = append(fields, usagestatistichour.FieldNewUser)
  27066. }
  27067. if m.label_dist != nil {
  27068. fields = append(fields, usagestatistichour.FieldLabelDist)
  27069. }
  27070. return fields
  27071. }
  27072. // Field returns the value of a field with the given name. The second boolean
  27073. // return value indicates that this field was not set, or was not defined in the
  27074. // schema.
  27075. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  27076. switch name {
  27077. case usagestatistichour.FieldCreatedAt:
  27078. return m.CreatedAt()
  27079. case usagestatistichour.FieldUpdatedAt:
  27080. return m.UpdatedAt()
  27081. case usagestatistichour.FieldStatus:
  27082. return m.Status()
  27083. case usagestatistichour.FieldDeletedAt:
  27084. return m.DeletedAt()
  27085. case usagestatistichour.FieldAddtime:
  27086. return m.Addtime()
  27087. case usagestatistichour.FieldType:
  27088. return m.GetType()
  27089. case usagestatistichour.FieldBotID:
  27090. return m.BotID()
  27091. case usagestatistichour.FieldOrganizationID:
  27092. return m.OrganizationID()
  27093. case usagestatistichour.FieldAiResponse:
  27094. return m.AiResponse()
  27095. case usagestatistichour.FieldSopRun:
  27096. return m.SopRun()
  27097. case usagestatistichour.FieldTotalFriend:
  27098. return m.TotalFriend()
  27099. case usagestatistichour.FieldTotalGroup:
  27100. return m.TotalGroup()
  27101. case usagestatistichour.FieldAccountBalance:
  27102. return m.AccountBalance()
  27103. case usagestatistichour.FieldConsumeToken:
  27104. return m.ConsumeToken()
  27105. case usagestatistichour.FieldActiveUser:
  27106. return m.ActiveUser()
  27107. case usagestatistichour.FieldNewUser:
  27108. return m.NewUser()
  27109. case usagestatistichour.FieldLabelDist:
  27110. return m.LabelDist()
  27111. }
  27112. return nil, false
  27113. }
  27114. // OldField returns the old value of the field from the database. An error is
  27115. // returned if the mutation operation is not UpdateOne, or the query to the
  27116. // database failed.
  27117. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27118. switch name {
  27119. case usagestatistichour.FieldCreatedAt:
  27120. return m.OldCreatedAt(ctx)
  27121. case usagestatistichour.FieldUpdatedAt:
  27122. return m.OldUpdatedAt(ctx)
  27123. case usagestatistichour.FieldStatus:
  27124. return m.OldStatus(ctx)
  27125. case usagestatistichour.FieldDeletedAt:
  27126. return m.OldDeletedAt(ctx)
  27127. case usagestatistichour.FieldAddtime:
  27128. return m.OldAddtime(ctx)
  27129. case usagestatistichour.FieldType:
  27130. return m.OldType(ctx)
  27131. case usagestatistichour.FieldBotID:
  27132. return m.OldBotID(ctx)
  27133. case usagestatistichour.FieldOrganizationID:
  27134. return m.OldOrganizationID(ctx)
  27135. case usagestatistichour.FieldAiResponse:
  27136. return m.OldAiResponse(ctx)
  27137. case usagestatistichour.FieldSopRun:
  27138. return m.OldSopRun(ctx)
  27139. case usagestatistichour.FieldTotalFriend:
  27140. return m.OldTotalFriend(ctx)
  27141. case usagestatistichour.FieldTotalGroup:
  27142. return m.OldTotalGroup(ctx)
  27143. case usagestatistichour.FieldAccountBalance:
  27144. return m.OldAccountBalance(ctx)
  27145. case usagestatistichour.FieldConsumeToken:
  27146. return m.OldConsumeToken(ctx)
  27147. case usagestatistichour.FieldActiveUser:
  27148. return m.OldActiveUser(ctx)
  27149. case usagestatistichour.FieldNewUser:
  27150. return m.OldNewUser(ctx)
  27151. case usagestatistichour.FieldLabelDist:
  27152. return m.OldLabelDist(ctx)
  27153. }
  27154. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  27155. }
  27156. // SetField sets the value of a field with the given name. It returns an error if
  27157. // the field is not defined in the schema, or if the type mismatched the field
  27158. // type.
  27159. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  27160. switch name {
  27161. case usagestatistichour.FieldCreatedAt:
  27162. v, ok := value.(time.Time)
  27163. if !ok {
  27164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27165. }
  27166. m.SetCreatedAt(v)
  27167. return nil
  27168. case usagestatistichour.FieldUpdatedAt:
  27169. v, ok := value.(time.Time)
  27170. if !ok {
  27171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27172. }
  27173. m.SetUpdatedAt(v)
  27174. return nil
  27175. case usagestatistichour.FieldStatus:
  27176. v, ok := value.(uint8)
  27177. if !ok {
  27178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27179. }
  27180. m.SetStatus(v)
  27181. return nil
  27182. case usagestatistichour.FieldDeletedAt:
  27183. v, ok := value.(time.Time)
  27184. if !ok {
  27185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27186. }
  27187. m.SetDeletedAt(v)
  27188. return nil
  27189. case usagestatistichour.FieldAddtime:
  27190. v, ok := value.(uint64)
  27191. if !ok {
  27192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27193. }
  27194. m.SetAddtime(v)
  27195. return nil
  27196. case usagestatistichour.FieldType:
  27197. v, ok := value.(int)
  27198. if !ok {
  27199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27200. }
  27201. m.SetType(v)
  27202. return nil
  27203. case usagestatistichour.FieldBotID:
  27204. v, ok := value.(string)
  27205. if !ok {
  27206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27207. }
  27208. m.SetBotID(v)
  27209. return nil
  27210. case usagestatistichour.FieldOrganizationID:
  27211. v, ok := value.(uint64)
  27212. if !ok {
  27213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27214. }
  27215. m.SetOrganizationID(v)
  27216. return nil
  27217. case usagestatistichour.FieldAiResponse:
  27218. v, ok := value.(uint64)
  27219. if !ok {
  27220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27221. }
  27222. m.SetAiResponse(v)
  27223. return nil
  27224. case usagestatistichour.FieldSopRun:
  27225. v, ok := value.(uint64)
  27226. if !ok {
  27227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27228. }
  27229. m.SetSopRun(v)
  27230. return nil
  27231. case usagestatistichour.FieldTotalFriend:
  27232. v, ok := value.(uint64)
  27233. if !ok {
  27234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27235. }
  27236. m.SetTotalFriend(v)
  27237. return nil
  27238. case usagestatistichour.FieldTotalGroup:
  27239. v, ok := value.(uint64)
  27240. if !ok {
  27241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27242. }
  27243. m.SetTotalGroup(v)
  27244. return nil
  27245. case usagestatistichour.FieldAccountBalance:
  27246. v, ok := value.(uint64)
  27247. if !ok {
  27248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27249. }
  27250. m.SetAccountBalance(v)
  27251. return nil
  27252. case usagestatistichour.FieldConsumeToken:
  27253. v, ok := value.(uint64)
  27254. if !ok {
  27255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27256. }
  27257. m.SetConsumeToken(v)
  27258. return nil
  27259. case usagestatistichour.FieldActiveUser:
  27260. v, ok := value.(uint64)
  27261. if !ok {
  27262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27263. }
  27264. m.SetActiveUser(v)
  27265. return nil
  27266. case usagestatistichour.FieldNewUser:
  27267. v, ok := value.(int64)
  27268. if !ok {
  27269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27270. }
  27271. m.SetNewUser(v)
  27272. return nil
  27273. case usagestatistichour.FieldLabelDist:
  27274. v, ok := value.([]custom_types.LabelDist)
  27275. if !ok {
  27276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27277. }
  27278. m.SetLabelDist(v)
  27279. return nil
  27280. }
  27281. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  27282. }
  27283. // AddedFields returns all numeric fields that were incremented/decremented during
  27284. // this mutation.
  27285. func (m *UsageStatisticHourMutation) AddedFields() []string {
  27286. var fields []string
  27287. if m.addstatus != nil {
  27288. fields = append(fields, usagestatistichour.FieldStatus)
  27289. }
  27290. if m.addaddtime != nil {
  27291. fields = append(fields, usagestatistichour.FieldAddtime)
  27292. }
  27293. if m.add_type != nil {
  27294. fields = append(fields, usagestatistichour.FieldType)
  27295. }
  27296. if m.addorganization_id != nil {
  27297. fields = append(fields, usagestatistichour.FieldOrganizationID)
  27298. }
  27299. if m.addai_response != nil {
  27300. fields = append(fields, usagestatistichour.FieldAiResponse)
  27301. }
  27302. if m.addsop_run != nil {
  27303. fields = append(fields, usagestatistichour.FieldSopRun)
  27304. }
  27305. if m.addtotal_friend != nil {
  27306. fields = append(fields, usagestatistichour.FieldTotalFriend)
  27307. }
  27308. if m.addtotal_group != nil {
  27309. fields = append(fields, usagestatistichour.FieldTotalGroup)
  27310. }
  27311. if m.addaccount_balance != nil {
  27312. fields = append(fields, usagestatistichour.FieldAccountBalance)
  27313. }
  27314. if m.addconsume_token != nil {
  27315. fields = append(fields, usagestatistichour.FieldConsumeToken)
  27316. }
  27317. if m.addactive_user != nil {
  27318. fields = append(fields, usagestatistichour.FieldActiveUser)
  27319. }
  27320. if m.addnew_user != nil {
  27321. fields = append(fields, usagestatistichour.FieldNewUser)
  27322. }
  27323. return fields
  27324. }
  27325. // AddedField returns the numeric value that was incremented/decremented on a field
  27326. // with the given name. The second boolean return value indicates that this field
  27327. // was not set, or was not defined in the schema.
  27328. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  27329. switch name {
  27330. case usagestatistichour.FieldStatus:
  27331. return m.AddedStatus()
  27332. case usagestatistichour.FieldAddtime:
  27333. return m.AddedAddtime()
  27334. case usagestatistichour.FieldType:
  27335. return m.AddedType()
  27336. case usagestatistichour.FieldOrganizationID:
  27337. return m.AddedOrganizationID()
  27338. case usagestatistichour.FieldAiResponse:
  27339. return m.AddedAiResponse()
  27340. case usagestatistichour.FieldSopRun:
  27341. return m.AddedSopRun()
  27342. case usagestatistichour.FieldTotalFriend:
  27343. return m.AddedTotalFriend()
  27344. case usagestatistichour.FieldTotalGroup:
  27345. return m.AddedTotalGroup()
  27346. case usagestatistichour.FieldAccountBalance:
  27347. return m.AddedAccountBalance()
  27348. case usagestatistichour.FieldConsumeToken:
  27349. return m.AddedConsumeToken()
  27350. case usagestatistichour.FieldActiveUser:
  27351. return m.AddedActiveUser()
  27352. case usagestatistichour.FieldNewUser:
  27353. return m.AddedNewUser()
  27354. }
  27355. return nil, false
  27356. }
  27357. // AddField adds the value to the field with the given name. It returns an error if
  27358. // the field is not defined in the schema, or if the type mismatched the field
  27359. // type.
  27360. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  27361. switch name {
  27362. case usagestatistichour.FieldStatus:
  27363. v, ok := value.(int8)
  27364. if !ok {
  27365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27366. }
  27367. m.AddStatus(v)
  27368. return nil
  27369. case usagestatistichour.FieldAddtime:
  27370. v, ok := value.(int64)
  27371. if !ok {
  27372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27373. }
  27374. m.AddAddtime(v)
  27375. return nil
  27376. case usagestatistichour.FieldType:
  27377. v, ok := value.(int)
  27378. if !ok {
  27379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27380. }
  27381. m.AddType(v)
  27382. return nil
  27383. case usagestatistichour.FieldOrganizationID:
  27384. v, ok := value.(int64)
  27385. if !ok {
  27386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27387. }
  27388. m.AddOrganizationID(v)
  27389. return nil
  27390. case usagestatistichour.FieldAiResponse:
  27391. v, ok := value.(int64)
  27392. if !ok {
  27393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27394. }
  27395. m.AddAiResponse(v)
  27396. return nil
  27397. case usagestatistichour.FieldSopRun:
  27398. v, ok := value.(int64)
  27399. if !ok {
  27400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27401. }
  27402. m.AddSopRun(v)
  27403. return nil
  27404. case usagestatistichour.FieldTotalFriend:
  27405. v, ok := value.(int64)
  27406. if !ok {
  27407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27408. }
  27409. m.AddTotalFriend(v)
  27410. return nil
  27411. case usagestatistichour.FieldTotalGroup:
  27412. v, ok := value.(int64)
  27413. if !ok {
  27414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27415. }
  27416. m.AddTotalGroup(v)
  27417. return nil
  27418. case usagestatistichour.FieldAccountBalance:
  27419. v, ok := value.(int64)
  27420. if !ok {
  27421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27422. }
  27423. m.AddAccountBalance(v)
  27424. return nil
  27425. case usagestatistichour.FieldConsumeToken:
  27426. v, ok := value.(int64)
  27427. if !ok {
  27428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27429. }
  27430. m.AddConsumeToken(v)
  27431. return nil
  27432. case usagestatistichour.FieldActiveUser:
  27433. v, ok := value.(int64)
  27434. if !ok {
  27435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27436. }
  27437. m.AddActiveUser(v)
  27438. return nil
  27439. case usagestatistichour.FieldNewUser:
  27440. v, ok := value.(int64)
  27441. if !ok {
  27442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27443. }
  27444. m.AddNewUser(v)
  27445. return nil
  27446. }
  27447. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  27448. }
  27449. // ClearedFields returns all nullable fields that were cleared during this
  27450. // mutation.
  27451. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  27452. var fields []string
  27453. if m.FieldCleared(usagestatistichour.FieldStatus) {
  27454. fields = append(fields, usagestatistichour.FieldStatus)
  27455. }
  27456. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  27457. fields = append(fields, usagestatistichour.FieldDeletedAt)
  27458. }
  27459. if m.FieldCleared(usagestatistichour.FieldBotID) {
  27460. fields = append(fields, usagestatistichour.FieldBotID)
  27461. }
  27462. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  27463. fields = append(fields, usagestatistichour.FieldOrganizationID)
  27464. }
  27465. return fields
  27466. }
  27467. // FieldCleared returns a boolean indicating if a field with the given name was
  27468. // cleared in this mutation.
  27469. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  27470. _, ok := m.clearedFields[name]
  27471. return ok
  27472. }
  27473. // ClearField clears the value of the field with the given name. It returns an
  27474. // error if the field is not defined in the schema.
  27475. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  27476. switch name {
  27477. case usagestatistichour.FieldStatus:
  27478. m.ClearStatus()
  27479. return nil
  27480. case usagestatistichour.FieldDeletedAt:
  27481. m.ClearDeletedAt()
  27482. return nil
  27483. case usagestatistichour.FieldBotID:
  27484. m.ClearBotID()
  27485. return nil
  27486. case usagestatistichour.FieldOrganizationID:
  27487. m.ClearOrganizationID()
  27488. return nil
  27489. }
  27490. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  27491. }
  27492. // ResetField resets all changes in the mutation for the field with the given name.
  27493. // It returns an error if the field is not defined in the schema.
  27494. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  27495. switch name {
  27496. case usagestatistichour.FieldCreatedAt:
  27497. m.ResetCreatedAt()
  27498. return nil
  27499. case usagestatistichour.FieldUpdatedAt:
  27500. m.ResetUpdatedAt()
  27501. return nil
  27502. case usagestatistichour.FieldStatus:
  27503. m.ResetStatus()
  27504. return nil
  27505. case usagestatistichour.FieldDeletedAt:
  27506. m.ResetDeletedAt()
  27507. return nil
  27508. case usagestatistichour.FieldAddtime:
  27509. m.ResetAddtime()
  27510. return nil
  27511. case usagestatistichour.FieldType:
  27512. m.ResetType()
  27513. return nil
  27514. case usagestatistichour.FieldBotID:
  27515. m.ResetBotID()
  27516. return nil
  27517. case usagestatistichour.FieldOrganizationID:
  27518. m.ResetOrganizationID()
  27519. return nil
  27520. case usagestatistichour.FieldAiResponse:
  27521. m.ResetAiResponse()
  27522. return nil
  27523. case usagestatistichour.FieldSopRun:
  27524. m.ResetSopRun()
  27525. return nil
  27526. case usagestatistichour.FieldTotalFriend:
  27527. m.ResetTotalFriend()
  27528. return nil
  27529. case usagestatistichour.FieldTotalGroup:
  27530. m.ResetTotalGroup()
  27531. return nil
  27532. case usagestatistichour.FieldAccountBalance:
  27533. m.ResetAccountBalance()
  27534. return nil
  27535. case usagestatistichour.FieldConsumeToken:
  27536. m.ResetConsumeToken()
  27537. return nil
  27538. case usagestatistichour.FieldActiveUser:
  27539. m.ResetActiveUser()
  27540. return nil
  27541. case usagestatistichour.FieldNewUser:
  27542. m.ResetNewUser()
  27543. return nil
  27544. case usagestatistichour.FieldLabelDist:
  27545. m.ResetLabelDist()
  27546. return nil
  27547. }
  27548. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  27549. }
  27550. // AddedEdges returns all edge names that were set/added in this mutation.
  27551. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  27552. edges := make([]string, 0, 0)
  27553. return edges
  27554. }
  27555. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27556. // name in this mutation.
  27557. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  27558. return nil
  27559. }
  27560. // RemovedEdges returns all edge names that were removed in this mutation.
  27561. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  27562. edges := make([]string, 0, 0)
  27563. return edges
  27564. }
  27565. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27566. // the given name in this mutation.
  27567. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  27568. return nil
  27569. }
  27570. // ClearedEdges returns all edge names that were cleared in this mutation.
  27571. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  27572. edges := make([]string, 0, 0)
  27573. return edges
  27574. }
  27575. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27576. // was cleared in this mutation.
  27577. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  27578. return false
  27579. }
  27580. // ClearEdge clears the value of the edge with the given name. It returns an error
  27581. // if that edge is not defined in the schema.
  27582. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  27583. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  27584. }
  27585. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27586. // It returns an error if the edge is not defined in the schema.
  27587. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  27588. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  27589. }
  27590. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  27591. type UsageStatisticMonthMutation struct {
  27592. config
  27593. op Op
  27594. typ string
  27595. id *uint64
  27596. created_at *time.Time
  27597. updated_at *time.Time
  27598. status *uint8
  27599. addstatus *int8
  27600. deleted_at *time.Time
  27601. addtime *uint64
  27602. addaddtime *int64
  27603. _type *int
  27604. add_type *int
  27605. bot_id *string
  27606. organization_id *uint64
  27607. addorganization_id *int64
  27608. ai_response *uint64
  27609. addai_response *int64
  27610. sop_run *uint64
  27611. addsop_run *int64
  27612. total_friend *uint64
  27613. addtotal_friend *int64
  27614. total_group *uint64
  27615. addtotal_group *int64
  27616. account_balance *uint64
  27617. addaccount_balance *int64
  27618. consume_token *uint64
  27619. addconsume_token *int64
  27620. active_user *uint64
  27621. addactive_user *int64
  27622. new_user *int64
  27623. addnew_user *int64
  27624. label_dist *[]custom_types.LabelDist
  27625. appendlabel_dist []custom_types.LabelDist
  27626. clearedFields map[string]struct{}
  27627. done bool
  27628. oldValue func(context.Context) (*UsageStatisticMonth, error)
  27629. predicates []predicate.UsageStatisticMonth
  27630. }
  27631. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  27632. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  27633. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  27634. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  27635. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  27636. m := &UsageStatisticMonthMutation{
  27637. config: c,
  27638. op: op,
  27639. typ: TypeUsageStatisticMonth,
  27640. clearedFields: make(map[string]struct{}),
  27641. }
  27642. for _, opt := range opts {
  27643. opt(m)
  27644. }
  27645. return m
  27646. }
  27647. // withUsageStatisticMonthID sets the ID field of the mutation.
  27648. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  27649. return func(m *UsageStatisticMonthMutation) {
  27650. var (
  27651. err error
  27652. once sync.Once
  27653. value *UsageStatisticMonth
  27654. )
  27655. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  27656. once.Do(func() {
  27657. if m.done {
  27658. err = errors.New("querying old values post mutation is not allowed")
  27659. } else {
  27660. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  27661. }
  27662. })
  27663. return value, err
  27664. }
  27665. m.id = &id
  27666. }
  27667. }
  27668. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  27669. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  27670. return func(m *UsageStatisticMonthMutation) {
  27671. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  27672. return node, nil
  27673. }
  27674. m.id = &node.ID
  27675. }
  27676. }
  27677. // Client returns a new `ent.Client` from the mutation. If the mutation was
  27678. // executed in a transaction (ent.Tx), a transactional client is returned.
  27679. func (m UsageStatisticMonthMutation) Client() *Client {
  27680. client := &Client{config: m.config}
  27681. client.init()
  27682. return client
  27683. }
  27684. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  27685. // it returns an error otherwise.
  27686. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  27687. if _, ok := m.driver.(*txDriver); !ok {
  27688. return nil, errors.New("ent: mutation is not running in a transaction")
  27689. }
  27690. tx := &Tx{config: m.config}
  27691. tx.init()
  27692. return tx, nil
  27693. }
  27694. // SetID sets the value of the id field. Note that this
  27695. // operation is only accepted on creation of UsageStatisticMonth entities.
  27696. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  27697. m.id = &id
  27698. }
  27699. // ID returns the ID value in the mutation. Note that the ID is only available
  27700. // if it was provided to the builder or after it was returned from the database.
  27701. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  27702. if m.id == nil {
  27703. return
  27704. }
  27705. return *m.id, true
  27706. }
  27707. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  27708. // That means, if the mutation is applied within a transaction with an isolation level such
  27709. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  27710. // or updated by the mutation.
  27711. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  27712. switch {
  27713. case m.op.Is(OpUpdateOne | OpDeleteOne):
  27714. id, exists := m.ID()
  27715. if exists {
  27716. return []uint64{id}, nil
  27717. }
  27718. fallthrough
  27719. case m.op.Is(OpUpdate | OpDelete):
  27720. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  27721. default:
  27722. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  27723. }
  27724. }
  27725. // SetCreatedAt sets the "created_at" field.
  27726. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  27727. m.created_at = &t
  27728. }
  27729. // CreatedAt returns the value of the "created_at" field in the mutation.
  27730. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  27731. v := m.created_at
  27732. if v == nil {
  27733. return
  27734. }
  27735. return *v, true
  27736. }
  27737. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  27738. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27740. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  27741. if !m.op.Is(OpUpdateOne) {
  27742. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  27743. }
  27744. if m.id == nil || m.oldValue == nil {
  27745. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  27746. }
  27747. oldValue, err := m.oldValue(ctx)
  27748. if err != nil {
  27749. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  27750. }
  27751. return oldValue.CreatedAt, nil
  27752. }
  27753. // ResetCreatedAt resets all changes to the "created_at" field.
  27754. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  27755. m.created_at = nil
  27756. }
  27757. // SetUpdatedAt sets the "updated_at" field.
  27758. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  27759. m.updated_at = &t
  27760. }
  27761. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  27762. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  27763. v := m.updated_at
  27764. if v == nil {
  27765. return
  27766. }
  27767. return *v, true
  27768. }
  27769. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  27770. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27771. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27772. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  27773. if !m.op.Is(OpUpdateOne) {
  27774. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  27775. }
  27776. if m.id == nil || m.oldValue == nil {
  27777. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  27778. }
  27779. oldValue, err := m.oldValue(ctx)
  27780. if err != nil {
  27781. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  27782. }
  27783. return oldValue.UpdatedAt, nil
  27784. }
  27785. // ResetUpdatedAt resets all changes to the "updated_at" field.
  27786. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  27787. m.updated_at = nil
  27788. }
  27789. // SetStatus sets the "status" field.
  27790. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  27791. m.status = &u
  27792. m.addstatus = nil
  27793. }
  27794. // Status returns the value of the "status" field in the mutation.
  27795. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  27796. v := m.status
  27797. if v == nil {
  27798. return
  27799. }
  27800. return *v, true
  27801. }
  27802. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  27803. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27805. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  27806. if !m.op.Is(OpUpdateOne) {
  27807. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  27808. }
  27809. if m.id == nil || m.oldValue == nil {
  27810. return v, errors.New("OldStatus requires an ID field in the mutation")
  27811. }
  27812. oldValue, err := m.oldValue(ctx)
  27813. if err != nil {
  27814. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  27815. }
  27816. return oldValue.Status, nil
  27817. }
  27818. // AddStatus adds u to the "status" field.
  27819. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  27820. if m.addstatus != nil {
  27821. *m.addstatus += u
  27822. } else {
  27823. m.addstatus = &u
  27824. }
  27825. }
  27826. // AddedStatus returns the value that was added to the "status" field in this mutation.
  27827. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  27828. v := m.addstatus
  27829. if v == nil {
  27830. return
  27831. }
  27832. return *v, true
  27833. }
  27834. // ClearStatus clears the value of the "status" field.
  27835. func (m *UsageStatisticMonthMutation) ClearStatus() {
  27836. m.status = nil
  27837. m.addstatus = nil
  27838. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  27839. }
  27840. // StatusCleared returns if the "status" field was cleared in this mutation.
  27841. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  27842. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  27843. return ok
  27844. }
  27845. // ResetStatus resets all changes to the "status" field.
  27846. func (m *UsageStatisticMonthMutation) ResetStatus() {
  27847. m.status = nil
  27848. m.addstatus = nil
  27849. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  27850. }
  27851. // SetDeletedAt sets the "deleted_at" field.
  27852. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  27853. m.deleted_at = &t
  27854. }
  27855. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  27856. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  27857. v := m.deleted_at
  27858. if v == nil {
  27859. return
  27860. }
  27861. return *v, true
  27862. }
  27863. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  27864. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27865. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27866. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  27867. if !m.op.Is(OpUpdateOne) {
  27868. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  27869. }
  27870. if m.id == nil || m.oldValue == nil {
  27871. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  27872. }
  27873. oldValue, err := m.oldValue(ctx)
  27874. if err != nil {
  27875. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  27876. }
  27877. return oldValue.DeletedAt, nil
  27878. }
  27879. // ClearDeletedAt clears the value of the "deleted_at" field.
  27880. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  27881. m.deleted_at = nil
  27882. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  27883. }
  27884. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  27885. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  27886. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  27887. return ok
  27888. }
  27889. // ResetDeletedAt resets all changes to the "deleted_at" field.
  27890. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  27891. m.deleted_at = nil
  27892. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  27893. }
  27894. // SetAddtime sets the "addtime" field.
  27895. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  27896. m.addtime = &u
  27897. m.addaddtime = nil
  27898. }
  27899. // Addtime returns the value of the "addtime" field in the mutation.
  27900. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  27901. v := m.addtime
  27902. if v == nil {
  27903. return
  27904. }
  27905. return *v, true
  27906. }
  27907. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  27908. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27909. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27910. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  27911. if !m.op.Is(OpUpdateOne) {
  27912. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  27913. }
  27914. if m.id == nil || m.oldValue == nil {
  27915. return v, errors.New("OldAddtime requires an ID field in the mutation")
  27916. }
  27917. oldValue, err := m.oldValue(ctx)
  27918. if err != nil {
  27919. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  27920. }
  27921. return oldValue.Addtime, nil
  27922. }
  27923. // AddAddtime adds u to the "addtime" field.
  27924. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  27925. if m.addaddtime != nil {
  27926. *m.addaddtime += u
  27927. } else {
  27928. m.addaddtime = &u
  27929. }
  27930. }
  27931. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  27932. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  27933. v := m.addaddtime
  27934. if v == nil {
  27935. return
  27936. }
  27937. return *v, true
  27938. }
  27939. // ResetAddtime resets all changes to the "addtime" field.
  27940. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  27941. m.addtime = nil
  27942. m.addaddtime = nil
  27943. }
  27944. // SetType sets the "type" field.
  27945. func (m *UsageStatisticMonthMutation) SetType(i int) {
  27946. m._type = &i
  27947. m.add_type = nil
  27948. }
  27949. // GetType returns the value of the "type" field in the mutation.
  27950. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  27951. v := m._type
  27952. if v == nil {
  27953. return
  27954. }
  27955. return *v, true
  27956. }
  27957. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  27958. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  27959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27960. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  27961. if !m.op.Is(OpUpdateOne) {
  27962. return v, errors.New("OldType is only allowed on UpdateOne operations")
  27963. }
  27964. if m.id == nil || m.oldValue == nil {
  27965. return v, errors.New("OldType requires an ID field in the mutation")
  27966. }
  27967. oldValue, err := m.oldValue(ctx)
  27968. if err != nil {
  27969. return v, fmt.Errorf("querying old value for OldType: %w", err)
  27970. }
  27971. return oldValue.Type, nil
  27972. }
  27973. // AddType adds i to the "type" field.
  27974. func (m *UsageStatisticMonthMutation) AddType(i int) {
  27975. if m.add_type != nil {
  27976. *m.add_type += i
  27977. } else {
  27978. m.add_type = &i
  27979. }
  27980. }
  27981. // AddedType returns the value that was added to the "type" field in this mutation.
  27982. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  27983. v := m.add_type
  27984. if v == nil {
  27985. return
  27986. }
  27987. return *v, true
  27988. }
  27989. // ResetType resets all changes to the "type" field.
  27990. func (m *UsageStatisticMonthMutation) ResetType() {
  27991. m._type = nil
  27992. m.add_type = nil
  27993. }
  27994. // SetBotID sets the "bot_id" field.
  27995. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  27996. m.bot_id = &s
  27997. }
  27998. // BotID returns the value of the "bot_id" field in the mutation.
  27999. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  28000. v := m.bot_id
  28001. if v == nil {
  28002. return
  28003. }
  28004. return *v, true
  28005. }
  28006. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  28007. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28009. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  28010. if !m.op.Is(OpUpdateOne) {
  28011. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  28012. }
  28013. if m.id == nil || m.oldValue == nil {
  28014. return v, errors.New("OldBotID requires an ID field in the mutation")
  28015. }
  28016. oldValue, err := m.oldValue(ctx)
  28017. if err != nil {
  28018. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  28019. }
  28020. return oldValue.BotID, nil
  28021. }
  28022. // ClearBotID clears the value of the "bot_id" field.
  28023. func (m *UsageStatisticMonthMutation) ClearBotID() {
  28024. m.bot_id = nil
  28025. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  28026. }
  28027. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  28028. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  28029. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  28030. return ok
  28031. }
  28032. // ResetBotID resets all changes to the "bot_id" field.
  28033. func (m *UsageStatisticMonthMutation) ResetBotID() {
  28034. m.bot_id = nil
  28035. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  28036. }
  28037. // SetOrganizationID sets the "organization_id" field.
  28038. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  28039. m.organization_id = &u
  28040. m.addorganization_id = nil
  28041. }
  28042. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28043. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  28044. v := m.organization_id
  28045. if v == nil {
  28046. return
  28047. }
  28048. return *v, true
  28049. }
  28050. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  28051. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28052. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28053. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28054. if !m.op.Is(OpUpdateOne) {
  28055. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28056. }
  28057. if m.id == nil || m.oldValue == nil {
  28058. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28059. }
  28060. oldValue, err := m.oldValue(ctx)
  28061. if err != nil {
  28062. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28063. }
  28064. return oldValue.OrganizationID, nil
  28065. }
  28066. // AddOrganizationID adds u to the "organization_id" field.
  28067. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  28068. if m.addorganization_id != nil {
  28069. *m.addorganization_id += u
  28070. } else {
  28071. m.addorganization_id = &u
  28072. }
  28073. }
  28074. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28075. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  28076. v := m.addorganization_id
  28077. if v == nil {
  28078. return
  28079. }
  28080. return *v, true
  28081. }
  28082. // ClearOrganizationID clears the value of the "organization_id" field.
  28083. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  28084. m.organization_id = nil
  28085. m.addorganization_id = nil
  28086. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  28087. }
  28088. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28089. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  28090. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  28091. return ok
  28092. }
  28093. // ResetOrganizationID resets all changes to the "organization_id" field.
  28094. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  28095. m.organization_id = nil
  28096. m.addorganization_id = nil
  28097. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  28098. }
  28099. // SetAiResponse sets the "ai_response" field.
  28100. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  28101. m.ai_response = &u
  28102. m.addai_response = nil
  28103. }
  28104. // AiResponse returns the value of the "ai_response" field in the mutation.
  28105. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  28106. v := m.ai_response
  28107. if v == nil {
  28108. return
  28109. }
  28110. return *v, true
  28111. }
  28112. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  28113. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28114. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28115. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  28116. if !m.op.Is(OpUpdateOne) {
  28117. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  28118. }
  28119. if m.id == nil || m.oldValue == nil {
  28120. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  28121. }
  28122. oldValue, err := m.oldValue(ctx)
  28123. if err != nil {
  28124. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  28125. }
  28126. return oldValue.AiResponse, nil
  28127. }
  28128. // AddAiResponse adds u to the "ai_response" field.
  28129. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  28130. if m.addai_response != nil {
  28131. *m.addai_response += u
  28132. } else {
  28133. m.addai_response = &u
  28134. }
  28135. }
  28136. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  28137. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  28138. v := m.addai_response
  28139. if v == nil {
  28140. return
  28141. }
  28142. return *v, true
  28143. }
  28144. // ResetAiResponse resets all changes to the "ai_response" field.
  28145. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  28146. m.ai_response = nil
  28147. m.addai_response = nil
  28148. }
  28149. // SetSopRun sets the "sop_run" field.
  28150. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  28151. m.sop_run = &u
  28152. m.addsop_run = nil
  28153. }
  28154. // SopRun returns the value of the "sop_run" field in the mutation.
  28155. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  28156. v := m.sop_run
  28157. if v == nil {
  28158. return
  28159. }
  28160. return *v, true
  28161. }
  28162. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  28163. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28165. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  28166. if !m.op.Is(OpUpdateOne) {
  28167. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  28168. }
  28169. if m.id == nil || m.oldValue == nil {
  28170. return v, errors.New("OldSopRun requires an ID field in the mutation")
  28171. }
  28172. oldValue, err := m.oldValue(ctx)
  28173. if err != nil {
  28174. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  28175. }
  28176. return oldValue.SopRun, nil
  28177. }
  28178. // AddSopRun adds u to the "sop_run" field.
  28179. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  28180. if m.addsop_run != nil {
  28181. *m.addsop_run += u
  28182. } else {
  28183. m.addsop_run = &u
  28184. }
  28185. }
  28186. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  28187. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  28188. v := m.addsop_run
  28189. if v == nil {
  28190. return
  28191. }
  28192. return *v, true
  28193. }
  28194. // ResetSopRun resets all changes to the "sop_run" field.
  28195. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  28196. m.sop_run = nil
  28197. m.addsop_run = nil
  28198. }
  28199. // SetTotalFriend sets the "total_friend" field.
  28200. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  28201. m.total_friend = &u
  28202. m.addtotal_friend = nil
  28203. }
  28204. // TotalFriend returns the value of the "total_friend" field in the mutation.
  28205. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  28206. v := m.total_friend
  28207. if v == nil {
  28208. return
  28209. }
  28210. return *v, true
  28211. }
  28212. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  28213. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28215. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  28216. if !m.op.Is(OpUpdateOne) {
  28217. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  28218. }
  28219. if m.id == nil || m.oldValue == nil {
  28220. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  28221. }
  28222. oldValue, err := m.oldValue(ctx)
  28223. if err != nil {
  28224. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  28225. }
  28226. return oldValue.TotalFriend, nil
  28227. }
  28228. // AddTotalFriend adds u to the "total_friend" field.
  28229. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  28230. if m.addtotal_friend != nil {
  28231. *m.addtotal_friend += u
  28232. } else {
  28233. m.addtotal_friend = &u
  28234. }
  28235. }
  28236. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  28237. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  28238. v := m.addtotal_friend
  28239. if v == nil {
  28240. return
  28241. }
  28242. return *v, true
  28243. }
  28244. // ResetTotalFriend resets all changes to the "total_friend" field.
  28245. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  28246. m.total_friend = nil
  28247. m.addtotal_friend = nil
  28248. }
  28249. // SetTotalGroup sets the "total_group" field.
  28250. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  28251. m.total_group = &u
  28252. m.addtotal_group = nil
  28253. }
  28254. // TotalGroup returns the value of the "total_group" field in the mutation.
  28255. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  28256. v := m.total_group
  28257. if v == nil {
  28258. return
  28259. }
  28260. return *v, true
  28261. }
  28262. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  28263. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28264. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28265. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  28266. if !m.op.Is(OpUpdateOne) {
  28267. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  28268. }
  28269. if m.id == nil || m.oldValue == nil {
  28270. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  28271. }
  28272. oldValue, err := m.oldValue(ctx)
  28273. if err != nil {
  28274. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  28275. }
  28276. return oldValue.TotalGroup, nil
  28277. }
  28278. // AddTotalGroup adds u to the "total_group" field.
  28279. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  28280. if m.addtotal_group != nil {
  28281. *m.addtotal_group += u
  28282. } else {
  28283. m.addtotal_group = &u
  28284. }
  28285. }
  28286. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  28287. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  28288. v := m.addtotal_group
  28289. if v == nil {
  28290. return
  28291. }
  28292. return *v, true
  28293. }
  28294. // ResetTotalGroup resets all changes to the "total_group" field.
  28295. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  28296. m.total_group = nil
  28297. m.addtotal_group = nil
  28298. }
  28299. // SetAccountBalance sets the "account_balance" field.
  28300. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  28301. m.account_balance = &u
  28302. m.addaccount_balance = nil
  28303. }
  28304. // AccountBalance returns the value of the "account_balance" field in the mutation.
  28305. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  28306. v := m.account_balance
  28307. if v == nil {
  28308. return
  28309. }
  28310. return *v, true
  28311. }
  28312. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  28313. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28315. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  28316. if !m.op.Is(OpUpdateOne) {
  28317. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  28318. }
  28319. if m.id == nil || m.oldValue == nil {
  28320. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  28321. }
  28322. oldValue, err := m.oldValue(ctx)
  28323. if err != nil {
  28324. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  28325. }
  28326. return oldValue.AccountBalance, nil
  28327. }
  28328. // AddAccountBalance adds u to the "account_balance" field.
  28329. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  28330. if m.addaccount_balance != nil {
  28331. *m.addaccount_balance += u
  28332. } else {
  28333. m.addaccount_balance = &u
  28334. }
  28335. }
  28336. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  28337. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  28338. v := m.addaccount_balance
  28339. if v == nil {
  28340. return
  28341. }
  28342. return *v, true
  28343. }
  28344. // ResetAccountBalance resets all changes to the "account_balance" field.
  28345. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  28346. m.account_balance = nil
  28347. m.addaccount_balance = nil
  28348. }
  28349. // SetConsumeToken sets the "consume_token" field.
  28350. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  28351. m.consume_token = &u
  28352. m.addconsume_token = nil
  28353. }
  28354. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  28355. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  28356. v := m.consume_token
  28357. if v == nil {
  28358. return
  28359. }
  28360. return *v, true
  28361. }
  28362. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  28363. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28365. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  28366. if !m.op.Is(OpUpdateOne) {
  28367. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  28368. }
  28369. if m.id == nil || m.oldValue == nil {
  28370. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  28371. }
  28372. oldValue, err := m.oldValue(ctx)
  28373. if err != nil {
  28374. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  28375. }
  28376. return oldValue.ConsumeToken, nil
  28377. }
  28378. // AddConsumeToken adds u to the "consume_token" field.
  28379. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  28380. if m.addconsume_token != nil {
  28381. *m.addconsume_token += u
  28382. } else {
  28383. m.addconsume_token = &u
  28384. }
  28385. }
  28386. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  28387. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  28388. v := m.addconsume_token
  28389. if v == nil {
  28390. return
  28391. }
  28392. return *v, true
  28393. }
  28394. // ResetConsumeToken resets all changes to the "consume_token" field.
  28395. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  28396. m.consume_token = nil
  28397. m.addconsume_token = nil
  28398. }
  28399. // SetActiveUser sets the "active_user" field.
  28400. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  28401. m.active_user = &u
  28402. m.addactive_user = nil
  28403. }
  28404. // ActiveUser returns the value of the "active_user" field in the mutation.
  28405. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  28406. v := m.active_user
  28407. if v == nil {
  28408. return
  28409. }
  28410. return *v, true
  28411. }
  28412. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  28413. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28415. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  28416. if !m.op.Is(OpUpdateOne) {
  28417. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  28418. }
  28419. if m.id == nil || m.oldValue == nil {
  28420. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  28421. }
  28422. oldValue, err := m.oldValue(ctx)
  28423. if err != nil {
  28424. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  28425. }
  28426. return oldValue.ActiveUser, nil
  28427. }
  28428. // AddActiveUser adds u to the "active_user" field.
  28429. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  28430. if m.addactive_user != nil {
  28431. *m.addactive_user += u
  28432. } else {
  28433. m.addactive_user = &u
  28434. }
  28435. }
  28436. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  28437. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  28438. v := m.addactive_user
  28439. if v == nil {
  28440. return
  28441. }
  28442. return *v, true
  28443. }
  28444. // ResetActiveUser resets all changes to the "active_user" field.
  28445. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  28446. m.active_user = nil
  28447. m.addactive_user = nil
  28448. }
  28449. // SetNewUser sets the "new_user" field.
  28450. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  28451. m.new_user = &i
  28452. m.addnew_user = nil
  28453. }
  28454. // NewUser returns the value of the "new_user" field in the mutation.
  28455. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  28456. v := m.new_user
  28457. if v == nil {
  28458. return
  28459. }
  28460. return *v, true
  28461. }
  28462. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  28463. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28465. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  28466. if !m.op.Is(OpUpdateOne) {
  28467. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  28468. }
  28469. if m.id == nil || m.oldValue == nil {
  28470. return v, errors.New("OldNewUser requires an ID field in the mutation")
  28471. }
  28472. oldValue, err := m.oldValue(ctx)
  28473. if err != nil {
  28474. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  28475. }
  28476. return oldValue.NewUser, nil
  28477. }
  28478. // AddNewUser adds i to the "new_user" field.
  28479. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  28480. if m.addnew_user != nil {
  28481. *m.addnew_user += i
  28482. } else {
  28483. m.addnew_user = &i
  28484. }
  28485. }
  28486. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  28487. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  28488. v := m.addnew_user
  28489. if v == nil {
  28490. return
  28491. }
  28492. return *v, true
  28493. }
  28494. // ResetNewUser resets all changes to the "new_user" field.
  28495. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  28496. m.new_user = nil
  28497. m.addnew_user = nil
  28498. }
  28499. // SetLabelDist sets the "label_dist" field.
  28500. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  28501. m.label_dist = &ctd
  28502. m.appendlabel_dist = nil
  28503. }
  28504. // LabelDist returns the value of the "label_dist" field in the mutation.
  28505. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  28506. v := m.label_dist
  28507. if v == nil {
  28508. return
  28509. }
  28510. return *v, true
  28511. }
  28512. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  28513. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  28514. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28515. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  28516. if !m.op.Is(OpUpdateOne) {
  28517. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  28518. }
  28519. if m.id == nil || m.oldValue == nil {
  28520. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  28521. }
  28522. oldValue, err := m.oldValue(ctx)
  28523. if err != nil {
  28524. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  28525. }
  28526. return oldValue.LabelDist, nil
  28527. }
  28528. // AppendLabelDist adds ctd to the "label_dist" field.
  28529. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  28530. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  28531. }
  28532. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  28533. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  28534. if len(m.appendlabel_dist) == 0 {
  28535. return nil, false
  28536. }
  28537. return m.appendlabel_dist, true
  28538. }
  28539. // ResetLabelDist resets all changes to the "label_dist" field.
  28540. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  28541. m.label_dist = nil
  28542. m.appendlabel_dist = nil
  28543. }
  28544. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  28545. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  28546. m.predicates = append(m.predicates, ps...)
  28547. }
  28548. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  28549. // users can use type-assertion to append predicates that do not depend on any generated package.
  28550. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  28551. p := make([]predicate.UsageStatisticMonth, len(ps))
  28552. for i := range ps {
  28553. p[i] = ps[i]
  28554. }
  28555. m.Where(p...)
  28556. }
  28557. // Op returns the operation name.
  28558. func (m *UsageStatisticMonthMutation) Op() Op {
  28559. return m.op
  28560. }
  28561. // SetOp allows setting the mutation operation.
  28562. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  28563. m.op = op
  28564. }
  28565. // Type returns the node type of this mutation (UsageStatisticMonth).
  28566. func (m *UsageStatisticMonthMutation) Type() string {
  28567. return m.typ
  28568. }
  28569. // Fields returns all fields that were changed during this mutation. Note that in
  28570. // order to get all numeric fields that were incremented/decremented, call
  28571. // AddedFields().
  28572. func (m *UsageStatisticMonthMutation) Fields() []string {
  28573. fields := make([]string, 0, 17)
  28574. if m.created_at != nil {
  28575. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  28576. }
  28577. if m.updated_at != nil {
  28578. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  28579. }
  28580. if m.status != nil {
  28581. fields = append(fields, usagestatisticmonth.FieldStatus)
  28582. }
  28583. if m.deleted_at != nil {
  28584. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  28585. }
  28586. if m.addtime != nil {
  28587. fields = append(fields, usagestatisticmonth.FieldAddtime)
  28588. }
  28589. if m._type != nil {
  28590. fields = append(fields, usagestatisticmonth.FieldType)
  28591. }
  28592. if m.bot_id != nil {
  28593. fields = append(fields, usagestatisticmonth.FieldBotID)
  28594. }
  28595. if m.organization_id != nil {
  28596. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  28597. }
  28598. if m.ai_response != nil {
  28599. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  28600. }
  28601. if m.sop_run != nil {
  28602. fields = append(fields, usagestatisticmonth.FieldSopRun)
  28603. }
  28604. if m.total_friend != nil {
  28605. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  28606. }
  28607. if m.total_group != nil {
  28608. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  28609. }
  28610. if m.account_balance != nil {
  28611. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  28612. }
  28613. if m.consume_token != nil {
  28614. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  28615. }
  28616. if m.active_user != nil {
  28617. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  28618. }
  28619. if m.new_user != nil {
  28620. fields = append(fields, usagestatisticmonth.FieldNewUser)
  28621. }
  28622. if m.label_dist != nil {
  28623. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  28624. }
  28625. return fields
  28626. }
  28627. // Field returns the value of a field with the given name. The second boolean
  28628. // return value indicates that this field was not set, or was not defined in the
  28629. // schema.
  28630. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  28631. switch name {
  28632. case usagestatisticmonth.FieldCreatedAt:
  28633. return m.CreatedAt()
  28634. case usagestatisticmonth.FieldUpdatedAt:
  28635. return m.UpdatedAt()
  28636. case usagestatisticmonth.FieldStatus:
  28637. return m.Status()
  28638. case usagestatisticmonth.FieldDeletedAt:
  28639. return m.DeletedAt()
  28640. case usagestatisticmonth.FieldAddtime:
  28641. return m.Addtime()
  28642. case usagestatisticmonth.FieldType:
  28643. return m.GetType()
  28644. case usagestatisticmonth.FieldBotID:
  28645. return m.BotID()
  28646. case usagestatisticmonth.FieldOrganizationID:
  28647. return m.OrganizationID()
  28648. case usagestatisticmonth.FieldAiResponse:
  28649. return m.AiResponse()
  28650. case usagestatisticmonth.FieldSopRun:
  28651. return m.SopRun()
  28652. case usagestatisticmonth.FieldTotalFriend:
  28653. return m.TotalFriend()
  28654. case usagestatisticmonth.FieldTotalGroup:
  28655. return m.TotalGroup()
  28656. case usagestatisticmonth.FieldAccountBalance:
  28657. return m.AccountBalance()
  28658. case usagestatisticmonth.FieldConsumeToken:
  28659. return m.ConsumeToken()
  28660. case usagestatisticmonth.FieldActiveUser:
  28661. return m.ActiveUser()
  28662. case usagestatisticmonth.FieldNewUser:
  28663. return m.NewUser()
  28664. case usagestatisticmonth.FieldLabelDist:
  28665. return m.LabelDist()
  28666. }
  28667. return nil, false
  28668. }
  28669. // OldField returns the old value of the field from the database. An error is
  28670. // returned if the mutation operation is not UpdateOne, or the query to the
  28671. // database failed.
  28672. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  28673. switch name {
  28674. case usagestatisticmonth.FieldCreatedAt:
  28675. return m.OldCreatedAt(ctx)
  28676. case usagestatisticmonth.FieldUpdatedAt:
  28677. return m.OldUpdatedAt(ctx)
  28678. case usagestatisticmonth.FieldStatus:
  28679. return m.OldStatus(ctx)
  28680. case usagestatisticmonth.FieldDeletedAt:
  28681. return m.OldDeletedAt(ctx)
  28682. case usagestatisticmonth.FieldAddtime:
  28683. return m.OldAddtime(ctx)
  28684. case usagestatisticmonth.FieldType:
  28685. return m.OldType(ctx)
  28686. case usagestatisticmonth.FieldBotID:
  28687. return m.OldBotID(ctx)
  28688. case usagestatisticmonth.FieldOrganizationID:
  28689. return m.OldOrganizationID(ctx)
  28690. case usagestatisticmonth.FieldAiResponse:
  28691. return m.OldAiResponse(ctx)
  28692. case usagestatisticmonth.FieldSopRun:
  28693. return m.OldSopRun(ctx)
  28694. case usagestatisticmonth.FieldTotalFriend:
  28695. return m.OldTotalFriend(ctx)
  28696. case usagestatisticmonth.FieldTotalGroup:
  28697. return m.OldTotalGroup(ctx)
  28698. case usagestatisticmonth.FieldAccountBalance:
  28699. return m.OldAccountBalance(ctx)
  28700. case usagestatisticmonth.FieldConsumeToken:
  28701. return m.OldConsumeToken(ctx)
  28702. case usagestatisticmonth.FieldActiveUser:
  28703. return m.OldActiveUser(ctx)
  28704. case usagestatisticmonth.FieldNewUser:
  28705. return m.OldNewUser(ctx)
  28706. case usagestatisticmonth.FieldLabelDist:
  28707. return m.OldLabelDist(ctx)
  28708. }
  28709. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  28710. }
  28711. // SetField sets the value of a field with the given name. It returns an error if
  28712. // the field is not defined in the schema, or if the type mismatched the field
  28713. // type.
  28714. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  28715. switch name {
  28716. case usagestatisticmonth.FieldCreatedAt:
  28717. v, ok := value.(time.Time)
  28718. if !ok {
  28719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28720. }
  28721. m.SetCreatedAt(v)
  28722. return nil
  28723. case usagestatisticmonth.FieldUpdatedAt:
  28724. v, ok := value.(time.Time)
  28725. if !ok {
  28726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28727. }
  28728. m.SetUpdatedAt(v)
  28729. return nil
  28730. case usagestatisticmonth.FieldStatus:
  28731. v, ok := value.(uint8)
  28732. if !ok {
  28733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28734. }
  28735. m.SetStatus(v)
  28736. return nil
  28737. case usagestatisticmonth.FieldDeletedAt:
  28738. v, ok := value.(time.Time)
  28739. if !ok {
  28740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28741. }
  28742. m.SetDeletedAt(v)
  28743. return nil
  28744. case usagestatisticmonth.FieldAddtime:
  28745. v, ok := value.(uint64)
  28746. if !ok {
  28747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28748. }
  28749. m.SetAddtime(v)
  28750. return nil
  28751. case usagestatisticmonth.FieldType:
  28752. v, ok := value.(int)
  28753. if !ok {
  28754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28755. }
  28756. m.SetType(v)
  28757. return nil
  28758. case usagestatisticmonth.FieldBotID:
  28759. v, ok := value.(string)
  28760. if !ok {
  28761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28762. }
  28763. m.SetBotID(v)
  28764. return nil
  28765. case usagestatisticmonth.FieldOrganizationID:
  28766. v, ok := value.(uint64)
  28767. if !ok {
  28768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28769. }
  28770. m.SetOrganizationID(v)
  28771. return nil
  28772. case usagestatisticmonth.FieldAiResponse:
  28773. v, ok := value.(uint64)
  28774. if !ok {
  28775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28776. }
  28777. m.SetAiResponse(v)
  28778. return nil
  28779. case usagestatisticmonth.FieldSopRun:
  28780. v, ok := value.(uint64)
  28781. if !ok {
  28782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28783. }
  28784. m.SetSopRun(v)
  28785. return nil
  28786. case usagestatisticmonth.FieldTotalFriend:
  28787. v, ok := value.(uint64)
  28788. if !ok {
  28789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28790. }
  28791. m.SetTotalFriend(v)
  28792. return nil
  28793. case usagestatisticmonth.FieldTotalGroup:
  28794. v, ok := value.(uint64)
  28795. if !ok {
  28796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28797. }
  28798. m.SetTotalGroup(v)
  28799. return nil
  28800. case usagestatisticmonth.FieldAccountBalance:
  28801. v, ok := value.(uint64)
  28802. if !ok {
  28803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28804. }
  28805. m.SetAccountBalance(v)
  28806. return nil
  28807. case usagestatisticmonth.FieldConsumeToken:
  28808. v, ok := value.(uint64)
  28809. if !ok {
  28810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28811. }
  28812. m.SetConsumeToken(v)
  28813. return nil
  28814. case usagestatisticmonth.FieldActiveUser:
  28815. v, ok := value.(uint64)
  28816. if !ok {
  28817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28818. }
  28819. m.SetActiveUser(v)
  28820. return nil
  28821. case usagestatisticmonth.FieldNewUser:
  28822. v, ok := value.(int64)
  28823. if !ok {
  28824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28825. }
  28826. m.SetNewUser(v)
  28827. return nil
  28828. case usagestatisticmonth.FieldLabelDist:
  28829. v, ok := value.([]custom_types.LabelDist)
  28830. if !ok {
  28831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28832. }
  28833. m.SetLabelDist(v)
  28834. return nil
  28835. }
  28836. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  28837. }
  28838. // AddedFields returns all numeric fields that were incremented/decremented during
  28839. // this mutation.
  28840. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  28841. var fields []string
  28842. if m.addstatus != nil {
  28843. fields = append(fields, usagestatisticmonth.FieldStatus)
  28844. }
  28845. if m.addaddtime != nil {
  28846. fields = append(fields, usagestatisticmonth.FieldAddtime)
  28847. }
  28848. if m.add_type != nil {
  28849. fields = append(fields, usagestatisticmonth.FieldType)
  28850. }
  28851. if m.addorganization_id != nil {
  28852. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  28853. }
  28854. if m.addai_response != nil {
  28855. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  28856. }
  28857. if m.addsop_run != nil {
  28858. fields = append(fields, usagestatisticmonth.FieldSopRun)
  28859. }
  28860. if m.addtotal_friend != nil {
  28861. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  28862. }
  28863. if m.addtotal_group != nil {
  28864. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  28865. }
  28866. if m.addaccount_balance != nil {
  28867. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  28868. }
  28869. if m.addconsume_token != nil {
  28870. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  28871. }
  28872. if m.addactive_user != nil {
  28873. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  28874. }
  28875. if m.addnew_user != nil {
  28876. fields = append(fields, usagestatisticmonth.FieldNewUser)
  28877. }
  28878. return fields
  28879. }
  28880. // AddedField returns the numeric value that was incremented/decremented on a field
  28881. // with the given name. The second boolean return value indicates that this field
  28882. // was not set, or was not defined in the schema.
  28883. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  28884. switch name {
  28885. case usagestatisticmonth.FieldStatus:
  28886. return m.AddedStatus()
  28887. case usagestatisticmonth.FieldAddtime:
  28888. return m.AddedAddtime()
  28889. case usagestatisticmonth.FieldType:
  28890. return m.AddedType()
  28891. case usagestatisticmonth.FieldOrganizationID:
  28892. return m.AddedOrganizationID()
  28893. case usagestatisticmonth.FieldAiResponse:
  28894. return m.AddedAiResponse()
  28895. case usagestatisticmonth.FieldSopRun:
  28896. return m.AddedSopRun()
  28897. case usagestatisticmonth.FieldTotalFriend:
  28898. return m.AddedTotalFriend()
  28899. case usagestatisticmonth.FieldTotalGroup:
  28900. return m.AddedTotalGroup()
  28901. case usagestatisticmonth.FieldAccountBalance:
  28902. return m.AddedAccountBalance()
  28903. case usagestatisticmonth.FieldConsumeToken:
  28904. return m.AddedConsumeToken()
  28905. case usagestatisticmonth.FieldActiveUser:
  28906. return m.AddedActiveUser()
  28907. case usagestatisticmonth.FieldNewUser:
  28908. return m.AddedNewUser()
  28909. }
  28910. return nil, false
  28911. }
  28912. // AddField adds the value to the field with the given name. It returns an error if
  28913. // the field is not defined in the schema, or if the type mismatched the field
  28914. // type.
  28915. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  28916. switch name {
  28917. case usagestatisticmonth.FieldStatus:
  28918. v, ok := value.(int8)
  28919. if !ok {
  28920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28921. }
  28922. m.AddStatus(v)
  28923. return nil
  28924. case usagestatisticmonth.FieldAddtime:
  28925. v, ok := value.(int64)
  28926. if !ok {
  28927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28928. }
  28929. m.AddAddtime(v)
  28930. return nil
  28931. case usagestatisticmonth.FieldType:
  28932. v, ok := value.(int)
  28933. if !ok {
  28934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28935. }
  28936. m.AddType(v)
  28937. return nil
  28938. case usagestatisticmonth.FieldOrganizationID:
  28939. v, ok := value.(int64)
  28940. if !ok {
  28941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28942. }
  28943. m.AddOrganizationID(v)
  28944. return nil
  28945. case usagestatisticmonth.FieldAiResponse:
  28946. v, ok := value.(int64)
  28947. if !ok {
  28948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28949. }
  28950. m.AddAiResponse(v)
  28951. return nil
  28952. case usagestatisticmonth.FieldSopRun:
  28953. v, ok := value.(int64)
  28954. if !ok {
  28955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28956. }
  28957. m.AddSopRun(v)
  28958. return nil
  28959. case usagestatisticmonth.FieldTotalFriend:
  28960. v, ok := value.(int64)
  28961. if !ok {
  28962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28963. }
  28964. m.AddTotalFriend(v)
  28965. return nil
  28966. case usagestatisticmonth.FieldTotalGroup:
  28967. v, ok := value.(int64)
  28968. if !ok {
  28969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28970. }
  28971. m.AddTotalGroup(v)
  28972. return nil
  28973. case usagestatisticmonth.FieldAccountBalance:
  28974. v, ok := value.(int64)
  28975. if !ok {
  28976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28977. }
  28978. m.AddAccountBalance(v)
  28979. return nil
  28980. case usagestatisticmonth.FieldConsumeToken:
  28981. v, ok := value.(int64)
  28982. if !ok {
  28983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28984. }
  28985. m.AddConsumeToken(v)
  28986. return nil
  28987. case usagestatisticmonth.FieldActiveUser:
  28988. v, ok := value.(int64)
  28989. if !ok {
  28990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28991. }
  28992. m.AddActiveUser(v)
  28993. return nil
  28994. case usagestatisticmonth.FieldNewUser:
  28995. v, ok := value.(int64)
  28996. if !ok {
  28997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  28998. }
  28999. m.AddNewUser(v)
  29000. return nil
  29001. }
  29002. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  29003. }
  29004. // ClearedFields returns all nullable fields that were cleared during this
  29005. // mutation.
  29006. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  29007. var fields []string
  29008. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  29009. fields = append(fields, usagestatisticmonth.FieldStatus)
  29010. }
  29011. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  29012. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  29013. }
  29014. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  29015. fields = append(fields, usagestatisticmonth.FieldBotID)
  29016. }
  29017. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  29018. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  29019. }
  29020. return fields
  29021. }
  29022. // FieldCleared returns a boolean indicating if a field with the given name was
  29023. // cleared in this mutation.
  29024. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  29025. _, ok := m.clearedFields[name]
  29026. return ok
  29027. }
  29028. // ClearField clears the value of the field with the given name. It returns an
  29029. // error if the field is not defined in the schema.
  29030. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  29031. switch name {
  29032. case usagestatisticmonth.FieldStatus:
  29033. m.ClearStatus()
  29034. return nil
  29035. case usagestatisticmonth.FieldDeletedAt:
  29036. m.ClearDeletedAt()
  29037. return nil
  29038. case usagestatisticmonth.FieldBotID:
  29039. m.ClearBotID()
  29040. return nil
  29041. case usagestatisticmonth.FieldOrganizationID:
  29042. m.ClearOrganizationID()
  29043. return nil
  29044. }
  29045. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  29046. }
  29047. // ResetField resets all changes in the mutation for the field with the given name.
  29048. // It returns an error if the field is not defined in the schema.
  29049. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  29050. switch name {
  29051. case usagestatisticmonth.FieldCreatedAt:
  29052. m.ResetCreatedAt()
  29053. return nil
  29054. case usagestatisticmonth.FieldUpdatedAt:
  29055. m.ResetUpdatedAt()
  29056. return nil
  29057. case usagestatisticmonth.FieldStatus:
  29058. m.ResetStatus()
  29059. return nil
  29060. case usagestatisticmonth.FieldDeletedAt:
  29061. m.ResetDeletedAt()
  29062. return nil
  29063. case usagestatisticmonth.FieldAddtime:
  29064. m.ResetAddtime()
  29065. return nil
  29066. case usagestatisticmonth.FieldType:
  29067. m.ResetType()
  29068. return nil
  29069. case usagestatisticmonth.FieldBotID:
  29070. m.ResetBotID()
  29071. return nil
  29072. case usagestatisticmonth.FieldOrganizationID:
  29073. m.ResetOrganizationID()
  29074. return nil
  29075. case usagestatisticmonth.FieldAiResponse:
  29076. m.ResetAiResponse()
  29077. return nil
  29078. case usagestatisticmonth.FieldSopRun:
  29079. m.ResetSopRun()
  29080. return nil
  29081. case usagestatisticmonth.FieldTotalFriend:
  29082. m.ResetTotalFriend()
  29083. return nil
  29084. case usagestatisticmonth.FieldTotalGroup:
  29085. m.ResetTotalGroup()
  29086. return nil
  29087. case usagestatisticmonth.FieldAccountBalance:
  29088. m.ResetAccountBalance()
  29089. return nil
  29090. case usagestatisticmonth.FieldConsumeToken:
  29091. m.ResetConsumeToken()
  29092. return nil
  29093. case usagestatisticmonth.FieldActiveUser:
  29094. m.ResetActiveUser()
  29095. return nil
  29096. case usagestatisticmonth.FieldNewUser:
  29097. m.ResetNewUser()
  29098. return nil
  29099. case usagestatisticmonth.FieldLabelDist:
  29100. m.ResetLabelDist()
  29101. return nil
  29102. }
  29103. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  29104. }
  29105. // AddedEdges returns all edge names that were set/added in this mutation.
  29106. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  29107. edges := make([]string, 0, 0)
  29108. return edges
  29109. }
  29110. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29111. // name in this mutation.
  29112. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  29113. return nil
  29114. }
  29115. // RemovedEdges returns all edge names that were removed in this mutation.
  29116. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  29117. edges := make([]string, 0, 0)
  29118. return edges
  29119. }
  29120. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29121. // the given name in this mutation.
  29122. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  29123. return nil
  29124. }
  29125. // ClearedEdges returns all edge names that were cleared in this mutation.
  29126. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  29127. edges := make([]string, 0, 0)
  29128. return edges
  29129. }
  29130. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29131. // was cleared in this mutation.
  29132. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  29133. return false
  29134. }
  29135. // ClearEdge clears the value of the edge with the given name. It returns an error
  29136. // if that edge is not defined in the schema.
  29137. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  29138. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  29139. }
  29140. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29141. // It returns an error if the edge is not defined in the schema.
  29142. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  29143. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  29144. }
  29145. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  29146. type UsageTotalMutation struct {
  29147. config
  29148. op Op
  29149. typ string
  29150. id *uint64
  29151. created_at *time.Time
  29152. updated_at *time.Time
  29153. status *uint8
  29154. addstatus *int8
  29155. _type *int
  29156. add_type *int
  29157. bot_id *string
  29158. total_tokens *uint64
  29159. addtotal_tokens *int64
  29160. start_index *uint64
  29161. addstart_index *int64
  29162. end_index *uint64
  29163. addend_index *int64
  29164. organization_id *uint64
  29165. addorganization_id *int64
  29166. clearedFields map[string]struct{}
  29167. done bool
  29168. oldValue func(context.Context) (*UsageTotal, error)
  29169. predicates []predicate.UsageTotal
  29170. }
  29171. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  29172. // usagetotalOption allows management of the mutation configuration using functional options.
  29173. type usagetotalOption func(*UsageTotalMutation)
  29174. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  29175. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  29176. m := &UsageTotalMutation{
  29177. config: c,
  29178. op: op,
  29179. typ: TypeUsageTotal,
  29180. clearedFields: make(map[string]struct{}),
  29181. }
  29182. for _, opt := range opts {
  29183. opt(m)
  29184. }
  29185. return m
  29186. }
  29187. // withUsageTotalID sets the ID field of the mutation.
  29188. func withUsageTotalID(id uint64) usagetotalOption {
  29189. return func(m *UsageTotalMutation) {
  29190. var (
  29191. err error
  29192. once sync.Once
  29193. value *UsageTotal
  29194. )
  29195. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  29196. once.Do(func() {
  29197. if m.done {
  29198. err = errors.New("querying old values post mutation is not allowed")
  29199. } else {
  29200. value, err = m.Client().UsageTotal.Get(ctx, id)
  29201. }
  29202. })
  29203. return value, err
  29204. }
  29205. m.id = &id
  29206. }
  29207. }
  29208. // withUsageTotal sets the old UsageTotal of the mutation.
  29209. func withUsageTotal(node *UsageTotal) usagetotalOption {
  29210. return func(m *UsageTotalMutation) {
  29211. m.oldValue = func(context.Context) (*UsageTotal, error) {
  29212. return node, nil
  29213. }
  29214. m.id = &node.ID
  29215. }
  29216. }
  29217. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29218. // executed in a transaction (ent.Tx), a transactional client is returned.
  29219. func (m UsageTotalMutation) Client() *Client {
  29220. client := &Client{config: m.config}
  29221. client.init()
  29222. return client
  29223. }
  29224. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29225. // it returns an error otherwise.
  29226. func (m UsageTotalMutation) Tx() (*Tx, error) {
  29227. if _, ok := m.driver.(*txDriver); !ok {
  29228. return nil, errors.New("ent: mutation is not running in a transaction")
  29229. }
  29230. tx := &Tx{config: m.config}
  29231. tx.init()
  29232. return tx, nil
  29233. }
  29234. // SetID sets the value of the id field. Note that this
  29235. // operation is only accepted on creation of UsageTotal entities.
  29236. func (m *UsageTotalMutation) SetID(id uint64) {
  29237. m.id = &id
  29238. }
  29239. // ID returns the ID value in the mutation. Note that the ID is only available
  29240. // if it was provided to the builder or after it was returned from the database.
  29241. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  29242. if m.id == nil {
  29243. return
  29244. }
  29245. return *m.id, true
  29246. }
  29247. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29248. // That means, if the mutation is applied within a transaction with an isolation level such
  29249. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29250. // or updated by the mutation.
  29251. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  29252. switch {
  29253. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29254. id, exists := m.ID()
  29255. if exists {
  29256. return []uint64{id}, nil
  29257. }
  29258. fallthrough
  29259. case m.op.Is(OpUpdate | OpDelete):
  29260. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  29261. default:
  29262. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29263. }
  29264. }
  29265. // SetCreatedAt sets the "created_at" field.
  29266. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  29267. m.created_at = &t
  29268. }
  29269. // CreatedAt returns the value of the "created_at" field in the mutation.
  29270. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  29271. v := m.created_at
  29272. if v == nil {
  29273. return
  29274. }
  29275. return *v, true
  29276. }
  29277. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  29278. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  29279. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29280. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29281. if !m.op.Is(OpUpdateOne) {
  29282. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29283. }
  29284. if m.id == nil || m.oldValue == nil {
  29285. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29286. }
  29287. oldValue, err := m.oldValue(ctx)
  29288. if err != nil {
  29289. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29290. }
  29291. return oldValue.CreatedAt, nil
  29292. }
  29293. // ResetCreatedAt resets all changes to the "created_at" field.
  29294. func (m *UsageTotalMutation) ResetCreatedAt() {
  29295. m.created_at = nil
  29296. }
  29297. // SetUpdatedAt sets the "updated_at" field.
  29298. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  29299. m.updated_at = &t
  29300. }
  29301. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29302. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  29303. v := m.updated_at
  29304. if v == nil {
  29305. return
  29306. }
  29307. return *v, true
  29308. }
  29309. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  29310. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  29311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29312. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29313. if !m.op.Is(OpUpdateOne) {
  29314. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29315. }
  29316. if m.id == nil || m.oldValue == nil {
  29317. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29318. }
  29319. oldValue, err := m.oldValue(ctx)
  29320. if err != nil {
  29321. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29322. }
  29323. return oldValue.UpdatedAt, nil
  29324. }
  29325. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29326. func (m *UsageTotalMutation) ResetUpdatedAt() {
  29327. m.updated_at = nil
  29328. }
  29329. // SetStatus sets the "status" field.
  29330. func (m *UsageTotalMutation) SetStatus(u uint8) {
  29331. m.status = &u
  29332. m.addstatus = nil
  29333. }
  29334. // Status returns the value of the "status" field in the mutation.
  29335. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  29336. v := m.status
  29337. if v == nil {
  29338. return
  29339. }
  29340. return *v, true
  29341. }
  29342. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  29343. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  29344. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29345. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29346. if !m.op.Is(OpUpdateOne) {
  29347. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29348. }
  29349. if m.id == nil || m.oldValue == nil {
  29350. return v, errors.New("OldStatus requires an ID field in the mutation")
  29351. }
  29352. oldValue, err := m.oldValue(ctx)
  29353. if err != nil {
  29354. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29355. }
  29356. return oldValue.Status, nil
  29357. }
  29358. // AddStatus adds u to the "status" field.
  29359. func (m *UsageTotalMutation) AddStatus(u int8) {
  29360. if m.addstatus != nil {
  29361. *m.addstatus += u
  29362. } else {
  29363. m.addstatus = &u
  29364. }
  29365. }
  29366. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29367. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  29368. v := m.addstatus
  29369. if v == nil {
  29370. return
  29371. }
  29372. return *v, true
  29373. }
  29374. // ClearStatus clears the value of the "status" field.
  29375. func (m *UsageTotalMutation) ClearStatus() {
  29376. m.status = nil
  29377. m.addstatus = nil
  29378. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  29379. }
  29380. // StatusCleared returns if the "status" field was cleared in this mutation.
  29381. func (m *UsageTotalMutation) StatusCleared() bool {
  29382. _, ok := m.clearedFields[usagetotal.FieldStatus]
  29383. return ok
  29384. }
  29385. // ResetStatus resets all changes to the "status" field.
  29386. func (m *UsageTotalMutation) ResetStatus() {
  29387. m.status = nil
  29388. m.addstatus = nil
  29389. delete(m.clearedFields, usagetotal.FieldStatus)
  29390. }
  29391. // SetType sets the "type" field.
  29392. func (m *UsageTotalMutation) SetType(i int) {
  29393. m._type = &i
  29394. m.add_type = nil
  29395. }
  29396. // GetType returns the value of the "type" field in the mutation.
  29397. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  29398. v := m._type
  29399. if v == nil {
  29400. return
  29401. }
  29402. return *v, true
  29403. }
  29404. // OldType returns the old "type" field's value of the UsageTotal entity.
  29405. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  29406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29407. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  29408. if !m.op.Is(OpUpdateOne) {
  29409. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29410. }
  29411. if m.id == nil || m.oldValue == nil {
  29412. return v, errors.New("OldType requires an ID field in the mutation")
  29413. }
  29414. oldValue, err := m.oldValue(ctx)
  29415. if err != nil {
  29416. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29417. }
  29418. return oldValue.Type, nil
  29419. }
  29420. // AddType adds i to the "type" field.
  29421. func (m *UsageTotalMutation) AddType(i int) {
  29422. if m.add_type != nil {
  29423. *m.add_type += i
  29424. } else {
  29425. m.add_type = &i
  29426. }
  29427. }
  29428. // AddedType returns the value that was added to the "type" field in this mutation.
  29429. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  29430. v := m.add_type
  29431. if v == nil {
  29432. return
  29433. }
  29434. return *v, true
  29435. }
  29436. // ClearType clears the value of the "type" field.
  29437. func (m *UsageTotalMutation) ClearType() {
  29438. m._type = nil
  29439. m.add_type = nil
  29440. m.clearedFields[usagetotal.FieldType] = struct{}{}
  29441. }
  29442. // TypeCleared returns if the "type" field was cleared in this mutation.
  29443. func (m *UsageTotalMutation) TypeCleared() bool {
  29444. _, ok := m.clearedFields[usagetotal.FieldType]
  29445. return ok
  29446. }
  29447. // ResetType resets all changes to the "type" field.
  29448. func (m *UsageTotalMutation) ResetType() {
  29449. m._type = nil
  29450. m.add_type = nil
  29451. delete(m.clearedFields, usagetotal.FieldType)
  29452. }
  29453. // SetBotID sets the "bot_id" field.
  29454. func (m *UsageTotalMutation) SetBotID(s string) {
  29455. m.bot_id = &s
  29456. }
  29457. // BotID returns the value of the "bot_id" field in the mutation.
  29458. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  29459. v := m.bot_id
  29460. if v == nil {
  29461. return
  29462. }
  29463. return *v, true
  29464. }
  29465. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  29466. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  29467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29468. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  29469. if !m.op.Is(OpUpdateOne) {
  29470. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  29471. }
  29472. if m.id == nil || m.oldValue == nil {
  29473. return v, errors.New("OldBotID requires an ID field in the mutation")
  29474. }
  29475. oldValue, err := m.oldValue(ctx)
  29476. if err != nil {
  29477. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  29478. }
  29479. return oldValue.BotID, nil
  29480. }
  29481. // ResetBotID resets all changes to the "bot_id" field.
  29482. func (m *UsageTotalMutation) ResetBotID() {
  29483. m.bot_id = nil
  29484. }
  29485. // SetTotalTokens sets the "total_tokens" field.
  29486. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  29487. m.total_tokens = &u
  29488. m.addtotal_tokens = nil
  29489. }
  29490. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  29491. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  29492. v := m.total_tokens
  29493. if v == nil {
  29494. return
  29495. }
  29496. return *v, true
  29497. }
  29498. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  29499. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  29500. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29501. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  29502. if !m.op.Is(OpUpdateOne) {
  29503. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  29504. }
  29505. if m.id == nil || m.oldValue == nil {
  29506. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  29507. }
  29508. oldValue, err := m.oldValue(ctx)
  29509. if err != nil {
  29510. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  29511. }
  29512. return oldValue.TotalTokens, nil
  29513. }
  29514. // AddTotalTokens adds u to the "total_tokens" field.
  29515. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  29516. if m.addtotal_tokens != nil {
  29517. *m.addtotal_tokens += u
  29518. } else {
  29519. m.addtotal_tokens = &u
  29520. }
  29521. }
  29522. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  29523. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  29524. v := m.addtotal_tokens
  29525. if v == nil {
  29526. return
  29527. }
  29528. return *v, true
  29529. }
  29530. // ClearTotalTokens clears the value of the "total_tokens" field.
  29531. func (m *UsageTotalMutation) ClearTotalTokens() {
  29532. m.total_tokens = nil
  29533. m.addtotal_tokens = nil
  29534. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  29535. }
  29536. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  29537. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  29538. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  29539. return ok
  29540. }
  29541. // ResetTotalTokens resets all changes to the "total_tokens" field.
  29542. func (m *UsageTotalMutation) ResetTotalTokens() {
  29543. m.total_tokens = nil
  29544. m.addtotal_tokens = nil
  29545. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  29546. }
  29547. // SetStartIndex sets the "start_index" field.
  29548. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  29549. m.start_index = &u
  29550. m.addstart_index = nil
  29551. }
  29552. // StartIndex returns the value of the "start_index" field in the mutation.
  29553. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  29554. v := m.start_index
  29555. if v == nil {
  29556. return
  29557. }
  29558. return *v, true
  29559. }
  29560. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  29561. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  29562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29563. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  29564. if !m.op.Is(OpUpdateOne) {
  29565. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  29566. }
  29567. if m.id == nil || m.oldValue == nil {
  29568. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  29569. }
  29570. oldValue, err := m.oldValue(ctx)
  29571. if err != nil {
  29572. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  29573. }
  29574. return oldValue.StartIndex, nil
  29575. }
  29576. // AddStartIndex adds u to the "start_index" field.
  29577. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  29578. if m.addstart_index != nil {
  29579. *m.addstart_index += u
  29580. } else {
  29581. m.addstart_index = &u
  29582. }
  29583. }
  29584. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  29585. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  29586. v := m.addstart_index
  29587. if v == nil {
  29588. return
  29589. }
  29590. return *v, true
  29591. }
  29592. // ClearStartIndex clears the value of the "start_index" field.
  29593. func (m *UsageTotalMutation) ClearStartIndex() {
  29594. m.start_index = nil
  29595. m.addstart_index = nil
  29596. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  29597. }
  29598. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  29599. func (m *UsageTotalMutation) StartIndexCleared() bool {
  29600. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  29601. return ok
  29602. }
  29603. // ResetStartIndex resets all changes to the "start_index" field.
  29604. func (m *UsageTotalMutation) ResetStartIndex() {
  29605. m.start_index = nil
  29606. m.addstart_index = nil
  29607. delete(m.clearedFields, usagetotal.FieldStartIndex)
  29608. }
  29609. // SetEndIndex sets the "end_index" field.
  29610. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  29611. m.end_index = &u
  29612. m.addend_index = nil
  29613. }
  29614. // EndIndex returns the value of the "end_index" field in the mutation.
  29615. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  29616. v := m.end_index
  29617. if v == nil {
  29618. return
  29619. }
  29620. return *v, true
  29621. }
  29622. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  29623. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  29624. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29625. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  29626. if !m.op.Is(OpUpdateOne) {
  29627. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  29628. }
  29629. if m.id == nil || m.oldValue == nil {
  29630. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  29631. }
  29632. oldValue, err := m.oldValue(ctx)
  29633. if err != nil {
  29634. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  29635. }
  29636. return oldValue.EndIndex, nil
  29637. }
  29638. // AddEndIndex adds u to the "end_index" field.
  29639. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  29640. if m.addend_index != nil {
  29641. *m.addend_index += u
  29642. } else {
  29643. m.addend_index = &u
  29644. }
  29645. }
  29646. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  29647. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  29648. v := m.addend_index
  29649. if v == nil {
  29650. return
  29651. }
  29652. return *v, true
  29653. }
  29654. // ClearEndIndex clears the value of the "end_index" field.
  29655. func (m *UsageTotalMutation) ClearEndIndex() {
  29656. m.end_index = nil
  29657. m.addend_index = nil
  29658. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  29659. }
  29660. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  29661. func (m *UsageTotalMutation) EndIndexCleared() bool {
  29662. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  29663. return ok
  29664. }
  29665. // ResetEndIndex resets all changes to the "end_index" field.
  29666. func (m *UsageTotalMutation) ResetEndIndex() {
  29667. m.end_index = nil
  29668. m.addend_index = nil
  29669. delete(m.clearedFields, usagetotal.FieldEndIndex)
  29670. }
  29671. // SetOrganizationID sets the "organization_id" field.
  29672. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  29673. m.organization_id = &u
  29674. m.addorganization_id = nil
  29675. }
  29676. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29677. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  29678. v := m.organization_id
  29679. if v == nil {
  29680. return
  29681. }
  29682. return *v, true
  29683. }
  29684. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  29685. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  29686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29687. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29688. if !m.op.Is(OpUpdateOne) {
  29689. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29690. }
  29691. if m.id == nil || m.oldValue == nil {
  29692. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29693. }
  29694. oldValue, err := m.oldValue(ctx)
  29695. if err != nil {
  29696. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29697. }
  29698. return oldValue.OrganizationID, nil
  29699. }
  29700. // AddOrganizationID adds u to the "organization_id" field.
  29701. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  29702. if m.addorganization_id != nil {
  29703. *m.addorganization_id += u
  29704. } else {
  29705. m.addorganization_id = &u
  29706. }
  29707. }
  29708. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29709. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  29710. v := m.addorganization_id
  29711. if v == nil {
  29712. return
  29713. }
  29714. return *v, true
  29715. }
  29716. // ClearOrganizationID clears the value of the "organization_id" field.
  29717. func (m *UsageTotalMutation) ClearOrganizationID() {
  29718. m.organization_id = nil
  29719. m.addorganization_id = nil
  29720. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  29721. }
  29722. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  29723. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  29724. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  29725. return ok
  29726. }
  29727. // ResetOrganizationID resets all changes to the "organization_id" field.
  29728. func (m *UsageTotalMutation) ResetOrganizationID() {
  29729. m.organization_id = nil
  29730. m.addorganization_id = nil
  29731. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  29732. }
  29733. // Where appends a list predicates to the UsageTotalMutation builder.
  29734. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  29735. m.predicates = append(m.predicates, ps...)
  29736. }
  29737. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  29738. // users can use type-assertion to append predicates that do not depend on any generated package.
  29739. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  29740. p := make([]predicate.UsageTotal, len(ps))
  29741. for i := range ps {
  29742. p[i] = ps[i]
  29743. }
  29744. m.Where(p...)
  29745. }
  29746. // Op returns the operation name.
  29747. func (m *UsageTotalMutation) Op() Op {
  29748. return m.op
  29749. }
  29750. // SetOp allows setting the mutation operation.
  29751. func (m *UsageTotalMutation) SetOp(op Op) {
  29752. m.op = op
  29753. }
  29754. // Type returns the node type of this mutation (UsageTotal).
  29755. func (m *UsageTotalMutation) Type() string {
  29756. return m.typ
  29757. }
  29758. // Fields returns all fields that were changed during this mutation. Note that in
  29759. // order to get all numeric fields that were incremented/decremented, call
  29760. // AddedFields().
  29761. func (m *UsageTotalMutation) Fields() []string {
  29762. fields := make([]string, 0, 9)
  29763. if m.created_at != nil {
  29764. fields = append(fields, usagetotal.FieldCreatedAt)
  29765. }
  29766. if m.updated_at != nil {
  29767. fields = append(fields, usagetotal.FieldUpdatedAt)
  29768. }
  29769. if m.status != nil {
  29770. fields = append(fields, usagetotal.FieldStatus)
  29771. }
  29772. if m._type != nil {
  29773. fields = append(fields, usagetotal.FieldType)
  29774. }
  29775. if m.bot_id != nil {
  29776. fields = append(fields, usagetotal.FieldBotID)
  29777. }
  29778. if m.total_tokens != nil {
  29779. fields = append(fields, usagetotal.FieldTotalTokens)
  29780. }
  29781. if m.start_index != nil {
  29782. fields = append(fields, usagetotal.FieldStartIndex)
  29783. }
  29784. if m.end_index != nil {
  29785. fields = append(fields, usagetotal.FieldEndIndex)
  29786. }
  29787. if m.organization_id != nil {
  29788. fields = append(fields, usagetotal.FieldOrganizationID)
  29789. }
  29790. return fields
  29791. }
  29792. // Field returns the value of a field with the given name. The second boolean
  29793. // return value indicates that this field was not set, or was not defined in the
  29794. // schema.
  29795. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  29796. switch name {
  29797. case usagetotal.FieldCreatedAt:
  29798. return m.CreatedAt()
  29799. case usagetotal.FieldUpdatedAt:
  29800. return m.UpdatedAt()
  29801. case usagetotal.FieldStatus:
  29802. return m.Status()
  29803. case usagetotal.FieldType:
  29804. return m.GetType()
  29805. case usagetotal.FieldBotID:
  29806. return m.BotID()
  29807. case usagetotal.FieldTotalTokens:
  29808. return m.TotalTokens()
  29809. case usagetotal.FieldStartIndex:
  29810. return m.StartIndex()
  29811. case usagetotal.FieldEndIndex:
  29812. return m.EndIndex()
  29813. case usagetotal.FieldOrganizationID:
  29814. return m.OrganizationID()
  29815. }
  29816. return nil, false
  29817. }
  29818. // OldField returns the old value of the field from the database. An error is
  29819. // returned if the mutation operation is not UpdateOne, or the query to the
  29820. // database failed.
  29821. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29822. switch name {
  29823. case usagetotal.FieldCreatedAt:
  29824. return m.OldCreatedAt(ctx)
  29825. case usagetotal.FieldUpdatedAt:
  29826. return m.OldUpdatedAt(ctx)
  29827. case usagetotal.FieldStatus:
  29828. return m.OldStatus(ctx)
  29829. case usagetotal.FieldType:
  29830. return m.OldType(ctx)
  29831. case usagetotal.FieldBotID:
  29832. return m.OldBotID(ctx)
  29833. case usagetotal.FieldTotalTokens:
  29834. return m.OldTotalTokens(ctx)
  29835. case usagetotal.FieldStartIndex:
  29836. return m.OldStartIndex(ctx)
  29837. case usagetotal.FieldEndIndex:
  29838. return m.OldEndIndex(ctx)
  29839. case usagetotal.FieldOrganizationID:
  29840. return m.OldOrganizationID(ctx)
  29841. }
  29842. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  29843. }
  29844. // SetField sets the value of a field with the given name. It returns an error if
  29845. // the field is not defined in the schema, or if the type mismatched the field
  29846. // type.
  29847. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  29848. switch name {
  29849. case usagetotal.FieldCreatedAt:
  29850. v, ok := value.(time.Time)
  29851. if !ok {
  29852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29853. }
  29854. m.SetCreatedAt(v)
  29855. return nil
  29856. case usagetotal.FieldUpdatedAt:
  29857. v, ok := value.(time.Time)
  29858. if !ok {
  29859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29860. }
  29861. m.SetUpdatedAt(v)
  29862. return nil
  29863. case usagetotal.FieldStatus:
  29864. v, ok := value.(uint8)
  29865. if !ok {
  29866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29867. }
  29868. m.SetStatus(v)
  29869. return nil
  29870. case usagetotal.FieldType:
  29871. v, ok := value.(int)
  29872. if !ok {
  29873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29874. }
  29875. m.SetType(v)
  29876. return nil
  29877. case usagetotal.FieldBotID:
  29878. v, ok := value.(string)
  29879. if !ok {
  29880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29881. }
  29882. m.SetBotID(v)
  29883. return nil
  29884. case usagetotal.FieldTotalTokens:
  29885. v, ok := value.(uint64)
  29886. if !ok {
  29887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29888. }
  29889. m.SetTotalTokens(v)
  29890. return nil
  29891. case usagetotal.FieldStartIndex:
  29892. v, ok := value.(uint64)
  29893. if !ok {
  29894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29895. }
  29896. m.SetStartIndex(v)
  29897. return nil
  29898. case usagetotal.FieldEndIndex:
  29899. v, ok := value.(uint64)
  29900. if !ok {
  29901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29902. }
  29903. m.SetEndIndex(v)
  29904. return nil
  29905. case usagetotal.FieldOrganizationID:
  29906. v, ok := value.(uint64)
  29907. if !ok {
  29908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29909. }
  29910. m.SetOrganizationID(v)
  29911. return nil
  29912. }
  29913. return fmt.Errorf("unknown UsageTotal field %s", name)
  29914. }
  29915. // AddedFields returns all numeric fields that were incremented/decremented during
  29916. // this mutation.
  29917. func (m *UsageTotalMutation) AddedFields() []string {
  29918. var fields []string
  29919. if m.addstatus != nil {
  29920. fields = append(fields, usagetotal.FieldStatus)
  29921. }
  29922. if m.add_type != nil {
  29923. fields = append(fields, usagetotal.FieldType)
  29924. }
  29925. if m.addtotal_tokens != nil {
  29926. fields = append(fields, usagetotal.FieldTotalTokens)
  29927. }
  29928. if m.addstart_index != nil {
  29929. fields = append(fields, usagetotal.FieldStartIndex)
  29930. }
  29931. if m.addend_index != nil {
  29932. fields = append(fields, usagetotal.FieldEndIndex)
  29933. }
  29934. if m.addorganization_id != nil {
  29935. fields = append(fields, usagetotal.FieldOrganizationID)
  29936. }
  29937. return fields
  29938. }
  29939. // AddedField returns the numeric value that was incremented/decremented on a field
  29940. // with the given name. The second boolean return value indicates that this field
  29941. // was not set, or was not defined in the schema.
  29942. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  29943. switch name {
  29944. case usagetotal.FieldStatus:
  29945. return m.AddedStatus()
  29946. case usagetotal.FieldType:
  29947. return m.AddedType()
  29948. case usagetotal.FieldTotalTokens:
  29949. return m.AddedTotalTokens()
  29950. case usagetotal.FieldStartIndex:
  29951. return m.AddedStartIndex()
  29952. case usagetotal.FieldEndIndex:
  29953. return m.AddedEndIndex()
  29954. case usagetotal.FieldOrganizationID:
  29955. return m.AddedOrganizationID()
  29956. }
  29957. return nil, false
  29958. }
  29959. // AddField adds the value to the field with the given name. It returns an error if
  29960. // the field is not defined in the schema, or if the type mismatched the field
  29961. // type.
  29962. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  29963. switch name {
  29964. case usagetotal.FieldStatus:
  29965. v, ok := value.(int8)
  29966. if !ok {
  29967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29968. }
  29969. m.AddStatus(v)
  29970. return nil
  29971. case usagetotal.FieldType:
  29972. v, ok := value.(int)
  29973. if !ok {
  29974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29975. }
  29976. m.AddType(v)
  29977. return nil
  29978. case usagetotal.FieldTotalTokens:
  29979. v, ok := value.(int64)
  29980. if !ok {
  29981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29982. }
  29983. m.AddTotalTokens(v)
  29984. return nil
  29985. case usagetotal.FieldStartIndex:
  29986. v, ok := value.(int64)
  29987. if !ok {
  29988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29989. }
  29990. m.AddStartIndex(v)
  29991. return nil
  29992. case usagetotal.FieldEndIndex:
  29993. v, ok := value.(int64)
  29994. if !ok {
  29995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29996. }
  29997. m.AddEndIndex(v)
  29998. return nil
  29999. case usagetotal.FieldOrganizationID:
  30000. v, ok := value.(int64)
  30001. if !ok {
  30002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30003. }
  30004. m.AddOrganizationID(v)
  30005. return nil
  30006. }
  30007. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  30008. }
  30009. // ClearedFields returns all nullable fields that were cleared during this
  30010. // mutation.
  30011. func (m *UsageTotalMutation) ClearedFields() []string {
  30012. var fields []string
  30013. if m.FieldCleared(usagetotal.FieldStatus) {
  30014. fields = append(fields, usagetotal.FieldStatus)
  30015. }
  30016. if m.FieldCleared(usagetotal.FieldType) {
  30017. fields = append(fields, usagetotal.FieldType)
  30018. }
  30019. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  30020. fields = append(fields, usagetotal.FieldTotalTokens)
  30021. }
  30022. if m.FieldCleared(usagetotal.FieldStartIndex) {
  30023. fields = append(fields, usagetotal.FieldStartIndex)
  30024. }
  30025. if m.FieldCleared(usagetotal.FieldEndIndex) {
  30026. fields = append(fields, usagetotal.FieldEndIndex)
  30027. }
  30028. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  30029. fields = append(fields, usagetotal.FieldOrganizationID)
  30030. }
  30031. return fields
  30032. }
  30033. // FieldCleared returns a boolean indicating if a field with the given name was
  30034. // cleared in this mutation.
  30035. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  30036. _, ok := m.clearedFields[name]
  30037. return ok
  30038. }
  30039. // ClearField clears the value of the field with the given name. It returns an
  30040. // error if the field is not defined in the schema.
  30041. func (m *UsageTotalMutation) ClearField(name string) error {
  30042. switch name {
  30043. case usagetotal.FieldStatus:
  30044. m.ClearStatus()
  30045. return nil
  30046. case usagetotal.FieldType:
  30047. m.ClearType()
  30048. return nil
  30049. case usagetotal.FieldTotalTokens:
  30050. m.ClearTotalTokens()
  30051. return nil
  30052. case usagetotal.FieldStartIndex:
  30053. m.ClearStartIndex()
  30054. return nil
  30055. case usagetotal.FieldEndIndex:
  30056. m.ClearEndIndex()
  30057. return nil
  30058. case usagetotal.FieldOrganizationID:
  30059. m.ClearOrganizationID()
  30060. return nil
  30061. }
  30062. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  30063. }
  30064. // ResetField resets all changes in the mutation for the field with the given name.
  30065. // It returns an error if the field is not defined in the schema.
  30066. func (m *UsageTotalMutation) ResetField(name string) error {
  30067. switch name {
  30068. case usagetotal.FieldCreatedAt:
  30069. m.ResetCreatedAt()
  30070. return nil
  30071. case usagetotal.FieldUpdatedAt:
  30072. m.ResetUpdatedAt()
  30073. return nil
  30074. case usagetotal.FieldStatus:
  30075. m.ResetStatus()
  30076. return nil
  30077. case usagetotal.FieldType:
  30078. m.ResetType()
  30079. return nil
  30080. case usagetotal.FieldBotID:
  30081. m.ResetBotID()
  30082. return nil
  30083. case usagetotal.FieldTotalTokens:
  30084. m.ResetTotalTokens()
  30085. return nil
  30086. case usagetotal.FieldStartIndex:
  30087. m.ResetStartIndex()
  30088. return nil
  30089. case usagetotal.FieldEndIndex:
  30090. m.ResetEndIndex()
  30091. return nil
  30092. case usagetotal.FieldOrganizationID:
  30093. m.ResetOrganizationID()
  30094. return nil
  30095. }
  30096. return fmt.Errorf("unknown UsageTotal field %s", name)
  30097. }
  30098. // AddedEdges returns all edge names that were set/added in this mutation.
  30099. func (m *UsageTotalMutation) AddedEdges() []string {
  30100. edges := make([]string, 0, 0)
  30101. return edges
  30102. }
  30103. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30104. // name in this mutation.
  30105. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  30106. return nil
  30107. }
  30108. // RemovedEdges returns all edge names that were removed in this mutation.
  30109. func (m *UsageTotalMutation) RemovedEdges() []string {
  30110. edges := make([]string, 0, 0)
  30111. return edges
  30112. }
  30113. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30114. // the given name in this mutation.
  30115. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  30116. return nil
  30117. }
  30118. // ClearedEdges returns all edge names that were cleared in this mutation.
  30119. func (m *UsageTotalMutation) ClearedEdges() []string {
  30120. edges := make([]string, 0, 0)
  30121. return edges
  30122. }
  30123. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30124. // was cleared in this mutation.
  30125. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  30126. return false
  30127. }
  30128. // ClearEdge clears the value of the edge with the given name. It returns an error
  30129. // if that edge is not defined in the schema.
  30130. func (m *UsageTotalMutation) ClearEdge(name string) error {
  30131. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  30132. }
  30133. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30134. // It returns an error if the edge is not defined in the schema.
  30135. func (m *UsageTotalMutation) ResetEdge(name string) error {
  30136. return fmt.Errorf("unknown UsageTotal edge %s", name)
  30137. }
  30138. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  30139. type WorkExperienceMutation struct {
  30140. config
  30141. op Op
  30142. typ string
  30143. id *uint64
  30144. created_at *time.Time
  30145. updated_at *time.Time
  30146. deleted_at *time.Time
  30147. start_date *time.Time
  30148. end_date *time.Time
  30149. company *string
  30150. experience *string
  30151. organization_id *uint64
  30152. addorganization_id *int64
  30153. clearedFields map[string]struct{}
  30154. employee *uint64
  30155. clearedemployee bool
  30156. done bool
  30157. oldValue func(context.Context) (*WorkExperience, error)
  30158. predicates []predicate.WorkExperience
  30159. }
  30160. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  30161. // workexperienceOption allows management of the mutation configuration using functional options.
  30162. type workexperienceOption func(*WorkExperienceMutation)
  30163. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  30164. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  30165. m := &WorkExperienceMutation{
  30166. config: c,
  30167. op: op,
  30168. typ: TypeWorkExperience,
  30169. clearedFields: make(map[string]struct{}),
  30170. }
  30171. for _, opt := range opts {
  30172. opt(m)
  30173. }
  30174. return m
  30175. }
  30176. // withWorkExperienceID sets the ID field of the mutation.
  30177. func withWorkExperienceID(id uint64) workexperienceOption {
  30178. return func(m *WorkExperienceMutation) {
  30179. var (
  30180. err error
  30181. once sync.Once
  30182. value *WorkExperience
  30183. )
  30184. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  30185. once.Do(func() {
  30186. if m.done {
  30187. err = errors.New("querying old values post mutation is not allowed")
  30188. } else {
  30189. value, err = m.Client().WorkExperience.Get(ctx, id)
  30190. }
  30191. })
  30192. return value, err
  30193. }
  30194. m.id = &id
  30195. }
  30196. }
  30197. // withWorkExperience sets the old WorkExperience of the mutation.
  30198. func withWorkExperience(node *WorkExperience) workexperienceOption {
  30199. return func(m *WorkExperienceMutation) {
  30200. m.oldValue = func(context.Context) (*WorkExperience, error) {
  30201. return node, nil
  30202. }
  30203. m.id = &node.ID
  30204. }
  30205. }
  30206. // Client returns a new `ent.Client` from the mutation. If the mutation was
  30207. // executed in a transaction (ent.Tx), a transactional client is returned.
  30208. func (m WorkExperienceMutation) Client() *Client {
  30209. client := &Client{config: m.config}
  30210. client.init()
  30211. return client
  30212. }
  30213. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  30214. // it returns an error otherwise.
  30215. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  30216. if _, ok := m.driver.(*txDriver); !ok {
  30217. return nil, errors.New("ent: mutation is not running in a transaction")
  30218. }
  30219. tx := &Tx{config: m.config}
  30220. tx.init()
  30221. return tx, nil
  30222. }
  30223. // SetID sets the value of the id field. Note that this
  30224. // operation is only accepted on creation of WorkExperience entities.
  30225. func (m *WorkExperienceMutation) SetID(id uint64) {
  30226. m.id = &id
  30227. }
  30228. // ID returns the ID value in the mutation. Note that the ID is only available
  30229. // if it was provided to the builder or after it was returned from the database.
  30230. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  30231. if m.id == nil {
  30232. return
  30233. }
  30234. return *m.id, true
  30235. }
  30236. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  30237. // That means, if the mutation is applied within a transaction with an isolation level such
  30238. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  30239. // or updated by the mutation.
  30240. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  30241. switch {
  30242. case m.op.Is(OpUpdateOne | OpDeleteOne):
  30243. id, exists := m.ID()
  30244. if exists {
  30245. return []uint64{id}, nil
  30246. }
  30247. fallthrough
  30248. case m.op.Is(OpUpdate | OpDelete):
  30249. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  30250. default:
  30251. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  30252. }
  30253. }
  30254. // SetCreatedAt sets the "created_at" field.
  30255. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  30256. m.created_at = &t
  30257. }
  30258. // CreatedAt returns the value of the "created_at" field in the mutation.
  30259. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  30260. v := m.created_at
  30261. if v == nil {
  30262. return
  30263. }
  30264. return *v, true
  30265. }
  30266. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  30267. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  30268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30269. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  30270. if !m.op.Is(OpUpdateOne) {
  30271. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  30272. }
  30273. if m.id == nil || m.oldValue == nil {
  30274. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  30275. }
  30276. oldValue, err := m.oldValue(ctx)
  30277. if err != nil {
  30278. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  30279. }
  30280. return oldValue.CreatedAt, nil
  30281. }
  30282. // ResetCreatedAt resets all changes to the "created_at" field.
  30283. func (m *WorkExperienceMutation) ResetCreatedAt() {
  30284. m.created_at = nil
  30285. }
  30286. // SetUpdatedAt sets the "updated_at" field.
  30287. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  30288. m.updated_at = &t
  30289. }
  30290. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  30291. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  30292. v := m.updated_at
  30293. if v == nil {
  30294. return
  30295. }
  30296. return *v, true
  30297. }
  30298. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  30299. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  30300. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30301. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  30302. if !m.op.Is(OpUpdateOne) {
  30303. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  30304. }
  30305. if m.id == nil || m.oldValue == nil {
  30306. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  30307. }
  30308. oldValue, err := m.oldValue(ctx)
  30309. if err != nil {
  30310. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  30311. }
  30312. return oldValue.UpdatedAt, nil
  30313. }
  30314. // ResetUpdatedAt resets all changes to the "updated_at" field.
  30315. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  30316. m.updated_at = nil
  30317. }
  30318. // SetDeletedAt sets the "deleted_at" field.
  30319. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  30320. m.deleted_at = &t
  30321. }
  30322. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  30323. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  30324. v := m.deleted_at
  30325. if v == nil {
  30326. return
  30327. }
  30328. return *v, true
  30329. }
  30330. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  30331. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  30332. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30333. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  30334. if !m.op.Is(OpUpdateOne) {
  30335. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  30336. }
  30337. if m.id == nil || m.oldValue == nil {
  30338. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  30339. }
  30340. oldValue, err := m.oldValue(ctx)
  30341. if err != nil {
  30342. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  30343. }
  30344. return oldValue.DeletedAt, nil
  30345. }
  30346. // ClearDeletedAt clears the value of the "deleted_at" field.
  30347. func (m *WorkExperienceMutation) ClearDeletedAt() {
  30348. m.deleted_at = nil
  30349. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  30350. }
  30351. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  30352. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  30353. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  30354. return ok
  30355. }
  30356. // ResetDeletedAt resets all changes to the "deleted_at" field.
  30357. func (m *WorkExperienceMutation) ResetDeletedAt() {
  30358. m.deleted_at = nil
  30359. delete(m.clearedFields, workexperience.FieldDeletedAt)
  30360. }
  30361. // SetEmployeeID sets the "employee_id" field.
  30362. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  30363. m.employee = &u
  30364. }
  30365. // EmployeeID returns the value of the "employee_id" field in the mutation.
  30366. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  30367. v := m.employee
  30368. if v == nil {
  30369. return
  30370. }
  30371. return *v, true
  30372. }
  30373. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  30374. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  30375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30376. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  30377. if !m.op.Is(OpUpdateOne) {
  30378. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  30379. }
  30380. if m.id == nil || m.oldValue == nil {
  30381. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  30382. }
  30383. oldValue, err := m.oldValue(ctx)
  30384. if err != nil {
  30385. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  30386. }
  30387. return oldValue.EmployeeID, nil
  30388. }
  30389. // ResetEmployeeID resets all changes to the "employee_id" field.
  30390. func (m *WorkExperienceMutation) ResetEmployeeID() {
  30391. m.employee = nil
  30392. }
  30393. // SetStartDate sets the "start_date" field.
  30394. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  30395. m.start_date = &t
  30396. }
  30397. // StartDate returns the value of the "start_date" field in the mutation.
  30398. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  30399. v := m.start_date
  30400. if v == nil {
  30401. return
  30402. }
  30403. return *v, true
  30404. }
  30405. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  30406. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  30407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30408. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  30409. if !m.op.Is(OpUpdateOne) {
  30410. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  30411. }
  30412. if m.id == nil || m.oldValue == nil {
  30413. return v, errors.New("OldStartDate requires an ID field in the mutation")
  30414. }
  30415. oldValue, err := m.oldValue(ctx)
  30416. if err != nil {
  30417. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  30418. }
  30419. return oldValue.StartDate, nil
  30420. }
  30421. // ResetStartDate resets all changes to the "start_date" field.
  30422. func (m *WorkExperienceMutation) ResetStartDate() {
  30423. m.start_date = nil
  30424. }
  30425. // SetEndDate sets the "end_date" field.
  30426. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  30427. m.end_date = &t
  30428. }
  30429. // EndDate returns the value of the "end_date" field in the mutation.
  30430. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  30431. v := m.end_date
  30432. if v == nil {
  30433. return
  30434. }
  30435. return *v, true
  30436. }
  30437. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  30438. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  30439. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30440. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  30441. if !m.op.Is(OpUpdateOne) {
  30442. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  30443. }
  30444. if m.id == nil || m.oldValue == nil {
  30445. return v, errors.New("OldEndDate requires an ID field in the mutation")
  30446. }
  30447. oldValue, err := m.oldValue(ctx)
  30448. if err != nil {
  30449. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  30450. }
  30451. return oldValue.EndDate, nil
  30452. }
  30453. // ResetEndDate resets all changes to the "end_date" field.
  30454. func (m *WorkExperienceMutation) ResetEndDate() {
  30455. m.end_date = nil
  30456. }
  30457. // SetCompany sets the "company" field.
  30458. func (m *WorkExperienceMutation) SetCompany(s string) {
  30459. m.company = &s
  30460. }
  30461. // Company returns the value of the "company" field in the mutation.
  30462. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  30463. v := m.company
  30464. if v == nil {
  30465. return
  30466. }
  30467. return *v, true
  30468. }
  30469. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  30470. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  30471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30472. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  30473. if !m.op.Is(OpUpdateOne) {
  30474. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  30475. }
  30476. if m.id == nil || m.oldValue == nil {
  30477. return v, errors.New("OldCompany requires an ID field in the mutation")
  30478. }
  30479. oldValue, err := m.oldValue(ctx)
  30480. if err != nil {
  30481. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  30482. }
  30483. return oldValue.Company, nil
  30484. }
  30485. // ResetCompany resets all changes to the "company" field.
  30486. func (m *WorkExperienceMutation) ResetCompany() {
  30487. m.company = nil
  30488. }
  30489. // SetExperience sets the "experience" field.
  30490. func (m *WorkExperienceMutation) SetExperience(s string) {
  30491. m.experience = &s
  30492. }
  30493. // Experience returns the value of the "experience" field in the mutation.
  30494. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  30495. v := m.experience
  30496. if v == nil {
  30497. return
  30498. }
  30499. return *v, true
  30500. }
  30501. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  30502. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  30503. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30504. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  30505. if !m.op.Is(OpUpdateOne) {
  30506. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  30507. }
  30508. if m.id == nil || m.oldValue == nil {
  30509. return v, errors.New("OldExperience requires an ID field in the mutation")
  30510. }
  30511. oldValue, err := m.oldValue(ctx)
  30512. if err != nil {
  30513. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  30514. }
  30515. return oldValue.Experience, nil
  30516. }
  30517. // ResetExperience resets all changes to the "experience" field.
  30518. func (m *WorkExperienceMutation) ResetExperience() {
  30519. m.experience = nil
  30520. }
  30521. // SetOrganizationID sets the "organization_id" field.
  30522. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  30523. m.organization_id = &u
  30524. m.addorganization_id = nil
  30525. }
  30526. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30527. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  30528. v := m.organization_id
  30529. if v == nil {
  30530. return
  30531. }
  30532. return *v, true
  30533. }
  30534. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  30535. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  30536. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30537. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30538. if !m.op.Is(OpUpdateOne) {
  30539. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30540. }
  30541. if m.id == nil || m.oldValue == nil {
  30542. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30543. }
  30544. oldValue, err := m.oldValue(ctx)
  30545. if err != nil {
  30546. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30547. }
  30548. return oldValue.OrganizationID, nil
  30549. }
  30550. // AddOrganizationID adds u to the "organization_id" field.
  30551. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  30552. if m.addorganization_id != nil {
  30553. *m.addorganization_id += u
  30554. } else {
  30555. m.addorganization_id = &u
  30556. }
  30557. }
  30558. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30559. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  30560. v := m.addorganization_id
  30561. if v == nil {
  30562. return
  30563. }
  30564. return *v, true
  30565. }
  30566. // ResetOrganizationID resets all changes to the "organization_id" field.
  30567. func (m *WorkExperienceMutation) ResetOrganizationID() {
  30568. m.organization_id = nil
  30569. m.addorganization_id = nil
  30570. }
  30571. // ClearEmployee clears the "employee" edge to the Employee entity.
  30572. func (m *WorkExperienceMutation) ClearEmployee() {
  30573. m.clearedemployee = true
  30574. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  30575. }
  30576. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  30577. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  30578. return m.clearedemployee
  30579. }
  30580. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  30581. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  30582. // EmployeeID instead. It exists only for internal usage by the builders.
  30583. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  30584. if id := m.employee; id != nil {
  30585. ids = append(ids, *id)
  30586. }
  30587. return
  30588. }
  30589. // ResetEmployee resets all changes to the "employee" edge.
  30590. func (m *WorkExperienceMutation) ResetEmployee() {
  30591. m.employee = nil
  30592. m.clearedemployee = false
  30593. }
  30594. // Where appends a list predicates to the WorkExperienceMutation builder.
  30595. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  30596. m.predicates = append(m.predicates, ps...)
  30597. }
  30598. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  30599. // users can use type-assertion to append predicates that do not depend on any generated package.
  30600. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  30601. p := make([]predicate.WorkExperience, len(ps))
  30602. for i := range ps {
  30603. p[i] = ps[i]
  30604. }
  30605. m.Where(p...)
  30606. }
  30607. // Op returns the operation name.
  30608. func (m *WorkExperienceMutation) Op() Op {
  30609. return m.op
  30610. }
  30611. // SetOp allows setting the mutation operation.
  30612. func (m *WorkExperienceMutation) SetOp(op Op) {
  30613. m.op = op
  30614. }
  30615. // Type returns the node type of this mutation (WorkExperience).
  30616. func (m *WorkExperienceMutation) Type() string {
  30617. return m.typ
  30618. }
  30619. // Fields returns all fields that were changed during this mutation. Note that in
  30620. // order to get all numeric fields that were incremented/decremented, call
  30621. // AddedFields().
  30622. func (m *WorkExperienceMutation) Fields() []string {
  30623. fields := make([]string, 0, 9)
  30624. if m.created_at != nil {
  30625. fields = append(fields, workexperience.FieldCreatedAt)
  30626. }
  30627. if m.updated_at != nil {
  30628. fields = append(fields, workexperience.FieldUpdatedAt)
  30629. }
  30630. if m.deleted_at != nil {
  30631. fields = append(fields, workexperience.FieldDeletedAt)
  30632. }
  30633. if m.employee != nil {
  30634. fields = append(fields, workexperience.FieldEmployeeID)
  30635. }
  30636. if m.start_date != nil {
  30637. fields = append(fields, workexperience.FieldStartDate)
  30638. }
  30639. if m.end_date != nil {
  30640. fields = append(fields, workexperience.FieldEndDate)
  30641. }
  30642. if m.company != nil {
  30643. fields = append(fields, workexperience.FieldCompany)
  30644. }
  30645. if m.experience != nil {
  30646. fields = append(fields, workexperience.FieldExperience)
  30647. }
  30648. if m.organization_id != nil {
  30649. fields = append(fields, workexperience.FieldOrganizationID)
  30650. }
  30651. return fields
  30652. }
  30653. // Field returns the value of a field with the given name. The second boolean
  30654. // return value indicates that this field was not set, or was not defined in the
  30655. // schema.
  30656. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  30657. switch name {
  30658. case workexperience.FieldCreatedAt:
  30659. return m.CreatedAt()
  30660. case workexperience.FieldUpdatedAt:
  30661. return m.UpdatedAt()
  30662. case workexperience.FieldDeletedAt:
  30663. return m.DeletedAt()
  30664. case workexperience.FieldEmployeeID:
  30665. return m.EmployeeID()
  30666. case workexperience.FieldStartDate:
  30667. return m.StartDate()
  30668. case workexperience.FieldEndDate:
  30669. return m.EndDate()
  30670. case workexperience.FieldCompany:
  30671. return m.Company()
  30672. case workexperience.FieldExperience:
  30673. return m.Experience()
  30674. case workexperience.FieldOrganizationID:
  30675. return m.OrganizationID()
  30676. }
  30677. return nil, false
  30678. }
  30679. // OldField returns the old value of the field from the database. An error is
  30680. // returned if the mutation operation is not UpdateOne, or the query to the
  30681. // database failed.
  30682. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30683. switch name {
  30684. case workexperience.FieldCreatedAt:
  30685. return m.OldCreatedAt(ctx)
  30686. case workexperience.FieldUpdatedAt:
  30687. return m.OldUpdatedAt(ctx)
  30688. case workexperience.FieldDeletedAt:
  30689. return m.OldDeletedAt(ctx)
  30690. case workexperience.FieldEmployeeID:
  30691. return m.OldEmployeeID(ctx)
  30692. case workexperience.FieldStartDate:
  30693. return m.OldStartDate(ctx)
  30694. case workexperience.FieldEndDate:
  30695. return m.OldEndDate(ctx)
  30696. case workexperience.FieldCompany:
  30697. return m.OldCompany(ctx)
  30698. case workexperience.FieldExperience:
  30699. return m.OldExperience(ctx)
  30700. case workexperience.FieldOrganizationID:
  30701. return m.OldOrganizationID(ctx)
  30702. }
  30703. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  30704. }
  30705. // SetField sets the value of a field with the given name. It returns an error if
  30706. // the field is not defined in the schema, or if the type mismatched the field
  30707. // type.
  30708. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  30709. switch name {
  30710. case workexperience.FieldCreatedAt:
  30711. v, ok := value.(time.Time)
  30712. if !ok {
  30713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30714. }
  30715. m.SetCreatedAt(v)
  30716. return nil
  30717. case workexperience.FieldUpdatedAt:
  30718. v, ok := value.(time.Time)
  30719. if !ok {
  30720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30721. }
  30722. m.SetUpdatedAt(v)
  30723. return nil
  30724. case workexperience.FieldDeletedAt:
  30725. v, ok := value.(time.Time)
  30726. if !ok {
  30727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30728. }
  30729. m.SetDeletedAt(v)
  30730. return nil
  30731. case workexperience.FieldEmployeeID:
  30732. v, ok := value.(uint64)
  30733. if !ok {
  30734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30735. }
  30736. m.SetEmployeeID(v)
  30737. return nil
  30738. case workexperience.FieldStartDate:
  30739. v, ok := value.(time.Time)
  30740. if !ok {
  30741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30742. }
  30743. m.SetStartDate(v)
  30744. return nil
  30745. case workexperience.FieldEndDate:
  30746. v, ok := value.(time.Time)
  30747. if !ok {
  30748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30749. }
  30750. m.SetEndDate(v)
  30751. return nil
  30752. case workexperience.FieldCompany:
  30753. v, ok := value.(string)
  30754. if !ok {
  30755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30756. }
  30757. m.SetCompany(v)
  30758. return nil
  30759. case workexperience.FieldExperience:
  30760. v, ok := value.(string)
  30761. if !ok {
  30762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30763. }
  30764. m.SetExperience(v)
  30765. return nil
  30766. case workexperience.FieldOrganizationID:
  30767. v, ok := value.(uint64)
  30768. if !ok {
  30769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30770. }
  30771. m.SetOrganizationID(v)
  30772. return nil
  30773. }
  30774. return fmt.Errorf("unknown WorkExperience field %s", name)
  30775. }
  30776. // AddedFields returns all numeric fields that were incremented/decremented during
  30777. // this mutation.
  30778. func (m *WorkExperienceMutation) AddedFields() []string {
  30779. var fields []string
  30780. if m.addorganization_id != nil {
  30781. fields = append(fields, workexperience.FieldOrganizationID)
  30782. }
  30783. return fields
  30784. }
  30785. // AddedField returns the numeric value that was incremented/decremented on a field
  30786. // with the given name. The second boolean return value indicates that this field
  30787. // was not set, or was not defined in the schema.
  30788. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  30789. switch name {
  30790. case workexperience.FieldOrganizationID:
  30791. return m.AddedOrganizationID()
  30792. }
  30793. return nil, false
  30794. }
  30795. // AddField adds the value to the field with the given name. It returns an error if
  30796. // the field is not defined in the schema, or if the type mismatched the field
  30797. // type.
  30798. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  30799. switch name {
  30800. case workexperience.FieldOrganizationID:
  30801. v, ok := value.(int64)
  30802. if !ok {
  30803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30804. }
  30805. m.AddOrganizationID(v)
  30806. return nil
  30807. }
  30808. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  30809. }
  30810. // ClearedFields returns all nullable fields that were cleared during this
  30811. // mutation.
  30812. func (m *WorkExperienceMutation) ClearedFields() []string {
  30813. var fields []string
  30814. if m.FieldCleared(workexperience.FieldDeletedAt) {
  30815. fields = append(fields, workexperience.FieldDeletedAt)
  30816. }
  30817. return fields
  30818. }
  30819. // FieldCleared returns a boolean indicating if a field with the given name was
  30820. // cleared in this mutation.
  30821. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  30822. _, ok := m.clearedFields[name]
  30823. return ok
  30824. }
  30825. // ClearField clears the value of the field with the given name. It returns an
  30826. // error if the field is not defined in the schema.
  30827. func (m *WorkExperienceMutation) ClearField(name string) error {
  30828. switch name {
  30829. case workexperience.FieldDeletedAt:
  30830. m.ClearDeletedAt()
  30831. return nil
  30832. }
  30833. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  30834. }
  30835. // ResetField resets all changes in the mutation for the field with the given name.
  30836. // It returns an error if the field is not defined in the schema.
  30837. func (m *WorkExperienceMutation) ResetField(name string) error {
  30838. switch name {
  30839. case workexperience.FieldCreatedAt:
  30840. m.ResetCreatedAt()
  30841. return nil
  30842. case workexperience.FieldUpdatedAt:
  30843. m.ResetUpdatedAt()
  30844. return nil
  30845. case workexperience.FieldDeletedAt:
  30846. m.ResetDeletedAt()
  30847. return nil
  30848. case workexperience.FieldEmployeeID:
  30849. m.ResetEmployeeID()
  30850. return nil
  30851. case workexperience.FieldStartDate:
  30852. m.ResetStartDate()
  30853. return nil
  30854. case workexperience.FieldEndDate:
  30855. m.ResetEndDate()
  30856. return nil
  30857. case workexperience.FieldCompany:
  30858. m.ResetCompany()
  30859. return nil
  30860. case workexperience.FieldExperience:
  30861. m.ResetExperience()
  30862. return nil
  30863. case workexperience.FieldOrganizationID:
  30864. m.ResetOrganizationID()
  30865. return nil
  30866. }
  30867. return fmt.Errorf("unknown WorkExperience field %s", name)
  30868. }
  30869. // AddedEdges returns all edge names that were set/added in this mutation.
  30870. func (m *WorkExperienceMutation) AddedEdges() []string {
  30871. edges := make([]string, 0, 1)
  30872. if m.employee != nil {
  30873. edges = append(edges, workexperience.EdgeEmployee)
  30874. }
  30875. return edges
  30876. }
  30877. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  30878. // name in this mutation.
  30879. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  30880. switch name {
  30881. case workexperience.EdgeEmployee:
  30882. if id := m.employee; id != nil {
  30883. return []ent.Value{*id}
  30884. }
  30885. }
  30886. return nil
  30887. }
  30888. // RemovedEdges returns all edge names that were removed in this mutation.
  30889. func (m *WorkExperienceMutation) RemovedEdges() []string {
  30890. edges := make([]string, 0, 1)
  30891. return edges
  30892. }
  30893. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  30894. // the given name in this mutation.
  30895. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  30896. return nil
  30897. }
  30898. // ClearedEdges returns all edge names that were cleared in this mutation.
  30899. func (m *WorkExperienceMutation) ClearedEdges() []string {
  30900. edges := make([]string, 0, 1)
  30901. if m.clearedemployee {
  30902. edges = append(edges, workexperience.EdgeEmployee)
  30903. }
  30904. return edges
  30905. }
  30906. // EdgeCleared returns a boolean which indicates if the edge with the given name
  30907. // was cleared in this mutation.
  30908. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  30909. switch name {
  30910. case workexperience.EdgeEmployee:
  30911. return m.clearedemployee
  30912. }
  30913. return false
  30914. }
  30915. // ClearEdge clears the value of the edge with the given name. It returns an error
  30916. // if that edge is not defined in the schema.
  30917. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  30918. switch name {
  30919. case workexperience.EdgeEmployee:
  30920. m.ClearEmployee()
  30921. return nil
  30922. }
  30923. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  30924. }
  30925. // ResetEdge resets all changes to the edge with the given name in this mutation.
  30926. // It returns an error if the edge is not defined in the schema.
  30927. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  30928. switch name {
  30929. case workexperience.EdgeEmployee:
  30930. m.ResetEmployee()
  30931. return nil
  30932. }
  30933. return fmt.Errorf("unknown WorkExperience edge %s", name)
  30934. }
  30935. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  30936. type WpChatroomMutation struct {
  30937. config
  30938. op Op
  30939. typ string
  30940. id *uint64
  30941. created_at *time.Time
  30942. updated_at *time.Time
  30943. status *uint8
  30944. addstatus *int8
  30945. wx_wxid *string
  30946. chatroom_id *string
  30947. nickname *string
  30948. owner *string
  30949. avatar *string
  30950. member_list *[]string
  30951. appendmember_list []string
  30952. clearedFields map[string]struct{}
  30953. done bool
  30954. oldValue func(context.Context) (*WpChatroom, error)
  30955. predicates []predicate.WpChatroom
  30956. }
  30957. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  30958. // wpchatroomOption allows management of the mutation configuration using functional options.
  30959. type wpchatroomOption func(*WpChatroomMutation)
  30960. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  30961. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  30962. m := &WpChatroomMutation{
  30963. config: c,
  30964. op: op,
  30965. typ: TypeWpChatroom,
  30966. clearedFields: make(map[string]struct{}),
  30967. }
  30968. for _, opt := range opts {
  30969. opt(m)
  30970. }
  30971. return m
  30972. }
  30973. // withWpChatroomID sets the ID field of the mutation.
  30974. func withWpChatroomID(id uint64) wpchatroomOption {
  30975. return func(m *WpChatroomMutation) {
  30976. var (
  30977. err error
  30978. once sync.Once
  30979. value *WpChatroom
  30980. )
  30981. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  30982. once.Do(func() {
  30983. if m.done {
  30984. err = errors.New("querying old values post mutation is not allowed")
  30985. } else {
  30986. value, err = m.Client().WpChatroom.Get(ctx, id)
  30987. }
  30988. })
  30989. return value, err
  30990. }
  30991. m.id = &id
  30992. }
  30993. }
  30994. // withWpChatroom sets the old WpChatroom of the mutation.
  30995. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  30996. return func(m *WpChatroomMutation) {
  30997. m.oldValue = func(context.Context) (*WpChatroom, error) {
  30998. return node, nil
  30999. }
  31000. m.id = &node.ID
  31001. }
  31002. }
  31003. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31004. // executed in a transaction (ent.Tx), a transactional client is returned.
  31005. func (m WpChatroomMutation) Client() *Client {
  31006. client := &Client{config: m.config}
  31007. client.init()
  31008. return client
  31009. }
  31010. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31011. // it returns an error otherwise.
  31012. func (m WpChatroomMutation) Tx() (*Tx, error) {
  31013. if _, ok := m.driver.(*txDriver); !ok {
  31014. return nil, errors.New("ent: mutation is not running in a transaction")
  31015. }
  31016. tx := &Tx{config: m.config}
  31017. tx.init()
  31018. return tx, nil
  31019. }
  31020. // SetID sets the value of the id field. Note that this
  31021. // operation is only accepted on creation of WpChatroom entities.
  31022. func (m *WpChatroomMutation) SetID(id uint64) {
  31023. m.id = &id
  31024. }
  31025. // ID returns the ID value in the mutation. Note that the ID is only available
  31026. // if it was provided to the builder or after it was returned from the database.
  31027. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  31028. if m.id == nil {
  31029. return
  31030. }
  31031. return *m.id, true
  31032. }
  31033. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31034. // That means, if the mutation is applied within a transaction with an isolation level such
  31035. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31036. // or updated by the mutation.
  31037. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  31038. switch {
  31039. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31040. id, exists := m.ID()
  31041. if exists {
  31042. return []uint64{id}, nil
  31043. }
  31044. fallthrough
  31045. case m.op.Is(OpUpdate | OpDelete):
  31046. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  31047. default:
  31048. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31049. }
  31050. }
  31051. // SetCreatedAt sets the "created_at" field.
  31052. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  31053. m.created_at = &t
  31054. }
  31055. // CreatedAt returns the value of the "created_at" field in the mutation.
  31056. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  31057. v := m.created_at
  31058. if v == nil {
  31059. return
  31060. }
  31061. return *v, true
  31062. }
  31063. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  31064. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31066. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31067. if !m.op.Is(OpUpdateOne) {
  31068. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31069. }
  31070. if m.id == nil || m.oldValue == nil {
  31071. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31072. }
  31073. oldValue, err := m.oldValue(ctx)
  31074. if err != nil {
  31075. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31076. }
  31077. return oldValue.CreatedAt, nil
  31078. }
  31079. // ResetCreatedAt resets all changes to the "created_at" field.
  31080. func (m *WpChatroomMutation) ResetCreatedAt() {
  31081. m.created_at = nil
  31082. }
  31083. // SetUpdatedAt sets the "updated_at" field.
  31084. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  31085. m.updated_at = &t
  31086. }
  31087. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31088. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  31089. v := m.updated_at
  31090. if v == nil {
  31091. return
  31092. }
  31093. return *v, true
  31094. }
  31095. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  31096. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31097. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31098. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31099. if !m.op.Is(OpUpdateOne) {
  31100. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31101. }
  31102. if m.id == nil || m.oldValue == nil {
  31103. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31104. }
  31105. oldValue, err := m.oldValue(ctx)
  31106. if err != nil {
  31107. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31108. }
  31109. return oldValue.UpdatedAt, nil
  31110. }
  31111. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31112. func (m *WpChatroomMutation) ResetUpdatedAt() {
  31113. m.updated_at = nil
  31114. }
  31115. // SetStatus sets the "status" field.
  31116. func (m *WpChatroomMutation) SetStatus(u uint8) {
  31117. m.status = &u
  31118. m.addstatus = nil
  31119. }
  31120. // Status returns the value of the "status" field in the mutation.
  31121. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  31122. v := m.status
  31123. if v == nil {
  31124. return
  31125. }
  31126. return *v, true
  31127. }
  31128. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  31129. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31130. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31131. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31132. if !m.op.Is(OpUpdateOne) {
  31133. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31134. }
  31135. if m.id == nil || m.oldValue == nil {
  31136. return v, errors.New("OldStatus requires an ID field in the mutation")
  31137. }
  31138. oldValue, err := m.oldValue(ctx)
  31139. if err != nil {
  31140. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31141. }
  31142. return oldValue.Status, nil
  31143. }
  31144. // AddStatus adds u to the "status" field.
  31145. func (m *WpChatroomMutation) AddStatus(u int8) {
  31146. if m.addstatus != nil {
  31147. *m.addstatus += u
  31148. } else {
  31149. m.addstatus = &u
  31150. }
  31151. }
  31152. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31153. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  31154. v := m.addstatus
  31155. if v == nil {
  31156. return
  31157. }
  31158. return *v, true
  31159. }
  31160. // ClearStatus clears the value of the "status" field.
  31161. func (m *WpChatroomMutation) ClearStatus() {
  31162. m.status = nil
  31163. m.addstatus = nil
  31164. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  31165. }
  31166. // StatusCleared returns if the "status" field was cleared in this mutation.
  31167. func (m *WpChatroomMutation) StatusCleared() bool {
  31168. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  31169. return ok
  31170. }
  31171. // ResetStatus resets all changes to the "status" field.
  31172. func (m *WpChatroomMutation) ResetStatus() {
  31173. m.status = nil
  31174. m.addstatus = nil
  31175. delete(m.clearedFields, wpchatroom.FieldStatus)
  31176. }
  31177. // SetWxWxid sets the "wx_wxid" field.
  31178. func (m *WpChatroomMutation) SetWxWxid(s string) {
  31179. m.wx_wxid = &s
  31180. }
  31181. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  31182. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  31183. v := m.wx_wxid
  31184. if v == nil {
  31185. return
  31186. }
  31187. return *v, true
  31188. }
  31189. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  31190. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31192. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  31193. if !m.op.Is(OpUpdateOne) {
  31194. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  31195. }
  31196. if m.id == nil || m.oldValue == nil {
  31197. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  31198. }
  31199. oldValue, err := m.oldValue(ctx)
  31200. if err != nil {
  31201. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  31202. }
  31203. return oldValue.WxWxid, nil
  31204. }
  31205. // ResetWxWxid resets all changes to the "wx_wxid" field.
  31206. func (m *WpChatroomMutation) ResetWxWxid() {
  31207. m.wx_wxid = nil
  31208. }
  31209. // SetChatroomID sets the "chatroom_id" field.
  31210. func (m *WpChatroomMutation) SetChatroomID(s string) {
  31211. m.chatroom_id = &s
  31212. }
  31213. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  31214. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  31215. v := m.chatroom_id
  31216. if v == nil {
  31217. return
  31218. }
  31219. return *v, true
  31220. }
  31221. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  31222. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31224. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  31225. if !m.op.Is(OpUpdateOne) {
  31226. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  31227. }
  31228. if m.id == nil || m.oldValue == nil {
  31229. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  31230. }
  31231. oldValue, err := m.oldValue(ctx)
  31232. if err != nil {
  31233. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  31234. }
  31235. return oldValue.ChatroomID, nil
  31236. }
  31237. // ResetChatroomID resets all changes to the "chatroom_id" field.
  31238. func (m *WpChatroomMutation) ResetChatroomID() {
  31239. m.chatroom_id = nil
  31240. }
  31241. // SetNickname sets the "nickname" field.
  31242. func (m *WpChatroomMutation) SetNickname(s string) {
  31243. m.nickname = &s
  31244. }
  31245. // Nickname returns the value of the "nickname" field in the mutation.
  31246. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  31247. v := m.nickname
  31248. if v == nil {
  31249. return
  31250. }
  31251. return *v, true
  31252. }
  31253. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  31254. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31256. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  31257. if !m.op.Is(OpUpdateOne) {
  31258. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  31259. }
  31260. if m.id == nil || m.oldValue == nil {
  31261. return v, errors.New("OldNickname requires an ID field in the mutation")
  31262. }
  31263. oldValue, err := m.oldValue(ctx)
  31264. if err != nil {
  31265. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  31266. }
  31267. return oldValue.Nickname, nil
  31268. }
  31269. // ResetNickname resets all changes to the "nickname" field.
  31270. func (m *WpChatroomMutation) ResetNickname() {
  31271. m.nickname = nil
  31272. }
  31273. // SetOwner sets the "owner" field.
  31274. func (m *WpChatroomMutation) SetOwner(s string) {
  31275. m.owner = &s
  31276. }
  31277. // Owner returns the value of the "owner" field in the mutation.
  31278. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  31279. v := m.owner
  31280. if v == nil {
  31281. return
  31282. }
  31283. return *v, true
  31284. }
  31285. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  31286. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31288. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  31289. if !m.op.Is(OpUpdateOne) {
  31290. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  31291. }
  31292. if m.id == nil || m.oldValue == nil {
  31293. return v, errors.New("OldOwner requires an ID field in the mutation")
  31294. }
  31295. oldValue, err := m.oldValue(ctx)
  31296. if err != nil {
  31297. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  31298. }
  31299. return oldValue.Owner, nil
  31300. }
  31301. // ResetOwner resets all changes to the "owner" field.
  31302. func (m *WpChatroomMutation) ResetOwner() {
  31303. m.owner = nil
  31304. }
  31305. // SetAvatar sets the "avatar" field.
  31306. func (m *WpChatroomMutation) SetAvatar(s string) {
  31307. m.avatar = &s
  31308. }
  31309. // Avatar returns the value of the "avatar" field in the mutation.
  31310. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  31311. v := m.avatar
  31312. if v == nil {
  31313. return
  31314. }
  31315. return *v, true
  31316. }
  31317. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  31318. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31320. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  31321. if !m.op.Is(OpUpdateOne) {
  31322. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  31323. }
  31324. if m.id == nil || m.oldValue == nil {
  31325. return v, errors.New("OldAvatar requires an ID field in the mutation")
  31326. }
  31327. oldValue, err := m.oldValue(ctx)
  31328. if err != nil {
  31329. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  31330. }
  31331. return oldValue.Avatar, nil
  31332. }
  31333. // ResetAvatar resets all changes to the "avatar" field.
  31334. func (m *WpChatroomMutation) ResetAvatar() {
  31335. m.avatar = nil
  31336. }
  31337. // SetMemberList sets the "member_list" field.
  31338. func (m *WpChatroomMutation) SetMemberList(s []string) {
  31339. m.member_list = &s
  31340. m.appendmember_list = nil
  31341. }
  31342. // MemberList returns the value of the "member_list" field in the mutation.
  31343. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  31344. v := m.member_list
  31345. if v == nil {
  31346. return
  31347. }
  31348. return *v, true
  31349. }
  31350. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  31351. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  31352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31353. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  31354. if !m.op.Is(OpUpdateOne) {
  31355. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  31356. }
  31357. if m.id == nil || m.oldValue == nil {
  31358. return v, errors.New("OldMemberList requires an ID field in the mutation")
  31359. }
  31360. oldValue, err := m.oldValue(ctx)
  31361. if err != nil {
  31362. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  31363. }
  31364. return oldValue.MemberList, nil
  31365. }
  31366. // AppendMemberList adds s to the "member_list" field.
  31367. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  31368. m.appendmember_list = append(m.appendmember_list, s...)
  31369. }
  31370. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  31371. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  31372. if len(m.appendmember_list) == 0 {
  31373. return nil, false
  31374. }
  31375. return m.appendmember_list, true
  31376. }
  31377. // ResetMemberList resets all changes to the "member_list" field.
  31378. func (m *WpChatroomMutation) ResetMemberList() {
  31379. m.member_list = nil
  31380. m.appendmember_list = nil
  31381. }
  31382. // Where appends a list predicates to the WpChatroomMutation builder.
  31383. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  31384. m.predicates = append(m.predicates, ps...)
  31385. }
  31386. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  31387. // users can use type-assertion to append predicates that do not depend on any generated package.
  31388. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  31389. p := make([]predicate.WpChatroom, len(ps))
  31390. for i := range ps {
  31391. p[i] = ps[i]
  31392. }
  31393. m.Where(p...)
  31394. }
  31395. // Op returns the operation name.
  31396. func (m *WpChatroomMutation) Op() Op {
  31397. return m.op
  31398. }
  31399. // SetOp allows setting the mutation operation.
  31400. func (m *WpChatroomMutation) SetOp(op Op) {
  31401. m.op = op
  31402. }
  31403. // Type returns the node type of this mutation (WpChatroom).
  31404. func (m *WpChatroomMutation) Type() string {
  31405. return m.typ
  31406. }
  31407. // Fields returns all fields that were changed during this mutation. Note that in
  31408. // order to get all numeric fields that were incremented/decremented, call
  31409. // AddedFields().
  31410. func (m *WpChatroomMutation) Fields() []string {
  31411. fields := make([]string, 0, 9)
  31412. if m.created_at != nil {
  31413. fields = append(fields, wpchatroom.FieldCreatedAt)
  31414. }
  31415. if m.updated_at != nil {
  31416. fields = append(fields, wpchatroom.FieldUpdatedAt)
  31417. }
  31418. if m.status != nil {
  31419. fields = append(fields, wpchatroom.FieldStatus)
  31420. }
  31421. if m.wx_wxid != nil {
  31422. fields = append(fields, wpchatroom.FieldWxWxid)
  31423. }
  31424. if m.chatroom_id != nil {
  31425. fields = append(fields, wpchatroom.FieldChatroomID)
  31426. }
  31427. if m.nickname != nil {
  31428. fields = append(fields, wpchatroom.FieldNickname)
  31429. }
  31430. if m.owner != nil {
  31431. fields = append(fields, wpchatroom.FieldOwner)
  31432. }
  31433. if m.avatar != nil {
  31434. fields = append(fields, wpchatroom.FieldAvatar)
  31435. }
  31436. if m.member_list != nil {
  31437. fields = append(fields, wpchatroom.FieldMemberList)
  31438. }
  31439. return fields
  31440. }
  31441. // Field returns the value of a field with the given name. The second boolean
  31442. // return value indicates that this field was not set, or was not defined in the
  31443. // schema.
  31444. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  31445. switch name {
  31446. case wpchatroom.FieldCreatedAt:
  31447. return m.CreatedAt()
  31448. case wpchatroom.FieldUpdatedAt:
  31449. return m.UpdatedAt()
  31450. case wpchatroom.FieldStatus:
  31451. return m.Status()
  31452. case wpchatroom.FieldWxWxid:
  31453. return m.WxWxid()
  31454. case wpchatroom.FieldChatroomID:
  31455. return m.ChatroomID()
  31456. case wpchatroom.FieldNickname:
  31457. return m.Nickname()
  31458. case wpchatroom.FieldOwner:
  31459. return m.Owner()
  31460. case wpchatroom.FieldAvatar:
  31461. return m.Avatar()
  31462. case wpchatroom.FieldMemberList:
  31463. return m.MemberList()
  31464. }
  31465. return nil, false
  31466. }
  31467. // OldField returns the old value of the field from the database. An error is
  31468. // returned if the mutation operation is not UpdateOne, or the query to the
  31469. // database failed.
  31470. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  31471. switch name {
  31472. case wpchatroom.FieldCreatedAt:
  31473. return m.OldCreatedAt(ctx)
  31474. case wpchatroom.FieldUpdatedAt:
  31475. return m.OldUpdatedAt(ctx)
  31476. case wpchatroom.FieldStatus:
  31477. return m.OldStatus(ctx)
  31478. case wpchatroom.FieldWxWxid:
  31479. return m.OldWxWxid(ctx)
  31480. case wpchatroom.FieldChatroomID:
  31481. return m.OldChatroomID(ctx)
  31482. case wpchatroom.FieldNickname:
  31483. return m.OldNickname(ctx)
  31484. case wpchatroom.FieldOwner:
  31485. return m.OldOwner(ctx)
  31486. case wpchatroom.FieldAvatar:
  31487. return m.OldAvatar(ctx)
  31488. case wpchatroom.FieldMemberList:
  31489. return m.OldMemberList(ctx)
  31490. }
  31491. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  31492. }
  31493. // SetField sets the value of a field with the given name. It returns an error if
  31494. // the field is not defined in the schema, or if the type mismatched the field
  31495. // type.
  31496. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  31497. switch name {
  31498. case wpchatroom.FieldCreatedAt:
  31499. v, ok := value.(time.Time)
  31500. if !ok {
  31501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31502. }
  31503. m.SetCreatedAt(v)
  31504. return nil
  31505. case wpchatroom.FieldUpdatedAt:
  31506. v, ok := value.(time.Time)
  31507. if !ok {
  31508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31509. }
  31510. m.SetUpdatedAt(v)
  31511. return nil
  31512. case wpchatroom.FieldStatus:
  31513. v, ok := value.(uint8)
  31514. if !ok {
  31515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31516. }
  31517. m.SetStatus(v)
  31518. return nil
  31519. case wpchatroom.FieldWxWxid:
  31520. v, ok := value.(string)
  31521. if !ok {
  31522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31523. }
  31524. m.SetWxWxid(v)
  31525. return nil
  31526. case wpchatroom.FieldChatroomID:
  31527. v, ok := value.(string)
  31528. if !ok {
  31529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31530. }
  31531. m.SetChatroomID(v)
  31532. return nil
  31533. case wpchatroom.FieldNickname:
  31534. v, ok := value.(string)
  31535. if !ok {
  31536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31537. }
  31538. m.SetNickname(v)
  31539. return nil
  31540. case wpchatroom.FieldOwner:
  31541. v, ok := value.(string)
  31542. if !ok {
  31543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31544. }
  31545. m.SetOwner(v)
  31546. return nil
  31547. case wpchatroom.FieldAvatar:
  31548. v, ok := value.(string)
  31549. if !ok {
  31550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31551. }
  31552. m.SetAvatar(v)
  31553. return nil
  31554. case wpchatroom.FieldMemberList:
  31555. v, ok := value.([]string)
  31556. if !ok {
  31557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31558. }
  31559. m.SetMemberList(v)
  31560. return nil
  31561. }
  31562. return fmt.Errorf("unknown WpChatroom field %s", name)
  31563. }
  31564. // AddedFields returns all numeric fields that were incremented/decremented during
  31565. // this mutation.
  31566. func (m *WpChatroomMutation) AddedFields() []string {
  31567. var fields []string
  31568. if m.addstatus != nil {
  31569. fields = append(fields, wpchatroom.FieldStatus)
  31570. }
  31571. return fields
  31572. }
  31573. // AddedField returns the numeric value that was incremented/decremented on a field
  31574. // with the given name. The second boolean return value indicates that this field
  31575. // was not set, or was not defined in the schema.
  31576. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  31577. switch name {
  31578. case wpchatroom.FieldStatus:
  31579. return m.AddedStatus()
  31580. }
  31581. return nil, false
  31582. }
  31583. // AddField adds the value to the field with the given name. It returns an error if
  31584. // the field is not defined in the schema, or if the type mismatched the field
  31585. // type.
  31586. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  31587. switch name {
  31588. case wpchatroom.FieldStatus:
  31589. v, ok := value.(int8)
  31590. if !ok {
  31591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31592. }
  31593. m.AddStatus(v)
  31594. return nil
  31595. }
  31596. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  31597. }
  31598. // ClearedFields returns all nullable fields that were cleared during this
  31599. // mutation.
  31600. func (m *WpChatroomMutation) ClearedFields() []string {
  31601. var fields []string
  31602. if m.FieldCleared(wpchatroom.FieldStatus) {
  31603. fields = append(fields, wpchatroom.FieldStatus)
  31604. }
  31605. return fields
  31606. }
  31607. // FieldCleared returns a boolean indicating if a field with the given name was
  31608. // cleared in this mutation.
  31609. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  31610. _, ok := m.clearedFields[name]
  31611. return ok
  31612. }
  31613. // ClearField clears the value of the field with the given name. It returns an
  31614. // error if the field is not defined in the schema.
  31615. func (m *WpChatroomMutation) ClearField(name string) error {
  31616. switch name {
  31617. case wpchatroom.FieldStatus:
  31618. m.ClearStatus()
  31619. return nil
  31620. }
  31621. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  31622. }
  31623. // ResetField resets all changes in the mutation for the field with the given name.
  31624. // It returns an error if the field is not defined in the schema.
  31625. func (m *WpChatroomMutation) ResetField(name string) error {
  31626. switch name {
  31627. case wpchatroom.FieldCreatedAt:
  31628. m.ResetCreatedAt()
  31629. return nil
  31630. case wpchatroom.FieldUpdatedAt:
  31631. m.ResetUpdatedAt()
  31632. return nil
  31633. case wpchatroom.FieldStatus:
  31634. m.ResetStatus()
  31635. return nil
  31636. case wpchatroom.FieldWxWxid:
  31637. m.ResetWxWxid()
  31638. return nil
  31639. case wpchatroom.FieldChatroomID:
  31640. m.ResetChatroomID()
  31641. return nil
  31642. case wpchatroom.FieldNickname:
  31643. m.ResetNickname()
  31644. return nil
  31645. case wpchatroom.FieldOwner:
  31646. m.ResetOwner()
  31647. return nil
  31648. case wpchatroom.FieldAvatar:
  31649. m.ResetAvatar()
  31650. return nil
  31651. case wpchatroom.FieldMemberList:
  31652. m.ResetMemberList()
  31653. return nil
  31654. }
  31655. return fmt.Errorf("unknown WpChatroom field %s", name)
  31656. }
  31657. // AddedEdges returns all edge names that were set/added in this mutation.
  31658. func (m *WpChatroomMutation) AddedEdges() []string {
  31659. edges := make([]string, 0, 0)
  31660. return edges
  31661. }
  31662. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31663. // name in this mutation.
  31664. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  31665. return nil
  31666. }
  31667. // RemovedEdges returns all edge names that were removed in this mutation.
  31668. func (m *WpChatroomMutation) RemovedEdges() []string {
  31669. edges := make([]string, 0, 0)
  31670. return edges
  31671. }
  31672. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31673. // the given name in this mutation.
  31674. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  31675. return nil
  31676. }
  31677. // ClearedEdges returns all edge names that were cleared in this mutation.
  31678. func (m *WpChatroomMutation) ClearedEdges() []string {
  31679. edges := make([]string, 0, 0)
  31680. return edges
  31681. }
  31682. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31683. // was cleared in this mutation.
  31684. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  31685. return false
  31686. }
  31687. // ClearEdge clears the value of the edge with the given name. It returns an error
  31688. // if that edge is not defined in the schema.
  31689. func (m *WpChatroomMutation) ClearEdge(name string) error {
  31690. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  31691. }
  31692. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31693. // It returns an error if the edge is not defined in the schema.
  31694. func (m *WpChatroomMutation) ResetEdge(name string) error {
  31695. return fmt.Errorf("unknown WpChatroom edge %s", name)
  31696. }
  31697. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  31698. type WpChatroomMemberMutation struct {
  31699. config
  31700. op Op
  31701. typ string
  31702. id *uint64
  31703. created_at *time.Time
  31704. updated_at *time.Time
  31705. status *uint8
  31706. addstatus *int8
  31707. wx_wxid *string
  31708. wxid *string
  31709. nickname *string
  31710. avatar *string
  31711. clearedFields map[string]struct{}
  31712. done bool
  31713. oldValue func(context.Context) (*WpChatroomMember, error)
  31714. predicates []predicate.WpChatroomMember
  31715. }
  31716. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  31717. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  31718. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  31719. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  31720. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  31721. m := &WpChatroomMemberMutation{
  31722. config: c,
  31723. op: op,
  31724. typ: TypeWpChatroomMember,
  31725. clearedFields: make(map[string]struct{}),
  31726. }
  31727. for _, opt := range opts {
  31728. opt(m)
  31729. }
  31730. return m
  31731. }
  31732. // withWpChatroomMemberID sets the ID field of the mutation.
  31733. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  31734. return func(m *WpChatroomMemberMutation) {
  31735. var (
  31736. err error
  31737. once sync.Once
  31738. value *WpChatroomMember
  31739. )
  31740. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  31741. once.Do(func() {
  31742. if m.done {
  31743. err = errors.New("querying old values post mutation is not allowed")
  31744. } else {
  31745. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  31746. }
  31747. })
  31748. return value, err
  31749. }
  31750. m.id = &id
  31751. }
  31752. }
  31753. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  31754. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  31755. return func(m *WpChatroomMemberMutation) {
  31756. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  31757. return node, nil
  31758. }
  31759. m.id = &node.ID
  31760. }
  31761. }
  31762. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31763. // executed in a transaction (ent.Tx), a transactional client is returned.
  31764. func (m WpChatroomMemberMutation) Client() *Client {
  31765. client := &Client{config: m.config}
  31766. client.init()
  31767. return client
  31768. }
  31769. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31770. // it returns an error otherwise.
  31771. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  31772. if _, ok := m.driver.(*txDriver); !ok {
  31773. return nil, errors.New("ent: mutation is not running in a transaction")
  31774. }
  31775. tx := &Tx{config: m.config}
  31776. tx.init()
  31777. return tx, nil
  31778. }
  31779. // SetID sets the value of the id field. Note that this
  31780. // operation is only accepted on creation of WpChatroomMember entities.
  31781. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  31782. m.id = &id
  31783. }
  31784. // ID returns the ID value in the mutation. Note that the ID is only available
  31785. // if it was provided to the builder or after it was returned from the database.
  31786. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  31787. if m.id == nil {
  31788. return
  31789. }
  31790. return *m.id, true
  31791. }
  31792. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31793. // That means, if the mutation is applied within a transaction with an isolation level such
  31794. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31795. // or updated by the mutation.
  31796. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  31797. switch {
  31798. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31799. id, exists := m.ID()
  31800. if exists {
  31801. return []uint64{id}, nil
  31802. }
  31803. fallthrough
  31804. case m.op.Is(OpUpdate | OpDelete):
  31805. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  31806. default:
  31807. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31808. }
  31809. }
  31810. // SetCreatedAt sets the "created_at" field.
  31811. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  31812. m.created_at = &t
  31813. }
  31814. // CreatedAt returns the value of the "created_at" field in the mutation.
  31815. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  31816. v := m.created_at
  31817. if v == nil {
  31818. return
  31819. }
  31820. return *v, true
  31821. }
  31822. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  31823. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  31824. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31825. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31826. if !m.op.Is(OpUpdateOne) {
  31827. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31828. }
  31829. if m.id == nil || m.oldValue == nil {
  31830. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31831. }
  31832. oldValue, err := m.oldValue(ctx)
  31833. if err != nil {
  31834. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31835. }
  31836. return oldValue.CreatedAt, nil
  31837. }
  31838. // ResetCreatedAt resets all changes to the "created_at" field.
  31839. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  31840. m.created_at = nil
  31841. }
  31842. // SetUpdatedAt sets the "updated_at" field.
  31843. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  31844. m.updated_at = &t
  31845. }
  31846. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31847. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  31848. v := m.updated_at
  31849. if v == nil {
  31850. return
  31851. }
  31852. return *v, true
  31853. }
  31854. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  31855. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  31856. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31857. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31858. if !m.op.Is(OpUpdateOne) {
  31859. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31860. }
  31861. if m.id == nil || m.oldValue == nil {
  31862. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31863. }
  31864. oldValue, err := m.oldValue(ctx)
  31865. if err != nil {
  31866. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31867. }
  31868. return oldValue.UpdatedAt, nil
  31869. }
  31870. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31871. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  31872. m.updated_at = nil
  31873. }
  31874. // SetStatus sets the "status" field.
  31875. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  31876. m.status = &u
  31877. m.addstatus = nil
  31878. }
  31879. // Status returns the value of the "status" field in the mutation.
  31880. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  31881. v := m.status
  31882. if v == nil {
  31883. return
  31884. }
  31885. return *v, true
  31886. }
  31887. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  31888. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  31889. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31890. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31891. if !m.op.Is(OpUpdateOne) {
  31892. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31893. }
  31894. if m.id == nil || m.oldValue == nil {
  31895. return v, errors.New("OldStatus requires an ID field in the mutation")
  31896. }
  31897. oldValue, err := m.oldValue(ctx)
  31898. if err != nil {
  31899. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31900. }
  31901. return oldValue.Status, nil
  31902. }
  31903. // AddStatus adds u to the "status" field.
  31904. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  31905. if m.addstatus != nil {
  31906. *m.addstatus += u
  31907. } else {
  31908. m.addstatus = &u
  31909. }
  31910. }
  31911. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31912. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  31913. v := m.addstatus
  31914. if v == nil {
  31915. return
  31916. }
  31917. return *v, true
  31918. }
  31919. // ClearStatus clears the value of the "status" field.
  31920. func (m *WpChatroomMemberMutation) ClearStatus() {
  31921. m.status = nil
  31922. m.addstatus = nil
  31923. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  31924. }
  31925. // StatusCleared returns if the "status" field was cleared in this mutation.
  31926. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  31927. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  31928. return ok
  31929. }
  31930. // ResetStatus resets all changes to the "status" field.
  31931. func (m *WpChatroomMemberMutation) ResetStatus() {
  31932. m.status = nil
  31933. m.addstatus = nil
  31934. delete(m.clearedFields, wpchatroommember.FieldStatus)
  31935. }
  31936. // SetWxWxid sets the "wx_wxid" field.
  31937. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  31938. m.wx_wxid = &s
  31939. }
  31940. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  31941. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  31942. v := m.wx_wxid
  31943. if v == nil {
  31944. return
  31945. }
  31946. return *v, true
  31947. }
  31948. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  31949. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  31950. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31951. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  31952. if !m.op.Is(OpUpdateOne) {
  31953. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  31954. }
  31955. if m.id == nil || m.oldValue == nil {
  31956. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  31957. }
  31958. oldValue, err := m.oldValue(ctx)
  31959. if err != nil {
  31960. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  31961. }
  31962. return oldValue.WxWxid, nil
  31963. }
  31964. // ResetWxWxid resets all changes to the "wx_wxid" field.
  31965. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  31966. m.wx_wxid = nil
  31967. }
  31968. // SetWxid sets the "wxid" field.
  31969. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  31970. m.wxid = &s
  31971. }
  31972. // Wxid returns the value of the "wxid" field in the mutation.
  31973. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  31974. v := m.wxid
  31975. if v == nil {
  31976. return
  31977. }
  31978. return *v, true
  31979. }
  31980. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  31981. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  31982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31983. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  31984. if !m.op.Is(OpUpdateOne) {
  31985. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  31986. }
  31987. if m.id == nil || m.oldValue == nil {
  31988. return v, errors.New("OldWxid requires an ID field in the mutation")
  31989. }
  31990. oldValue, err := m.oldValue(ctx)
  31991. if err != nil {
  31992. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  31993. }
  31994. return oldValue.Wxid, nil
  31995. }
  31996. // ResetWxid resets all changes to the "wxid" field.
  31997. func (m *WpChatroomMemberMutation) ResetWxid() {
  31998. m.wxid = nil
  31999. }
  32000. // SetNickname sets the "nickname" field.
  32001. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  32002. m.nickname = &s
  32003. }
  32004. // Nickname returns the value of the "nickname" field in the mutation.
  32005. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  32006. v := m.nickname
  32007. if v == nil {
  32008. return
  32009. }
  32010. return *v, true
  32011. }
  32012. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  32013. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  32014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32015. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  32016. if !m.op.Is(OpUpdateOne) {
  32017. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  32018. }
  32019. if m.id == nil || m.oldValue == nil {
  32020. return v, errors.New("OldNickname requires an ID field in the mutation")
  32021. }
  32022. oldValue, err := m.oldValue(ctx)
  32023. if err != nil {
  32024. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  32025. }
  32026. return oldValue.Nickname, nil
  32027. }
  32028. // ResetNickname resets all changes to the "nickname" field.
  32029. func (m *WpChatroomMemberMutation) ResetNickname() {
  32030. m.nickname = nil
  32031. }
  32032. // SetAvatar sets the "avatar" field.
  32033. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  32034. m.avatar = &s
  32035. }
  32036. // Avatar returns the value of the "avatar" field in the mutation.
  32037. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  32038. v := m.avatar
  32039. if v == nil {
  32040. return
  32041. }
  32042. return *v, true
  32043. }
  32044. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  32045. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  32046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32047. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  32048. if !m.op.Is(OpUpdateOne) {
  32049. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  32050. }
  32051. if m.id == nil || m.oldValue == nil {
  32052. return v, errors.New("OldAvatar requires an ID field in the mutation")
  32053. }
  32054. oldValue, err := m.oldValue(ctx)
  32055. if err != nil {
  32056. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  32057. }
  32058. return oldValue.Avatar, nil
  32059. }
  32060. // ResetAvatar resets all changes to the "avatar" field.
  32061. func (m *WpChatroomMemberMutation) ResetAvatar() {
  32062. m.avatar = nil
  32063. }
  32064. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  32065. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  32066. m.predicates = append(m.predicates, ps...)
  32067. }
  32068. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  32069. // users can use type-assertion to append predicates that do not depend on any generated package.
  32070. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  32071. p := make([]predicate.WpChatroomMember, len(ps))
  32072. for i := range ps {
  32073. p[i] = ps[i]
  32074. }
  32075. m.Where(p...)
  32076. }
  32077. // Op returns the operation name.
  32078. func (m *WpChatroomMemberMutation) Op() Op {
  32079. return m.op
  32080. }
  32081. // SetOp allows setting the mutation operation.
  32082. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  32083. m.op = op
  32084. }
  32085. // Type returns the node type of this mutation (WpChatroomMember).
  32086. func (m *WpChatroomMemberMutation) Type() string {
  32087. return m.typ
  32088. }
  32089. // Fields returns all fields that were changed during this mutation. Note that in
  32090. // order to get all numeric fields that were incremented/decremented, call
  32091. // AddedFields().
  32092. func (m *WpChatroomMemberMutation) Fields() []string {
  32093. fields := make([]string, 0, 7)
  32094. if m.created_at != nil {
  32095. fields = append(fields, wpchatroommember.FieldCreatedAt)
  32096. }
  32097. if m.updated_at != nil {
  32098. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  32099. }
  32100. if m.status != nil {
  32101. fields = append(fields, wpchatroommember.FieldStatus)
  32102. }
  32103. if m.wx_wxid != nil {
  32104. fields = append(fields, wpchatroommember.FieldWxWxid)
  32105. }
  32106. if m.wxid != nil {
  32107. fields = append(fields, wpchatroommember.FieldWxid)
  32108. }
  32109. if m.nickname != nil {
  32110. fields = append(fields, wpchatroommember.FieldNickname)
  32111. }
  32112. if m.avatar != nil {
  32113. fields = append(fields, wpchatroommember.FieldAvatar)
  32114. }
  32115. return fields
  32116. }
  32117. // Field returns the value of a field with the given name. The second boolean
  32118. // return value indicates that this field was not set, or was not defined in the
  32119. // schema.
  32120. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  32121. switch name {
  32122. case wpchatroommember.FieldCreatedAt:
  32123. return m.CreatedAt()
  32124. case wpchatroommember.FieldUpdatedAt:
  32125. return m.UpdatedAt()
  32126. case wpchatroommember.FieldStatus:
  32127. return m.Status()
  32128. case wpchatroommember.FieldWxWxid:
  32129. return m.WxWxid()
  32130. case wpchatroommember.FieldWxid:
  32131. return m.Wxid()
  32132. case wpchatroommember.FieldNickname:
  32133. return m.Nickname()
  32134. case wpchatroommember.FieldAvatar:
  32135. return m.Avatar()
  32136. }
  32137. return nil, false
  32138. }
  32139. // OldField returns the old value of the field from the database. An error is
  32140. // returned if the mutation operation is not UpdateOne, or the query to the
  32141. // database failed.
  32142. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32143. switch name {
  32144. case wpchatroommember.FieldCreatedAt:
  32145. return m.OldCreatedAt(ctx)
  32146. case wpchatroommember.FieldUpdatedAt:
  32147. return m.OldUpdatedAt(ctx)
  32148. case wpchatroommember.FieldStatus:
  32149. return m.OldStatus(ctx)
  32150. case wpchatroommember.FieldWxWxid:
  32151. return m.OldWxWxid(ctx)
  32152. case wpchatroommember.FieldWxid:
  32153. return m.OldWxid(ctx)
  32154. case wpchatroommember.FieldNickname:
  32155. return m.OldNickname(ctx)
  32156. case wpchatroommember.FieldAvatar:
  32157. return m.OldAvatar(ctx)
  32158. }
  32159. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  32160. }
  32161. // SetField sets the value of a field with the given name. It returns an error if
  32162. // the field is not defined in the schema, or if the type mismatched the field
  32163. // type.
  32164. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  32165. switch name {
  32166. case wpchatroommember.FieldCreatedAt:
  32167. v, ok := value.(time.Time)
  32168. if !ok {
  32169. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32170. }
  32171. m.SetCreatedAt(v)
  32172. return nil
  32173. case wpchatroommember.FieldUpdatedAt:
  32174. v, ok := value.(time.Time)
  32175. if !ok {
  32176. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32177. }
  32178. m.SetUpdatedAt(v)
  32179. return nil
  32180. case wpchatroommember.FieldStatus:
  32181. v, ok := value.(uint8)
  32182. if !ok {
  32183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32184. }
  32185. m.SetStatus(v)
  32186. return nil
  32187. case wpchatroommember.FieldWxWxid:
  32188. v, ok := value.(string)
  32189. if !ok {
  32190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32191. }
  32192. m.SetWxWxid(v)
  32193. return nil
  32194. case wpchatroommember.FieldWxid:
  32195. v, ok := value.(string)
  32196. if !ok {
  32197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32198. }
  32199. m.SetWxid(v)
  32200. return nil
  32201. case wpchatroommember.FieldNickname:
  32202. v, ok := value.(string)
  32203. if !ok {
  32204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32205. }
  32206. m.SetNickname(v)
  32207. return nil
  32208. case wpchatroommember.FieldAvatar:
  32209. v, ok := value.(string)
  32210. if !ok {
  32211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32212. }
  32213. m.SetAvatar(v)
  32214. return nil
  32215. }
  32216. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  32217. }
  32218. // AddedFields returns all numeric fields that were incremented/decremented during
  32219. // this mutation.
  32220. func (m *WpChatroomMemberMutation) AddedFields() []string {
  32221. var fields []string
  32222. if m.addstatus != nil {
  32223. fields = append(fields, wpchatroommember.FieldStatus)
  32224. }
  32225. return fields
  32226. }
  32227. // AddedField returns the numeric value that was incremented/decremented on a field
  32228. // with the given name. The second boolean return value indicates that this field
  32229. // was not set, or was not defined in the schema.
  32230. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  32231. switch name {
  32232. case wpchatroommember.FieldStatus:
  32233. return m.AddedStatus()
  32234. }
  32235. return nil, false
  32236. }
  32237. // AddField adds the value to the field with the given name. It returns an error if
  32238. // the field is not defined in the schema, or if the type mismatched the field
  32239. // type.
  32240. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  32241. switch name {
  32242. case wpchatroommember.FieldStatus:
  32243. v, ok := value.(int8)
  32244. if !ok {
  32245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32246. }
  32247. m.AddStatus(v)
  32248. return nil
  32249. }
  32250. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  32251. }
  32252. // ClearedFields returns all nullable fields that were cleared during this
  32253. // mutation.
  32254. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  32255. var fields []string
  32256. if m.FieldCleared(wpchatroommember.FieldStatus) {
  32257. fields = append(fields, wpchatroommember.FieldStatus)
  32258. }
  32259. return fields
  32260. }
  32261. // FieldCleared returns a boolean indicating if a field with the given name was
  32262. // cleared in this mutation.
  32263. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  32264. _, ok := m.clearedFields[name]
  32265. return ok
  32266. }
  32267. // ClearField clears the value of the field with the given name. It returns an
  32268. // error if the field is not defined in the schema.
  32269. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  32270. switch name {
  32271. case wpchatroommember.FieldStatus:
  32272. m.ClearStatus()
  32273. return nil
  32274. }
  32275. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  32276. }
  32277. // ResetField resets all changes in the mutation for the field with the given name.
  32278. // It returns an error if the field is not defined in the schema.
  32279. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  32280. switch name {
  32281. case wpchatroommember.FieldCreatedAt:
  32282. m.ResetCreatedAt()
  32283. return nil
  32284. case wpchatroommember.FieldUpdatedAt:
  32285. m.ResetUpdatedAt()
  32286. return nil
  32287. case wpchatroommember.FieldStatus:
  32288. m.ResetStatus()
  32289. return nil
  32290. case wpchatroommember.FieldWxWxid:
  32291. m.ResetWxWxid()
  32292. return nil
  32293. case wpchatroommember.FieldWxid:
  32294. m.ResetWxid()
  32295. return nil
  32296. case wpchatroommember.FieldNickname:
  32297. m.ResetNickname()
  32298. return nil
  32299. case wpchatroommember.FieldAvatar:
  32300. m.ResetAvatar()
  32301. return nil
  32302. }
  32303. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  32304. }
  32305. // AddedEdges returns all edge names that were set/added in this mutation.
  32306. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  32307. edges := make([]string, 0, 0)
  32308. return edges
  32309. }
  32310. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32311. // name in this mutation.
  32312. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  32313. return nil
  32314. }
  32315. // RemovedEdges returns all edge names that were removed in this mutation.
  32316. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  32317. edges := make([]string, 0, 0)
  32318. return edges
  32319. }
  32320. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32321. // the given name in this mutation.
  32322. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  32323. return nil
  32324. }
  32325. // ClearedEdges returns all edge names that were cleared in this mutation.
  32326. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  32327. edges := make([]string, 0, 0)
  32328. return edges
  32329. }
  32330. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32331. // was cleared in this mutation.
  32332. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  32333. return false
  32334. }
  32335. // ClearEdge clears the value of the edge with the given name. It returns an error
  32336. // if that edge is not defined in the schema.
  32337. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  32338. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  32339. }
  32340. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32341. // It returns an error if the edge is not defined in the schema.
  32342. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  32343. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  32344. }
  32345. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  32346. type WxMutation struct {
  32347. config
  32348. op Op
  32349. typ string
  32350. id *uint64
  32351. created_at *time.Time
  32352. updated_at *time.Time
  32353. status *uint8
  32354. addstatus *int8
  32355. deleted_at *time.Time
  32356. port *string
  32357. process_id *string
  32358. callback *string
  32359. wxid *string
  32360. account *string
  32361. nickname *string
  32362. tel *string
  32363. head_big *string
  32364. organization_id *uint64
  32365. addorganization_id *int64
  32366. api_base *string
  32367. api_key *string
  32368. allow_list *[]string
  32369. appendallow_list []string
  32370. group_allow_list *[]string
  32371. appendgroup_allow_list []string
  32372. block_list *[]string
  32373. appendblock_list []string
  32374. group_block_list *[]string
  32375. appendgroup_block_list []string
  32376. clearedFields map[string]struct{}
  32377. server *uint64
  32378. clearedserver bool
  32379. agent *uint64
  32380. clearedagent bool
  32381. done bool
  32382. oldValue func(context.Context) (*Wx, error)
  32383. predicates []predicate.Wx
  32384. }
  32385. var _ ent.Mutation = (*WxMutation)(nil)
  32386. // wxOption allows management of the mutation configuration using functional options.
  32387. type wxOption func(*WxMutation)
  32388. // newWxMutation creates new mutation for the Wx entity.
  32389. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  32390. m := &WxMutation{
  32391. config: c,
  32392. op: op,
  32393. typ: TypeWx,
  32394. clearedFields: make(map[string]struct{}),
  32395. }
  32396. for _, opt := range opts {
  32397. opt(m)
  32398. }
  32399. return m
  32400. }
  32401. // withWxID sets the ID field of the mutation.
  32402. func withWxID(id uint64) wxOption {
  32403. return func(m *WxMutation) {
  32404. var (
  32405. err error
  32406. once sync.Once
  32407. value *Wx
  32408. )
  32409. m.oldValue = func(ctx context.Context) (*Wx, error) {
  32410. once.Do(func() {
  32411. if m.done {
  32412. err = errors.New("querying old values post mutation is not allowed")
  32413. } else {
  32414. value, err = m.Client().Wx.Get(ctx, id)
  32415. }
  32416. })
  32417. return value, err
  32418. }
  32419. m.id = &id
  32420. }
  32421. }
  32422. // withWx sets the old Wx of the mutation.
  32423. func withWx(node *Wx) wxOption {
  32424. return func(m *WxMutation) {
  32425. m.oldValue = func(context.Context) (*Wx, error) {
  32426. return node, nil
  32427. }
  32428. m.id = &node.ID
  32429. }
  32430. }
  32431. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32432. // executed in a transaction (ent.Tx), a transactional client is returned.
  32433. func (m WxMutation) Client() *Client {
  32434. client := &Client{config: m.config}
  32435. client.init()
  32436. return client
  32437. }
  32438. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32439. // it returns an error otherwise.
  32440. func (m WxMutation) Tx() (*Tx, error) {
  32441. if _, ok := m.driver.(*txDriver); !ok {
  32442. return nil, errors.New("ent: mutation is not running in a transaction")
  32443. }
  32444. tx := &Tx{config: m.config}
  32445. tx.init()
  32446. return tx, nil
  32447. }
  32448. // SetID sets the value of the id field. Note that this
  32449. // operation is only accepted on creation of Wx entities.
  32450. func (m *WxMutation) SetID(id uint64) {
  32451. m.id = &id
  32452. }
  32453. // ID returns the ID value in the mutation. Note that the ID is only available
  32454. // if it was provided to the builder or after it was returned from the database.
  32455. func (m *WxMutation) ID() (id uint64, exists bool) {
  32456. if m.id == nil {
  32457. return
  32458. }
  32459. return *m.id, true
  32460. }
  32461. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32462. // That means, if the mutation is applied within a transaction with an isolation level such
  32463. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32464. // or updated by the mutation.
  32465. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  32466. switch {
  32467. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32468. id, exists := m.ID()
  32469. if exists {
  32470. return []uint64{id}, nil
  32471. }
  32472. fallthrough
  32473. case m.op.Is(OpUpdate | OpDelete):
  32474. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  32475. default:
  32476. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32477. }
  32478. }
  32479. // SetCreatedAt sets the "created_at" field.
  32480. func (m *WxMutation) SetCreatedAt(t time.Time) {
  32481. m.created_at = &t
  32482. }
  32483. // CreatedAt returns the value of the "created_at" field in the mutation.
  32484. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  32485. v := m.created_at
  32486. if v == nil {
  32487. return
  32488. }
  32489. return *v, true
  32490. }
  32491. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  32492. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32494. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32495. if !m.op.Is(OpUpdateOne) {
  32496. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32497. }
  32498. if m.id == nil || m.oldValue == nil {
  32499. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32500. }
  32501. oldValue, err := m.oldValue(ctx)
  32502. if err != nil {
  32503. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32504. }
  32505. return oldValue.CreatedAt, nil
  32506. }
  32507. // ResetCreatedAt resets all changes to the "created_at" field.
  32508. func (m *WxMutation) ResetCreatedAt() {
  32509. m.created_at = nil
  32510. }
  32511. // SetUpdatedAt sets the "updated_at" field.
  32512. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  32513. m.updated_at = &t
  32514. }
  32515. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32516. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  32517. v := m.updated_at
  32518. if v == nil {
  32519. return
  32520. }
  32521. return *v, true
  32522. }
  32523. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  32524. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32526. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32527. if !m.op.Is(OpUpdateOne) {
  32528. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32529. }
  32530. if m.id == nil || m.oldValue == nil {
  32531. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32532. }
  32533. oldValue, err := m.oldValue(ctx)
  32534. if err != nil {
  32535. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32536. }
  32537. return oldValue.UpdatedAt, nil
  32538. }
  32539. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32540. func (m *WxMutation) ResetUpdatedAt() {
  32541. m.updated_at = nil
  32542. }
  32543. // SetStatus sets the "status" field.
  32544. func (m *WxMutation) SetStatus(u uint8) {
  32545. m.status = &u
  32546. m.addstatus = nil
  32547. }
  32548. // Status returns the value of the "status" field in the mutation.
  32549. func (m *WxMutation) Status() (r uint8, exists bool) {
  32550. v := m.status
  32551. if v == nil {
  32552. return
  32553. }
  32554. return *v, true
  32555. }
  32556. // OldStatus returns the old "status" field's value of the Wx entity.
  32557. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32559. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32560. if !m.op.Is(OpUpdateOne) {
  32561. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32562. }
  32563. if m.id == nil || m.oldValue == nil {
  32564. return v, errors.New("OldStatus requires an ID field in the mutation")
  32565. }
  32566. oldValue, err := m.oldValue(ctx)
  32567. if err != nil {
  32568. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32569. }
  32570. return oldValue.Status, nil
  32571. }
  32572. // AddStatus adds u to the "status" field.
  32573. func (m *WxMutation) AddStatus(u int8) {
  32574. if m.addstatus != nil {
  32575. *m.addstatus += u
  32576. } else {
  32577. m.addstatus = &u
  32578. }
  32579. }
  32580. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32581. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  32582. v := m.addstatus
  32583. if v == nil {
  32584. return
  32585. }
  32586. return *v, true
  32587. }
  32588. // ClearStatus clears the value of the "status" field.
  32589. func (m *WxMutation) ClearStatus() {
  32590. m.status = nil
  32591. m.addstatus = nil
  32592. m.clearedFields[wx.FieldStatus] = struct{}{}
  32593. }
  32594. // StatusCleared returns if the "status" field was cleared in this mutation.
  32595. func (m *WxMutation) StatusCleared() bool {
  32596. _, ok := m.clearedFields[wx.FieldStatus]
  32597. return ok
  32598. }
  32599. // ResetStatus resets all changes to the "status" field.
  32600. func (m *WxMutation) ResetStatus() {
  32601. m.status = nil
  32602. m.addstatus = nil
  32603. delete(m.clearedFields, wx.FieldStatus)
  32604. }
  32605. // SetDeletedAt sets the "deleted_at" field.
  32606. func (m *WxMutation) SetDeletedAt(t time.Time) {
  32607. m.deleted_at = &t
  32608. }
  32609. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  32610. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  32611. v := m.deleted_at
  32612. if v == nil {
  32613. return
  32614. }
  32615. return *v, true
  32616. }
  32617. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  32618. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32619. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32620. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  32621. if !m.op.Is(OpUpdateOne) {
  32622. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  32623. }
  32624. if m.id == nil || m.oldValue == nil {
  32625. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  32626. }
  32627. oldValue, err := m.oldValue(ctx)
  32628. if err != nil {
  32629. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  32630. }
  32631. return oldValue.DeletedAt, nil
  32632. }
  32633. // ClearDeletedAt clears the value of the "deleted_at" field.
  32634. func (m *WxMutation) ClearDeletedAt() {
  32635. m.deleted_at = nil
  32636. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  32637. }
  32638. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  32639. func (m *WxMutation) DeletedAtCleared() bool {
  32640. _, ok := m.clearedFields[wx.FieldDeletedAt]
  32641. return ok
  32642. }
  32643. // ResetDeletedAt resets all changes to the "deleted_at" field.
  32644. func (m *WxMutation) ResetDeletedAt() {
  32645. m.deleted_at = nil
  32646. delete(m.clearedFields, wx.FieldDeletedAt)
  32647. }
  32648. // SetServerID sets the "server_id" field.
  32649. func (m *WxMutation) SetServerID(u uint64) {
  32650. m.server = &u
  32651. }
  32652. // ServerID returns the value of the "server_id" field in the mutation.
  32653. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  32654. v := m.server
  32655. if v == nil {
  32656. return
  32657. }
  32658. return *v, true
  32659. }
  32660. // OldServerID returns the old "server_id" field's value of the Wx entity.
  32661. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32662. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32663. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  32664. if !m.op.Is(OpUpdateOne) {
  32665. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  32666. }
  32667. if m.id == nil || m.oldValue == nil {
  32668. return v, errors.New("OldServerID requires an ID field in the mutation")
  32669. }
  32670. oldValue, err := m.oldValue(ctx)
  32671. if err != nil {
  32672. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  32673. }
  32674. return oldValue.ServerID, nil
  32675. }
  32676. // ClearServerID clears the value of the "server_id" field.
  32677. func (m *WxMutation) ClearServerID() {
  32678. m.server = nil
  32679. m.clearedFields[wx.FieldServerID] = struct{}{}
  32680. }
  32681. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  32682. func (m *WxMutation) ServerIDCleared() bool {
  32683. _, ok := m.clearedFields[wx.FieldServerID]
  32684. return ok
  32685. }
  32686. // ResetServerID resets all changes to the "server_id" field.
  32687. func (m *WxMutation) ResetServerID() {
  32688. m.server = nil
  32689. delete(m.clearedFields, wx.FieldServerID)
  32690. }
  32691. // SetPort sets the "port" field.
  32692. func (m *WxMutation) SetPort(s string) {
  32693. m.port = &s
  32694. }
  32695. // Port returns the value of the "port" field in the mutation.
  32696. func (m *WxMutation) Port() (r string, exists bool) {
  32697. v := m.port
  32698. if v == nil {
  32699. return
  32700. }
  32701. return *v, true
  32702. }
  32703. // OldPort returns the old "port" field's value of the Wx entity.
  32704. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32705. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32706. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  32707. if !m.op.Is(OpUpdateOne) {
  32708. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  32709. }
  32710. if m.id == nil || m.oldValue == nil {
  32711. return v, errors.New("OldPort requires an ID field in the mutation")
  32712. }
  32713. oldValue, err := m.oldValue(ctx)
  32714. if err != nil {
  32715. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  32716. }
  32717. return oldValue.Port, nil
  32718. }
  32719. // ResetPort resets all changes to the "port" field.
  32720. func (m *WxMutation) ResetPort() {
  32721. m.port = nil
  32722. }
  32723. // SetProcessID sets the "process_id" field.
  32724. func (m *WxMutation) SetProcessID(s string) {
  32725. m.process_id = &s
  32726. }
  32727. // ProcessID returns the value of the "process_id" field in the mutation.
  32728. func (m *WxMutation) ProcessID() (r string, exists bool) {
  32729. v := m.process_id
  32730. if v == nil {
  32731. return
  32732. }
  32733. return *v, true
  32734. }
  32735. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  32736. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32737. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32738. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  32739. if !m.op.Is(OpUpdateOne) {
  32740. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  32741. }
  32742. if m.id == nil || m.oldValue == nil {
  32743. return v, errors.New("OldProcessID requires an ID field in the mutation")
  32744. }
  32745. oldValue, err := m.oldValue(ctx)
  32746. if err != nil {
  32747. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  32748. }
  32749. return oldValue.ProcessID, nil
  32750. }
  32751. // ResetProcessID resets all changes to the "process_id" field.
  32752. func (m *WxMutation) ResetProcessID() {
  32753. m.process_id = nil
  32754. }
  32755. // SetCallback sets the "callback" field.
  32756. func (m *WxMutation) SetCallback(s string) {
  32757. m.callback = &s
  32758. }
  32759. // Callback returns the value of the "callback" field in the mutation.
  32760. func (m *WxMutation) Callback() (r string, exists bool) {
  32761. v := m.callback
  32762. if v == nil {
  32763. return
  32764. }
  32765. return *v, true
  32766. }
  32767. // OldCallback returns the old "callback" field's value of the Wx entity.
  32768. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32769. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32770. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  32771. if !m.op.Is(OpUpdateOne) {
  32772. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  32773. }
  32774. if m.id == nil || m.oldValue == nil {
  32775. return v, errors.New("OldCallback requires an ID field in the mutation")
  32776. }
  32777. oldValue, err := m.oldValue(ctx)
  32778. if err != nil {
  32779. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  32780. }
  32781. return oldValue.Callback, nil
  32782. }
  32783. // ResetCallback resets all changes to the "callback" field.
  32784. func (m *WxMutation) ResetCallback() {
  32785. m.callback = nil
  32786. }
  32787. // SetWxid sets the "wxid" field.
  32788. func (m *WxMutation) SetWxid(s string) {
  32789. m.wxid = &s
  32790. }
  32791. // Wxid returns the value of the "wxid" field in the mutation.
  32792. func (m *WxMutation) Wxid() (r string, exists bool) {
  32793. v := m.wxid
  32794. if v == nil {
  32795. return
  32796. }
  32797. return *v, true
  32798. }
  32799. // OldWxid returns the old "wxid" field's value of the Wx entity.
  32800. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32801. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32802. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  32803. if !m.op.Is(OpUpdateOne) {
  32804. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  32805. }
  32806. if m.id == nil || m.oldValue == nil {
  32807. return v, errors.New("OldWxid requires an ID field in the mutation")
  32808. }
  32809. oldValue, err := m.oldValue(ctx)
  32810. if err != nil {
  32811. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  32812. }
  32813. return oldValue.Wxid, nil
  32814. }
  32815. // ResetWxid resets all changes to the "wxid" field.
  32816. func (m *WxMutation) ResetWxid() {
  32817. m.wxid = nil
  32818. }
  32819. // SetAccount sets the "account" field.
  32820. func (m *WxMutation) SetAccount(s string) {
  32821. m.account = &s
  32822. }
  32823. // Account returns the value of the "account" field in the mutation.
  32824. func (m *WxMutation) Account() (r string, exists bool) {
  32825. v := m.account
  32826. if v == nil {
  32827. return
  32828. }
  32829. return *v, true
  32830. }
  32831. // OldAccount returns the old "account" field's value of the Wx entity.
  32832. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32833. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32834. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  32835. if !m.op.Is(OpUpdateOne) {
  32836. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  32837. }
  32838. if m.id == nil || m.oldValue == nil {
  32839. return v, errors.New("OldAccount requires an ID field in the mutation")
  32840. }
  32841. oldValue, err := m.oldValue(ctx)
  32842. if err != nil {
  32843. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  32844. }
  32845. return oldValue.Account, nil
  32846. }
  32847. // ResetAccount resets all changes to the "account" field.
  32848. func (m *WxMutation) ResetAccount() {
  32849. m.account = nil
  32850. }
  32851. // SetNickname sets the "nickname" field.
  32852. func (m *WxMutation) SetNickname(s string) {
  32853. m.nickname = &s
  32854. }
  32855. // Nickname returns the value of the "nickname" field in the mutation.
  32856. func (m *WxMutation) Nickname() (r string, exists bool) {
  32857. v := m.nickname
  32858. if v == nil {
  32859. return
  32860. }
  32861. return *v, true
  32862. }
  32863. // OldNickname returns the old "nickname" field's value of the Wx entity.
  32864. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32865. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32866. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  32867. if !m.op.Is(OpUpdateOne) {
  32868. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  32869. }
  32870. if m.id == nil || m.oldValue == nil {
  32871. return v, errors.New("OldNickname requires an ID field in the mutation")
  32872. }
  32873. oldValue, err := m.oldValue(ctx)
  32874. if err != nil {
  32875. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  32876. }
  32877. return oldValue.Nickname, nil
  32878. }
  32879. // ResetNickname resets all changes to the "nickname" field.
  32880. func (m *WxMutation) ResetNickname() {
  32881. m.nickname = nil
  32882. }
  32883. // SetTel sets the "tel" field.
  32884. func (m *WxMutation) SetTel(s string) {
  32885. m.tel = &s
  32886. }
  32887. // Tel returns the value of the "tel" field in the mutation.
  32888. func (m *WxMutation) Tel() (r string, exists bool) {
  32889. v := m.tel
  32890. if v == nil {
  32891. return
  32892. }
  32893. return *v, true
  32894. }
  32895. // OldTel returns the old "tel" field's value of the Wx entity.
  32896. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32897. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32898. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  32899. if !m.op.Is(OpUpdateOne) {
  32900. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  32901. }
  32902. if m.id == nil || m.oldValue == nil {
  32903. return v, errors.New("OldTel requires an ID field in the mutation")
  32904. }
  32905. oldValue, err := m.oldValue(ctx)
  32906. if err != nil {
  32907. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  32908. }
  32909. return oldValue.Tel, nil
  32910. }
  32911. // ResetTel resets all changes to the "tel" field.
  32912. func (m *WxMutation) ResetTel() {
  32913. m.tel = nil
  32914. }
  32915. // SetHeadBig sets the "head_big" field.
  32916. func (m *WxMutation) SetHeadBig(s string) {
  32917. m.head_big = &s
  32918. }
  32919. // HeadBig returns the value of the "head_big" field in the mutation.
  32920. func (m *WxMutation) HeadBig() (r string, exists bool) {
  32921. v := m.head_big
  32922. if v == nil {
  32923. return
  32924. }
  32925. return *v, true
  32926. }
  32927. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  32928. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32930. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  32931. if !m.op.Is(OpUpdateOne) {
  32932. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  32933. }
  32934. if m.id == nil || m.oldValue == nil {
  32935. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  32936. }
  32937. oldValue, err := m.oldValue(ctx)
  32938. if err != nil {
  32939. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  32940. }
  32941. return oldValue.HeadBig, nil
  32942. }
  32943. // ResetHeadBig resets all changes to the "head_big" field.
  32944. func (m *WxMutation) ResetHeadBig() {
  32945. m.head_big = nil
  32946. }
  32947. // SetOrganizationID sets the "organization_id" field.
  32948. func (m *WxMutation) SetOrganizationID(u uint64) {
  32949. m.organization_id = &u
  32950. m.addorganization_id = nil
  32951. }
  32952. // OrganizationID returns the value of the "organization_id" field in the mutation.
  32953. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  32954. v := m.organization_id
  32955. if v == nil {
  32956. return
  32957. }
  32958. return *v, true
  32959. }
  32960. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  32961. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  32962. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32963. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  32964. if !m.op.Is(OpUpdateOne) {
  32965. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  32966. }
  32967. if m.id == nil || m.oldValue == nil {
  32968. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  32969. }
  32970. oldValue, err := m.oldValue(ctx)
  32971. if err != nil {
  32972. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  32973. }
  32974. return oldValue.OrganizationID, nil
  32975. }
  32976. // AddOrganizationID adds u to the "organization_id" field.
  32977. func (m *WxMutation) AddOrganizationID(u int64) {
  32978. if m.addorganization_id != nil {
  32979. *m.addorganization_id += u
  32980. } else {
  32981. m.addorganization_id = &u
  32982. }
  32983. }
  32984. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  32985. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  32986. v := m.addorganization_id
  32987. if v == nil {
  32988. return
  32989. }
  32990. return *v, true
  32991. }
  32992. // ClearOrganizationID clears the value of the "organization_id" field.
  32993. func (m *WxMutation) ClearOrganizationID() {
  32994. m.organization_id = nil
  32995. m.addorganization_id = nil
  32996. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  32997. }
  32998. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  32999. func (m *WxMutation) OrganizationIDCleared() bool {
  33000. _, ok := m.clearedFields[wx.FieldOrganizationID]
  33001. return ok
  33002. }
  33003. // ResetOrganizationID resets all changes to the "organization_id" field.
  33004. func (m *WxMutation) ResetOrganizationID() {
  33005. m.organization_id = nil
  33006. m.addorganization_id = nil
  33007. delete(m.clearedFields, wx.FieldOrganizationID)
  33008. }
  33009. // SetAgentID sets the "agent_id" field.
  33010. func (m *WxMutation) SetAgentID(u uint64) {
  33011. m.agent = &u
  33012. }
  33013. // AgentID returns the value of the "agent_id" field in the mutation.
  33014. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  33015. v := m.agent
  33016. if v == nil {
  33017. return
  33018. }
  33019. return *v, true
  33020. }
  33021. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  33022. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33023. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33024. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  33025. if !m.op.Is(OpUpdateOne) {
  33026. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  33027. }
  33028. if m.id == nil || m.oldValue == nil {
  33029. return v, errors.New("OldAgentID requires an ID field in the mutation")
  33030. }
  33031. oldValue, err := m.oldValue(ctx)
  33032. if err != nil {
  33033. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  33034. }
  33035. return oldValue.AgentID, nil
  33036. }
  33037. // ResetAgentID resets all changes to the "agent_id" field.
  33038. func (m *WxMutation) ResetAgentID() {
  33039. m.agent = nil
  33040. }
  33041. // SetAPIBase sets the "api_base" field.
  33042. func (m *WxMutation) SetAPIBase(s string) {
  33043. m.api_base = &s
  33044. }
  33045. // APIBase returns the value of the "api_base" field in the mutation.
  33046. func (m *WxMutation) APIBase() (r string, exists bool) {
  33047. v := m.api_base
  33048. if v == nil {
  33049. return
  33050. }
  33051. return *v, true
  33052. }
  33053. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  33054. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33056. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  33057. if !m.op.Is(OpUpdateOne) {
  33058. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  33059. }
  33060. if m.id == nil || m.oldValue == nil {
  33061. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  33062. }
  33063. oldValue, err := m.oldValue(ctx)
  33064. if err != nil {
  33065. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  33066. }
  33067. return oldValue.APIBase, nil
  33068. }
  33069. // ClearAPIBase clears the value of the "api_base" field.
  33070. func (m *WxMutation) ClearAPIBase() {
  33071. m.api_base = nil
  33072. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  33073. }
  33074. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  33075. func (m *WxMutation) APIBaseCleared() bool {
  33076. _, ok := m.clearedFields[wx.FieldAPIBase]
  33077. return ok
  33078. }
  33079. // ResetAPIBase resets all changes to the "api_base" field.
  33080. func (m *WxMutation) ResetAPIBase() {
  33081. m.api_base = nil
  33082. delete(m.clearedFields, wx.FieldAPIBase)
  33083. }
  33084. // SetAPIKey sets the "api_key" field.
  33085. func (m *WxMutation) SetAPIKey(s string) {
  33086. m.api_key = &s
  33087. }
  33088. // APIKey returns the value of the "api_key" field in the mutation.
  33089. func (m *WxMutation) APIKey() (r string, exists bool) {
  33090. v := m.api_key
  33091. if v == nil {
  33092. return
  33093. }
  33094. return *v, true
  33095. }
  33096. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  33097. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33098. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33099. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  33100. if !m.op.Is(OpUpdateOne) {
  33101. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  33102. }
  33103. if m.id == nil || m.oldValue == nil {
  33104. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  33105. }
  33106. oldValue, err := m.oldValue(ctx)
  33107. if err != nil {
  33108. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  33109. }
  33110. return oldValue.APIKey, nil
  33111. }
  33112. // ClearAPIKey clears the value of the "api_key" field.
  33113. func (m *WxMutation) ClearAPIKey() {
  33114. m.api_key = nil
  33115. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  33116. }
  33117. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  33118. func (m *WxMutation) APIKeyCleared() bool {
  33119. _, ok := m.clearedFields[wx.FieldAPIKey]
  33120. return ok
  33121. }
  33122. // ResetAPIKey resets all changes to the "api_key" field.
  33123. func (m *WxMutation) ResetAPIKey() {
  33124. m.api_key = nil
  33125. delete(m.clearedFields, wx.FieldAPIKey)
  33126. }
  33127. // SetAllowList sets the "allow_list" field.
  33128. func (m *WxMutation) SetAllowList(s []string) {
  33129. m.allow_list = &s
  33130. m.appendallow_list = nil
  33131. }
  33132. // AllowList returns the value of the "allow_list" field in the mutation.
  33133. func (m *WxMutation) AllowList() (r []string, exists bool) {
  33134. v := m.allow_list
  33135. if v == nil {
  33136. return
  33137. }
  33138. return *v, true
  33139. }
  33140. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  33141. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33142. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33143. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  33144. if !m.op.Is(OpUpdateOne) {
  33145. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  33146. }
  33147. if m.id == nil || m.oldValue == nil {
  33148. return v, errors.New("OldAllowList requires an ID field in the mutation")
  33149. }
  33150. oldValue, err := m.oldValue(ctx)
  33151. if err != nil {
  33152. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  33153. }
  33154. return oldValue.AllowList, nil
  33155. }
  33156. // AppendAllowList adds s to the "allow_list" field.
  33157. func (m *WxMutation) AppendAllowList(s []string) {
  33158. m.appendallow_list = append(m.appendallow_list, s...)
  33159. }
  33160. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  33161. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  33162. if len(m.appendallow_list) == 0 {
  33163. return nil, false
  33164. }
  33165. return m.appendallow_list, true
  33166. }
  33167. // ResetAllowList resets all changes to the "allow_list" field.
  33168. func (m *WxMutation) ResetAllowList() {
  33169. m.allow_list = nil
  33170. m.appendallow_list = nil
  33171. }
  33172. // SetGroupAllowList sets the "group_allow_list" field.
  33173. func (m *WxMutation) SetGroupAllowList(s []string) {
  33174. m.group_allow_list = &s
  33175. m.appendgroup_allow_list = nil
  33176. }
  33177. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  33178. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  33179. v := m.group_allow_list
  33180. if v == nil {
  33181. return
  33182. }
  33183. return *v, true
  33184. }
  33185. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  33186. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33188. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  33189. if !m.op.Is(OpUpdateOne) {
  33190. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  33191. }
  33192. if m.id == nil || m.oldValue == nil {
  33193. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  33194. }
  33195. oldValue, err := m.oldValue(ctx)
  33196. if err != nil {
  33197. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  33198. }
  33199. return oldValue.GroupAllowList, nil
  33200. }
  33201. // AppendGroupAllowList adds s to the "group_allow_list" field.
  33202. func (m *WxMutation) AppendGroupAllowList(s []string) {
  33203. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  33204. }
  33205. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  33206. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  33207. if len(m.appendgroup_allow_list) == 0 {
  33208. return nil, false
  33209. }
  33210. return m.appendgroup_allow_list, true
  33211. }
  33212. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  33213. func (m *WxMutation) ResetGroupAllowList() {
  33214. m.group_allow_list = nil
  33215. m.appendgroup_allow_list = nil
  33216. }
  33217. // SetBlockList sets the "block_list" field.
  33218. func (m *WxMutation) SetBlockList(s []string) {
  33219. m.block_list = &s
  33220. m.appendblock_list = nil
  33221. }
  33222. // BlockList returns the value of the "block_list" field in the mutation.
  33223. func (m *WxMutation) BlockList() (r []string, exists bool) {
  33224. v := m.block_list
  33225. if v == nil {
  33226. return
  33227. }
  33228. return *v, true
  33229. }
  33230. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  33231. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33232. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33233. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  33234. if !m.op.Is(OpUpdateOne) {
  33235. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  33236. }
  33237. if m.id == nil || m.oldValue == nil {
  33238. return v, errors.New("OldBlockList requires an ID field in the mutation")
  33239. }
  33240. oldValue, err := m.oldValue(ctx)
  33241. if err != nil {
  33242. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  33243. }
  33244. return oldValue.BlockList, nil
  33245. }
  33246. // AppendBlockList adds s to the "block_list" field.
  33247. func (m *WxMutation) AppendBlockList(s []string) {
  33248. m.appendblock_list = append(m.appendblock_list, s...)
  33249. }
  33250. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  33251. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  33252. if len(m.appendblock_list) == 0 {
  33253. return nil, false
  33254. }
  33255. return m.appendblock_list, true
  33256. }
  33257. // ResetBlockList resets all changes to the "block_list" field.
  33258. func (m *WxMutation) ResetBlockList() {
  33259. m.block_list = nil
  33260. m.appendblock_list = nil
  33261. }
  33262. // SetGroupBlockList sets the "group_block_list" field.
  33263. func (m *WxMutation) SetGroupBlockList(s []string) {
  33264. m.group_block_list = &s
  33265. m.appendgroup_block_list = nil
  33266. }
  33267. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  33268. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  33269. v := m.group_block_list
  33270. if v == nil {
  33271. return
  33272. }
  33273. return *v, true
  33274. }
  33275. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  33276. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  33277. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33278. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  33279. if !m.op.Is(OpUpdateOne) {
  33280. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  33281. }
  33282. if m.id == nil || m.oldValue == nil {
  33283. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  33284. }
  33285. oldValue, err := m.oldValue(ctx)
  33286. if err != nil {
  33287. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  33288. }
  33289. return oldValue.GroupBlockList, nil
  33290. }
  33291. // AppendGroupBlockList adds s to the "group_block_list" field.
  33292. func (m *WxMutation) AppendGroupBlockList(s []string) {
  33293. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  33294. }
  33295. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  33296. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  33297. if len(m.appendgroup_block_list) == 0 {
  33298. return nil, false
  33299. }
  33300. return m.appendgroup_block_list, true
  33301. }
  33302. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  33303. func (m *WxMutation) ResetGroupBlockList() {
  33304. m.group_block_list = nil
  33305. m.appendgroup_block_list = nil
  33306. }
  33307. // ClearServer clears the "server" edge to the Server entity.
  33308. func (m *WxMutation) ClearServer() {
  33309. m.clearedserver = true
  33310. m.clearedFields[wx.FieldServerID] = struct{}{}
  33311. }
  33312. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  33313. func (m *WxMutation) ServerCleared() bool {
  33314. return m.ServerIDCleared() || m.clearedserver
  33315. }
  33316. // ServerIDs returns the "server" edge IDs in the mutation.
  33317. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  33318. // ServerID instead. It exists only for internal usage by the builders.
  33319. func (m *WxMutation) ServerIDs() (ids []uint64) {
  33320. if id := m.server; id != nil {
  33321. ids = append(ids, *id)
  33322. }
  33323. return
  33324. }
  33325. // ResetServer resets all changes to the "server" edge.
  33326. func (m *WxMutation) ResetServer() {
  33327. m.server = nil
  33328. m.clearedserver = false
  33329. }
  33330. // ClearAgent clears the "agent" edge to the Agent entity.
  33331. func (m *WxMutation) ClearAgent() {
  33332. m.clearedagent = true
  33333. m.clearedFields[wx.FieldAgentID] = struct{}{}
  33334. }
  33335. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  33336. func (m *WxMutation) AgentCleared() bool {
  33337. return m.clearedagent
  33338. }
  33339. // AgentIDs returns the "agent" edge IDs in the mutation.
  33340. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  33341. // AgentID instead. It exists only for internal usage by the builders.
  33342. func (m *WxMutation) AgentIDs() (ids []uint64) {
  33343. if id := m.agent; id != nil {
  33344. ids = append(ids, *id)
  33345. }
  33346. return
  33347. }
  33348. // ResetAgent resets all changes to the "agent" edge.
  33349. func (m *WxMutation) ResetAgent() {
  33350. m.agent = nil
  33351. m.clearedagent = false
  33352. }
  33353. // Where appends a list predicates to the WxMutation builder.
  33354. func (m *WxMutation) Where(ps ...predicate.Wx) {
  33355. m.predicates = append(m.predicates, ps...)
  33356. }
  33357. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  33358. // users can use type-assertion to append predicates that do not depend on any generated package.
  33359. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  33360. p := make([]predicate.Wx, len(ps))
  33361. for i := range ps {
  33362. p[i] = ps[i]
  33363. }
  33364. m.Where(p...)
  33365. }
  33366. // Op returns the operation name.
  33367. func (m *WxMutation) Op() Op {
  33368. return m.op
  33369. }
  33370. // SetOp allows setting the mutation operation.
  33371. func (m *WxMutation) SetOp(op Op) {
  33372. m.op = op
  33373. }
  33374. // Type returns the node type of this mutation (Wx).
  33375. func (m *WxMutation) Type() string {
  33376. return m.typ
  33377. }
  33378. // Fields returns all fields that were changed during this mutation. Note that in
  33379. // order to get all numeric fields that were incremented/decremented, call
  33380. // AddedFields().
  33381. func (m *WxMutation) Fields() []string {
  33382. fields := make([]string, 0, 21)
  33383. if m.created_at != nil {
  33384. fields = append(fields, wx.FieldCreatedAt)
  33385. }
  33386. if m.updated_at != nil {
  33387. fields = append(fields, wx.FieldUpdatedAt)
  33388. }
  33389. if m.status != nil {
  33390. fields = append(fields, wx.FieldStatus)
  33391. }
  33392. if m.deleted_at != nil {
  33393. fields = append(fields, wx.FieldDeletedAt)
  33394. }
  33395. if m.server != nil {
  33396. fields = append(fields, wx.FieldServerID)
  33397. }
  33398. if m.port != nil {
  33399. fields = append(fields, wx.FieldPort)
  33400. }
  33401. if m.process_id != nil {
  33402. fields = append(fields, wx.FieldProcessID)
  33403. }
  33404. if m.callback != nil {
  33405. fields = append(fields, wx.FieldCallback)
  33406. }
  33407. if m.wxid != nil {
  33408. fields = append(fields, wx.FieldWxid)
  33409. }
  33410. if m.account != nil {
  33411. fields = append(fields, wx.FieldAccount)
  33412. }
  33413. if m.nickname != nil {
  33414. fields = append(fields, wx.FieldNickname)
  33415. }
  33416. if m.tel != nil {
  33417. fields = append(fields, wx.FieldTel)
  33418. }
  33419. if m.head_big != nil {
  33420. fields = append(fields, wx.FieldHeadBig)
  33421. }
  33422. if m.organization_id != nil {
  33423. fields = append(fields, wx.FieldOrganizationID)
  33424. }
  33425. if m.agent != nil {
  33426. fields = append(fields, wx.FieldAgentID)
  33427. }
  33428. if m.api_base != nil {
  33429. fields = append(fields, wx.FieldAPIBase)
  33430. }
  33431. if m.api_key != nil {
  33432. fields = append(fields, wx.FieldAPIKey)
  33433. }
  33434. if m.allow_list != nil {
  33435. fields = append(fields, wx.FieldAllowList)
  33436. }
  33437. if m.group_allow_list != nil {
  33438. fields = append(fields, wx.FieldGroupAllowList)
  33439. }
  33440. if m.block_list != nil {
  33441. fields = append(fields, wx.FieldBlockList)
  33442. }
  33443. if m.group_block_list != nil {
  33444. fields = append(fields, wx.FieldGroupBlockList)
  33445. }
  33446. return fields
  33447. }
  33448. // Field returns the value of a field with the given name. The second boolean
  33449. // return value indicates that this field was not set, or was not defined in the
  33450. // schema.
  33451. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  33452. switch name {
  33453. case wx.FieldCreatedAt:
  33454. return m.CreatedAt()
  33455. case wx.FieldUpdatedAt:
  33456. return m.UpdatedAt()
  33457. case wx.FieldStatus:
  33458. return m.Status()
  33459. case wx.FieldDeletedAt:
  33460. return m.DeletedAt()
  33461. case wx.FieldServerID:
  33462. return m.ServerID()
  33463. case wx.FieldPort:
  33464. return m.Port()
  33465. case wx.FieldProcessID:
  33466. return m.ProcessID()
  33467. case wx.FieldCallback:
  33468. return m.Callback()
  33469. case wx.FieldWxid:
  33470. return m.Wxid()
  33471. case wx.FieldAccount:
  33472. return m.Account()
  33473. case wx.FieldNickname:
  33474. return m.Nickname()
  33475. case wx.FieldTel:
  33476. return m.Tel()
  33477. case wx.FieldHeadBig:
  33478. return m.HeadBig()
  33479. case wx.FieldOrganizationID:
  33480. return m.OrganizationID()
  33481. case wx.FieldAgentID:
  33482. return m.AgentID()
  33483. case wx.FieldAPIBase:
  33484. return m.APIBase()
  33485. case wx.FieldAPIKey:
  33486. return m.APIKey()
  33487. case wx.FieldAllowList:
  33488. return m.AllowList()
  33489. case wx.FieldGroupAllowList:
  33490. return m.GroupAllowList()
  33491. case wx.FieldBlockList:
  33492. return m.BlockList()
  33493. case wx.FieldGroupBlockList:
  33494. return m.GroupBlockList()
  33495. }
  33496. return nil, false
  33497. }
  33498. // OldField returns the old value of the field from the database. An error is
  33499. // returned if the mutation operation is not UpdateOne, or the query to the
  33500. // database failed.
  33501. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33502. switch name {
  33503. case wx.FieldCreatedAt:
  33504. return m.OldCreatedAt(ctx)
  33505. case wx.FieldUpdatedAt:
  33506. return m.OldUpdatedAt(ctx)
  33507. case wx.FieldStatus:
  33508. return m.OldStatus(ctx)
  33509. case wx.FieldDeletedAt:
  33510. return m.OldDeletedAt(ctx)
  33511. case wx.FieldServerID:
  33512. return m.OldServerID(ctx)
  33513. case wx.FieldPort:
  33514. return m.OldPort(ctx)
  33515. case wx.FieldProcessID:
  33516. return m.OldProcessID(ctx)
  33517. case wx.FieldCallback:
  33518. return m.OldCallback(ctx)
  33519. case wx.FieldWxid:
  33520. return m.OldWxid(ctx)
  33521. case wx.FieldAccount:
  33522. return m.OldAccount(ctx)
  33523. case wx.FieldNickname:
  33524. return m.OldNickname(ctx)
  33525. case wx.FieldTel:
  33526. return m.OldTel(ctx)
  33527. case wx.FieldHeadBig:
  33528. return m.OldHeadBig(ctx)
  33529. case wx.FieldOrganizationID:
  33530. return m.OldOrganizationID(ctx)
  33531. case wx.FieldAgentID:
  33532. return m.OldAgentID(ctx)
  33533. case wx.FieldAPIBase:
  33534. return m.OldAPIBase(ctx)
  33535. case wx.FieldAPIKey:
  33536. return m.OldAPIKey(ctx)
  33537. case wx.FieldAllowList:
  33538. return m.OldAllowList(ctx)
  33539. case wx.FieldGroupAllowList:
  33540. return m.OldGroupAllowList(ctx)
  33541. case wx.FieldBlockList:
  33542. return m.OldBlockList(ctx)
  33543. case wx.FieldGroupBlockList:
  33544. return m.OldGroupBlockList(ctx)
  33545. }
  33546. return nil, fmt.Errorf("unknown Wx field %s", name)
  33547. }
  33548. // SetField sets the value of a field with the given name. It returns an error if
  33549. // the field is not defined in the schema, or if the type mismatched the field
  33550. // type.
  33551. func (m *WxMutation) SetField(name string, value ent.Value) error {
  33552. switch name {
  33553. case wx.FieldCreatedAt:
  33554. v, ok := value.(time.Time)
  33555. if !ok {
  33556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33557. }
  33558. m.SetCreatedAt(v)
  33559. return nil
  33560. case wx.FieldUpdatedAt:
  33561. v, ok := value.(time.Time)
  33562. if !ok {
  33563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33564. }
  33565. m.SetUpdatedAt(v)
  33566. return nil
  33567. case wx.FieldStatus:
  33568. v, ok := value.(uint8)
  33569. if !ok {
  33570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33571. }
  33572. m.SetStatus(v)
  33573. return nil
  33574. case wx.FieldDeletedAt:
  33575. v, ok := value.(time.Time)
  33576. if !ok {
  33577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33578. }
  33579. m.SetDeletedAt(v)
  33580. return nil
  33581. case wx.FieldServerID:
  33582. v, ok := value.(uint64)
  33583. if !ok {
  33584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33585. }
  33586. m.SetServerID(v)
  33587. return nil
  33588. case wx.FieldPort:
  33589. v, ok := value.(string)
  33590. if !ok {
  33591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33592. }
  33593. m.SetPort(v)
  33594. return nil
  33595. case wx.FieldProcessID:
  33596. v, ok := value.(string)
  33597. if !ok {
  33598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33599. }
  33600. m.SetProcessID(v)
  33601. return nil
  33602. case wx.FieldCallback:
  33603. v, ok := value.(string)
  33604. if !ok {
  33605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33606. }
  33607. m.SetCallback(v)
  33608. return nil
  33609. case wx.FieldWxid:
  33610. v, ok := value.(string)
  33611. if !ok {
  33612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33613. }
  33614. m.SetWxid(v)
  33615. return nil
  33616. case wx.FieldAccount:
  33617. v, ok := value.(string)
  33618. if !ok {
  33619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33620. }
  33621. m.SetAccount(v)
  33622. return nil
  33623. case wx.FieldNickname:
  33624. v, ok := value.(string)
  33625. if !ok {
  33626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33627. }
  33628. m.SetNickname(v)
  33629. return nil
  33630. case wx.FieldTel:
  33631. v, ok := value.(string)
  33632. if !ok {
  33633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33634. }
  33635. m.SetTel(v)
  33636. return nil
  33637. case wx.FieldHeadBig:
  33638. v, ok := value.(string)
  33639. if !ok {
  33640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33641. }
  33642. m.SetHeadBig(v)
  33643. return nil
  33644. case wx.FieldOrganizationID:
  33645. v, ok := value.(uint64)
  33646. if !ok {
  33647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33648. }
  33649. m.SetOrganizationID(v)
  33650. return nil
  33651. case wx.FieldAgentID:
  33652. v, ok := value.(uint64)
  33653. if !ok {
  33654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33655. }
  33656. m.SetAgentID(v)
  33657. return nil
  33658. case wx.FieldAPIBase:
  33659. v, ok := value.(string)
  33660. if !ok {
  33661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33662. }
  33663. m.SetAPIBase(v)
  33664. return nil
  33665. case wx.FieldAPIKey:
  33666. v, ok := value.(string)
  33667. if !ok {
  33668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33669. }
  33670. m.SetAPIKey(v)
  33671. return nil
  33672. case wx.FieldAllowList:
  33673. v, ok := value.([]string)
  33674. if !ok {
  33675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33676. }
  33677. m.SetAllowList(v)
  33678. return nil
  33679. case wx.FieldGroupAllowList:
  33680. v, ok := value.([]string)
  33681. if !ok {
  33682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33683. }
  33684. m.SetGroupAllowList(v)
  33685. return nil
  33686. case wx.FieldBlockList:
  33687. v, ok := value.([]string)
  33688. if !ok {
  33689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33690. }
  33691. m.SetBlockList(v)
  33692. return nil
  33693. case wx.FieldGroupBlockList:
  33694. v, ok := value.([]string)
  33695. if !ok {
  33696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33697. }
  33698. m.SetGroupBlockList(v)
  33699. return nil
  33700. }
  33701. return fmt.Errorf("unknown Wx field %s", name)
  33702. }
  33703. // AddedFields returns all numeric fields that were incremented/decremented during
  33704. // this mutation.
  33705. func (m *WxMutation) AddedFields() []string {
  33706. var fields []string
  33707. if m.addstatus != nil {
  33708. fields = append(fields, wx.FieldStatus)
  33709. }
  33710. if m.addorganization_id != nil {
  33711. fields = append(fields, wx.FieldOrganizationID)
  33712. }
  33713. return fields
  33714. }
  33715. // AddedField returns the numeric value that was incremented/decremented on a field
  33716. // with the given name. The second boolean return value indicates that this field
  33717. // was not set, or was not defined in the schema.
  33718. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  33719. switch name {
  33720. case wx.FieldStatus:
  33721. return m.AddedStatus()
  33722. case wx.FieldOrganizationID:
  33723. return m.AddedOrganizationID()
  33724. }
  33725. return nil, false
  33726. }
  33727. // AddField adds the value to the field with the given name. It returns an error if
  33728. // the field is not defined in the schema, or if the type mismatched the field
  33729. // type.
  33730. func (m *WxMutation) AddField(name string, value ent.Value) error {
  33731. switch name {
  33732. case wx.FieldStatus:
  33733. v, ok := value.(int8)
  33734. if !ok {
  33735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33736. }
  33737. m.AddStatus(v)
  33738. return nil
  33739. case wx.FieldOrganizationID:
  33740. v, ok := value.(int64)
  33741. if !ok {
  33742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33743. }
  33744. m.AddOrganizationID(v)
  33745. return nil
  33746. }
  33747. return fmt.Errorf("unknown Wx numeric field %s", name)
  33748. }
  33749. // ClearedFields returns all nullable fields that were cleared during this
  33750. // mutation.
  33751. func (m *WxMutation) ClearedFields() []string {
  33752. var fields []string
  33753. if m.FieldCleared(wx.FieldStatus) {
  33754. fields = append(fields, wx.FieldStatus)
  33755. }
  33756. if m.FieldCleared(wx.FieldDeletedAt) {
  33757. fields = append(fields, wx.FieldDeletedAt)
  33758. }
  33759. if m.FieldCleared(wx.FieldServerID) {
  33760. fields = append(fields, wx.FieldServerID)
  33761. }
  33762. if m.FieldCleared(wx.FieldOrganizationID) {
  33763. fields = append(fields, wx.FieldOrganizationID)
  33764. }
  33765. if m.FieldCleared(wx.FieldAPIBase) {
  33766. fields = append(fields, wx.FieldAPIBase)
  33767. }
  33768. if m.FieldCleared(wx.FieldAPIKey) {
  33769. fields = append(fields, wx.FieldAPIKey)
  33770. }
  33771. return fields
  33772. }
  33773. // FieldCleared returns a boolean indicating if a field with the given name was
  33774. // cleared in this mutation.
  33775. func (m *WxMutation) FieldCleared(name string) bool {
  33776. _, ok := m.clearedFields[name]
  33777. return ok
  33778. }
  33779. // ClearField clears the value of the field with the given name. It returns an
  33780. // error if the field is not defined in the schema.
  33781. func (m *WxMutation) ClearField(name string) error {
  33782. switch name {
  33783. case wx.FieldStatus:
  33784. m.ClearStatus()
  33785. return nil
  33786. case wx.FieldDeletedAt:
  33787. m.ClearDeletedAt()
  33788. return nil
  33789. case wx.FieldServerID:
  33790. m.ClearServerID()
  33791. return nil
  33792. case wx.FieldOrganizationID:
  33793. m.ClearOrganizationID()
  33794. return nil
  33795. case wx.FieldAPIBase:
  33796. m.ClearAPIBase()
  33797. return nil
  33798. case wx.FieldAPIKey:
  33799. m.ClearAPIKey()
  33800. return nil
  33801. }
  33802. return fmt.Errorf("unknown Wx nullable field %s", name)
  33803. }
  33804. // ResetField resets all changes in the mutation for the field with the given name.
  33805. // It returns an error if the field is not defined in the schema.
  33806. func (m *WxMutation) ResetField(name string) error {
  33807. switch name {
  33808. case wx.FieldCreatedAt:
  33809. m.ResetCreatedAt()
  33810. return nil
  33811. case wx.FieldUpdatedAt:
  33812. m.ResetUpdatedAt()
  33813. return nil
  33814. case wx.FieldStatus:
  33815. m.ResetStatus()
  33816. return nil
  33817. case wx.FieldDeletedAt:
  33818. m.ResetDeletedAt()
  33819. return nil
  33820. case wx.FieldServerID:
  33821. m.ResetServerID()
  33822. return nil
  33823. case wx.FieldPort:
  33824. m.ResetPort()
  33825. return nil
  33826. case wx.FieldProcessID:
  33827. m.ResetProcessID()
  33828. return nil
  33829. case wx.FieldCallback:
  33830. m.ResetCallback()
  33831. return nil
  33832. case wx.FieldWxid:
  33833. m.ResetWxid()
  33834. return nil
  33835. case wx.FieldAccount:
  33836. m.ResetAccount()
  33837. return nil
  33838. case wx.FieldNickname:
  33839. m.ResetNickname()
  33840. return nil
  33841. case wx.FieldTel:
  33842. m.ResetTel()
  33843. return nil
  33844. case wx.FieldHeadBig:
  33845. m.ResetHeadBig()
  33846. return nil
  33847. case wx.FieldOrganizationID:
  33848. m.ResetOrganizationID()
  33849. return nil
  33850. case wx.FieldAgentID:
  33851. m.ResetAgentID()
  33852. return nil
  33853. case wx.FieldAPIBase:
  33854. m.ResetAPIBase()
  33855. return nil
  33856. case wx.FieldAPIKey:
  33857. m.ResetAPIKey()
  33858. return nil
  33859. case wx.FieldAllowList:
  33860. m.ResetAllowList()
  33861. return nil
  33862. case wx.FieldGroupAllowList:
  33863. m.ResetGroupAllowList()
  33864. return nil
  33865. case wx.FieldBlockList:
  33866. m.ResetBlockList()
  33867. return nil
  33868. case wx.FieldGroupBlockList:
  33869. m.ResetGroupBlockList()
  33870. return nil
  33871. }
  33872. return fmt.Errorf("unknown Wx field %s", name)
  33873. }
  33874. // AddedEdges returns all edge names that were set/added in this mutation.
  33875. func (m *WxMutation) AddedEdges() []string {
  33876. edges := make([]string, 0, 2)
  33877. if m.server != nil {
  33878. edges = append(edges, wx.EdgeServer)
  33879. }
  33880. if m.agent != nil {
  33881. edges = append(edges, wx.EdgeAgent)
  33882. }
  33883. return edges
  33884. }
  33885. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33886. // name in this mutation.
  33887. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  33888. switch name {
  33889. case wx.EdgeServer:
  33890. if id := m.server; id != nil {
  33891. return []ent.Value{*id}
  33892. }
  33893. case wx.EdgeAgent:
  33894. if id := m.agent; id != nil {
  33895. return []ent.Value{*id}
  33896. }
  33897. }
  33898. return nil
  33899. }
  33900. // RemovedEdges returns all edge names that were removed in this mutation.
  33901. func (m *WxMutation) RemovedEdges() []string {
  33902. edges := make([]string, 0, 2)
  33903. return edges
  33904. }
  33905. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33906. // the given name in this mutation.
  33907. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  33908. return nil
  33909. }
  33910. // ClearedEdges returns all edge names that were cleared in this mutation.
  33911. func (m *WxMutation) ClearedEdges() []string {
  33912. edges := make([]string, 0, 2)
  33913. if m.clearedserver {
  33914. edges = append(edges, wx.EdgeServer)
  33915. }
  33916. if m.clearedagent {
  33917. edges = append(edges, wx.EdgeAgent)
  33918. }
  33919. return edges
  33920. }
  33921. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33922. // was cleared in this mutation.
  33923. func (m *WxMutation) EdgeCleared(name string) bool {
  33924. switch name {
  33925. case wx.EdgeServer:
  33926. return m.clearedserver
  33927. case wx.EdgeAgent:
  33928. return m.clearedagent
  33929. }
  33930. return false
  33931. }
  33932. // ClearEdge clears the value of the edge with the given name. It returns an error
  33933. // if that edge is not defined in the schema.
  33934. func (m *WxMutation) ClearEdge(name string) error {
  33935. switch name {
  33936. case wx.EdgeServer:
  33937. m.ClearServer()
  33938. return nil
  33939. case wx.EdgeAgent:
  33940. m.ClearAgent()
  33941. return nil
  33942. }
  33943. return fmt.Errorf("unknown Wx unique edge %s", name)
  33944. }
  33945. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33946. // It returns an error if the edge is not defined in the schema.
  33947. func (m *WxMutation) ResetEdge(name string) error {
  33948. switch name {
  33949. case wx.EdgeServer:
  33950. m.ResetServer()
  33951. return nil
  33952. case wx.EdgeAgent:
  33953. m.ResetAgent()
  33954. return nil
  33955. }
  33956. return fmt.Errorf("unknown Wx edge %s", name)
  33957. }
  33958. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  33959. type WxCardMutation struct {
  33960. config
  33961. op Op
  33962. typ string
  33963. id *uint64
  33964. created_at *time.Time
  33965. updated_at *time.Time
  33966. deleted_at *time.Time
  33967. user_id *uint64
  33968. adduser_id *int64
  33969. wx_user_id *uint64
  33970. addwx_user_id *int64
  33971. avatar *string
  33972. logo *string
  33973. name *string
  33974. company *string
  33975. address *string
  33976. phone *string
  33977. official_account *string
  33978. wechat_account *string
  33979. email *string
  33980. api_base *string
  33981. api_key *string
  33982. ai_info *string
  33983. intro *string
  33984. clearedFields map[string]struct{}
  33985. done bool
  33986. oldValue func(context.Context) (*WxCard, error)
  33987. predicates []predicate.WxCard
  33988. }
  33989. var _ ent.Mutation = (*WxCardMutation)(nil)
  33990. // wxcardOption allows management of the mutation configuration using functional options.
  33991. type wxcardOption func(*WxCardMutation)
  33992. // newWxCardMutation creates new mutation for the WxCard entity.
  33993. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  33994. m := &WxCardMutation{
  33995. config: c,
  33996. op: op,
  33997. typ: TypeWxCard,
  33998. clearedFields: make(map[string]struct{}),
  33999. }
  34000. for _, opt := range opts {
  34001. opt(m)
  34002. }
  34003. return m
  34004. }
  34005. // withWxCardID sets the ID field of the mutation.
  34006. func withWxCardID(id uint64) wxcardOption {
  34007. return func(m *WxCardMutation) {
  34008. var (
  34009. err error
  34010. once sync.Once
  34011. value *WxCard
  34012. )
  34013. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  34014. once.Do(func() {
  34015. if m.done {
  34016. err = errors.New("querying old values post mutation is not allowed")
  34017. } else {
  34018. value, err = m.Client().WxCard.Get(ctx, id)
  34019. }
  34020. })
  34021. return value, err
  34022. }
  34023. m.id = &id
  34024. }
  34025. }
  34026. // withWxCard sets the old WxCard of the mutation.
  34027. func withWxCard(node *WxCard) wxcardOption {
  34028. return func(m *WxCardMutation) {
  34029. m.oldValue = func(context.Context) (*WxCard, error) {
  34030. return node, nil
  34031. }
  34032. m.id = &node.ID
  34033. }
  34034. }
  34035. // Client returns a new `ent.Client` from the mutation. If the mutation was
  34036. // executed in a transaction (ent.Tx), a transactional client is returned.
  34037. func (m WxCardMutation) Client() *Client {
  34038. client := &Client{config: m.config}
  34039. client.init()
  34040. return client
  34041. }
  34042. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  34043. // it returns an error otherwise.
  34044. func (m WxCardMutation) Tx() (*Tx, error) {
  34045. if _, ok := m.driver.(*txDriver); !ok {
  34046. return nil, errors.New("ent: mutation is not running in a transaction")
  34047. }
  34048. tx := &Tx{config: m.config}
  34049. tx.init()
  34050. return tx, nil
  34051. }
  34052. // SetID sets the value of the id field. Note that this
  34053. // operation is only accepted on creation of WxCard entities.
  34054. func (m *WxCardMutation) SetID(id uint64) {
  34055. m.id = &id
  34056. }
  34057. // ID returns the ID value in the mutation. Note that the ID is only available
  34058. // if it was provided to the builder or after it was returned from the database.
  34059. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  34060. if m.id == nil {
  34061. return
  34062. }
  34063. return *m.id, true
  34064. }
  34065. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  34066. // That means, if the mutation is applied within a transaction with an isolation level such
  34067. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  34068. // or updated by the mutation.
  34069. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  34070. switch {
  34071. case m.op.Is(OpUpdateOne | OpDeleteOne):
  34072. id, exists := m.ID()
  34073. if exists {
  34074. return []uint64{id}, nil
  34075. }
  34076. fallthrough
  34077. case m.op.Is(OpUpdate | OpDelete):
  34078. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  34079. default:
  34080. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  34081. }
  34082. }
  34083. // SetCreatedAt sets the "created_at" field.
  34084. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  34085. m.created_at = &t
  34086. }
  34087. // CreatedAt returns the value of the "created_at" field in the mutation.
  34088. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  34089. v := m.created_at
  34090. if v == nil {
  34091. return
  34092. }
  34093. return *v, true
  34094. }
  34095. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  34096. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34097. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34098. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  34099. if !m.op.Is(OpUpdateOne) {
  34100. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  34101. }
  34102. if m.id == nil || m.oldValue == nil {
  34103. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  34104. }
  34105. oldValue, err := m.oldValue(ctx)
  34106. if err != nil {
  34107. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  34108. }
  34109. return oldValue.CreatedAt, nil
  34110. }
  34111. // ResetCreatedAt resets all changes to the "created_at" field.
  34112. func (m *WxCardMutation) ResetCreatedAt() {
  34113. m.created_at = nil
  34114. }
  34115. // SetUpdatedAt sets the "updated_at" field.
  34116. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  34117. m.updated_at = &t
  34118. }
  34119. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  34120. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  34121. v := m.updated_at
  34122. if v == nil {
  34123. return
  34124. }
  34125. return *v, true
  34126. }
  34127. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  34128. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34130. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  34131. if !m.op.Is(OpUpdateOne) {
  34132. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  34133. }
  34134. if m.id == nil || m.oldValue == nil {
  34135. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  34136. }
  34137. oldValue, err := m.oldValue(ctx)
  34138. if err != nil {
  34139. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  34140. }
  34141. return oldValue.UpdatedAt, nil
  34142. }
  34143. // ResetUpdatedAt resets all changes to the "updated_at" field.
  34144. func (m *WxCardMutation) ResetUpdatedAt() {
  34145. m.updated_at = nil
  34146. }
  34147. // SetDeletedAt sets the "deleted_at" field.
  34148. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  34149. m.deleted_at = &t
  34150. }
  34151. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  34152. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  34153. v := m.deleted_at
  34154. if v == nil {
  34155. return
  34156. }
  34157. return *v, true
  34158. }
  34159. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  34160. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34162. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  34163. if !m.op.Is(OpUpdateOne) {
  34164. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  34165. }
  34166. if m.id == nil || m.oldValue == nil {
  34167. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  34168. }
  34169. oldValue, err := m.oldValue(ctx)
  34170. if err != nil {
  34171. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  34172. }
  34173. return oldValue.DeletedAt, nil
  34174. }
  34175. // ClearDeletedAt clears the value of the "deleted_at" field.
  34176. func (m *WxCardMutation) ClearDeletedAt() {
  34177. m.deleted_at = nil
  34178. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  34179. }
  34180. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  34181. func (m *WxCardMutation) DeletedAtCleared() bool {
  34182. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  34183. return ok
  34184. }
  34185. // ResetDeletedAt resets all changes to the "deleted_at" field.
  34186. func (m *WxCardMutation) ResetDeletedAt() {
  34187. m.deleted_at = nil
  34188. delete(m.clearedFields, wxcard.FieldDeletedAt)
  34189. }
  34190. // SetUserID sets the "user_id" field.
  34191. func (m *WxCardMutation) SetUserID(u uint64) {
  34192. m.user_id = &u
  34193. m.adduser_id = nil
  34194. }
  34195. // UserID returns the value of the "user_id" field in the mutation.
  34196. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  34197. v := m.user_id
  34198. if v == nil {
  34199. return
  34200. }
  34201. return *v, true
  34202. }
  34203. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  34204. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34206. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  34207. if !m.op.Is(OpUpdateOne) {
  34208. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  34209. }
  34210. if m.id == nil || m.oldValue == nil {
  34211. return v, errors.New("OldUserID requires an ID field in the mutation")
  34212. }
  34213. oldValue, err := m.oldValue(ctx)
  34214. if err != nil {
  34215. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  34216. }
  34217. return oldValue.UserID, nil
  34218. }
  34219. // AddUserID adds u to the "user_id" field.
  34220. func (m *WxCardMutation) AddUserID(u int64) {
  34221. if m.adduser_id != nil {
  34222. *m.adduser_id += u
  34223. } else {
  34224. m.adduser_id = &u
  34225. }
  34226. }
  34227. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  34228. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  34229. v := m.adduser_id
  34230. if v == nil {
  34231. return
  34232. }
  34233. return *v, true
  34234. }
  34235. // ClearUserID clears the value of the "user_id" field.
  34236. func (m *WxCardMutation) ClearUserID() {
  34237. m.user_id = nil
  34238. m.adduser_id = nil
  34239. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  34240. }
  34241. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  34242. func (m *WxCardMutation) UserIDCleared() bool {
  34243. _, ok := m.clearedFields[wxcard.FieldUserID]
  34244. return ok
  34245. }
  34246. // ResetUserID resets all changes to the "user_id" field.
  34247. func (m *WxCardMutation) ResetUserID() {
  34248. m.user_id = nil
  34249. m.adduser_id = nil
  34250. delete(m.clearedFields, wxcard.FieldUserID)
  34251. }
  34252. // SetWxUserID sets the "wx_user_id" field.
  34253. func (m *WxCardMutation) SetWxUserID(u uint64) {
  34254. m.wx_user_id = &u
  34255. m.addwx_user_id = nil
  34256. }
  34257. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  34258. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  34259. v := m.wx_user_id
  34260. if v == nil {
  34261. return
  34262. }
  34263. return *v, true
  34264. }
  34265. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  34266. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34268. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  34269. if !m.op.Is(OpUpdateOne) {
  34270. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  34271. }
  34272. if m.id == nil || m.oldValue == nil {
  34273. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  34274. }
  34275. oldValue, err := m.oldValue(ctx)
  34276. if err != nil {
  34277. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  34278. }
  34279. return oldValue.WxUserID, nil
  34280. }
  34281. // AddWxUserID adds u to the "wx_user_id" field.
  34282. func (m *WxCardMutation) AddWxUserID(u int64) {
  34283. if m.addwx_user_id != nil {
  34284. *m.addwx_user_id += u
  34285. } else {
  34286. m.addwx_user_id = &u
  34287. }
  34288. }
  34289. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  34290. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  34291. v := m.addwx_user_id
  34292. if v == nil {
  34293. return
  34294. }
  34295. return *v, true
  34296. }
  34297. // ClearWxUserID clears the value of the "wx_user_id" field.
  34298. func (m *WxCardMutation) ClearWxUserID() {
  34299. m.wx_user_id = nil
  34300. m.addwx_user_id = nil
  34301. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  34302. }
  34303. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  34304. func (m *WxCardMutation) WxUserIDCleared() bool {
  34305. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  34306. return ok
  34307. }
  34308. // ResetWxUserID resets all changes to the "wx_user_id" field.
  34309. func (m *WxCardMutation) ResetWxUserID() {
  34310. m.wx_user_id = nil
  34311. m.addwx_user_id = nil
  34312. delete(m.clearedFields, wxcard.FieldWxUserID)
  34313. }
  34314. // SetAvatar sets the "avatar" field.
  34315. func (m *WxCardMutation) SetAvatar(s string) {
  34316. m.avatar = &s
  34317. }
  34318. // Avatar returns the value of the "avatar" field in the mutation.
  34319. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  34320. v := m.avatar
  34321. if v == nil {
  34322. return
  34323. }
  34324. return *v, true
  34325. }
  34326. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  34327. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34329. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  34330. if !m.op.Is(OpUpdateOne) {
  34331. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  34332. }
  34333. if m.id == nil || m.oldValue == nil {
  34334. return v, errors.New("OldAvatar requires an ID field in the mutation")
  34335. }
  34336. oldValue, err := m.oldValue(ctx)
  34337. if err != nil {
  34338. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  34339. }
  34340. return oldValue.Avatar, nil
  34341. }
  34342. // ResetAvatar resets all changes to the "avatar" field.
  34343. func (m *WxCardMutation) ResetAvatar() {
  34344. m.avatar = nil
  34345. }
  34346. // SetLogo sets the "logo" field.
  34347. func (m *WxCardMutation) SetLogo(s string) {
  34348. m.logo = &s
  34349. }
  34350. // Logo returns the value of the "logo" field in the mutation.
  34351. func (m *WxCardMutation) Logo() (r string, exists bool) {
  34352. v := m.logo
  34353. if v == nil {
  34354. return
  34355. }
  34356. return *v, true
  34357. }
  34358. // OldLogo returns the old "logo" field's value of the WxCard entity.
  34359. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34360. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34361. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  34362. if !m.op.Is(OpUpdateOne) {
  34363. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  34364. }
  34365. if m.id == nil || m.oldValue == nil {
  34366. return v, errors.New("OldLogo requires an ID field in the mutation")
  34367. }
  34368. oldValue, err := m.oldValue(ctx)
  34369. if err != nil {
  34370. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  34371. }
  34372. return oldValue.Logo, nil
  34373. }
  34374. // ResetLogo resets all changes to the "logo" field.
  34375. func (m *WxCardMutation) ResetLogo() {
  34376. m.logo = nil
  34377. }
  34378. // SetName sets the "name" field.
  34379. func (m *WxCardMutation) SetName(s string) {
  34380. m.name = &s
  34381. }
  34382. // Name returns the value of the "name" field in the mutation.
  34383. func (m *WxCardMutation) Name() (r string, exists bool) {
  34384. v := m.name
  34385. if v == nil {
  34386. return
  34387. }
  34388. return *v, true
  34389. }
  34390. // OldName returns the old "name" field's value of the WxCard entity.
  34391. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34393. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  34394. if !m.op.Is(OpUpdateOne) {
  34395. return v, errors.New("OldName is only allowed on UpdateOne operations")
  34396. }
  34397. if m.id == nil || m.oldValue == nil {
  34398. return v, errors.New("OldName requires an ID field in the mutation")
  34399. }
  34400. oldValue, err := m.oldValue(ctx)
  34401. if err != nil {
  34402. return v, fmt.Errorf("querying old value for OldName: %w", err)
  34403. }
  34404. return oldValue.Name, nil
  34405. }
  34406. // ResetName resets all changes to the "name" field.
  34407. func (m *WxCardMutation) ResetName() {
  34408. m.name = nil
  34409. }
  34410. // SetCompany sets the "company" field.
  34411. func (m *WxCardMutation) SetCompany(s string) {
  34412. m.company = &s
  34413. }
  34414. // Company returns the value of the "company" field in the mutation.
  34415. func (m *WxCardMutation) Company() (r string, exists bool) {
  34416. v := m.company
  34417. if v == nil {
  34418. return
  34419. }
  34420. return *v, true
  34421. }
  34422. // OldCompany returns the old "company" field's value of the WxCard entity.
  34423. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34424. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34425. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  34426. if !m.op.Is(OpUpdateOne) {
  34427. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  34428. }
  34429. if m.id == nil || m.oldValue == nil {
  34430. return v, errors.New("OldCompany requires an ID field in the mutation")
  34431. }
  34432. oldValue, err := m.oldValue(ctx)
  34433. if err != nil {
  34434. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  34435. }
  34436. return oldValue.Company, nil
  34437. }
  34438. // ResetCompany resets all changes to the "company" field.
  34439. func (m *WxCardMutation) ResetCompany() {
  34440. m.company = nil
  34441. }
  34442. // SetAddress sets the "address" field.
  34443. func (m *WxCardMutation) SetAddress(s string) {
  34444. m.address = &s
  34445. }
  34446. // Address returns the value of the "address" field in the mutation.
  34447. func (m *WxCardMutation) Address() (r string, exists bool) {
  34448. v := m.address
  34449. if v == nil {
  34450. return
  34451. }
  34452. return *v, true
  34453. }
  34454. // OldAddress returns the old "address" field's value of the WxCard entity.
  34455. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34456. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34457. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  34458. if !m.op.Is(OpUpdateOne) {
  34459. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  34460. }
  34461. if m.id == nil || m.oldValue == nil {
  34462. return v, errors.New("OldAddress requires an ID field in the mutation")
  34463. }
  34464. oldValue, err := m.oldValue(ctx)
  34465. if err != nil {
  34466. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  34467. }
  34468. return oldValue.Address, nil
  34469. }
  34470. // ResetAddress resets all changes to the "address" field.
  34471. func (m *WxCardMutation) ResetAddress() {
  34472. m.address = nil
  34473. }
  34474. // SetPhone sets the "phone" field.
  34475. func (m *WxCardMutation) SetPhone(s string) {
  34476. m.phone = &s
  34477. }
  34478. // Phone returns the value of the "phone" field in the mutation.
  34479. func (m *WxCardMutation) Phone() (r string, exists bool) {
  34480. v := m.phone
  34481. if v == nil {
  34482. return
  34483. }
  34484. return *v, true
  34485. }
  34486. // OldPhone returns the old "phone" field's value of the WxCard entity.
  34487. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34489. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  34490. if !m.op.Is(OpUpdateOne) {
  34491. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  34492. }
  34493. if m.id == nil || m.oldValue == nil {
  34494. return v, errors.New("OldPhone requires an ID field in the mutation")
  34495. }
  34496. oldValue, err := m.oldValue(ctx)
  34497. if err != nil {
  34498. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  34499. }
  34500. return oldValue.Phone, nil
  34501. }
  34502. // ResetPhone resets all changes to the "phone" field.
  34503. func (m *WxCardMutation) ResetPhone() {
  34504. m.phone = nil
  34505. }
  34506. // SetOfficialAccount sets the "official_account" field.
  34507. func (m *WxCardMutation) SetOfficialAccount(s string) {
  34508. m.official_account = &s
  34509. }
  34510. // OfficialAccount returns the value of the "official_account" field in the mutation.
  34511. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  34512. v := m.official_account
  34513. if v == nil {
  34514. return
  34515. }
  34516. return *v, true
  34517. }
  34518. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  34519. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34520. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34521. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  34522. if !m.op.Is(OpUpdateOne) {
  34523. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  34524. }
  34525. if m.id == nil || m.oldValue == nil {
  34526. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  34527. }
  34528. oldValue, err := m.oldValue(ctx)
  34529. if err != nil {
  34530. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  34531. }
  34532. return oldValue.OfficialAccount, nil
  34533. }
  34534. // ResetOfficialAccount resets all changes to the "official_account" field.
  34535. func (m *WxCardMutation) ResetOfficialAccount() {
  34536. m.official_account = nil
  34537. }
  34538. // SetWechatAccount sets the "wechat_account" field.
  34539. func (m *WxCardMutation) SetWechatAccount(s string) {
  34540. m.wechat_account = &s
  34541. }
  34542. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  34543. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  34544. v := m.wechat_account
  34545. if v == nil {
  34546. return
  34547. }
  34548. return *v, true
  34549. }
  34550. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  34551. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34553. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  34554. if !m.op.Is(OpUpdateOne) {
  34555. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  34556. }
  34557. if m.id == nil || m.oldValue == nil {
  34558. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  34559. }
  34560. oldValue, err := m.oldValue(ctx)
  34561. if err != nil {
  34562. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  34563. }
  34564. return oldValue.WechatAccount, nil
  34565. }
  34566. // ResetWechatAccount resets all changes to the "wechat_account" field.
  34567. func (m *WxCardMutation) ResetWechatAccount() {
  34568. m.wechat_account = nil
  34569. }
  34570. // SetEmail sets the "email" field.
  34571. func (m *WxCardMutation) SetEmail(s string) {
  34572. m.email = &s
  34573. }
  34574. // Email returns the value of the "email" field in the mutation.
  34575. func (m *WxCardMutation) Email() (r string, exists bool) {
  34576. v := m.email
  34577. if v == nil {
  34578. return
  34579. }
  34580. return *v, true
  34581. }
  34582. // OldEmail returns the old "email" field's value of the WxCard entity.
  34583. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34585. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  34586. if !m.op.Is(OpUpdateOne) {
  34587. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  34588. }
  34589. if m.id == nil || m.oldValue == nil {
  34590. return v, errors.New("OldEmail requires an ID field in the mutation")
  34591. }
  34592. oldValue, err := m.oldValue(ctx)
  34593. if err != nil {
  34594. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  34595. }
  34596. return oldValue.Email, nil
  34597. }
  34598. // ClearEmail clears the value of the "email" field.
  34599. func (m *WxCardMutation) ClearEmail() {
  34600. m.email = nil
  34601. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  34602. }
  34603. // EmailCleared returns if the "email" field was cleared in this mutation.
  34604. func (m *WxCardMutation) EmailCleared() bool {
  34605. _, ok := m.clearedFields[wxcard.FieldEmail]
  34606. return ok
  34607. }
  34608. // ResetEmail resets all changes to the "email" field.
  34609. func (m *WxCardMutation) ResetEmail() {
  34610. m.email = nil
  34611. delete(m.clearedFields, wxcard.FieldEmail)
  34612. }
  34613. // SetAPIBase sets the "api_base" field.
  34614. func (m *WxCardMutation) SetAPIBase(s string) {
  34615. m.api_base = &s
  34616. }
  34617. // APIBase returns the value of the "api_base" field in the mutation.
  34618. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  34619. v := m.api_base
  34620. if v == nil {
  34621. return
  34622. }
  34623. return *v, true
  34624. }
  34625. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  34626. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34628. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  34629. if !m.op.Is(OpUpdateOne) {
  34630. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  34631. }
  34632. if m.id == nil || m.oldValue == nil {
  34633. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  34634. }
  34635. oldValue, err := m.oldValue(ctx)
  34636. if err != nil {
  34637. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  34638. }
  34639. return oldValue.APIBase, nil
  34640. }
  34641. // ClearAPIBase clears the value of the "api_base" field.
  34642. func (m *WxCardMutation) ClearAPIBase() {
  34643. m.api_base = nil
  34644. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  34645. }
  34646. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  34647. func (m *WxCardMutation) APIBaseCleared() bool {
  34648. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  34649. return ok
  34650. }
  34651. // ResetAPIBase resets all changes to the "api_base" field.
  34652. func (m *WxCardMutation) ResetAPIBase() {
  34653. m.api_base = nil
  34654. delete(m.clearedFields, wxcard.FieldAPIBase)
  34655. }
  34656. // SetAPIKey sets the "api_key" field.
  34657. func (m *WxCardMutation) SetAPIKey(s string) {
  34658. m.api_key = &s
  34659. }
  34660. // APIKey returns the value of the "api_key" field in the mutation.
  34661. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  34662. v := m.api_key
  34663. if v == nil {
  34664. return
  34665. }
  34666. return *v, true
  34667. }
  34668. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  34669. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34670. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34671. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  34672. if !m.op.Is(OpUpdateOne) {
  34673. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  34674. }
  34675. if m.id == nil || m.oldValue == nil {
  34676. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  34677. }
  34678. oldValue, err := m.oldValue(ctx)
  34679. if err != nil {
  34680. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  34681. }
  34682. return oldValue.APIKey, nil
  34683. }
  34684. // ClearAPIKey clears the value of the "api_key" field.
  34685. func (m *WxCardMutation) ClearAPIKey() {
  34686. m.api_key = nil
  34687. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  34688. }
  34689. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  34690. func (m *WxCardMutation) APIKeyCleared() bool {
  34691. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  34692. return ok
  34693. }
  34694. // ResetAPIKey resets all changes to the "api_key" field.
  34695. func (m *WxCardMutation) ResetAPIKey() {
  34696. m.api_key = nil
  34697. delete(m.clearedFields, wxcard.FieldAPIKey)
  34698. }
  34699. // SetAiInfo sets the "ai_info" field.
  34700. func (m *WxCardMutation) SetAiInfo(s string) {
  34701. m.ai_info = &s
  34702. }
  34703. // AiInfo returns the value of the "ai_info" field in the mutation.
  34704. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  34705. v := m.ai_info
  34706. if v == nil {
  34707. return
  34708. }
  34709. return *v, true
  34710. }
  34711. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  34712. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34714. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  34715. if !m.op.Is(OpUpdateOne) {
  34716. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  34717. }
  34718. if m.id == nil || m.oldValue == nil {
  34719. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  34720. }
  34721. oldValue, err := m.oldValue(ctx)
  34722. if err != nil {
  34723. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  34724. }
  34725. return oldValue.AiInfo, nil
  34726. }
  34727. // ClearAiInfo clears the value of the "ai_info" field.
  34728. func (m *WxCardMutation) ClearAiInfo() {
  34729. m.ai_info = nil
  34730. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  34731. }
  34732. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  34733. func (m *WxCardMutation) AiInfoCleared() bool {
  34734. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  34735. return ok
  34736. }
  34737. // ResetAiInfo resets all changes to the "ai_info" field.
  34738. func (m *WxCardMutation) ResetAiInfo() {
  34739. m.ai_info = nil
  34740. delete(m.clearedFields, wxcard.FieldAiInfo)
  34741. }
  34742. // SetIntro sets the "intro" field.
  34743. func (m *WxCardMutation) SetIntro(s string) {
  34744. m.intro = &s
  34745. }
  34746. // Intro returns the value of the "intro" field in the mutation.
  34747. func (m *WxCardMutation) Intro() (r string, exists bool) {
  34748. v := m.intro
  34749. if v == nil {
  34750. return
  34751. }
  34752. return *v, true
  34753. }
  34754. // OldIntro returns the old "intro" field's value of the WxCard entity.
  34755. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  34756. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34757. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  34758. if !m.op.Is(OpUpdateOne) {
  34759. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  34760. }
  34761. if m.id == nil || m.oldValue == nil {
  34762. return v, errors.New("OldIntro requires an ID field in the mutation")
  34763. }
  34764. oldValue, err := m.oldValue(ctx)
  34765. if err != nil {
  34766. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  34767. }
  34768. return oldValue.Intro, nil
  34769. }
  34770. // ClearIntro clears the value of the "intro" field.
  34771. func (m *WxCardMutation) ClearIntro() {
  34772. m.intro = nil
  34773. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  34774. }
  34775. // IntroCleared returns if the "intro" field was cleared in this mutation.
  34776. func (m *WxCardMutation) IntroCleared() bool {
  34777. _, ok := m.clearedFields[wxcard.FieldIntro]
  34778. return ok
  34779. }
  34780. // ResetIntro resets all changes to the "intro" field.
  34781. func (m *WxCardMutation) ResetIntro() {
  34782. m.intro = nil
  34783. delete(m.clearedFields, wxcard.FieldIntro)
  34784. }
  34785. // Where appends a list predicates to the WxCardMutation builder.
  34786. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  34787. m.predicates = append(m.predicates, ps...)
  34788. }
  34789. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  34790. // users can use type-assertion to append predicates that do not depend on any generated package.
  34791. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  34792. p := make([]predicate.WxCard, len(ps))
  34793. for i := range ps {
  34794. p[i] = ps[i]
  34795. }
  34796. m.Where(p...)
  34797. }
  34798. // Op returns the operation name.
  34799. func (m *WxCardMutation) Op() Op {
  34800. return m.op
  34801. }
  34802. // SetOp allows setting the mutation operation.
  34803. func (m *WxCardMutation) SetOp(op Op) {
  34804. m.op = op
  34805. }
  34806. // Type returns the node type of this mutation (WxCard).
  34807. func (m *WxCardMutation) Type() string {
  34808. return m.typ
  34809. }
  34810. // Fields returns all fields that were changed during this mutation. Note that in
  34811. // order to get all numeric fields that were incremented/decremented, call
  34812. // AddedFields().
  34813. func (m *WxCardMutation) Fields() []string {
  34814. fields := make([]string, 0, 18)
  34815. if m.created_at != nil {
  34816. fields = append(fields, wxcard.FieldCreatedAt)
  34817. }
  34818. if m.updated_at != nil {
  34819. fields = append(fields, wxcard.FieldUpdatedAt)
  34820. }
  34821. if m.deleted_at != nil {
  34822. fields = append(fields, wxcard.FieldDeletedAt)
  34823. }
  34824. if m.user_id != nil {
  34825. fields = append(fields, wxcard.FieldUserID)
  34826. }
  34827. if m.wx_user_id != nil {
  34828. fields = append(fields, wxcard.FieldWxUserID)
  34829. }
  34830. if m.avatar != nil {
  34831. fields = append(fields, wxcard.FieldAvatar)
  34832. }
  34833. if m.logo != nil {
  34834. fields = append(fields, wxcard.FieldLogo)
  34835. }
  34836. if m.name != nil {
  34837. fields = append(fields, wxcard.FieldName)
  34838. }
  34839. if m.company != nil {
  34840. fields = append(fields, wxcard.FieldCompany)
  34841. }
  34842. if m.address != nil {
  34843. fields = append(fields, wxcard.FieldAddress)
  34844. }
  34845. if m.phone != nil {
  34846. fields = append(fields, wxcard.FieldPhone)
  34847. }
  34848. if m.official_account != nil {
  34849. fields = append(fields, wxcard.FieldOfficialAccount)
  34850. }
  34851. if m.wechat_account != nil {
  34852. fields = append(fields, wxcard.FieldWechatAccount)
  34853. }
  34854. if m.email != nil {
  34855. fields = append(fields, wxcard.FieldEmail)
  34856. }
  34857. if m.api_base != nil {
  34858. fields = append(fields, wxcard.FieldAPIBase)
  34859. }
  34860. if m.api_key != nil {
  34861. fields = append(fields, wxcard.FieldAPIKey)
  34862. }
  34863. if m.ai_info != nil {
  34864. fields = append(fields, wxcard.FieldAiInfo)
  34865. }
  34866. if m.intro != nil {
  34867. fields = append(fields, wxcard.FieldIntro)
  34868. }
  34869. return fields
  34870. }
  34871. // Field returns the value of a field with the given name. The second boolean
  34872. // return value indicates that this field was not set, or was not defined in the
  34873. // schema.
  34874. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  34875. switch name {
  34876. case wxcard.FieldCreatedAt:
  34877. return m.CreatedAt()
  34878. case wxcard.FieldUpdatedAt:
  34879. return m.UpdatedAt()
  34880. case wxcard.FieldDeletedAt:
  34881. return m.DeletedAt()
  34882. case wxcard.FieldUserID:
  34883. return m.UserID()
  34884. case wxcard.FieldWxUserID:
  34885. return m.WxUserID()
  34886. case wxcard.FieldAvatar:
  34887. return m.Avatar()
  34888. case wxcard.FieldLogo:
  34889. return m.Logo()
  34890. case wxcard.FieldName:
  34891. return m.Name()
  34892. case wxcard.FieldCompany:
  34893. return m.Company()
  34894. case wxcard.FieldAddress:
  34895. return m.Address()
  34896. case wxcard.FieldPhone:
  34897. return m.Phone()
  34898. case wxcard.FieldOfficialAccount:
  34899. return m.OfficialAccount()
  34900. case wxcard.FieldWechatAccount:
  34901. return m.WechatAccount()
  34902. case wxcard.FieldEmail:
  34903. return m.Email()
  34904. case wxcard.FieldAPIBase:
  34905. return m.APIBase()
  34906. case wxcard.FieldAPIKey:
  34907. return m.APIKey()
  34908. case wxcard.FieldAiInfo:
  34909. return m.AiInfo()
  34910. case wxcard.FieldIntro:
  34911. return m.Intro()
  34912. }
  34913. return nil, false
  34914. }
  34915. // OldField returns the old value of the field from the database. An error is
  34916. // returned if the mutation operation is not UpdateOne, or the query to the
  34917. // database failed.
  34918. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34919. switch name {
  34920. case wxcard.FieldCreatedAt:
  34921. return m.OldCreatedAt(ctx)
  34922. case wxcard.FieldUpdatedAt:
  34923. return m.OldUpdatedAt(ctx)
  34924. case wxcard.FieldDeletedAt:
  34925. return m.OldDeletedAt(ctx)
  34926. case wxcard.FieldUserID:
  34927. return m.OldUserID(ctx)
  34928. case wxcard.FieldWxUserID:
  34929. return m.OldWxUserID(ctx)
  34930. case wxcard.FieldAvatar:
  34931. return m.OldAvatar(ctx)
  34932. case wxcard.FieldLogo:
  34933. return m.OldLogo(ctx)
  34934. case wxcard.FieldName:
  34935. return m.OldName(ctx)
  34936. case wxcard.FieldCompany:
  34937. return m.OldCompany(ctx)
  34938. case wxcard.FieldAddress:
  34939. return m.OldAddress(ctx)
  34940. case wxcard.FieldPhone:
  34941. return m.OldPhone(ctx)
  34942. case wxcard.FieldOfficialAccount:
  34943. return m.OldOfficialAccount(ctx)
  34944. case wxcard.FieldWechatAccount:
  34945. return m.OldWechatAccount(ctx)
  34946. case wxcard.FieldEmail:
  34947. return m.OldEmail(ctx)
  34948. case wxcard.FieldAPIBase:
  34949. return m.OldAPIBase(ctx)
  34950. case wxcard.FieldAPIKey:
  34951. return m.OldAPIKey(ctx)
  34952. case wxcard.FieldAiInfo:
  34953. return m.OldAiInfo(ctx)
  34954. case wxcard.FieldIntro:
  34955. return m.OldIntro(ctx)
  34956. }
  34957. return nil, fmt.Errorf("unknown WxCard field %s", name)
  34958. }
  34959. // SetField sets the value of a field with the given name. It returns an error if
  34960. // the field is not defined in the schema, or if the type mismatched the field
  34961. // type.
  34962. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  34963. switch name {
  34964. case wxcard.FieldCreatedAt:
  34965. v, ok := value.(time.Time)
  34966. if !ok {
  34967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34968. }
  34969. m.SetCreatedAt(v)
  34970. return nil
  34971. case wxcard.FieldUpdatedAt:
  34972. v, ok := value.(time.Time)
  34973. if !ok {
  34974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34975. }
  34976. m.SetUpdatedAt(v)
  34977. return nil
  34978. case wxcard.FieldDeletedAt:
  34979. v, ok := value.(time.Time)
  34980. if !ok {
  34981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34982. }
  34983. m.SetDeletedAt(v)
  34984. return nil
  34985. case wxcard.FieldUserID:
  34986. v, ok := value.(uint64)
  34987. if !ok {
  34988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34989. }
  34990. m.SetUserID(v)
  34991. return nil
  34992. case wxcard.FieldWxUserID:
  34993. v, ok := value.(uint64)
  34994. if !ok {
  34995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34996. }
  34997. m.SetWxUserID(v)
  34998. return nil
  34999. case wxcard.FieldAvatar:
  35000. v, ok := value.(string)
  35001. if !ok {
  35002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35003. }
  35004. m.SetAvatar(v)
  35005. return nil
  35006. case wxcard.FieldLogo:
  35007. v, ok := value.(string)
  35008. if !ok {
  35009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35010. }
  35011. m.SetLogo(v)
  35012. return nil
  35013. case wxcard.FieldName:
  35014. v, ok := value.(string)
  35015. if !ok {
  35016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35017. }
  35018. m.SetName(v)
  35019. return nil
  35020. case wxcard.FieldCompany:
  35021. v, ok := value.(string)
  35022. if !ok {
  35023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35024. }
  35025. m.SetCompany(v)
  35026. return nil
  35027. case wxcard.FieldAddress:
  35028. v, ok := value.(string)
  35029. if !ok {
  35030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35031. }
  35032. m.SetAddress(v)
  35033. return nil
  35034. case wxcard.FieldPhone:
  35035. v, ok := value.(string)
  35036. if !ok {
  35037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35038. }
  35039. m.SetPhone(v)
  35040. return nil
  35041. case wxcard.FieldOfficialAccount:
  35042. v, ok := value.(string)
  35043. if !ok {
  35044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35045. }
  35046. m.SetOfficialAccount(v)
  35047. return nil
  35048. case wxcard.FieldWechatAccount:
  35049. v, ok := value.(string)
  35050. if !ok {
  35051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35052. }
  35053. m.SetWechatAccount(v)
  35054. return nil
  35055. case wxcard.FieldEmail:
  35056. v, ok := value.(string)
  35057. if !ok {
  35058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35059. }
  35060. m.SetEmail(v)
  35061. return nil
  35062. case wxcard.FieldAPIBase:
  35063. v, ok := value.(string)
  35064. if !ok {
  35065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35066. }
  35067. m.SetAPIBase(v)
  35068. return nil
  35069. case wxcard.FieldAPIKey:
  35070. v, ok := value.(string)
  35071. if !ok {
  35072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35073. }
  35074. m.SetAPIKey(v)
  35075. return nil
  35076. case wxcard.FieldAiInfo:
  35077. v, ok := value.(string)
  35078. if !ok {
  35079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35080. }
  35081. m.SetAiInfo(v)
  35082. return nil
  35083. case wxcard.FieldIntro:
  35084. v, ok := value.(string)
  35085. if !ok {
  35086. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35087. }
  35088. m.SetIntro(v)
  35089. return nil
  35090. }
  35091. return fmt.Errorf("unknown WxCard field %s", name)
  35092. }
  35093. // AddedFields returns all numeric fields that were incremented/decremented during
  35094. // this mutation.
  35095. func (m *WxCardMutation) AddedFields() []string {
  35096. var fields []string
  35097. if m.adduser_id != nil {
  35098. fields = append(fields, wxcard.FieldUserID)
  35099. }
  35100. if m.addwx_user_id != nil {
  35101. fields = append(fields, wxcard.FieldWxUserID)
  35102. }
  35103. return fields
  35104. }
  35105. // AddedField returns the numeric value that was incremented/decremented on a field
  35106. // with the given name. The second boolean return value indicates that this field
  35107. // was not set, or was not defined in the schema.
  35108. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  35109. switch name {
  35110. case wxcard.FieldUserID:
  35111. return m.AddedUserID()
  35112. case wxcard.FieldWxUserID:
  35113. return m.AddedWxUserID()
  35114. }
  35115. return nil, false
  35116. }
  35117. // AddField adds the value to the field with the given name. It returns an error if
  35118. // the field is not defined in the schema, or if the type mismatched the field
  35119. // type.
  35120. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  35121. switch name {
  35122. case wxcard.FieldUserID:
  35123. v, ok := value.(int64)
  35124. if !ok {
  35125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35126. }
  35127. m.AddUserID(v)
  35128. return nil
  35129. case wxcard.FieldWxUserID:
  35130. v, ok := value.(int64)
  35131. if !ok {
  35132. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35133. }
  35134. m.AddWxUserID(v)
  35135. return nil
  35136. }
  35137. return fmt.Errorf("unknown WxCard numeric field %s", name)
  35138. }
  35139. // ClearedFields returns all nullable fields that were cleared during this
  35140. // mutation.
  35141. func (m *WxCardMutation) ClearedFields() []string {
  35142. var fields []string
  35143. if m.FieldCleared(wxcard.FieldDeletedAt) {
  35144. fields = append(fields, wxcard.FieldDeletedAt)
  35145. }
  35146. if m.FieldCleared(wxcard.FieldUserID) {
  35147. fields = append(fields, wxcard.FieldUserID)
  35148. }
  35149. if m.FieldCleared(wxcard.FieldWxUserID) {
  35150. fields = append(fields, wxcard.FieldWxUserID)
  35151. }
  35152. if m.FieldCleared(wxcard.FieldEmail) {
  35153. fields = append(fields, wxcard.FieldEmail)
  35154. }
  35155. if m.FieldCleared(wxcard.FieldAPIBase) {
  35156. fields = append(fields, wxcard.FieldAPIBase)
  35157. }
  35158. if m.FieldCleared(wxcard.FieldAPIKey) {
  35159. fields = append(fields, wxcard.FieldAPIKey)
  35160. }
  35161. if m.FieldCleared(wxcard.FieldAiInfo) {
  35162. fields = append(fields, wxcard.FieldAiInfo)
  35163. }
  35164. if m.FieldCleared(wxcard.FieldIntro) {
  35165. fields = append(fields, wxcard.FieldIntro)
  35166. }
  35167. return fields
  35168. }
  35169. // FieldCleared returns a boolean indicating if a field with the given name was
  35170. // cleared in this mutation.
  35171. func (m *WxCardMutation) FieldCleared(name string) bool {
  35172. _, ok := m.clearedFields[name]
  35173. return ok
  35174. }
  35175. // ClearField clears the value of the field with the given name. It returns an
  35176. // error if the field is not defined in the schema.
  35177. func (m *WxCardMutation) ClearField(name string) error {
  35178. switch name {
  35179. case wxcard.FieldDeletedAt:
  35180. m.ClearDeletedAt()
  35181. return nil
  35182. case wxcard.FieldUserID:
  35183. m.ClearUserID()
  35184. return nil
  35185. case wxcard.FieldWxUserID:
  35186. m.ClearWxUserID()
  35187. return nil
  35188. case wxcard.FieldEmail:
  35189. m.ClearEmail()
  35190. return nil
  35191. case wxcard.FieldAPIBase:
  35192. m.ClearAPIBase()
  35193. return nil
  35194. case wxcard.FieldAPIKey:
  35195. m.ClearAPIKey()
  35196. return nil
  35197. case wxcard.FieldAiInfo:
  35198. m.ClearAiInfo()
  35199. return nil
  35200. case wxcard.FieldIntro:
  35201. m.ClearIntro()
  35202. return nil
  35203. }
  35204. return fmt.Errorf("unknown WxCard nullable field %s", name)
  35205. }
  35206. // ResetField resets all changes in the mutation for the field with the given name.
  35207. // It returns an error if the field is not defined in the schema.
  35208. func (m *WxCardMutation) ResetField(name string) error {
  35209. switch name {
  35210. case wxcard.FieldCreatedAt:
  35211. m.ResetCreatedAt()
  35212. return nil
  35213. case wxcard.FieldUpdatedAt:
  35214. m.ResetUpdatedAt()
  35215. return nil
  35216. case wxcard.FieldDeletedAt:
  35217. m.ResetDeletedAt()
  35218. return nil
  35219. case wxcard.FieldUserID:
  35220. m.ResetUserID()
  35221. return nil
  35222. case wxcard.FieldWxUserID:
  35223. m.ResetWxUserID()
  35224. return nil
  35225. case wxcard.FieldAvatar:
  35226. m.ResetAvatar()
  35227. return nil
  35228. case wxcard.FieldLogo:
  35229. m.ResetLogo()
  35230. return nil
  35231. case wxcard.FieldName:
  35232. m.ResetName()
  35233. return nil
  35234. case wxcard.FieldCompany:
  35235. m.ResetCompany()
  35236. return nil
  35237. case wxcard.FieldAddress:
  35238. m.ResetAddress()
  35239. return nil
  35240. case wxcard.FieldPhone:
  35241. m.ResetPhone()
  35242. return nil
  35243. case wxcard.FieldOfficialAccount:
  35244. m.ResetOfficialAccount()
  35245. return nil
  35246. case wxcard.FieldWechatAccount:
  35247. m.ResetWechatAccount()
  35248. return nil
  35249. case wxcard.FieldEmail:
  35250. m.ResetEmail()
  35251. return nil
  35252. case wxcard.FieldAPIBase:
  35253. m.ResetAPIBase()
  35254. return nil
  35255. case wxcard.FieldAPIKey:
  35256. m.ResetAPIKey()
  35257. return nil
  35258. case wxcard.FieldAiInfo:
  35259. m.ResetAiInfo()
  35260. return nil
  35261. case wxcard.FieldIntro:
  35262. m.ResetIntro()
  35263. return nil
  35264. }
  35265. return fmt.Errorf("unknown WxCard field %s", name)
  35266. }
  35267. // AddedEdges returns all edge names that were set/added in this mutation.
  35268. func (m *WxCardMutation) AddedEdges() []string {
  35269. edges := make([]string, 0, 0)
  35270. return edges
  35271. }
  35272. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35273. // name in this mutation.
  35274. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  35275. return nil
  35276. }
  35277. // RemovedEdges returns all edge names that were removed in this mutation.
  35278. func (m *WxCardMutation) RemovedEdges() []string {
  35279. edges := make([]string, 0, 0)
  35280. return edges
  35281. }
  35282. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35283. // the given name in this mutation.
  35284. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  35285. return nil
  35286. }
  35287. // ClearedEdges returns all edge names that were cleared in this mutation.
  35288. func (m *WxCardMutation) ClearedEdges() []string {
  35289. edges := make([]string, 0, 0)
  35290. return edges
  35291. }
  35292. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35293. // was cleared in this mutation.
  35294. func (m *WxCardMutation) EdgeCleared(name string) bool {
  35295. return false
  35296. }
  35297. // ClearEdge clears the value of the edge with the given name. It returns an error
  35298. // if that edge is not defined in the schema.
  35299. func (m *WxCardMutation) ClearEdge(name string) error {
  35300. return fmt.Errorf("unknown WxCard unique edge %s", name)
  35301. }
  35302. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35303. // It returns an error if the edge is not defined in the schema.
  35304. func (m *WxCardMutation) ResetEdge(name string) error {
  35305. return fmt.Errorf("unknown WxCard edge %s", name)
  35306. }
  35307. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  35308. type WxCardUserMutation struct {
  35309. config
  35310. op Op
  35311. typ string
  35312. id *uint64
  35313. created_at *time.Time
  35314. updated_at *time.Time
  35315. deleted_at *time.Time
  35316. wxid *string
  35317. account *string
  35318. avatar *string
  35319. nickname *string
  35320. remark *string
  35321. phone *string
  35322. open_id *string
  35323. union_id *string
  35324. session_key *string
  35325. is_vip *int
  35326. addis_vip *int
  35327. clearedFields map[string]struct{}
  35328. done bool
  35329. oldValue func(context.Context) (*WxCardUser, error)
  35330. predicates []predicate.WxCardUser
  35331. }
  35332. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  35333. // wxcarduserOption allows management of the mutation configuration using functional options.
  35334. type wxcarduserOption func(*WxCardUserMutation)
  35335. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  35336. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  35337. m := &WxCardUserMutation{
  35338. config: c,
  35339. op: op,
  35340. typ: TypeWxCardUser,
  35341. clearedFields: make(map[string]struct{}),
  35342. }
  35343. for _, opt := range opts {
  35344. opt(m)
  35345. }
  35346. return m
  35347. }
  35348. // withWxCardUserID sets the ID field of the mutation.
  35349. func withWxCardUserID(id uint64) wxcarduserOption {
  35350. return func(m *WxCardUserMutation) {
  35351. var (
  35352. err error
  35353. once sync.Once
  35354. value *WxCardUser
  35355. )
  35356. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  35357. once.Do(func() {
  35358. if m.done {
  35359. err = errors.New("querying old values post mutation is not allowed")
  35360. } else {
  35361. value, err = m.Client().WxCardUser.Get(ctx, id)
  35362. }
  35363. })
  35364. return value, err
  35365. }
  35366. m.id = &id
  35367. }
  35368. }
  35369. // withWxCardUser sets the old WxCardUser of the mutation.
  35370. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  35371. return func(m *WxCardUserMutation) {
  35372. m.oldValue = func(context.Context) (*WxCardUser, error) {
  35373. return node, nil
  35374. }
  35375. m.id = &node.ID
  35376. }
  35377. }
  35378. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35379. // executed in a transaction (ent.Tx), a transactional client is returned.
  35380. func (m WxCardUserMutation) Client() *Client {
  35381. client := &Client{config: m.config}
  35382. client.init()
  35383. return client
  35384. }
  35385. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35386. // it returns an error otherwise.
  35387. func (m WxCardUserMutation) Tx() (*Tx, error) {
  35388. if _, ok := m.driver.(*txDriver); !ok {
  35389. return nil, errors.New("ent: mutation is not running in a transaction")
  35390. }
  35391. tx := &Tx{config: m.config}
  35392. tx.init()
  35393. return tx, nil
  35394. }
  35395. // SetID sets the value of the id field. Note that this
  35396. // operation is only accepted on creation of WxCardUser entities.
  35397. func (m *WxCardUserMutation) SetID(id uint64) {
  35398. m.id = &id
  35399. }
  35400. // ID returns the ID value in the mutation. Note that the ID is only available
  35401. // if it was provided to the builder or after it was returned from the database.
  35402. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  35403. if m.id == nil {
  35404. return
  35405. }
  35406. return *m.id, true
  35407. }
  35408. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35409. // That means, if the mutation is applied within a transaction with an isolation level such
  35410. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35411. // or updated by the mutation.
  35412. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  35413. switch {
  35414. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35415. id, exists := m.ID()
  35416. if exists {
  35417. return []uint64{id}, nil
  35418. }
  35419. fallthrough
  35420. case m.op.Is(OpUpdate | OpDelete):
  35421. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  35422. default:
  35423. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35424. }
  35425. }
  35426. // SetCreatedAt sets the "created_at" field.
  35427. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  35428. m.created_at = &t
  35429. }
  35430. // CreatedAt returns the value of the "created_at" field in the mutation.
  35431. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  35432. v := m.created_at
  35433. if v == nil {
  35434. return
  35435. }
  35436. return *v, true
  35437. }
  35438. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  35439. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35440. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35441. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35442. if !m.op.Is(OpUpdateOne) {
  35443. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35444. }
  35445. if m.id == nil || m.oldValue == nil {
  35446. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35447. }
  35448. oldValue, err := m.oldValue(ctx)
  35449. if err != nil {
  35450. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35451. }
  35452. return oldValue.CreatedAt, nil
  35453. }
  35454. // ResetCreatedAt resets all changes to the "created_at" field.
  35455. func (m *WxCardUserMutation) ResetCreatedAt() {
  35456. m.created_at = nil
  35457. }
  35458. // SetUpdatedAt sets the "updated_at" field.
  35459. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  35460. m.updated_at = &t
  35461. }
  35462. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35463. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  35464. v := m.updated_at
  35465. if v == nil {
  35466. return
  35467. }
  35468. return *v, true
  35469. }
  35470. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  35471. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35473. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35474. if !m.op.Is(OpUpdateOne) {
  35475. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35476. }
  35477. if m.id == nil || m.oldValue == nil {
  35478. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35479. }
  35480. oldValue, err := m.oldValue(ctx)
  35481. if err != nil {
  35482. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35483. }
  35484. return oldValue.UpdatedAt, nil
  35485. }
  35486. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35487. func (m *WxCardUserMutation) ResetUpdatedAt() {
  35488. m.updated_at = nil
  35489. }
  35490. // SetDeletedAt sets the "deleted_at" field.
  35491. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  35492. m.deleted_at = &t
  35493. }
  35494. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35495. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  35496. v := m.deleted_at
  35497. if v == nil {
  35498. return
  35499. }
  35500. return *v, true
  35501. }
  35502. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  35503. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35505. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35506. if !m.op.Is(OpUpdateOne) {
  35507. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35508. }
  35509. if m.id == nil || m.oldValue == nil {
  35510. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35511. }
  35512. oldValue, err := m.oldValue(ctx)
  35513. if err != nil {
  35514. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35515. }
  35516. return oldValue.DeletedAt, nil
  35517. }
  35518. // ClearDeletedAt clears the value of the "deleted_at" field.
  35519. func (m *WxCardUserMutation) ClearDeletedAt() {
  35520. m.deleted_at = nil
  35521. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  35522. }
  35523. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35524. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  35525. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  35526. return ok
  35527. }
  35528. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35529. func (m *WxCardUserMutation) ResetDeletedAt() {
  35530. m.deleted_at = nil
  35531. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  35532. }
  35533. // SetWxid sets the "wxid" field.
  35534. func (m *WxCardUserMutation) SetWxid(s string) {
  35535. m.wxid = &s
  35536. }
  35537. // Wxid returns the value of the "wxid" field in the mutation.
  35538. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  35539. v := m.wxid
  35540. if v == nil {
  35541. return
  35542. }
  35543. return *v, true
  35544. }
  35545. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  35546. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35548. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  35549. if !m.op.Is(OpUpdateOne) {
  35550. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  35551. }
  35552. if m.id == nil || m.oldValue == nil {
  35553. return v, errors.New("OldWxid requires an ID field in the mutation")
  35554. }
  35555. oldValue, err := m.oldValue(ctx)
  35556. if err != nil {
  35557. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  35558. }
  35559. return oldValue.Wxid, nil
  35560. }
  35561. // ResetWxid resets all changes to the "wxid" field.
  35562. func (m *WxCardUserMutation) ResetWxid() {
  35563. m.wxid = nil
  35564. }
  35565. // SetAccount sets the "account" field.
  35566. func (m *WxCardUserMutation) SetAccount(s string) {
  35567. m.account = &s
  35568. }
  35569. // Account returns the value of the "account" field in the mutation.
  35570. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  35571. v := m.account
  35572. if v == nil {
  35573. return
  35574. }
  35575. return *v, true
  35576. }
  35577. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  35578. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35579. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35580. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  35581. if !m.op.Is(OpUpdateOne) {
  35582. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  35583. }
  35584. if m.id == nil || m.oldValue == nil {
  35585. return v, errors.New("OldAccount requires an ID field in the mutation")
  35586. }
  35587. oldValue, err := m.oldValue(ctx)
  35588. if err != nil {
  35589. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  35590. }
  35591. return oldValue.Account, nil
  35592. }
  35593. // ResetAccount resets all changes to the "account" field.
  35594. func (m *WxCardUserMutation) ResetAccount() {
  35595. m.account = nil
  35596. }
  35597. // SetAvatar sets the "avatar" field.
  35598. func (m *WxCardUserMutation) SetAvatar(s string) {
  35599. m.avatar = &s
  35600. }
  35601. // Avatar returns the value of the "avatar" field in the mutation.
  35602. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  35603. v := m.avatar
  35604. if v == nil {
  35605. return
  35606. }
  35607. return *v, true
  35608. }
  35609. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  35610. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35612. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  35613. if !m.op.Is(OpUpdateOne) {
  35614. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  35615. }
  35616. if m.id == nil || m.oldValue == nil {
  35617. return v, errors.New("OldAvatar requires an ID field in the mutation")
  35618. }
  35619. oldValue, err := m.oldValue(ctx)
  35620. if err != nil {
  35621. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  35622. }
  35623. return oldValue.Avatar, nil
  35624. }
  35625. // ResetAvatar resets all changes to the "avatar" field.
  35626. func (m *WxCardUserMutation) ResetAvatar() {
  35627. m.avatar = nil
  35628. }
  35629. // SetNickname sets the "nickname" field.
  35630. func (m *WxCardUserMutation) SetNickname(s string) {
  35631. m.nickname = &s
  35632. }
  35633. // Nickname returns the value of the "nickname" field in the mutation.
  35634. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  35635. v := m.nickname
  35636. if v == nil {
  35637. return
  35638. }
  35639. return *v, true
  35640. }
  35641. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  35642. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35643. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35644. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  35645. if !m.op.Is(OpUpdateOne) {
  35646. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  35647. }
  35648. if m.id == nil || m.oldValue == nil {
  35649. return v, errors.New("OldNickname requires an ID field in the mutation")
  35650. }
  35651. oldValue, err := m.oldValue(ctx)
  35652. if err != nil {
  35653. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  35654. }
  35655. return oldValue.Nickname, nil
  35656. }
  35657. // ResetNickname resets all changes to the "nickname" field.
  35658. func (m *WxCardUserMutation) ResetNickname() {
  35659. m.nickname = nil
  35660. }
  35661. // SetRemark sets the "remark" field.
  35662. func (m *WxCardUserMutation) SetRemark(s string) {
  35663. m.remark = &s
  35664. }
  35665. // Remark returns the value of the "remark" field in the mutation.
  35666. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  35667. v := m.remark
  35668. if v == nil {
  35669. return
  35670. }
  35671. return *v, true
  35672. }
  35673. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  35674. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35676. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  35677. if !m.op.Is(OpUpdateOne) {
  35678. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  35679. }
  35680. if m.id == nil || m.oldValue == nil {
  35681. return v, errors.New("OldRemark requires an ID field in the mutation")
  35682. }
  35683. oldValue, err := m.oldValue(ctx)
  35684. if err != nil {
  35685. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  35686. }
  35687. return oldValue.Remark, nil
  35688. }
  35689. // ResetRemark resets all changes to the "remark" field.
  35690. func (m *WxCardUserMutation) ResetRemark() {
  35691. m.remark = nil
  35692. }
  35693. // SetPhone sets the "phone" field.
  35694. func (m *WxCardUserMutation) SetPhone(s string) {
  35695. m.phone = &s
  35696. }
  35697. // Phone returns the value of the "phone" field in the mutation.
  35698. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  35699. v := m.phone
  35700. if v == nil {
  35701. return
  35702. }
  35703. return *v, true
  35704. }
  35705. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  35706. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35708. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  35709. if !m.op.Is(OpUpdateOne) {
  35710. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  35711. }
  35712. if m.id == nil || m.oldValue == nil {
  35713. return v, errors.New("OldPhone requires an ID field in the mutation")
  35714. }
  35715. oldValue, err := m.oldValue(ctx)
  35716. if err != nil {
  35717. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  35718. }
  35719. return oldValue.Phone, nil
  35720. }
  35721. // ResetPhone resets all changes to the "phone" field.
  35722. func (m *WxCardUserMutation) ResetPhone() {
  35723. m.phone = nil
  35724. }
  35725. // SetOpenID sets the "open_id" field.
  35726. func (m *WxCardUserMutation) SetOpenID(s string) {
  35727. m.open_id = &s
  35728. }
  35729. // OpenID returns the value of the "open_id" field in the mutation.
  35730. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  35731. v := m.open_id
  35732. if v == nil {
  35733. return
  35734. }
  35735. return *v, true
  35736. }
  35737. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  35738. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35740. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  35741. if !m.op.Is(OpUpdateOne) {
  35742. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  35743. }
  35744. if m.id == nil || m.oldValue == nil {
  35745. return v, errors.New("OldOpenID requires an ID field in the mutation")
  35746. }
  35747. oldValue, err := m.oldValue(ctx)
  35748. if err != nil {
  35749. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  35750. }
  35751. return oldValue.OpenID, nil
  35752. }
  35753. // ResetOpenID resets all changes to the "open_id" field.
  35754. func (m *WxCardUserMutation) ResetOpenID() {
  35755. m.open_id = nil
  35756. }
  35757. // SetUnionID sets the "union_id" field.
  35758. func (m *WxCardUserMutation) SetUnionID(s string) {
  35759. m.union_id = &s
  35760. }
  35761. // UnionID returns the value of the "union_id" field in the mutation.
  35762. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  35763. v := m.union_id
  35764. if v == nil {
  35765. return
  35766. }
  35767. return *v, true
  35768. }
  35769. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  35770. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35771. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35772. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  35773. if !m.op.Is(OpUpdateOne) {
  35774. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  35775. }
  35776. if m.id == nil || m.oldValue == nil {
  35777. return v, errors.New("OldUnionID requires an ID field in the mutation")
  35778. }
  35779. oldValue, err := m.oldValue(ctx)
  35780. if err != nil {
  35781. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  35782. }
  35783. return oldValue.UnionID, nil
  35784. }
  35785. // ResetUnionID resets all changes to the "union_id" field.
  35786. func (m *WxCardUserMutation) ResetUnionID() {
  35787. m.union_id = nil
  35788. }
  35789. // SetSessionKey sets the "session_key" field.
  35790. func (m *WxCardUserMutation) SetSessionKey(s string) {
  35791. m.session_key = &s
  35792. }
  35793. // SessionKey returns the value of the "session_key" field in the mutation.
  35794. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  35795. v := m.session_key
  35796. if v == nil {
  35797. return
  35798. }
  35799. return *v, true
  35800. }
  35801. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  35802. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35803. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35804. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  35805. if !m.op.Is(OpUpdateOne) {
  35806. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  35807. }
  35808. if m.id == nil || m.oldValue == nil {
  35809. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  35810. }
  35811. oldValue, err := m.oldValue(ctx)
  35812. if err != nil {
  35813. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  35814. }
  35815. return oldValue.SessionKey, nil
  35816. }
  35817. // ResetSessionKey resets all changes to the "session_key" field.
  35818. func (m *WxCardUserMutation) ResetSessionKey() {
  35819. m.session_key = nil
  35820. }
  35821. // SetIsVip sets the "is_vip" field.
  35822. func (m *WxCardUserMutation) SetIsVip(i int) {
  35823. m.is_vip = &i
  35824. m.addis_vip = nil
  35825. }
  35826. // IsVip returns the value of the "is_vip" field in the mutation.
  35827. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  35828. v := m.is_vip
  35829. if v == nil {
  35830. return
  35831. }
  35832. return *v, true
  35833. }
  35834. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  35835. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  35836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35837. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  35838. if !m.op.Is(OpUpdateOne) {
  35839. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  35840. }
  35841. if m.id == nil || m.oldValue == nil {
  35842. return v, errors.New("OldIsVip requires an ID field in the mutation")
  35843. }
  35844. oldValue, err := m.oldValue(ctx)
  35845. if err != nil {
  35846. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  35847. }
  35848. return oldValue.IsVip, nil
  35849. }
  35850. // AddIsVip adds i to the "is_vip" field.
  35851. func (m *WxCardUserMutation) AddIsVip(i int) {
  35852. if m.addis_vip != nil {
  35853. *m.addis_vip += i
  35854. } else {
  35855. m.addis_vip = &i
  35856. }
  35857. }
  35858. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  35859. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  35860. v := m.addis_vip
  35861. if v == nil {
  35862. return
  35863. }
  35864. return *v, true
  35865. }
  35866. // ResetIsVip resets all changes to the "is_vip" field.
  35867. func (m *WxCardUserMutation) ResetIsVip() {
  35868. m.is_vip = nil
  35869. m.addis_vip = nil
  35870. }
  35871. // Where appends a list predicates to the WxCardUserMutation builder.
  35872. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  35873. m.predicates = append(m.predicates, ps...)
  35874. }
  35875. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  35876. // users can use type-assertion to append predicates that do not depend on any generated package.
  35877. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  35878. p := make([]predicate.WxCardUser, len(ps))
  35879. for i := range ps {
  35880. p[i] = ps[i]
  35881. }
  35882. m.Where(p...)
  35883. }
  35884. // Op returns the operation name.
  35885. func (m *WxCardUserMutation) Op() Op {
  35886. return m.op
  35887. }
  35888. // SetOp allows setting the mutation operation.
  35889. func (m *WxCardUserMutation) SetOp(op Op) {
  35890. m.op = op
  35891. }
  35892. // Type returns the node type of this mutation (WxCardUser).
  35893. func (m *WxCardUserMutation) Type() string {
  35894. return m.typ
  35895. }
  35896. // Fields returns all fields that were changed during this mutation. Note that in
  35897. // order to get all numeric fields that were incremented/decremented, call
  35898. // AddedFields().
  35899. func (m *WxCardUserMutation) Fields() []string {
  35900. fields := make([]string, 0, 13)
  35901. if m.created_at != nil {
  35902. fields = append(fields, wxcarduser.FieldCreatedAt)
  35903. }
  35904. if m.updated_at != nil {
  35905. fields = append(fields, wxcarduser.FieldUpdatedAt)
  35906. }
  35907. if m.deleted_at != nil {
  35908. fields = append(fields, wxcarduser.FieldDeletedAt)
  35909. }
  35910. if m.wxid != nil {
  35911. fields = append(fields, wxcarduser.FieldWxid)
  35912. }
  35913. if m.account != nil {
  35914. fields = append(fields, wxcarduser.FieldAccount)
  35915. }
  35916. if m.avatar != nil {
  35917. fields = append(fields, wxcarduser.FieldAvatar)
  35918. }
  35919. if m.nickname != nil {
  35920. fields = append(fields, wxcarduser.FieldNickname)
  35921. }
  35922. if m.remark != nil {
  35923. fields = append(fields, wxcarduser.FieldRemark)
  35924. }
  35925. if m.phone != nil {
  35926. fields = append(fields, wxcarduser.FieldPhone)
  35927. }
  35928. if m.open_id != nil {
  35929. fields = append(fields, wxcarduser.FieldOpenID)
  35930. }
  35931. if m.union_id != nil {
  35932. fields = append(fields, wxcarduser.FieldUnionID)
  35933. }
  35934. if m.session_key != nil {
  35935. fields = append(fields, wxcarduser.FieldSessionKey)
  35936. }
  35937. if m.is_vip != nil {
  35938. fields = append(fields, wxcarduser.FieldIsVip)
  35939. }
  35940. return fields
  35941. }
  35942. // Field returns the value of a field with the given name. The second boolean
  35943. // return value indicates that this field was not set, or was not defined in the
  35944. // schema.
  35945. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  35946. switch name {
  35947. case wxcarduser.FieldCreatedAt:
  35948. return m.CreatedAt()
  35949. case wxcarduser.FieldUpdatedAt:
  35950. return m.UpdatedAt()
  35951. case wxcarduser.FieldDeletedAt:
  35952. return m.DeletedAt()
  35953. case wxcarduser.FieldWxid:
  35954. return m.Wxid()
  35955. case wxcarduser.FieldAccount:
  35956. return m.Account()
  35957. case wxcarduser.FieldAvatar:
  35958. return m.Avatar()
  35959. case wxcarduser.FieldNickname:
  35960. return m.Nickname()
  35961. case wxcarduser.FieldRemark:
  35962. return m.Remark()
  35963. case wxcarduser.FieldPhone:
  35964. return m.Phone()
  35965. case wxcarduser.FieldOpenID:
  35966. return m.OpenID()
  35967. case wxcarduser.FieldUnionID:
  35968. return m.UnionID()
  35969. case wxcarduser.FieldSessionKey:
  35970. return m.SessionKey()
  35971. case wxcarduser.FieldIsVip:
  35972. return m.IsVip()
  35973. }
  35974. return nil, false
  35975. }
  35976. // OldField returns the old value of the field from the database. An error is
  35977. // returned if the mutation operation is not UpdateOne, or the query to the
  35978. // database failed.
  35979. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35980. switch name {
  35981. case wxcarduser.FieldCreatedAt:
  35982. return m.OldCreatedAt(ctx)
  35983. case wxcarduser.FieldUpdatedAt:
  35984. return m.OldUpdatedAt(ctx)
  35985. case wxcarduser.FieldDeletedAt:
  35986. return m.OldDeletedAt(ctx)
  35987. case wxcarduser.FieldWxid:
  35988. return m.OldWxid(ctx)
  35989. case wxcarduser.FieldAccount:
  35990. return m.OldAccount(ctx)
  35991. case wxcarduser.FieldAvatar:
  35992. return m.OldAvatar(ctx)
  35993. case wxcarduser.FieldNickname:
  35994. return m.OldNickname(ctx)
  35995. case wxcarduser.FieldRemark:
  35996. return m.OldRemark(ctx)
  35997. case wxcarduser.FieldPhone:
  35998. return m.OldPhone(ctx)
  35999. case wxcarduser.FieldOpenID:
  36000. return m.OldOpenID(ctx)
  36001. case wxcarduser.FieldUnionID:
  36002. return m.OldUnionID(ctx)
  36003. case wxcarduser.FieldSessionKey:
  36004. return m.OldSessionKey(ctx)
  36005. case wxcarduser.FieldIsVip:
  36006. return m.OldIsVip(ctx)
  36007. }
  36008. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  36009. }
  36010. // SetField sets the value of a field with the given name. It returns an error if
  36011. // the field is not defined in the schema, or if the type mismatched the field
  36012. // type.
  36013. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  36014. switch name {
  36015. case wxcarduser.FieldCreatedAt:
  36016. v, ok := value.(time.Time)
  36017. if !ok {
  36018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36019. }
  36020. m.SetCreatedAt(v)
  36021. return nil
  36022. case wxcarduser.FieldUpdatedAt:
  36023. v, ok := value.(time.Time)
  36024. if !ok {
  36025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36026. }
  36027. m.SetUpdatedAt(v)
  36028. return nil
  36029. case wxcarduser.FieldDeletedAt:
  36030. v, ok := value.(time.Time)
  36031. if !ok {
  36032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36033. }
  36034. m.SetDeletedAt(v)
  36035. return nil
  36036. case wxcarduser.FieldWxid:
  36037. v, ok := value.(string)
  36038. if !ok {
  36039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36040. }
  36041. m.SetWxid(v)
  36042. return nil
  36043. case wxcarduser.FieldAccount:
  36044. v, ok := value.(string)
  36045. if !ok {
  36046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36047. }
  36048. m.SetAccount(v)
  36049. return nil
  36050. case wxcarduser.FieldAvatar:
  36051. v, ok := value.(string)
  36052. if !ok {
  36053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36054. }
  36055. m.SetAvatar(v)
  36056. return nil
  36057. case wxcarduser.FieldNickname:
  36058. v, ok := value.(string)
  36059. if !ok {
  36060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36061. }
  36062. m.SetNickname(v)
  36063. return nil
  36064. case wxcarduser.FieldRemark:
  36065. v, ok := value.(string)
  36066. if !ok {
  36067. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36068. }
  36069. m.SetRemark(v)
  36070. return nil
  36071. case wxcarduser.FieldPhone:
  36072. v, ok := value.(string)
  36073. if !ok {
  36074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36075. }
  36076. m.SetPhone(v)
  36077. return nil
  36078. case wxcarduser.FieldOpenID:
  36079. v, ok := value.(string)
  36080. if !ok {
  36081. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36082. }
  36083. m.SetOpenID(v)
  36084. return nil
  36085. case wxcarduser.FieldUnionID:
  36086. v, ok := value.(string)
  36087. if !ok {
  36088. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36089. }
  36090. m.SetUnionID(v)
  36091. return nil
  36092. case wxcarduser.FieldSessionKey:
  36093. v, ok := value.(string)
  36094. if !ok {
  36095. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36096. }
  36097. m.SetSessionKey(v)
  36098. return nil
  36099. case wxcarduser.FieldIsVip:
  36100. v, ok := value.(int)
  36101. if !ok {
  36102. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36103. }
  36104. m.SetIsVip(v)
  36105. return nil
  36106. }
  36107. return fmt.Errorf("unknown WxCardUser field %s", name)
  36108. }
  36109. // AddedFields returns all numeric fields that were incremented/decremented during
  36110. // this mutation.
  36111. func (m *WxCardUserMutation) AddedFields() []string {
  36112. var fields []string
  36113. if m.addis_vip != nil {
  36114. fields = append(fields, wxcarduser.FieldIsVip)
  36115. }
  36116. return fields
  36117. }
  36118. // AddedField returns the numeric value that was incremented/decremented on a field
  36119. // with the given name. The second boolean return value indicates that this field
  36120. // was not set, or was not defined in the schema.
  36121. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  36122. switch name {
  36123. case wxcarduser.FieldIsVip:
  36124. return m.AddedIsVip()
  36125. }
  36126. return nil, false
  36127. }
  36128. // AddField adds the value to the field with the given name. It returns an error if
  36129. // the field is not defined in the schema, or if the type mismatched the field
  36130. // type.
  36131. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  36132. switch name {
  36133. case wxcarduser.FieldIsVip:
  36134. v, ok := value.(int)
  36135. if !ok {
  36136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36137. }
  36138. m.AddIsVip(v)
  36139. return nil
  36140. }
  36141. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  36142. }
  36143. // ClearedFields returns all nullable fields that were cleared during this
  36144. // mutation.
  36145. func (m *WxCardUserMutation) ClearedFields() []string {
  36146. var fields []string
  36147. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  36148. fields = append(fields, wxcarduser.FieldDeletedAt)
  36149. }
  36150. return fields
  36151. }
  36152. // FieldCleared returns a boolean indicating if a field with the given name was
  36153. // cleared in this mutation.
  36154. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  36155. _, ok := m.clearedFields[name]
  36156. return ok
  36157. }
  36158. // ClearField clears the value of the field with the given name. It returns an
  36159. // error if the field is not defined in the schema.
  36160. func (m *WxCardUserMutation) ClearField(name string) error {
  36161. switch name {
  36162. case wxcarduser.FieldDeletedAt:
  36163. m.ClearDeletedAt()
  36164. return nil
  36165. }
  36166. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  36167. }
  36168. // ResetField resets all changes in the mutation for the field with the given name.
  36169. // It returns an error if the field is not defined in the schema.
  36170. func (m *WxCardUserMutation) ResetField(name string) error {
  36171. switch name {
  36172. case wxcarduser.FieldCreatedAt:
  36173. m.ResetCreatedAt()
  36174. return nil
  36175. case wxcarduser.FieldUpdatedAt:
  36176. m.ResetUpdatedAt()
  36177. return nil
  36178. case wxcarduser.FieldDeletedAt:
  36179. m.ResetDeletedAt()
  36180. return nil
  36181. case wxcarduser.FieldWxid:
  36182. m.ResetWxid()
  36183. return nil
  36184. case wxcarduser.FieldAccount:
  36185. m.ResetAccount()
  36186. return nil
  36187. case wxcarduser.FieldAvatar:
  36188. m.ResetAvatar()
  36189. return nil
  36190. case wxcarduser.FieldNickname:
  36191. m.ResetNickname()
  36192. return nil
  36193. case wxcarduser.FieldRemark:
  36194. m.ResetRemark()
  36195. return nil
  36196. case wxcarduser.FieldPhone:
  36197. m.ResetPhone()
  36198. return nil
  36199. case wxcarduser.FieldOpenID:
  36200. m.ResetOpenID()
  36201. return nil
  36202. case wxcarduser.FieldUnionID:
  36203. m.ResetUnionID()
  36204. return nil
  36205. case wxcarduser.FieldSessionKey:
  36206. m.ResetSessionKey()
  36207. return nil
  36208. case wxcarduser.FieldIsVip:
  36209. m.ResetIsVip()
  36210. return nil
  36211. }
  36212. return fmt.Errorf("unknown WxCardUser field %s", name)
  36213. }
  36214. // AddedEdges returns all edge names that were set/added in this mutation.
  36215. func (m *WxCardUserMutation) AddedEdges() []string {
  36216. edges := make([]string, 0, 0)
  36217. return edges
  36218. }
  36219. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36220. // name in this mutation.
  36221. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  36222. return nil
  36223. }
  36224. // RemovedEdges returns all edge names that were removed in this mutation.
  36225. func (m *WxCardUserMutation) RemovedEdges() []string {
  36226. edges := make([]string, 0, 0)
  36227. return edges
  36228. }
  36229. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36230. // the given name in this mutation.
  36231. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  36232. return nil
  36233. }
  36234. // ClearedEdges returns all edge names that were cleared in this mutation.
  36235. func (m *WxCardUserMutation) ClearedEdges() []string {
  36236. edges := make([]string, 0, 0)
  36237. return edges
  36238. }
  36239. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36240. // was cleared in this mutation.
  36241. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  36242. return false
  36243. }
  36244. // ClearEdge clears the value of the edge with the given name. It returns an error
  36245. // if that edge is not defined in the schema.
  36246. func (m *WxCardUserMutation) ClearEdge(name string) error {
  36247. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  36248. }
  36249. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36250. // It returns an error if the edge is not defined in the schema.
  36251. func (m *WxCardUserMutation) ResetEdge(name string) error {
  36252. return fmt.Errorf("unknown WxCardUser edge %s", name)
  36253. }
  36254. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  36255. type WxCardVisitMutation struct {
  36256. config
  36257. op Op
  36258. typ string
  36259. id *uint64
  36260. created_at *time.Time
  36261. updated_at *time.Time
  36262. deleted_at *time.Time
  36263. user_id *uint64
  36264. adduser_id *int64
  36265. bot_id *uint64
  36266. addbot_id *int64
  36267. bot_type *uint8
  36268. addbot_type *int8
  36269. clearedFields map[string]struct{}
  36270. done bool
  36271. oldValue func(context.Context) (*WxCardVisit, error)
  36272. predicates []predicate.WxCardVisit
  36273. }
  36274. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  36275. // wxcardvisitOption allows management of the mutation configuration using functional options.
  36276. type wxcardvisitOption func(*WxCardVisitMutation)
  36277. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  36278. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  36279. m := &WxCardVisitMutation{
  36280. config: c,
  36281. op: op,
  36282. typ: TypeWxCardVisit,
  36283. clearedFields: make(map[string]struct{}),
  36284. }
  36285. for _, opt := range opts {
  36286. opt(m)
  36287. }
  36288. return m
  36289. }
  36290. // withWxCardVisitID sets the ID field of the mutation.
  36291. func withWxCardVisitID(id uint64) wxcardvisitOption {
  36292. return func(m *WxCardVisitMutation) {
  36293. var (
  36294. err error
  36295. once sync.Once
  36296. value *WxCardVisit
  36297. )
  36298. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  36299. once.Do(func() {
  36300. if m.done {
  36301. err = errors.New("querying old values post mutation is not allowed")
  36302. } else {
  36303. value, err = m.Client().WxCardVisit.Get(ctx, id)
  36304. }
  36305. })
  36306. return value, err
  36307. }
  36308. m.id = &id
  36309. }
  36310. }
  36311. // withWxCardVisit sets the old WxCardVisit of the mutation.
  36312. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  36313. return func(m *WxCardVisitMutation) {
  36314. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  36315. return node, nil
  36316. }
  36317. m.id = &node.ID
  36318. }
  36319. }
  36320. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36321. // executed in a transaction (ent.Tx), a transactional client is returned.
  36322. func (m WxCardVisitMutation) Client() *Client {
  36323. client := &Client{config: m.config}
  36324. client.init()
  36325. return client
  36326. }
  36327. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36328. // it returns an error otherwise.
  36329. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  36330. if _, ok := m.driver.(*txDriver); !ok {
  36331. return nil, errors.New("ent: mutation is not running in a transaction")
  36332. }
  36333. tx := &Tx{config: m.config}
  36334. tx.init()
  36335. return tx, nil
  36336. }
  36337. // SetID sets the value of the id field. Note that this
  36338. // operation is only accepted on creation of WxCardVisit entities.
  36339. func (m *WxCardVisitMutation) SetID(id uint64) {
  36340. m.id = &id
  36341. }
  36342. // ID returns the ID value in the mutation. Note that the ID is only available
  36343. // if it was provided to the builder or after it was returned from the database.
  36344. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  36345. if m.id == nil {
  36346. return
  36347. }
  36348. return *m.id, true
  36349. }
  36350. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36351. // That means, if the mutation is applied within a transaction with an isolation level such
  36352. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36353. // or updated by the mutation.
  36354. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  36355. switch {
  36356. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36357. id, exists := m.ID()
  36358. if exists {
  36359. return []uint64{id}, nil
  36360. }
  36361. fallthrough
  36362. case m.op.Is(OpUpdate | OpDelete):
  36363. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  36364. default:
  36365. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36366. }
  36367. }
  36368. // SetCreatedAt sets the "created_at" field.
  36369. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  36370. m.created_at = &t
  36371. }
  36372. // CreatedAt returns the value of the "created_at" field in the mutation.
  36373. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  36374. v := m.created_at
  36375. if v == nil {
  36376. return
  36377. }
  36378. return *v, true
  36379. }
  36380. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  36381. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  36382. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36383. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36384. if !m.op.Is(OpUpdateOne) {
  36385. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36386. }
  36387. if m.id == nil || m.oldValue == nil {
  36388. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36389. }
  36390. oldValue, err := m.oldValue(ctx)
  36391. if err != nil {
  36392. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36393. }
  36394. return oldValue.CreatedAt, nil
  36395. }
  36396. // ResetCreatedAt resets all changes to the "created_at" field.
  36397. func (m *WxCardVisitMutation) ResetCreatedAt() {
  36398. m.created_at = nil
  36399. }
  36400. // SetUpdatedAt sets the "updated_at" field.
  36401. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  36402. m.updated_at = &t
  36403. }
  36404. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36405. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  36406. v := m.updated_at
  36407. if v == nil {
  36408. return
  36409. }
  36410. return *v, true
  36411. }
  36412. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  36413. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  36414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36415. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36416. if !m.op.Is(OpUpdateOne) {
  36417. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36418. }
  36419. if m.id == nil || m.oldValue == nil {
  36420. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36421. }
  36422. oldValue, err := m.oldValue(ctx)
  36423. if err != nil {
  36424. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36425. }
  36426. return oldValue.UpdatedAt, nil
  36427. }
  36428. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36429. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  36430. m.updated_at = nil
  36431. }
  36432. // SetDeletedAt sets the "deleted_at" field.
  36433. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  36434. m.deleted_at = &t
  36435. }
  36436. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  36437. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  36438. v := m.deleted_at
  36439. if v == nil {
  36440. return
  36441. }
  36442. return *v, true
  36443. }
  36444. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  36445. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  36446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36447. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  36448. if !m.op.Is(OpUpdateOne) {
  36449. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  36450. }
  36451. if m.id == nil || m.oldValue == nil {
  36452. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  36453. }
  36454. oldValue, err := m.oldValue(ctx)
  36455. if err != nil {
  36456. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  36457. }
  36458. return oldValue.DeletedAt, nil
  36459. }
  36460. // ClearDeletedAt clears the value of the "deleted_at" field.
  36461. func (m *WxCardVisitMutation) ClearDeletedAt() {
  36462. m.deleted_at = nil
  36463. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  36464. }
  36465. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  36466. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  36467. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  36468. return ok
  36469. }
  36470. // ResetDeletedAt resets all changes to the "deleted_at" field.
  36471. func (m *WxCardVisitMutation) ResetDeletedAt() {
  36472. m.deleted_at = nil
  36473. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  36474. }
  36475. // SetUserID sets the "user_id" field.
  36476. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  36477. m.user_id = &u
  36478. m.adduser_id = nil
  36479. }
  36480. // UserID returns the value of the "user_id" field in the mutation.
  36481. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  36482. v := m.user_id
  36483. if v == nil {
  36484. return
  36485. }
  36486. return *v, true
  36487. }
  36488. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  36489. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  36490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36491. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  36492. if !m.op.Is(OpUpdateOne) {
  36493. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  36494. }
  36495. if m.id == nil || m.oldValue == nil {
  36496. return v, errors.New("OldUserID requires an ID field in the mutation")
  36497. }
  36498. oldValue, err := m.oldValue(ctx)
  36499. if err != nil {
  36500. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  36501. }
  36502. return oldValue.UserID, nil
  36503. }
  36504. // AddUserID adds u to the "user_id" field.
  36505. func (m *WxCardVisitMutation) AddUserID(u int64) {
  36506. if m.adduser_id != nil {
  36507. *m.adduser_id += u
  36508. } else {
  36509. m.adduser_id = &u
  36510. }
  36511. }
  36512. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  36513. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  36514. v := m.adduser_id
  36515. if v == nil {
  36516. return
  36517. }
  36518. return *v, true
  36519. }
  36520. // ClearUserID clears the value of the "user_id" field.
  36521. func (m *WxCardVisitMutation) ClearUserID() {
  36522. m.user_id = nil
  36523. m.adduser_id = nil
  36524. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  36525. }
  36526. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  36527. func (m *WxCardVisitMutation) UserIDCleared() bool {
  36528. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  36529. return ok
  36530. }
  36531. // ResetUserID resets all changes to the "user_id" field.
  36532. func (m *WxCardVisitMutation) ResetUserID() {
  36533. m.user_id = nil
  36534. m.adduser_id = nil
  36535. delete(m.clearedFields, wxcardvisit.FieldUserID)
  36536. }
  36537. // SetBotID sets the "bot_id" field.
  36538. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  36539. m.bot_id = &u
  36540. m.addbot_id = nil
  36541. }
  36542. // BotID returns the value of the "bot_id" field in the mutation.
  36543. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  36544. v := m.bot_id
  36545. if v == nil {
  36546. return
  36547. }
  36548. return *v, true
  36549. }
  36550. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  36551. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  36552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36553. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  36554. if !m.op.Is(OpUpdateOne) {
  36555. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  36556. }
  36557. if m.id == nil || m.oldValue == nil {
  36558. return v, errors.New("OldBotID requires an ID field in the mutation")
  36559. }
  36560. oldValue, err := m.oldValue(ctx)
  36561. if err != nil {
  36562. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  36563. }
  36564. return oldValue.BotID, nil
  36565. }
  36566. // AddBotID adds u to the "bot_id" field.
  36567. func (m *WxCardVisitMutation) AddBotID(u int64) {
  36568. if m.addbot_id != nil {
  36569. *m.addbot_id += u
  36570. } else {
  36571. m.addbot_id = &u
  36572. }
  36573. }
  36574. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  36575. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  36576. v := m.addbot_id
  36577. if v == nil {
  36578. return
  36579. }
  36580. return *v, true
  36581. }
  36582. // ResetBotID resets all changes to the "bot_id" field.
  36583. func (m *WxCardVisitMutation) ResetBotID() {
  36584. m.bot_id = nil
  36585. m.addbot_id = nil
  36586. }
  36587. // SetBotType sets the "bot_type" field.
  36588. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  36589. m.bot_type = &u
  36590. m.addbot_type = nil
  36591. }
  36592. // BotType returns the value of the "bot_type" field in the mutation.
  36593. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  36594. v := m.bot_type
  36595. if v == nil {
  36596. return
  36597. }
  36598. return *v, true
  36599. }
  36600. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  36601. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  36602. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36603. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  36604. if !m.op.Is(OpUpdateOne) {
  36605. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  36606. }
  36607. if m.id == nil || m.oldValue == nil {
  36608. return v, errors.New("OldBotType requires an ID field in the mutation")
  36609. }
  36610. oldValue, err := m.oldValue(ctx)
  36611. if err != nil {
  36612. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  36613. }
  36614. return oldValue.BotType, nil
  36615. }
  36616. // AddBotType adds u to the "bot_type" field.
  36617. func (m *WxCardVisitMutation) AddBotType(u int8) {
  36618. if m.addbot_type != nil {
  36619. *m.addbot_type += u
  36620. } else {
  36621. m.addbot_type = &u
  36622. }
  36623. }
  36624. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  36625. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  36626. v := m.addbot_type
  36627. if v == nil {
  36628. return
  36629. }
  36630. return *v, true
  36631. }
  36632. // ResetBotType resets all changes to the "bot_type" field.
  36633. func (m *WxCardVisitMutation) ResetBotType() {
  36634. m.bot_type = nil
  36635. m.addbot_type = nil
  36636. }
  36637. // Where appends a list predicates to the WxCardVisitMutation builder.
  36638. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  36639. m.predicates = append(m.predicates, ps...)
  36640. }
  36641. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  36642. // users can use type-assertion to append predicates that do not depend on any generated package.
  36643. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  36644. p := make([]predicate.WxCardVisit, len(ps))
  36645. for i := range ps {
  36646. p[i] = ps[i]
  36647. }
  36648. m.Where(p...)
  36649. }
  36650. // Op returns the operation name.
  36651. func (m *WxCardVisitMutation) Op() Op {
  36652. return m.op
  36653. }
  36654. // SetOp allows setting the mutation operation.
  36655. func (m *WxCardVisitMutation) SetOp(op Op) {
  36656. m.op = op
  36657. }
  36658. // Type returns the node type of this mutation (WxCardVisit).
  36659. func (m *WxCardVisitMutation) Type() string {
  36660. return m.typ
  36661. }
  36662. // Fields returns all fields that were changed during this mutation. Note that in
  36663. // order to get all numeric fields that were incremented/decremented, call
  36664. // AddedFields().
  36665. func (m *WxCardVisitMutation) Fields() []string {
  36666. fields := make([]string, 0, 6)
  36667. if m.created_at != nil {
  36668. fields = append(fields, wxcardvisit.FieldCreatedAt)
  36669. }
  36670. if m.updated_at != nil {
  36671. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  36672. }
  36673. if m.deleted_at != nil {
  36674. fields = append(fields, wxcardvisit.FieldDeletedAt)
  36675. }
  36676. if m.user_id != nil {
  36677. fields = append(fields, wxcardvisit.FieldUserID)
  36678. }
  36679. if m.bot_id != nil {
  36680. fields = append(fields, wxcardvisit.FieldBotID)
  36681. }
  36682. if m.bot_type != nil {
  36683. fields = append(fields, wxcardvisit.FieldBotType)
  36684. }
  36685. return fields
  36686. }
  36687. // Field returns the value of a field with the given name. The second boolean
  36688. // return value indicates that this field was not set, or was not defined in the
  36689. // schema.
  36690. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  36691. switch name {
  36692. case wxcardvisit.FieldCreatedAt:
  36693. return m.CreatedAt()
  36694. case wxcardvisit.FieldUpdatedAt:
  36695. return m.UpdatedAt()
  36696. case wxcardvisit.FieldDeletedAt:
  36697. return m.DeletedAt()
  36698. case wxcardvisit.FieldUserID:
  36699. return m.UserID()
  36700. case wxcardvisit.FieldBotID:
  36701. return m.BotID()
  36702. case wxcardvisit.FieldBotType:
  36703. return m.BotType()
  36704. }
  36705. return nil, false
  36706. }
  36707. // OldField returns the old value of the field from the database. An error is
  36708. // returned if the mutation operation is not UpdateOne, or the query to the
  36709. // database failed.
  36710. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36711. switch name {
  36712. case wxcardvisit.FieldCreatedAt:
  36713. return m.OldCreatedAt(ctx)
  36714. case wxcardvisit.FieldUpdatedAt:
  36715. return m.OldUpdatedAt(ctx)
  36716. case wxcardvisit.FieldDeletedAt:
  36717. return m.OldDeletedAt(ctx)
  36718. case wxcardvisit.FieldUserID:
  36719. return m.OldUserID(ctx)
  36720. case wxcardvisit.FieldBotID:
  36721. return m.OldBotID(ctx)
  36722. case wxcardvisit.FieldBotType:
  36723. return m.OldBotType(ctx)
  36724. }
  36725. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  36726. }
  36727. // SetField sets the value of a field with the given name. It returns an error if
  36728. // the field is not defined in the schema, or if the type mismatched the field
  36729. // type.
  36730. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  36731. switch name {
  36732. case wxcardvisit.FieldCreatedAt:
  36733. v, ok := value.(time.Time)
  36734. if !ok {
  36735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36736. }
  36737. m.SetCreatedAt(v)
  36738. return nil
  36739. case wxcardvisit.FieldUpdatedAt:
  36740. v, ok := value.(time.Time)
  36741. if !ok {
  36742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36743. }
  36744. m.SetUpdatedAt(v)
  36745. return nil
  36746. case wxcardvisit.FieldDeletedAt:
  36747. v, ok := value.(time.Time)
  36748. if !ok {
  36749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36750. }
  36751. m.SetDeletedAt(v)
  36752. return nil
  36753. case wxcardvisit.FieldUserID:
  36754. v, ok := value.(uint64)
  36755. if !ok {
  36756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36757. }
  36758. m.SetUserID(v)
  36759. return nil
  36760. case wxcardvisit.FieldBotID:
  36761. v, ok := value.(uint64)
  36762. if !ok {
  36763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36764. }
  36765. m.SetBotID(v)
  36766. return nil
  36767. case wxcardvisit.FieldBotType:
  36768. v, ok := value.(uint8)
  36769. if !ok {
  36770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36771. }
  36772. m.SetBotType(v)
  36773. return nil
  36774. }
  36775. return fmt.Errorf("unknown WxCardVisit field %s", name)
  36776. }
  36777. // AddedFields returns all numeric fields that were incremented/decremented during
  36778. // this mutation.
  36779. func (m *WxCardVisitMutation) AddedFields() []string {
  36780. var fields []string
  36781. if m.adduser_id != nil {
  36782. fields = append(fields, wxcardvisit.FieldUserID)
  36783. }
  36784. if m.addbot_id != nil {
  36785. fields = append(fields, wxcardvisit.FieldBotID)
  36786. }
  36787. if m.addbot_type != nil {
  36788. fields = append(fields, wxcardvisit.FieldBotType)
  36789. }
  36790. return fields
  36791. }
  36792. // AddedField returns the numeric value that was incremented/decremented on a field
  36793. // with the given name. The second boolean return value indicates that this field
  36794. // was not set, or was not defined in the schema.
  36795. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  36796. switch name {
  36797. case wxcardvisit.FieldUserID:
  36798. return m.AddedUserID()
  36799. case wxcardvisit.FieldBotID:
  36800. return m.AddedBotID()
  36801. case wxcardvisit.FieldBotType:
  36802. return m.AddedBotType()
  36803. }
  36804. return nil, false
  36805. }
  36806. // AddField adds the value to the field with the given name. It returns an error if
  36807. // the field is not defined in the schema, or if the type mismatched the field
  36808. // type.
  36809. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  36810. switch name {
  36811. case wxcardvisit.FieldUserID:
  36812. v, ok := value.(int64)
  36813. if !ok {
  36814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36815. }
  36816. m.AddUserID(v)
  36817. return nil
  36818. case wxcardvisit.FieldBotID:
  36819. v, ok := value.(int64)
  36820. if !ok {
  36821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36822. }
  36823. m.AddBotID(v)
  36824. return nil
  36825. case wxcardvisit.FieldBotType:
  36826. v, ok := value.(int8)
  36827. if !ok {
  36828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36829. }
  36830. m.AddBotType(v)
  36831. return nil
  36832. }
  36833. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  36834. }
  36835. // ClearedFields returns all nullable fields that were cleared during this
  36836. // mutation.
  36837. func (m *WxCardVisitMutation) ClearedFields() []string {
  36838. var fields []string
  36839. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  36840. fields = append(fields, wxcardvisit.FieldDeletedAt)
  36841. }
  36842. if m.FieldCleared(wxcardvisit.FieldUserID) {
  36843. fields = append(fields, wxcardvisit.FieldUserID)
  36844. }
  36845. return fields
  36846. }
  36847. // FieldCleared returns a boolean indicating if a field with the given name was
  36848. // cleared in this mutation.
  36849. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  36850. _, ok := m.clearedFields[name]
  36851. return ok
  36852. }
  36853. // ClearField clears the value of the field with the given name. It returns an
  36854. // error if the field is not defined in the schema.
  36855. func (m *WxCardVisitMutation) ClearField(name string) error {
  36856. switch name {
  36857. case wxcardvisit.FieldDeletedAt:
  36858. m.ClearDeletedAt()
  36859. return nil
  36860. case wxcardvisit.FieldUserID:
  36861. m.ClearUserID()
  36862. return nil
  36863. }
  36864. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  36865. }
  36866. // ResetField resets all changes in the mutation for the field with the given name.
  36867. // It returns an error if the field is not defined in the schema.
  36868. func (m *WxCardVisitMutation) ResetField(name string) error {
  36869. switch name {
  36870. case wxcardvisit.FieldCreatedAt:
  36871. m.ResetCreatedAt()
  36872. return nil
  36873. case wxcardvisit.FieldUpdatedAt:
  36874. m.ResetUpdatedAt()
  36875. return nil
  36876. case wxcardvisit.FieldDeletedAt:
  36877. m.ResetDeletedAt()
  36878. return nil
  36879. case wxcardvisit.FieldUserID:
  36880. m.ResetUserID()
  36881. return nil
  36882. case wxcardvisit.FieldBotID:
  36883. m.ResetBotID()
  36884. return nil
  36885. case wxcardvisit.FieldBotType:
  36886. m.ResetBotType()
  36887. return nil
  36888. }
  36889. return fmt.Errorf("unknown WxCardVisit field %s", name)
  36890. }
  36891. // AddedEdges returns all edge names that were set/added in this mutation.
  36892. func (m *WxCardVisitMutation) AddedEdges() []string {
  36893. edges := make([]string, 0, 0)
  36894. return edges
  36895. }
  36896. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36897. // name in this mutation.
  36898. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  36899. return nil
  36900. }
  36901. // RemovedEdges returns all edge names that were removed in this mutation.
  36902. func (m *WxCardVisitMutation) RemovedEdges() []string {
  36903. edges := make([]string, 0, 0)
  36904. return edges
  36905. }
  36906. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36907. // the given name in this mutation.
  36908. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  36909. return nil
  36910. }
  36911. // ClearedEdges returns all edge names that were cleared in this mutation.
  36912. func (m *WxCardVisitMutation) ClearedEdges() []string {
  36913. edges := make([]string, 0, 0)
  36914. return edges
  36915. }
  36916. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36917. // was cleared in this mutation.
  36918. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  36919. return false
  36920. }
  36921. // ClearEdge clears the value of the edge with the given name. It returns an error
  36922. // if that edge is not defined in the schema.
  36923. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  36924. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  36925. }
  36926. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36927. // It returns an error if the edge is not defined in the schema.
  36928. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  36929. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  36930. }